docs: secret scanning self hosted documentation
@@ -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()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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 ({
|
||||
|
||||
@@ -146,6 +146,7 @@ const envSchema = z
|
||||
SECRET_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")),
|
||||
// LICENSE
|
||||
LICENSE_SERVER_URL: zpStr(z.string().optional().default("https://portal.infisical.com")),
|
||||
LICENSE_SERVER_KEY: zpStr(z.string().optional()),
|
||||
|
||||
@@ -7,6 +7,114 @@ The Infisical Secret Scanner allows you to keep an overview and stay alert of ex
|
||||
|
||||
To 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 Scanning
|
||||
|
||||

|
||||
|
||||
BIN
docs/images/platform/secret-scanning/github-app-copy-app-id.png
Normal file
|
After Width: | Height: | Size: 126 KiB |
BIN
docs/images/platform/secret-scanning/github-app-copy-slug.png
Normal file
|
After Width: | Height: | Size: 135 KiB |
|
After Width: | Height: | Size: 83 KiB |
BIN
docs/images/platform/secret-scanning/github-configure-app.png
Normal file
|
After Width: | Height: | Size: 107 KiB |
|
After Width: | Height: | Size: 154 KiB |
BIN
docs/images/platform/secret-scanning/github-create-app.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
docs/images/platform/secret-scanning/github-register-app.png
Normal file
|
After Width: | Height: | Size: 95 KiB |
BIN
docs/images/platform/secret-scanning/github-repo-permissions.png
Normal file
|
After Width: | Height: | Size: 240 KiB |
BIN
docs/images/platform/secret-scanning/github-select-org-2.png
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
docs/images/platform/secret-scanning/github-select-org.png
Normal file
|
After Width: | Height: | Size: 65 KiB |
BIN
docs/images/platform/secret-scanning/github-select-repos.png
Normal file
|
After Width: | Height: | Size: 104 KiB |
|
After Width: | Height: | Size: 186 KiB |
|
After Width: | Height: | Size: 116 KiB |
@@ -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>
|
||||
|
||||
## Observability
|
||||
|
||||
You can configure Infisical to collect and expose telemetry data for analytics and monitoring.
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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 (
|
||||
|
||||