Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
docs: secret scanning self hosted documentation
Daniel Hougaard57342cf2a054
diff --git a/backend/src/ee/routes/v1/secret-scanning-router.ts b/backend/src/ee/routes/v1/secret-scanning-router.tsindex f144a6c006..dd860ce757 100644--- a/backend/src/ee/routes/v1/secret-scanning-router.ts+++ b/backend/src/ee/routes/v1/secret-scanning-router.ts@@ -23,7 +23,8 @@ export const registerSecretScanningRouter = async (server: FastifyZodProvider) =body: z.object({ organizationId: z.string().trim() }),response: {200: z.object({- sessionId: z.string()+ sessionId: z.string(),+ gitAppSlug: z.string()})}},diff --git a/backend/src/ee/services/secret-scanning/secret-scanning-service.ts b/backend/src/ee/services/secret-scanning/secret-scanning-service.tsindex c5e7be9d89..2b59256c6f 100644--- a/backend/src/ee/services/secret-scanning/secret-scanning-service.ts+++ b/backend/src/ee/services/secret-scanning/secret-scanning-service.ts@@ -47,12 +47,14 @@ export const secretScanningServiceFactory = ({actorAuthMethod,actorOrgId}: TInstallAppSessionDTO) => {+ const appCfg = getConfig();+const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.SecretScanning);const sessionId = crypto.randomBytes(16).toString("hex");await gitAppInstallSessionDAL.upsert({ orgId, sessionId, userId: actorId });- return { sessionId };+ return { sessionId, gitAppSlug: appCfg.SECRET_SCANNING_GIT_APP_SLUG };};const linkInstallationToOrg = async ({diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.tsindex 907884433a..e38dbcfb51 100644--- a/backend/src/lib/config/env.ts+++ b/backend/src/lib/config/env.ts@@ -146,6 +146,7 @@ const envSchema = zSECRET_SCANNING_GIT_APP_ID: zpStr(z.string().optional()),SECRET_SCANNING_PRIVATE_KEY: zpStr(z.string().optional()),SECRET_SCANNING_ORG_WHITELIST: zpStr(z.string().optional()),+ SECRET_SCANNING_GIT_APP_SLUG: zpStr(z.string().default("infisical-radar")),// LICENSELICENSE_SERVER_URL: zpStr(z.string().optional().default("https://portal.infisical.com")),LICENSE_SERVER_KEY: zpStr(z.string().optional()),diff --git a/docs/documentation/platform/secret-scanning.mdx b/docs/documentation/platform/secret-scanning.mdxindex 4f030e8820..e477d69b6e 100644--- a/docs/documentation/platform/secret-scanning.mdx+++ b/docs/documentation/platform/secret-scanning.mdx@@ -7,6 +7,114 @@ The Infisical Secret Scanner allows you to keep an overview and stay alert of exTo further enhance security, we recommend you also use our [CLI Secret Scanner](/cli/scanning-overview#automatically-scan-changes-before-you-commit) to scan for exposed secrets prior to pushing your changes.++<Accordion title="Self-hosting">++ To setup secret scanning on your own instance of Infisical, you can follow the steps below.++ <Steps>+ <Step title="Create a GitHub App">+ Create a new GitHub app in your GitHub organization or personal [Developer Settings](https://github.com/settings/apps).++ ++ ### Configure the GitHub App+ To configure the GitHub app to work with Infisical, you'll need to modify the following settings:+ - **Homepage URL**: Required to be set. Set it to the URL of your Infisical instance. (e.g. `https://app.infisical.com`)+ - **Setup URL**: Set this to `https://<your-infisical-instance.com>/organization/secret-scanning`+ - **Webhook URL**: Set this to `https://<your-infisical-instance.com>/api/v1/secret-scanning/webhook`+ - **Webhook Secret**: Set this to a random string. This is used to verify the webhook request from Infisical. Use `openssl rand -base64 32` in your terminal to generate a random secret.++ <Note>+ Remember to save the webhook secret as you will need it in the next step.+ </Note>++ ++ ### Configure the GitHub App Permissions+ The GitHub app needs the following permissions:++ Repository permissions:+ - `Checks`: Read and Write+ - `Contents`: Read-only+ - `Issues`: Read and Write+ - `Pull Requests`: Read and Write+ - `Metadata`: Read-only (enabled by default)++ ++ Subscribed events:+ - `Check run`+ - `Pull request`+ - `Push`++ +++ ### Create the GitHub App+ Now you can create the GitHub app by clicking on the "Create GitHub App" button.++ <Note>+ If you want other Github users to be able to install the app, you need to tick the "Any account" option under "Where can this GitHub App be installed?"+ </Note>++ + </Step>++ <Step title="Retrieve the GitHub App ID">+ After clicking the "Create GitHub App" button, you will be redirected to the GitHub settings page. Here you can copy the "App ID" and save it for later when you need to configure your environment variables for your Infisical instance.++ + </Step>++ <Step title="Retrieve your GitHub App slug">+ The GitHub App slug is the name of the app you created in a slug friendly format. You can find the slug in the URL of the app you created.++ + </Step>++ <Step title="Create a new GitHub App private key">+ Create a new app private key by clicking on the "Generate a private key" button under the "Private keys" section.++ Once you click the "Generate a private key" button, the private key will be downloaded to your computer. Save this file for later as you will need the private key when configuring Infisical.++ ++ <Note>+ Remember to save the private key as you will need it in the next step.+ </Note>++ </Step>+++ <Step title="Configure your Infisical instance">+ Now you can configure your Infisical instance by setting the following environment variables:++ - `INFISICAL_GITHUB_APP_ID`: The App ID of your GitHub App.+ - `INFISICAL_GITHUB_APP_SLUG`: The slug of your GitHub App.+ - `INFISICAL_GITHUB_APP_PRIVATE_KEY`: The private key of your GitHub App that you created in a previous step.+ - `INFISICAL_GITHUB_APP_WEBHOOK_SECRET`: The webhook secret of your GitHub App that you created in a previous step.+ - `SECRET_SCANNING_ORG_WHITELIST`: A comma separated list of Infisical organization ID's that are allowed to use the secret scanning feature. Set this to the ID of your organization. You can find the ID by navigating to your organization settings within Infisical.+ </Step>+ </Steps>++ After restarting your Infisical instance, you should be able to use the secret scanning feature within your organization. Follow the steps below to add the GitHub App to your Infisical organization.+</Accordion>++## Install the Infisical Radar GitHub App++To install the GitHub App, press the "Integrate With GitHub" button in the top right corner of your Infisical Secret Scanning dashboard.++++Next, you'll be prompted to select which organization you'd like to install the app into. Select the organization you'd like to install the app into by clicking the organization in the menu.++++Select the repositories you'd like to scan for secrets and press the "Install" button.+++## Code Scanningdiff --git a/docs/images/platform/secret-scanning/github-app-copy-app-id.png b/docs/images/platform/secret-scanning/github-app-copy-app-id.pngnew file mode 100644index 0000000000..a94cb5ece0Binary files /dev/null and b/docs/images/platform/secret-scanning/github-app-copy-app-id.png differdiff --git a/docs/images/platform/secret-scanning/github-app-copy-slug.png b/docs/images/platform/secret-scanning/github-app-copy-slug.pngnew file mode 100644index 0000000000..c555dcd415Binary files /dev/null and b/docs/images/platform/secret-scanning/github-app-copy-slug.png differdiff --git a/docs/images/platform/secret-scanning/github-app-create-private-key.png b/docs/images/platform/secret-scanning/github-app-create-private-key.pngnew file mode 100644index 0000000000..50f602a362Binary files /dev/null and b/docs/images/platform/secret-scanning/github-app-create-private-key.png differdiff --git a/docs/images/platform/secret-scanning/github-configure-app.png b/docs/images/platform/secret-scanning/github-configure-app.pngnew file mode 100644index 0000000000..df64eeb188Binary files /dev/null and b/docs/images/platform/secret-scanning/github-configure-app.png differdiff --git a/docs/images/platform/secret-scanning/github-create-app-button.png b/docs/images/platform/secret-scanning/github-create-app-button.pngnew file mode 100644index 0000000000..3ea4b2d383Binary files /dev/null and b/docs/images/platform/secret-scanning/github-create-app-button.png differdiff --git a/docs/images/platform/secret-scanning/github-create-app.png b/docs/images/platform/secret-scanning/github-create-app.pngnew file mode 100644index 0000000000..f4d1cdb8c3Binary files /dev/null and b/docs/images/platform/secret-scanning/github-create-app.png differdiff --git a/docs/images/platform/secret-scanning/github-register-app.png b/docs/images/platform/secret-scanning/github-register-app.pngnew file mode 100644index 0000000000..904c07bf23Binary files /dev/null and b/docs/images/platform/secret-scanning/github-register-app.png differdiff --git a/docs/images/platform/secret-scanning/github-repo-permissions.png b/docs/images/platform/secret-scanning/github-repo-permissions.pngnew file mode 100644index 0000000000..53eae9a415Binary files /dev/null and b/docs/images/platform/secret-scanning/github-repo-permissions.png differdiff --git a/docs/images/platform/secret-scanning/github-select-org-2.png b/docs/images/platform/secret-scanning/github-select-org-2.pngnew file mode 100644index 0000000000..55b945c186Binary files /dev/null and b/docs/images/platform/secret-scanning/github-select-org-2.png differdiff --git a/docs/images/platform/secret-scanning/github-select-org.png b/docs/images/platform/secret-scanning/github-select-org.pngnew file mode 100644index 0000000000..7d6e5abc50Binary files /dev/null and b/docs/images/platform/secret-scanning/github-select-org.png differdiff --git a/docs/images/platform/secret-scanning/github-select-repos.png b/docs/images/platform/secret-scanning/github-select-repos.pngnew file mode 100644index 0000000000..51a6648d21Binary files /dev/null and b/docs/images/platform/secret-scanning/github-select-repos.png differdiff --git a/docs/images/platform/secret-scanning/github-subscribed-events.png b/docs/images/platform/secret-scanning/github-subscribed-events.pngnew file mode 100644index 0000000000..7aa6b431f1Binary files /dev/null and b/docs/images/platform/secret-scanning/github-subscribed-events.png differdiff --git a/docs/images/platform/secret-scanning/infisical-connect-secret-scanner.png b/docs/images/platform/secret-scanning/infisical-connect-secret-scanner.pngnew file mode 100644index 0000000000..11f24fd742Binary files /dev/null and b/docs/images/platform/secret-scanning/infisical-connect-secret-scanner.png differdiff --git a/docs/self-hosting/configuration/envars.mdx b/docs/self-hosting/configuration/envars.mdxindex ae7c4ab330..55e316ffbc 100644--- a/docs/self-hosting/configuration/envars.mdx+++ b/docs/self-hosting/configuration/envars.mdx@@ -625,6 +625,30 @@ To help you sync secrets from Infisical to services such as Github and Gitlab, I</ParamField></Accordion>+## Secret Scanning++<Accordion title="GitHub">+ <ParamField query="INFISICAL_GITHUB_APP_ID" type="string" default="none" optional>+ The App ID of your GitHub App.+ </ParamField>++ <ParamField query="INFISICAL_GITHUB_APP_SLUG" type="string" default="none" optional>+ The slug of your GitHub App.+ </ParamField>++ <ParamField query="INFISICAL_GITHUB_APP_PRIVATE_KEY" type="string" default="none" optional>+ A private key for your GitHub App.+ </ParamField>++ <ParamField query="INFISICAL_GITHUB_APP_WEBHOOK_SECRET" type="string" default="none" optional>+ The webhook secret of your GitHub App.+ </ParamField>++ <ParamField query="SECRET_SCANNING_ORG_WHITELIST" type="string" default="none" optional>+ A comma separated list of Infisical organization ID's that are allowed to use the secret scanning feature.+ </ParamField>+</Accordion>+## ObservabilityYou can configure Infisical to collect and expose telemetry data for analytics and monitoring.diff --git a/frontend/src/hooks/api/secretScanning/mutation.ts b/frontend/src/hooks/api/secretScanning/mutation.tsindex 7298b9af1a..5055da4aae 100644--- a/frontend/src/hooks/api/secretScanning/mutation.ts+++ b/frontend/src/hooks/api/secretScanning/mutation.ts@@ -10,15 +10,17 @@ import {} from "./types";export const useCreateNewInstallationSession = () => {- return useMutation<{ sessionId: string }, object, { organizationId: string }>({- mutationFn: async (opt) => {- const { data } = await apiRequest.post(- "/api/v1/secret-scanning/create-installation-session/organization",- opt- );- return data;+ return useMutation<{ sessionId: string; gitAppSlug: string }, object, { organizationId: string }>(+ {+ mutationFn: async (opt) => {+ const { data } = await apiRequest.post(+ "/api/v1/secret-scanning/create-installation-session/organization",+ opt+ );+ return data;+ }}- });+ );};export const useUpdateRiskStatus = () => {diff --git a/frontend/src/pages/organization/SecretScanningPage/SecretScanningPage.tsx b/frontend/src/pages/organization/SecretScanningPage/SecretScanningPage.tsxindex ba919cdd39..23cdcf8002 100644--- a/frontend/src/pages/organization/SecretScanningPage/SecretScanningPage.tsx+++ b/frontend/src/pages/organization/SecretScanningPage/SecretScanningPage.tsx@@ -108,7 +108,7 @@ export const SecretScanningPage = withPermission(const generateNewIntegrationSession = async () => {const session = await createNewIntegrationSession({ organizationId });- window.location.href = `https://github.com/apps/infisical-radar/installations/new?state=${session.sessionId}`;+ window.location.href = `https://github.com/apps/${session.gitAppSlug}/installations/new?state=${session.sessionId}`;};return (