From 00030f223103c3247c7c5e36923e6e9e80eddc51 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Fri, 4 Aug 2023 17:42:29 -0400 Subject: [PATCH] move secret scanning to ee --- .../src/controllers/v1/secretScanningController.ts | 6 +++--- .../{ => ee}/models/gitAppInstallationSession.ts | 0 .../models/gitAppOrganizationInstallation.ts | 0 backend/src/{ => ee}/models/gitRisks.ts | 0 backend/src/ee/models/index.ts | 5 ++++- backend/src/ee/routes/v1/index.ts | 2 ++ backend/src/{ => ee}/routes/v1/secretScanning.ts | 6 +++--- backend/src/index.ts | 2 +- backend/src/models/index.ts | 5 +---- backend/src/routes/v1/index.ts | 2 -- .../GithubSecretScanningService.ts | 14 +++++++------- backend/src/services/index.ts | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) rename backend/src/{ => ee}/models/gitAppInstallationSession.ts (100%) rename backend/src/{ => ee}/models/gitAppOrganizationInstallation.ts (100%) rename backend/src/{ => ee}/models/gitRisks.ts (100%) rename backend/src/{ => ee}/routes/v1/secretScanning.ts (91%) rename backend/src/services/{ => GithubSecretScanning}/GithubSecretScanningService.ts (95%) diff --git a/backend/src/controllers/v1/secretScanningController.ts b/backend/src/controllers/v1/secretScanningController.ts index e84e5994c..3acd7e293 100644 --- a/backend/src/controllers/v1/secretScanningController.ts +++ b/backend/src/controllers/v1/secretScanningController.ts @@ -1,11 +1,11 @@ import { Request, Response } from "express"; -import GitAppInstallationSession from "../../models/gitAppInstallationSession"; +import GitAppInstallationSession from "../../ee/models/gitAppInstallationSession"; import crypto from "crypto"; import { Types } from "mongoose"; import { UnauthorizedRequestError } from "../../utils/errors"; -import GitAppOrganizationInstallation from "../../models/gitAppOrganizationInstallation"; +import GitAppOrganizationInstallation from "../../ee/models/gitAppOrganizationInstallation"; import { MembershipOrg } from "../../models"; -import GitRisks, { STATUS_RESOLVED_FALSE_POSITIVE, STATUS_RESOLVED_NOT_REVOKED, STATUS_RESOLVED_REVOKED } from "../../models/gitRisks"; +import GitRisks, { STATUS_RESOLVED_FALSE_POSITIVE, STATUS_RESOLVED_NOT_REVOKED, STATUS_RESOLVED_REVOKED } from "../../ee/models/gitRisks"; export const createInstallationSession = async (req: Request, res: Response) => { const sessionId = crypto.randomBytes(16).toString("hex"); diff --git a/backend/src/models/gitAppInstallationSession.ts b/backend/src/ee/models/gitAppInstallationSession.ts similarity index 100% rename from backend/src/models/gitAppInstallationSession.ts rename to backend/src/ee/models/gitAppInstallationSession.ts diff --git a/backend/src/models/gitAppOrganizationInstallation.ts b/backend/src/ee/models/gitAppOrganizationInstallation.ts similarity index 100% rename from backend/src/models/gitAppOrganizationInstallation.ts rename to backend/src/ee/models/gitAppOrganizationInstallation.ts diff --git a/backend/src/models/gitRisks.ts b/backend/src/ee/models/gitRisks.ts similarity index 100% rename from backend/src/models/gitRisks.ts rename to backend/src/ee/models/gitRisks.ts diff --git a/backend/src/ee/models/index.ts b/backend/src/ee/models/index.ts index 1def9073d..c364e3c51 100644 --- a/backend/src/ee/models/index.ts +++ b/backend/src/ee/models/index.ts @@ -4,4 +4,7 @@ export * from "./folderVersion"; export * from "./log"; export * from "./action"; export * from "./ssoConfig"; -export * from "./trustedIp"; \ No newline at end of file +export * from "./trustedIp"; +export * from "./gitRisks"; +export * from "./gitAppOrganizationInstallation"; +export * from "./gitAppInstallationSession"; diff --git a/backend/src/ee/routes/v1/index.ts b/backend/src/ee/routes/v1/index.ts index cf92bfc6c..be4847cef 100644 --- a/backend/src/ee/routes/v1/index.ts +++ b/backend/src/ee/routes/v1/index.ts @@ -6,6 +6,7 @@ import users from "./users"; import workspace from "./workspace"; import action from "./action"; import cloudProducts from "./cloudProducts"; +import secretScanning from "./secretScanning"; export { secret, @@ -16,4 +17,5 @@ export { workspace, action, cloudProducts, + secretScanning } \ No newline at end of file diff --git a/backend/src/routes/v1/secretScanning.ts b/backend/src/ee/routes/v1/secretScanning.ts similarity index 91% rename from backend/src/routes/v1/secretScanning.ts rename to backend/src/ee/routes/v1/secretScanning.ts index fa162ce68..0f6490d8d 100644 --- a/backend/src/routes/v1/secretScanning.ts +++ b/backend/src/ee/routes/v1/secretScanning.ts @@ -4,10 +4,10 @@ import { requireAuth, requireOrganizationAuth, validateRequest, -} from "../../middleware"; +} from "../../../middleware"; import { body, param } from "express-validator"; -import { createInstallationSession, getCurrentOrganizationInstallationStatus, getRisksForOrganization, linkInstallationToOrganization, updateRisksStatus } from "../../controllers/v1/secretScanningController"; -import { ACCEPTED, ADMIN, MEMBER, OWNER } from "../../variables"; +import { createInstallationSession, getCurrentOrganizationInstallationStatus, getRisksForOrganization, linkInstallationToOrganization, updateRisksStatus } from "../../../controllers/v1/secretScanningController"; +import { ACCEPTED, ADMIN, MEMBER, OWNER } from "../../../variables"; router.post( "/create-installation-session/organization/:organizationId", diff --git a/backend/src/index.ts b/backend/src/index.ts index 098e7fc27..e5c384f2a 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -24,6 +24,7 @@ import { secretSnapshot as eeSecretSnapshotRouter, users as eeUsersRouter, workspace as eeWorkspaceRouter, + secretScanning as v1SecretScanningRouter, } from "./ee/routes/v1"; import { auth as v1AuthRouter, @@ -38,7 +39,6 @@ import { password as v1PasswordRouter, secretImport as v1SecretImportRouter, secret as v1SecretRouter, - secretScanning as v1SecretScanningRouter, secretsFolder as v1SecretsFolder, serviceToken as v1ServiceTokenRouter, signup as v1SignupRouter, diff --git a/backend/src/models/index.ts b/backend/src/models/index.ts index d94d2b917..b852b3245 100644 --- a/backend/src/models/index.ts +++ b/backend/src/models/index.ts @@ -24,7 +24,6 @@ import ServiceTokenData, { IServiceTokenData } from "./serviceTokenData"; import APIKeyData, { IAPIKeyData } from "./apiKeyData"; import LoginSRPDetail, { ILoginSRPDetail } from "./loginSRPDetail"; import TokenVersion, { ITokenVersion } from "./tokenVersion"; -import GitRisks, { STATUS_RESOLVED_FALSE_POSITIVE } from "./gitRisks"; export { AuthProvider, @@ -79,7 +78,5 @@ export { LoginSRPDetail, ILoginSRPDetail, TokenVersion, - ITokenVersion, - GitRisks, - STATUS_RESOLVED_FALSE_POSITIVE + ITokenVersion }; diff --git a/backend/src/routes/v1/index.ts b/backend/src/routes/v1/index.ts index ce5b5dd58..08298a1c6 100644 --- a/backend/src/routes/v1/index.ts +++ b/backend/src/routes/v1/index.ts @@ -15,7 +15,6 @@ import password from "./password"; import integration from "./integration"; import integrationAuth from "./integrationAuth"; import secretsFolder from "./secretsFolder"; -import secretScanning from "./secretScanning"; import webhooks from "./webhook"; import secretImport from "./secretImport"; @@ -37,7 +36,6 @@ export { integration, integrationAuth, secretsFolder, - secretScanning, webhooks, secretImport }; diff --git a/backend/src/services/GithubSecretScanningService.ts b/backend/src/services/GithubSecretScanning/GithubSecretScanningService.ts similarity index 95% rename from backend/src/services/GithubSecretScanningService.ts rename to backend/src/services/GithubSecretScanning/GithubSecretScanningService.ts index 295be13b9..7d7a0c03d 100644 --- a/backend/src/services/GithubSecretScanningService.ts +++ b/backend/src/services/GithubSecretScanning/GithubSecretScanningService.ts @@ -3,13 +3,13 @@ import { exec } from "child_process"; import { mkdir, readFile, rm, writeFile } from "fs"; import { tmpdir } from "os"; import { join } from "path" -import GitRisks from "../models/gitRisks"; -import GitAppOrganizationInstallation from "../models/gitAppOrganizationInstallation"; -import MembershipOrg from "../models/membershipOrg"; -import { ADMIN, OWNER } from "../variables"; -import User from "../models/user"; -import { sendMail } from "../helpers"; -import TelemetryService from "./TelemetryService"; +import GitRisks from "../../ee/models/gitRisks"; +import GitAppOrganizationInstallation from "../../ee/models/gitAppOrganizationInstallation"; +import MembershipOrg from "../../models/membershipOrg"; +import { ADMIN, OWNER } from "../../variables"; +import User from "../../models/user"; +import { sendMail } from "../../helpers"; +import TelemetryService from "../TelemetryService"; type SecretMatch = { Description: string; diff --git a/backend/src/services/index.ts b/backend/src/services/index.ts index 5b6d42f26..537de95b1 100644 --- a/backend/src/services/index.ts +++ b/backend/src/services/index.ts @@ -7,7 +7,7 @@ import EventService from "./EventService"; import IntegrationService from "./IntegrationService"; import TokenService from "./TokenService"; import SecretService from "./SecretService"; -import GithubSecretScanningService from "./GithubSecretScanningService" +import GithubSecretScanningService from "./GithubSecretScanning/GithubSecretScanningService" export { TelemetryService,