Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

rename diffScan with realtimeScan

Matheus Nogueiraf2d43873f382
diff --git a/backend/AGENTS.md b/backend/AGENTS.md
index 961c8e612f..3013378ec7 100644
--- a/backend/AGENTS.md
+++ b/backend/AGENTS.md
@@ -1235,7 +1235,7 @@ EE routes register before community routes so they can override/extend endpoints
**Secret scanning scans and GitHub pull request checks**:
- A scan's `trigger` (`SecretScanningScanTrigger`) records what started it, separate from `type` (`historical` / `realtime`). `metadata` (jsonb) holds trigger-specific data, is parsed by trigger, and is never returned raw by the API.
-- `secret-scanning-v2-queue.ts` stays provider-agnostic. Provider behavior goes behind optional hooks on the data source factory (`getDiffScanReport` / `getScanReport` for reporting a scan back, `processEvent` for webhook events beyond pushes), never behind a provider check in the queue.
+- `secret-scanning-v2-queue.ts` stays provider-agnostic. Provider behavior goes behind optional hooks on the data source factory (`getRealtimeScanReport` / `getScanReport` for reporting a scan back, `processEvent` for webhook events beyond pushes), never behind a provider check in the queue.
- PR checks are realtime scans with `trigger: pull-request`, gated on `isScanNewCommitsEnabled`. Webhook handlers only enqueue; `processGitHubPullRequestEvent` does the work. The check run is created before the scan, with the scan's ID as its `external_id`, which is how re-runs and skip actions find the scan.
- Every exit of a PR scan closes its check (including the stuck-scan reaper, which also fails realtime scans left `queued`), since a check left open blocks merging when it is required.
- Fork PRs aren't scanned: they get a `skipped` check under the same name, unless the commit already has one of our checks (checks belong to the commit, so it would replace a real result).
diff --git a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-factory.ts b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-factory.ts
index 9dcfd0fe1a..3a6e7d9b20 100644
--- a/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-factory.ts
+++ b/backend/src/ee/services/secret-scanning-v2/github/github-secret-scanning-factory.ts
@@ -11,7 +11,7 @@ import {
} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-fns";
import {
TSecretScanningFactoryGetDiffScanFindingsPayload,
- TSecretScanningFactoryGetDiffScanReport,
+ TSecretScanningFactoryGetRealtimeScanReport,
TSecretScanningFactoryGetDiffScanResourcePayload,
TSecretScanningFactoryGetFullScanPath,
TSecretScanningFactoryGetScanReport,
@@ -183,7 +183,7 @@ export const GitHubSecretScanningFactory = () => {
};
// Pull request scans report to the check run they were created for; pushes report nowhere.
- const getDiffScanReport: TSecretScanningFactoryGetDiffScanReport<TQueueGitHubResourceDiffScan["payload"]> = (
+ const getRealtimeScanReport: TSecretScanningFactoryGetRealtimeScanReport<TQueueGitHubResourceDiffScan["payload"]> = (
payload
) => {
if (!isGitHubPullRequestScanPayload(payload)) return undefined;
@@ -216,7 +216,7 @@ export const GitHubSecretScanningFactory = () => {
getFullScanPath,
getDiffScanResourcePayload,
getDiffScanFindingsPayload,
- getDiffScanReport,
+ getRealtimeScanReport,
getScanReport,
processEvent: processGitHubPullRequestEvent,
teardown,
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.ts
index 66e75a1166..8027472e09 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
@@ -18,7 +18,7 @@ import { GitRepositoryScanFindingDetailsSchema } from "@app/ee/services/secret-s
import {
TFindingsPayload,
TQueueSecretScanningResourceDiffScan,
- TSecretScanningDiffScanFindings,
+ TSecretScanningRealtimeScanFindings,
TSecretScanningFactoryProcessEvent,
TSecretScanningScanReport
} from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-types";
@@ -274,7 +274,7 @@ export const scanGitHubPullRequest = async ({
payload: TGitHubPullRequestScanPayload;
resourceName: string;
configPath?: string;
-}): Promise<TSecretScanningDiffScanFindings> => {
+}): Promise<TSecretScanningRealtimeScanFindings> => {
const octokit = getGitHubRadarInstallationOctokit(payload.installationId);
const { commits, totalCommits } = await listPullRequestCommits(octokit, {
@@ -645,7 +645,7 @@ export const processGitHubPullRequestEvent: TSecretScanningFactoryProcessEvent<T
secretScanningV2DAL,
auditLogService,
discoverResource,
- queueReportedDiffScan
+ queueReportedRealtimeScan
}) => {
// Pull requests are checked only while the data source scans new commits. A repository the data source doesn't cover
// yet is discovered the same way a push discovers it, or skipped when discovery is off. If the check run cannot be
@@ -771,7 +771,7 @@ export const processGitHubPullRequestEvent: TSecretScanningFactoryProcessEvent<T
checkRunId
};
- await queueReportedDiffScan({
+ await queueReportedRealtimeScan({
scanId,
dataSourceId: dataSource.id,
dataSourceType: SecretScanningDataSource.GitHub,
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.ts
index 2d85e7a2ed..d520c2cfc5 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
@@ -47,7 +47,7 @@ export type TQueueGitHubResourceDiffScan = {
scanId: string;
};
-export type TGitHubDiffScanDetails = {
+export type TGitHubRealtimeScanDetails = {
scannedCommitCount: number;
totalCommitCount: number;
};
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.ts
index 9f8fd88f23..9b584339f9 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
@@ -57,7 +57,7 @@ import {
TSecretScanningDataSourceWithConnection,
TSecretScanningDiscoverResource,
TSecretScanningFinding,
- TSecretScanningQueueReportedDiffScan
+ TSecretScanningQueueReportedRealtimeScan
} from "./secret-scanning-v2-types";
type TSecretRotationV2QueueServiceFactoryDep = {
@@ -773,7 +773,7 @@ export const secretScanningV2QueueServiceFactory = ({
appConnectionDAL
});
- const report = factory.getDiffScanReport?.(payload);
+ const report = factory.getRealtimeScanReport?.(payload);
const prepareScan = async () => {
// Primary for the same reason as the full scan: a lagging replica would drop a just-queued scan.
@@ -1303,7 +1303,7 @@ export const secretScanningV2QueueServiceFactory = ({
* ID the report already carries. Nothing redelivers a realtime scan whose job was never submitted, so if either step
* fails the scan is failed and its report closed here, rather than left queued.
*/
- const queueReportedDiffScan: TSecretScanningQueueReportedDiffScan = async ({
+ const queueReportedRealtimeScan: TSecretScanningQueueReportedRealtimeScan = async ({
scanId,
dataSourceId,
dataSourceType,
@@ -1340,18 +1340,18 @@ export const secretScanningV2QueueServiceFactory = ({
}
);
} catch (error) {
- logger.error(error, `secretScanningV2Queue: Failed to queue reported diff scan ${logDetails}`);
+ logger.error(error, `secretScanningV2Queue: Failed to queue reported realtime scan ${logDetails}`);
const statusMessage = "The scan could not be started.";
try {
await markScanAsFailed({ scanId, statusMessage });
} catch (markError) {
- logger.error(markError, `secretScanningV2Queue: Failed to mark reported diff scan as failed ${logDetails}`);
+ logger.error(markError, `secretScanningV2Queue: Failed to mark reported realtime scan as failed ${logDetails}`);
}
await SECRET_SCANNING_FACTORY_MAP[dataSourceType]({ kmsService, appConnectionDAL })
- .getDiffScanReport?.(payload)
+ .getRealtimeScanReport?.(payload)
?.fail({ reason: statusMessage });
}
};
@@ -1369,7 +1369,7 @@ export const secretScanningV2QueueServiceFactory = ({
secretScanningV2DAL,
auditLogService,
discoverResource,
- queueReportedDiffScan
+ queueReportedRealtimeScan
});
};
diff --git a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-types.ts b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-types.ts
index df975021ee..4596a15b30 100644
--- a/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-types.ts
+++ b/backend/src/ee/services/secret-scanning-v2/secret-scanning-v2-types.ts
@@ -21,7 +21,7 @@ import {
TGitHubDataSourceInput,
TGitHubDataSourceListItem,
TGitHubDataSourceWithConnection,
- TGitHubDiffScanDetails,
+ TGitHubRealtimeScanDetails,
TGitHubFinding,
TQueueGitHubDataSourceEvent,
TQueueGitHubResourceDiffScan
@@ -211,11 +211,11 @@ export type TSecretScanningFactoryGetFullScanPath<T extends TSecretScanningDataS
}) => Promise<string>;
// What a provider learned about the scanned changes beyond the findings, for the scan's report.
-export type TSecretScanningDiffScanDetails = TGitHubDiffScanDetails;
+export type TSecretScanningRealtimeScanDetails = TGitHubRealtimeScanDetails;
-export type TSecretScanningDiffScanFindings = {
+export type TSecretScanningRealtimeScanFindings = {
findings: TFindingsPayload;
- details?: TSecretScanningDiffScanDetails;
+ details?: TSecretScanningRealtimeScanDetails;
};
export type TSecretScanningFactoryGetDiffScanFindingsPayload<
@@ -226,7 +226,7 @@ export type TSecretScanningFactoryGetDiffScanFindingsPayload<
resourceName: string;
payload: P;
configPath?: string;
-}) => Promise<TSecretScanningDiffScanFindings>;
+}) => Promise<TSecretScanningRealtimeScanFindings>;
/**
* Reports a scan back to where it was requested, such as a check run on a GitHub pull request. Every method is called
@@ -244,11 +244,11 @@ export type TSecretScanningScanReport = {
export type TSecretScanningScanReportCompletion = {
findings: TSecretScanningFindings[];
- details?: TSecretScanningDiffScanDetails;
+ details?: TSecretScanningRealtimeScanDetails;
};
// Built from the job payload, so a scan whose data source was deleted can still close its report.
-export type TSecretScanningFactoryGetDiffScanReport<P extends TQueueSecretScanningResourceDiffScan["payload"]> = (
+export type TSecretScanningFactoryGetRealtimeScanReport<P extends TQueueSecretScanningResourceDiffScan["payload"]> = (
payload: P
) => TSecretScanningScanReport | undefined;
@@ -335,7 +335,7 @@ export type TSecretScanningFactory<
validateConfigUpdate: TSecretScanningFactoryValidateConfigUpdate<I["config"], T>;
getDiffScanResourcePayload: TSecretScanningFactoryGetDiffScanResourcePayload<P>;
getDiffScanFindingsPayload: TSecretScanningFactoryGetDiffScanFindingsPayload<T, P>;
- getDiffScanReport?: TSecretScanningFactoryGetDiffScanReport<P>;
+ getRealtimeScanReport?: TSecretScanningFactoryGetRealtimeScanReport<P>;
getScanReport?: TSecretScanningFactoryGetScanReport;
// Processes webhook events beyond pushes, in the worker; only providers that receive them implement it.
processEvent?: TSecretScanningFactoryProcessEvent<E>;
@@ -347,7 +347,7 @@ export type TSecretScanningDiscoverResource = (params: {
trigger: SecretScanningScanTrigger.Push | SecretScanningScanTrigger.PullRequest;
}) => Promise<TSecretScanningResources | undefined>;
-export type TSecretScanningQueueReportedDiffScan = (
+export type TSecretScanningQueueReportedRealtimeScan = (
params: Pick<TQueueSecretScanningResourceDiffScan, "dataSourceType" | "payload"> & {
scanId: string;
dataSourceId: string;
@@ -362,7 +362,7 @@ export type TSecretScanningFactoryProcessEvent<E extends TQueueSecretScanningDat
secretScanningV2DAL: TSecretScanningV2DALFactory;
auditLogService: Pick<TAuditLogServiceFactory, "createAuditLog">;
discoverResource: TSecretScanningDiscoverResource;
- queueReportedDiffScan: TSecretScanningQueueReportedDiffScan;
+ queueReportedRealtimeScan: TSecretScanningQueueReportedRealtimeScan;
}) => Promise<void>;
export type TFindingsPayload = Pick<TSecretScanningFindingsInsert, "details" | "fingerprint" | "severity" | "rule">[];