OXYGENHUB
◆ draft-ready oxygenhub / crates / hub / migrations-pg / 0086_secret_history_scan.sql
1.5 KiB · SQL · last changed Secret scanning: scan existing history, remove an allowed fingerprint 16 days ago source blame history raw
cb7b3cd4 Andy McCall ↶ 1
-- Secret scanning, part 2 (oxygenhub#277): findings from the background
2
-- scan of each repository's history beside those of refused pushes, with
3
-- the change and bookmark they were found in and a maintainer's mark that
4
-- the secret was revoked; and each repository's scan progress, so a pass
5
-- resumes where the last one stopped and a push is scanned incrementally.
6
ALTER TABLE secret_findings ADD COLUMN source TEXT NOT NULL DEFAULT 'push';
7
ALTER TABLE secret_findings ADD COLUMN change_hash TEXT NOT NULL DEFAULT '';
8
ALTER TABLE secret_findings ADD COLUMN bookmark TEXT NOT NULL DEFAULT '';
9
ALTER TABLE secret_findings ADD COLUMN resolved_ms BIGINT;
10
ALTER TABLE secret_findings ADD COLUMN resolved_by TEXT NOT NULL DEFAULT '';
11
ALTER TABLE secret_findings ADD COLUMN resolved_reason TEXT NOT NULL DEFAULT '';
12
-- One history finding per value and file, however many changes carry it.
13
CREATE UNIQUE INDEX secret_findings_history ON secret_findings(repo_id, fingerprint, path) WHERE source = 'history';
14
CREATE TABLE secret_scans (
15
    repo_id       BIGINT PRIMARY KEY REFERENCES repositories(id) ON DELETE CASCADE,
16
    rules_version BIGINT NOT NULL DEFAULT 0,
17
    done_heads    TEXT NOT NULL DEFAULT '',
18
    target_heads  TEXT NOT NULL DEFAULT '',
19
    position      BIGINT NOT NULL DEFAULT 0,
20
    pending       BIGINT NOT NULL DEFAULT 0,
21
    changes       BIGINT NOT NULL DEFAULT 0,
22
    bytes         BIGINT NOT NULL DEFAULT 0,
23
    requested_ms  BIGINT,
24
    pass_ms       BIGINT,
25
    finished_ms   BIGINT,
26
    error         TEXT NOT NULL DEFAULT ''
27
);