summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/db')
-rw-r--r--src/db/migrations.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/db/migrations.rs b/src/db/migrations.rs
index dddb301..8ba925c 100644
--- a/src/db/migrations.rs
+++ b/src/db/migrations.rs
@@ -282,12 +282,30 @@ ALTER TABLE artifact ADD COLUMN build_id TEXT;
CREATE INDEX artifact_by_build ON artifact (build_id);
"#;
+/// §7.2: the approval record is immutable. It is the only proof the system has
+/// of *what a human actually looked at*, so editing it would let a later
+/// attacker retarget a published artifact onto a clean review.
+const M_0006_APPROVAL_IMMUTABLE: &str = r#"
+CREATE TRIGGER approval_no_update
+BEFORE UPDATE ON approval
+BEGIN
+ SELECT RAISE(ABORT, 'approval records are immutable');
+END;
+
+CREATE TRIGGER approval_no_delete
+BEFORE DELETE ON approval
+BEGIN
+ SELECT RAISE(ABORT, 'approval records are immutable');
+END;
+"#;
+
pub static MIGRATIONS: &[Migration] = &[
Migration { version: 1, name: "core", sql: M_0001_CORE },
Migration { version: 2, name: "build", sql: M_0002_BUILD },
Migration { version: 3, name: "notices", sql: M_0003_NOTICES },
Migration { version: 4, name: "audit-triggers", sql: M_0004_TRIGGERS },
Migration { version: 5, name: "artifact-build", sql: M_0005_ARTIFACT_BUILD },
+ Migration { version: 6, name: "approval-immutable", sql: M_0006_APPROVAL_IMMUTABLE },
];
/// Default settings seeded into `settings` (DESIGN.md §11).