201 lines · 7.0 KB
import { MAX_IN_LIST, chunks, placeholders } from "../db";
import { repoDb } from "../scoped-db";
import { accountsById } from "../people";
import { randomId } from "../crypto";
import { forbidden } from "../errors";
import { detectorName } from "./detectors";
import type { RedactedFinding } from "./detectors";
import { nextSecurityNumber } from "./settings";
import { notifySecretAlerts } from "../notify/security";

const MAX_ALERTS_PER_SCAN = 100;
const ALERT_PAGE = 50;

export type SecretResolution = "revoked" | "false_positive" | "used_in_tests" | "wont_fix";
export type LocatedFinding = RedactedFinding & { path: string | null; commitSha: string | null };

export type SecretAlert = {
  number: number;
  detector: string;
  detectorName: string;
  preview: string;
  path: string | null;
  line: number | null;
  commitSha: string | null;
  state: "open" | "resolved";
  resolution: string | null;
  resolvedBy: string | null;
  resolvedAt: number | null;
  createdAt: number;
};

type AlertRow = {
  number: number;
  detector: string;
  preview: string;
  path: string | null;
  line: number | null;
  commit_sha: string | null;
  state: "open" | "resolved";
  resolution: string | null;