OXYGENHUB
# c43e4f631d99 oxygenhub / crates / hub / migrations / 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
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 INTEGER;
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       INTEGER PRIMARY KEY REFERENCES repositories(id) ON DELETE CASCADE,
16
    rules_version INTEGER NOT NULL DEFAULT 0,
17
    done_heads    TEXT NOT NULL DEFAULT '',
18
    target_heads  TEXT NOT NULL DEFAULT '',
19
    position      INTEGER NOT NULL DEFAULT 0,
20
    pending       INTEGER NOT NULL DEFAULT 0,
21
    changes       INTEGER NOT NULL DEFAULT 0,
22
    bytes         INTEGER NOT NULL DEFAULT 0,
23
    requested_ms  INTEGER,
24
    pass_ms       INTEGER,
25
    finished_ms   INTEGER,
26
    error         TEXT NOT NULL DEFAULT ''
27
);