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
enable request actions
Matheus Nogueirad21043d4d423
diff --git a/backend/AGENTS.md b/backend/AGENTS.mdindex 98b77b1238..9a9bbf76db 100644--- a/backend/AGENTS.md+++ b/backend/AGENTS.md@@ -1233,7 +1233,7 @@ EE routes register before community routes so they can override/extend endpoints**Secret Scanning** is single-project (see the root `AGENTS.md`): `secret-scanning-v2-project-bootstrap.ts` creates the project with the org when it has a creator to make admin (like PAM and Agent Vault), `secret-scanning-v2-project-resolver.ts` picks the active project and lazily creates it, with every org admin as project admin, for older orgs and for orgs created from the admin console, whose admins are only invited after the org exists, and routes that take `projectId` read `req.internalSecretScanningProjectId`. A data source covers the resources it has rows for (added by a user or discovered from a push); its `config` only says where to look (Bitbucket workspace, GitLab group), never which resources, so scans, "included" state and GitLab account-scope webhooks all key off rows. Stored configs may still carry the old `includeRepos` / `includeProjects` keys, which nothing reads.-**Secret scanning scans record what started them in `trigger`** (`SecretScanningScanTrigger`: `manual`, `resources-added`, `push`, `pull-request`), separate from `type`, which says how much was scanned (`historical` / `realtime`). Rows from before the column are null. `metadata` (jsonb) holds trigger-specific data and is parsed by trigger; it is omitted from API responses. **GitHub pull request checks** are realtime scans with `trigger: pull-request`, gated on the data source's `isScanNewCommitsEnabled`. A PR on a repository that isn't a resource yet goes through `discoverResource`, the same discovery a push gets (skipped when discovery is off, history scanned when historical scan is on), so both webhooks add repositories the same way. The `pull_request`, `check_run.rerequested` and `check_suite.rerequested` webhook handlers in `github-secret-scanning-service.ts` only enqueue a reduced `TQueueGitHubPullRequestEvent` on the `secret-scanning-v2` queue (job ID from the GitHub delivery ID, 3 attempts); `github-secret-scanning-pull-request-events.ts` processes it in the worker. Everything before the check run is created is safe to repeat and nothing after it throws, which is what makes the retries safe. The processor creates the check run *before* the scan row: the scan's uuid is generated in the app and sent as the check run's `external_id`, so a `check_run.rerequested` event (whose `pull_requests` is empty for forks) loads the scan by primary key and reads the PR from `metadata` (`GitHubPullRequestScanMetadataSchema`). `check_suite.rerequested` ("Re-run all checks") names only the suite, so it lists the suite's latest check run with our name and takes the same path from its `external_id`. If the check run can't be created (typically an installation that hasn't accepted the Checks permission), nothing is scanned. The scan lists commits with the compare API pinned to the event's base and head SHAs (not `pulls.listCommits`, which caps at 250 and drifts as commits land) and reuses the push path's per-commit scan, so fingerprints match and findings dedupe with push scans. The check fails on every finding in the PR's commits, not only the rows its own scan inserted: a finding a push scan saved first keeps that scan's `scanId`. Every exit of `handleDiffScan` and the stuck-scan reaper closes the check run, since a check left `queued` blocks merging when it is required; check reporting is best effort after the scan's outcome is committed (diff scans run with one attempt).+**Secret scanning scans record what started them in `trigger`** (`SecretScanningScanTrigger`: `manual`, `resources-added`, `push`, `pull-request`), separate from `type`, which says how much was scanned (`historical` / `realtime`). Rows from before the column are null. `metadata` (jsonb) holds trigger-specific data and is parsed by trigger; it is omitted from API responses. **GitHub pull request checks** are realtime scans with `trigger: pull-request`, gated on the data source's `isScanNewCommitsEnabled`. A PR on a repository that isn't a resource yet goes through `discoverResource`, the same discovery a push gets (skipped when discovery is off, history scanned when historical scan is on), so both webhooks add repositories the same way. The `pull_request`, `check_run.rerequested` and `check_suite.rerequested` webhook handlers in `github-secret-scanning-service.ts` only enqueue a reduced `TQueueGitHubPullRequestEvent` on the `secret-scanning-v2` queue (job ID from the GitHub delivery ID, 3 attempts); `github-secret-scanning-pull-request-events.ts` processes it in the worker. Everything before the check run is created is safe to repeat and nothing after it throws, which is what makes the retries safe. The processor creates the check run *before* the scan row: the scan's uuid is generated in the app and sent as the check run's `external_id`, so a `check_run.rerequested` event (whose `pull_requests` is empty for forks) loads the scan by primary key and reads the PR from `metadata` (`GitHubPullRequestScanMetadataSchema`). `check_suite.rerequested` ("Re-run all checks") names only the suite, so it lists the suite's latest check run with our name and takes the same path from its `external_id`. If the check run can't be created (typically an installation that hasn't accepted the Checks permission), nothing is scanned. The scan lists commits with the compare API pinned to the event's base and head SHAs (not `pulls.listCommits`, which caps at 250 and drifts as commits land) and reuses the push path's per-commit scan, so fingerprints match and findings dedupe with push scans. The check fails on every finding in the PR's commits, not only the rows its own scan inserted: a finding a push scan saved first keeps that scan's `scanId`. Findings triaged `false-positive` or `ignore` don't fail the check: the result is judged on the rows the upsert returns, which carry their stored status, and the scan stores every finding ID in `metadata.findingIds` when it completes. A failing check offers **Skip: False positive** and **Skip: Ignore** (`PULL_REQUEST_CHECK_SKIP_ACTIONS`); the `check_run.requested_action` event verifies the scan belongs to the event's installation and repository, sets that status on the PR's findings like Infisical's own triage (audited per finding, GitHub login in `triageComment`), and starts a new check run. GitHub shows those buttons to anyone with write access to the repository. Every exit of `handleDiffScan` and the stuck-scan reaper closes the check run, since a check left `queued` blocks merging when it is required; check reporting is best effort after the scan's outcome is committed (diff scans run with one attempt).**Dynamic secret lease secrets needed at revoke time go in `dynamic_secret_leases.encryptedLeaseData`**, never in `externalEntityId` or `config` (both plaintext, and `externalEntityId` is returned by every lease route and logged in audit events). A provider opts in by listing the `create()` `data` keys in `persistedLeaseFields`; the lease service encrypts them with the project's SecretManager key and every revoke path passes them back as `metadata.leaseData`. Lease routes return `SanitizedDynamicSecretLeaseSchema` so the column never reaches a response. Secret *config* fields are listed separately in `DYNAMIC_SECRET_SECRET_FIELDS` (`providers/redact.ts`), as dotted paths so nested secrets work (`clientAuth.clientSecret`): reads strip them via `redactStoredInputs`, and an update that omits one keeps the stored value via `restoreOmittedSecretFields`, because the update merge is shallow.diff --git a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-enums.ts b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-enums.tsindex d3e169f155..e65daad9bc 100644--- a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-enums.ts+++ b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-enums.ts@@ -1,5 +1,6 @@export enum GitHubPullRequestEvent {PullRequest = "pull-request",CheckRunRerequested = "check-run-rerequested",- CheckSuiteRerequested = "check-suite-rerequested"+ CheckSuiteRerequested = "check-suite-rerequested",+ CheckRunRequestedAction = "check-run-requested-action"}diff --git a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-fns.test.ts b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-fns.test.tsindex 68be36d0ad..b0308b6cbb 100644--- a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-fns.test.ts+++ b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-fns.test.ts@@ -1,6 +1,9 @@import { beforeEach, describe, expect, test, vi } from "vitest";-import { SecretScanningFindingSeverity } from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-enums";+import {+ SecretScanningFindingSeverity,+ SecretScanningFindingStatus+} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-enums";import { TFindingsPayload } from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-types";import {@@ -34,7 +37,7 @@ const makeFinding = (index: number): TFindingsPayload[number] => ({severity: SecretScanningFindingSeverity.High,fingerprint: `abc123:config|${index}.ts:github-pat:${index + 1}:4`,details: {- description: "GitHub Personal Access Token",+ description: "GitHub Personal Access Token.",startLine: index + 1,endLine: index + 1,startColumn: 4,@@ -103,6 +106,38 @@ describe("getPullRequestScanCheckRunResult", () => {expect(result.summary).not.toContain(SECRET_VALUE);});+ test("passes when every finding was marked as a false positive or ignored", () => {+ const result = getPullRequestScanCheckRunResult({+ findings: [+ { ...makeFinding(0), status: SecretScanningFindingStatus.FalsePositive },+ { ...makeFinding(1), status: SecretScanningFindingStatus.Ignore }+ ],+ scannedCommitCount: 1,+ totalCommitCount: 1+ });++ expect(result.conclusion).toBe("success");+ expect(result.title).toBe("2 secret(s) skipped");+ expect(result.offerSkipActions).toBeFalsy();+ });++ test("still fails on findings that were resolved or not triaged, and offers the skip actions", () => {+ const result = getPullRequestScanCheckRunResult({+ findings: [+ { ...makeFinding(0), status: SecretScanningFindingStatus.FalsePositive },+ { ...makeFinding(1), status: SecretScanningFindingStatus.Resolved },+ { ...makeFinding(2), status: SecretScanningFindingStatus.Unresolved }+ ],+ scannedCommitCount: 1,+ totalCommitCount: 1+ });++ expect(result.conclusion).toBe("failure");+ expect(result.title).toBe("2 secret(s) found");+ expect(result.summary).toContain("1 more secret(s) were marked as false positives or ignored");+ expect(result.offerSkipActions).toBe(true);+ });+test("caps the summary table and says how many findings it shows", () => {const findings = Array.from({ length: 60 }, (_, index) => makeFinding(index));const result = getPullRequestScanCheckRunResult({ findings, scannedCommitCount: 1, totalCommitCount: 1 });@@ -142,6 +177,12 @@ describe("completePullRequestCheckRun", () => {expect(second.output.annotations).toHaveLength(50);expect(second.conclusion).toBeUndefined();expect(third.output.annotations).toHaveLength(20);+ expect(first.actions.map((action: { identifier: string }) => action.identifier)).toEqual([+ SecretScanningFindingStatus.FalsePositive,+ SecretScanningFindingStatus.Ignore+ ]);+ expect(second.actions).toBeUndefined();+ expect(first.output.annotations[0].message).toBe("GitHub Personal Access Token. Found in commit abc123d.");expect(JSON.stringify(checksUpdate.mock.calls)).not.toContain(SECRET_VALUE);});@@ -155,5 +196,6 @@ describe("completePullRequestCheckRun", () => {expect(checksUpdate).toHaveBeenCalledTimes(1);expect(checksUpdate.mock.calls[0][0]).toMatchObject({ conclusion: "success", output: { annotations: [] } });+ expect(checksUpdate.mock.calls[0][0].actions).toBeUndefined();});});diff --git a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-fns.ts b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-fns.tsindex afbc136566..bdf97f91db 100644--- a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-fns.ts+++ b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-fns.ts@@ -1,6 +1,9 @@import { ProbotOctokit } from "probot";-import { SecretScanningFindingSeverity } from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-enums";+import {+ SecretScanningFindingSeverity,+ SecretScanningFindingStatus+} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-enums";import {convertPatchLineToFileLineNumber,replaceNonChangesWithNewlines,@@ -44,11 +47,32 @@ type TPullRequestCheckRunTarget = {checkRunId: number;};+// The statuses a pull request check can be skipped with; each is offered as a button on a failing check, and its+// value is the button's identifier (GitHub allows 20 characters for a label or identifier, 40 for a description).+export const PULL_REQUEST_CHECK_SKIP_ACTIONS = {+ [SecretScanningFindingStatus.FalsePositive]: {+ label: "Skip: False positive",+ description: "Mark the findings as false positives"+ },+ [SecretScanningFindingStatus.Ignore]: {+ label: "Skip: Ignore",+ description: "Ignore the findings"+ }+} as const;++export type TPullRequestCheckSkipStatus = keyof typeof PULL_REQUEST_CHECK_SKIP_ACTIONS;++export const isPullRequestCheckSkipStatus = (+ status: string | null | undefined+): status is TPullRequestCheckSkipStatus =>+ Boolean(status) && Object.keys(PULL_REQUEST_CHECK_SKIP_ACTIONS).includes(status as string);+export type TPullRequestCheckRunResult = {conclusion: "success" | "failure" | "neutral" | "cancelled" | "timed_out";title: string;summary: string;findings?: TFindingsPayload;+ offerSkipActions?: boolean;};export const getGitHubRadarInstallationOctokit = (installationId: string) => {@@ -311,17 +335,17 @@ const toCheckRunAnnotations = (findings: TFindingsPayload) =>end_line: endLine,annotation_level: "failure" as const,title: `Secret detected: ${rule}`,- message: `${description}. Found in commit ${commit.slice(0, 7)}.`+ message: `${description.replace(/\.+$/, "")}. Found in commit ${commit.slice(0, 7)}.`}));const escapeMarkdownTableCell = (value: string) => value.replace(/\|/g, "\\|").replace(/\r?\n/g, " ");export const getPullRequestScanCheckRunResult = ({- findings,+ findings: allFindings,scannedCommitCount,totalCommitCount}: {- findings: TFindingsPayload;+ findings: (TFindingsPayload[number] & { status?: string | null })[];scannedCommitCount: number;totalCommitCount: number;}): TPullRequestCheckRunResult => {@@ -330,6 +354,22 @@ export const getPullRequestScanCheckRunResult = ({? `This pull request has ${totalCommitCount} commits. Infisical scanned the first ${scannedCommitCount}; later commits were not scanned.`: "";+ const findings = allFindings.filter((finding) => !isPullRequestCheckSkipStatus(finding.status));+ const skippedCount = allFindings.length - findings.length;++ if (!findings.length && skippedCount) {+ return {+ conclusion: truncationNote ? "neutral" : "success",+ title: `${skippedCount} secret(s) skipped`,+ summary: [+ `Found ${skippedCount} secret(s) in the commits of this pull request, all marked as false positives or ignored in Infisical.`,+ truncationNote+ ]+ .filter(Boolean)+ .join("\n\n")+ };+ }+if (!findings.length) {if (truncationNote) {return {@@ -357,7 +397,8 @@ export const getPullRequestScanCheckRunResult = ({const summary = [`Found ${findings.length} secret(s) in the commits of this pull request. Rotate each secret, then remove it from the pull request's history.`,- "If a finding is a false positive, add it to the allowlist in your Infisical secret scanning configuration, then re-run this check.",+ "If the findings are false positives or safe to ignore, use Skip: False positive or Skip: Ignore above to mark them in Infisical and re-run this check. To stop a value from being reported anywhere, add it to the allowlist in your Infisical secret scanning configuration.",+ skippedCount ? `${skippedCount} more secret(s) were marked as false positives or ignored in Infisical.` : "",truncationNote,table,findings.length > CHECK_RUN_MAX_SUMMARY_FINDINGS@@ -371,7 +412,8 @@ export const getPullRequestScanCheckRunResult = ({conclusion: "failure",title: `${findings.length} secret(s) found`,summary,- findings+ findings,+ offerSkipActions: true};};@@ -411,7 +453,16 @@ export const completePullRequestCheckRun = async ({status: "completed",conclusion: result.conclusion,completed_at: new Date().toISOString(),- output: { title: result.title, summary: result.summary, annotations: firstBatch }+ output: { title: result.title, summary: result.summary, annotations: firstBatch },+ ...(result.offerSkipActions+ ? {+ actions: Object.entries(PULL_REQUEST_CHECK_SKIP_ACTIONS).map(([identifier, action]) => ({+ identifier,+ label: action.label,+ description: action.description+ }))+ }+ : {})});// Annotations sent in later updates are appended to the ones already on the check run.diff --git a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-pull-request-events.ts b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-pull-request-events.tsindex fbc8077825..28dc63c1ce 100644--- a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-pull-request-events.ts+++ b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-pull-request-events.ts@@ -2,22 +2,30 @@ import { Repository } from "@octokit/webhooks-types";import { z } from "zod";import { TSecretScanningDataSources, TSecretScanningResources, TSecretScanningResourcesInsert } from "@app/db/schemas";+import { EventType, TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";import { TSecretScanningV2DALFactory } from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-dal";import {SecretScanningDataSource,+ SecretScanningFindingStatus,SecretScanningScanTrigger} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-enums";import { getConfig } from "@app/lib/config/env";import { crypto } from "@app/lib/crypto";import { logger } from "@app/lib/logger";+import { ActorType } from "@app/services/auth/auth-type";import { GitHubPullRequestEvent } from "./github-secret-scanning-enums";-import { createPullRequestCheckRun, getLatestPullRequestCheckRunExternalId } from "./github-secret-scanning-fns";+import {+ createPullRequestCheckRun,+ getLatestPullRequestCheckRunExternalId,+ isPullRequestCheckSkipStatus+} from "./github-secret-scanning-fns";import { GitHubPullRequestScanMetadataSchema } from "./github-secret-scanning-schemas";import { TGitHubPullRequestScanPayload, TQueueGitHubPullRequestEvent } from "./github-secret-scanning-types";type TGitHubPullRequestEventsFactoryDep = {secretScanningV2DAL: TSecretScanningV2DALFactory;+ auditLogService: Pick<TAuditLogServiceFactory, "createAuditLog">;discoverResource: (params: {dataSource: Pick<TSecretScanningDataSources, "id" | "isHistoricalScanEnabled">;resourcePayload: Pick<TSecretScanningResourcesInsert, "externalId" | "name">;@@ -34,6 +42,7 @@ type TGitHubPullRequestEventsFactoryDep = {// Runs in the secret scanning worker, so the webhook only has to enqueue the event.export const githubPullRequestEventsFactory = ({secretScanningV2DAL,+ auditLogService,discoverResource,queuePullRequestScan}: TGitHubPullRequestEventsFactoryDep) => {@@ -215,6 +224,110 @@ export const githubPullRequestEventsFactory = ({await rerunPullRequestScan({ installationId, repository, externalId, logDetails });};+ // GitHub shows the skip buttons to anyone with write access to the repository, so the scan the check run names is+ // confirmed to belong to the installation and repository the event came from before any finding is changed. The+ // findings are then triaged as Infisical's own triage would, and the check is run again, which passes once every+ // finding in it is skipped.+ const skipPullRequestFindings = async ({+ installationId,+ repository,+ checkRunId,+ externalId,+ action,+ sender+ }: {+ installationId: number;+ repository: Pick<Repository, "id" | "full_name">;+ checkRunId: number;+ externalId: string | null;+ action: string;+ sender: { id: number; login: string };+ }) => {+ const logDetails = `[installationId=${installationId}] [repository=${repository.full_name}] [checkRunId=${checkRunId}] [action=${action}] [sender=${sender.login}]`;++ if (!isPullRequestCheckSkipStatus(action)) {+ logger.warn(`secretScanningV2CheckRunEvent: GitHub - ignoring unknown check run action ${logDetails}`);+ return;+ }++ const scanId = z.string().uuid().safeParse(externalId);+ const previousScan = scanId.success ? await secretScanningV2DAL.scans.findById(scanId.data) : undefined;+ const metadata = GitHubPullRequestScanMetadataSchema.safeParse(previousScan?.metadata);++ if (!previousScan || previousScan.trigger !== SecretScanningScanTrigger.PullRequest || !metadata.success) {+ logger.info(+ `secretScanningV2CheckRunEvent: GitHub - ignoring skip, the pull request scan no longer exists ${logDetails}`+ );+ return;+ }++ const resource = await secretScanningV2DAL.resources.findById(previousScan.resourceId);+ const dataSource = resource ? await secretScanningV2DAL.dataSources.findById(resource.dataSourceId) : undefined;++ if (+ !resource ||+ !dataSource ||+ dataSource.type !== SecretScanningDataSource.GitHub ||+ dataSource.externalId !== String(installationId) ||+ resource.externalId !== String(repository.id)+ ) {+ logger.warn(+ `secretScanningV2CheckRunEvent: GitHub - ignoring skip, the scan does not belong to this repository ${logDetails} [scanId=${previousScan.id}]`+ );+ return;+ }++ const { pullRequestNumber, findingIds = [] } = metadata.data;++ const findings = findingIds.length+ ? await secretScanningV2DAL.findings.find({ resourceId: resource.id, $in: { id: findingIds } })+ : [];+ const findingsToSkip = findings.filter((finding) => !isPullRequestCheckSkipStatus(finding.status));++ if (findingsToSkip.length) {+ const triageComment = `${+ action === SecretScanningFindingStatus.FalsePositive ? "Marked as a false positive" : "Ignored"+ } from GitHub by @${sender.login} on pull request ${repository.full_name}#${pullRequestNumber}.`;+ const now = new Date();++ await secretScanningV2DAL.findings.update(+ { $in: { id: findingsToSkip.map((finding) => finding.id) } },+ { status: action, triageComment, triagedAt: now, triagedByUserId: null, resolvedAt: null }+ );++ await Promise.all(+ findingsToSkip.map((finding) =>+ auditLogService.createAuditLog({+ projectId: dataSource.projectId,+ actor: {+ type: ActorType.PLATFORM,+ metadata: {}+ },+ event: {+ type: EventType.SECRET_SCANNING_FINDING_UPDATE,+ metadata: { findingId: finding.id, status: action, triageComment }+ }+ })+ )+ );++ logger.info(+ `secretScanningV2CheckRunEvent: GitHub - skipped pull request findings ${logDetails} [scanId=${previousScan.id}] [findings=${findingsToSkip.length}]`+ );+ }++ await startPullRequestScan({+ installationId,+ repository,+ pullRequest: {+ number: pullRequestNumber,+ baseSha: metadata.data.baseSha,+ headSha: metadata.data.headSha+ },+ expectedResourceId: resource.id+ });+ };+const processPullRequestEvent = async (job: TQueueGitHubPullRequestEvent) => {const { installationId, repository } = job;@@ -230,6 +343,15 @@ export const githubPullRequestEventsFactory = ({});case GitHubPullRequestEvent.CheckSuiteRerequested:return rerunCheckSuite({ installationId, repository, checkSuiteId: job.checkSuiteId });+ case GitHubPullRequestEvent.CheckRunRequestedAction:+ return skipPullRequestFindings({+ installationId,+ repository,+ checkRunId: job.checkRunId,+ externalId: job.externalId,+ action: job.action,+ sender: job.sender+ });default:logger.error(`secretScanningV2PullRequestEvent: GitHub - unhandled event [event=${(job as { event: string }).event}]`diff --git a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-schemas.ts b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-schemas.tsindex 910d004c1e..15a317f3d5 100644--- a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-schemas.ts+++ b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-schemas.ts@@ -70,5 +70,7 @@ export const GitHubPullRequestScanMetadataSchema = z.object({pullRequestNumber: z.number().int().positive(),baseSha: z.string(),headSha: z.string(),- checkRunId: z.number().int().positive()+ checkRunId: z.number().int().positive(),+ // Every finding in the pull request's commits, including ones another scan saved first; set when the scan completes.+ findingIds: z.string().uuid().array().optional()});diff --git a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-service.ts b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-service.tsindex ba8bd40e58..ea04e18b88 100644--- a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-service.ts+++ b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-service.ts@@ -1,4 +1,5 @@import {+ CheckRunRequestedActionEvent,CheckRunRerequestedEvent,CheckSuiteRerequestedEvent,PullRequestOpenedEvent,@@ -150,11 +151,38 @@ export const githubSecretScanningService = ();};+ const handleCheckRunRequestedActionEvent = async (payload: CheckRunRequestedActionEvent, deliveryId: string) => {+ const { check_run: checkRun, installation, repository, requested_action: requestedAction, sender } = payload;++ if (!installation || !requestedAction.identifier) {+ logger.warn(+ `secretScanningV2CheckRunEvent: GitHub - Insufficient data [repository=${repository.full_name}] [checkRunId=${checkRun.id}]`+ );+ return;+ }++ if (String(checkRun.app.id) !== getConfig().INF_APP_CONNECTION_GITHUB_RADAR_APP_ID) return;++ await secretScanningV2Queue.queueGitHubPullRequestEvent(+ {+ event: GitHubPullRequestEvent.CheckRunRequestedAction,+ installationId: installation.id,+ repository: { id: repository.id, full_name: repository.full_name },+ checkRunId: checkRun.id,+ externalId: checkRun.external_id,+ action: requestedAction.identifier,+ sender: { id: sender.id, login: sender.login }+ },+ deliveryId+ );+ };+return {handlePushEvent,handlePullRequestEvent,handleCheckRunRerequestedEvent,handleCheckSuiteRerequestedEvent,+ handleCheckRunRequestedActionEvent,handleInstallationDeletedEvent};};diff --git a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-types.ts b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-types.tsindex 70ff4ba1e3..c05806de9a 100644--- a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-types.ts+++ b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-types.ts@@ -55,4 +55,11 @@ export type TQueueGitHubPullRequestEvent = {| { event: GitHubPullRequestEvent.PullRequest; pullRequest: TGitHubPullRequestScanPayload["pullRequest"] }| { event: GitHubPullRequestEvent.CheckRunRerequested; checkRunId: number; externalId: string | null }| { event: GitHubPullRequestEvent.CheckSuiteRerequested; checkSuiteId: number }+ | {+ event: GitHubPullRequestEvent.CheckRunRequestedAction;+ checkRunId: number;+ externalId: string | null;+ action: string;+ sender: { id: number; login: string };+ });diff --git a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-queue.ts b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-queue.tsindex fce7cdc243..d2e5d5dc42 100644--- a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-queue.ts+++ b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-queue.ts@@ -853,7 +853,7 @@ export const secretScanningV2QueueServiceFactory = ({}let findingsPayload: TFindingsPayload;- let pullRequestCheckResult: TPullRequestCheckRunResult | undefined;+ let pullRequestCommitCounts: { scannedCommitCount: number; totalCommitCount: number } | undefined;if (pullRequestScan) {const { findings, scannedCommitCount, totalCommitCount } = await scanGitHubPullRequest({@@ -863,8 +863,7 @@ export const secretScanningV2QueueServiceFactory = ({});findingsPayload = findings;- // Judged on every finding in the pull request's commits, including ones an earlier push scan already saved.- pullRequestCheckResult = getPullRequestScanCheckRunResult({ findings, scannedCommitCount, totalCommitCount });+ pullRequestCommitCounts = { scannedCommitCount, totalCommitCount };} else {findingsPayload = await factory.getDiffScanFindingsPayload({dataSource: {@@ -898,7 +897,18 @@ export const secretScanningV2QueueServiceFactory = ({{ id: scanId, status: SecretScanningScanStatus.Scanning },{status: SecretScanningScanStatus.Completed,- completedAt: new Date()+ completedAt: new Date(),+ ...(pullRequestScan+ ? {+ metadata: {+ pullRequestNumber: pullRequestScan.pullRequest.number,+ baseSha: pullRequestScan.pullRequest.baseSha,+ headSha: pullRequestScan.pullRequest.headSha,+ checkRunId: pullRequestScan.checkRunId,+ findingIds: findings.map((finding) => finding.id)+ } satisfies TGitHubPullRequestScanMetadata+ }+ : {})},tx);@@ -913,7 +923,13 @@ export const secretScanningV2QueueServiceFactory = ({return;}- if (pullRequestCheckResult) await reportPullRequestCheck(pullRequestCheckResult);+ // Judged on every finding in the pull request's commits, including ones an earlier push scan saved first; the+ // upsert returns those rows with the status they were triaged to, so skipped findings don't fail the check.+ if (pullRequestCommitCounts) {+ await reportPullRequestCheck(+ getPullRequestScanCheckRunResult({ findings: allFindings, ...pullRequestCommitCounts })+ );+ }const newFindings = allFindings.filter((finding) => finding.scanId === scanId);@@ -1400,6 +1416,7 @@ export const secretScanningV2QueueServiceFactory = ({const githubPullRequestEvents = githubPullRequestEventsFactory({secretScanningV2DAL,+ auditLogService,discoverResource,queuePullRequestScan});diff --git a/backend/src/server/plugins/secret-scanner-v2.ts b/backend/src/server/plugins/secret-scanner-v2.tsindex 58e6fe5659..b8865e9f22 100644--- a/backend/src/server/plugins/secret-scanner-v2.ts+++ b/backend/src/server/plugins/secret-scanner-v2.ts@@ -43,6 +43,10 @@ export const registerSecretScanningV2Webhooks = async (server: FastifyZodProvideapp.on("check_suite.rerequested", async (context) => {await server.services.secretScanningV2.github.handleCheckSuiteRerequestedEvent(context.payload, context.id);});++ app.on("check_run.requested_action", async (context) => {+ await server.services.secretScanningV2.github.handleCheckRunRequestedActionEvent(context.payload, context.id);+ });};const probot = new Probot({diff --git a/docs/documentation/platform/secret-scanning/github.mdx b/docs/documentation/platform/secret-scanning/github.mdxindex d72a2b0f28..4c30288204 100644--- a/docs/documentation/platform/secret-scanning/github.mdx+++ b/docs/documentation/platform/secret-scanning/github.mdx@@ -61,13 +61,15 @@ To scan your GitHub repositories for leaked secrets, create a GitHub [data sourcIf **Scan New Commits** is on for a GitHub data source, Infisical scans the commits of each pull request opened against a repository in the data source. Infisical reports the result as a check named **Infisical Secret Scanning** on the pull request, and scans the pull request again each time someone pushes to it.-- If Infisical finds a secret in any commit of the pull request, the check fails and marks the file and line of each secret+- If Infisical finds a secret in any commit of the pull request, the check fails and marks the file and line of each secret, unless the secret's finding is marked as a false positive or ignored- If Infisical can't finish the scan, the check fails, and you can re-run the check from the pull request- If Infisical finds no secrets, the check passesTo stop a pull request that contains a secret from being merged, [require the check in a branch protection rule](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches#require-status-checks-before-merging).-If a finding is a false positive, add it to the allowlist in your [scanning configuration](/documentation/platform/secret-scanning/configuration), then re-run the check.+If the secrets on a failed check are false positives or safe to ignore, select **Skip: False positive** or **Skip: Ignore** on the check. Infisical sets that status on every [finding](/documentation/platform/secret-scanning/findings) the check failed on, records the GitHub user who selected it in the finding's comment, and runs the check again. Anyone with write access to the repository can select these.++To stop Infisical from reporting a value in any repository, add it to the allowlist in your [scanning configuration](/documentation/platform/secret-scanning/configuration).<Note>If your GitHub organization installed the app for your [GitHub Radar Connection](/integrations/app-connections/github-radar) before pull request checks were available, an organization owner has to accept the app's new permissions in GitHub before Infisical can check pull requests.