Bind retained updater history to qualified baseline decoder contract
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -520,8 +520,36 @@ mod tests {
|
|||||||
os::unix::fs::OpenOptionsExt,
|
os::unix::fs::OpenOptionsExt,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
// The production census correctly denies a changing descriptor table.
|
||||||
|
// Other parallel unit tests open/close files in this same test process;
|
||||||
|
// exercise each actual /proc fixture in a separate exact-test process.
|
||||||
|
fn in_isolated_fixture(name: &str) -> bool {
|
||||||
|
const CHILD: &str = "RMM_CENSUS_EXACT_TEST_PROCESS";
|
||||||
|
if std::env::var_os(CHILD).as_deref() == Some(std::ffi::OsStr::new(name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let output = std::process::Command::new(std::env::current_exe().unwrap())
|
||||||
|
.args(["--exact", name, "--test-threads=1"])
|
||||||
|
.env(CHILD, name)
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
assert!(
|
||||||
|
output.status.success()
|
||||||
|
&& String::from_utf8_lossy(&output.stdout).contains("1 passed; 0 failed"),
|
||||||
|
"isolated census fixture: {:?}\n{}\n{}",
|
||||||
|
output.status.code(),
|
||||||
|
String::from_utf8_lossy(&output.stdout),
|
||||||
|
String::from_utf8_lossy(&output.stderr)
|
||||||
|
);
|
||||||
|
false
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn private_thread_fd_table_cannot_hide_a_reader_from_the_group_probe() {
|
fn private_thread_fd_table_cannot_hide_a_reader_from_the_group_probe() {
|
||||||
|
if !in_isolated_fixture(
|
||||||
|
"census_process::tests::private_thread_fd_table_cannot_hide_a_reader_from_the_group_probe",
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
assert_eq!(unsafe { libc::geteuid() }, 0);
|
assert_eq!(unsafe { libc::geteuid() }, 0);
|
||||||
let path = std::path::Path::new("/run")
|
let path = std::path::Path::new("/run")
|
||||||
.join(format!("rmm-census-thread-{}", uuid::Uuid::new_v4()));
|
.join(format!("rmm-census-thread-{}", uuid::Uuid::new_v4()));
|
||||||
@@ -625,6 +653,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn actual_proc_probe_detects_existing_descriptors_and_mapped_inode_without_exporting_paths() {
|
fn actual_proc_probe_detects_existing_descriptors_and_mapped_inode_without_exporting_paths() {
|
||||||
|
if !in_isolated_fixture(
|
||||||
|
"census_process::tests::actual_proc_probe_detects_existing_descriptors_and_mapped_inode_without_exporting_paths",
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// An isolated network-none container process, not a host-wide scan,
|
// An isolated network-none container process, not a host-wide scan,
|
||||||
// service/namespace qualification or admission-positive fixture.
|
// service/namespace qualification or admission-positive fixture.
|
||||||
assert_eq!(unsafe { libc::geteuid() }, 0);
|
assert_eq!(unsafe { libc::geteuid() }, 0);
|
||||||
|
|||||||
@@ -81,7 +81,13 @@ pub fn verify_history(
|
|||||||
let mut signed = BASELINE_SIGNATURE_DOMAIN.to_vec();
|
let mut signed = BASELINE_SIGNATURE_DOMAIN.to_vec();
|
||||||
signed.extend_from_slice(&initial.payload_bytes);
|
signed.extend_from_slice(&initial.payload_bytes);
|
||||||
verifier.verify_strict(&signed, &Signature::from_bytes(&initial.signature))?;
|
verifier.verify_strict(&signed, &Signature::from_bytes(&initial.signature))?;
|
||||||
verify_record_release(&keyring, protected_keyring.generation, &initial.record)?;
|
verify_record_release(
|
||||||
|
&keyring,
|
||||||
|
protected_keyring.generation,
|
||||||
|
&initial.record,
|
||||||
|
initial_release.manifest.protocol_major,
|
||||||
|
initial_release.manifest.state_schema,
|
||||||
|
)?;
|
||||||
|
|
||||||
ensure!(
|
ensure!(
|
||||||
predecessor_records.len() < MAX_RECORDS
|
predecessor_records.len() < MAX_RECORDS
|
||||||
@@ -156,7 +162,13 @@ pub fn verify_history(
|
|||||||
&& record.activated_at >= parent.activated_at,
|
&& record.activated_at >= parent.activated_at,
|
||||||
"UPDATE_HISTORY_FLOOR_OR_ROLLBACK"
|
"UPDATE_HISTORY_FLOOR_OR_ROLLBACK"
|
||||||
);
|
);
|
||||||
verify_record_release(&keyring, protected_keyring.generation, record)?;
|
verify_record_release(
|
||||||
|
&keyring,
|
||||||
|
protected_keyring.generation,
|
||||||
|
record,
|
||||||
|
initial_release.manifest.protocol_major,
|
||||||
|
initial_release.manifest.state_schema,
|
||||||
|
)?;
|
||||||
let grant = verify_update(db, guard, binding, raw, record, parent_digest, parent)?;
|
let grant = verify_update(db, guard, binding, raw, record, parent_digest, parent)?;
|
||||||
ensure!(grants.insert(grant), "UPDATE_HISTORY_REUSED_GRANT");
|
ensure!(grants.insert(grant), "UPDATE_HISTORY_REUSED_GRANT");
|
||||||
ensure!(*digest == hash(raw), "UPDATE_HISTORY_RECORD_CHANGED");
|
ensure!(*digest == hash(raw), "UPDATE_HISTORY_RECORD_CHANGED");
|
||||||
@@ -280,6 +292,8 @@ fn verify_record_release(
|
|||||||
keys: &UpdateKeyring,
|
keys: &UpdateKeyring,
|
||||||
generation: u64,
|
generation: u64,
|
||||||
record: &InstalledReleaseRecord,
|
record: &InstalledReleaseRecord,
|
||||||
|
baseline_protocol_major: u32,
|
||||||
|
baseline_state_schema: u32,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
ensure!(
|
ensure!(
|
||||||
!record.rolled_back,
|
!record.rolled_back,
|
||||||
@@ -306,8 +320,11 @@ fn verify_record_release(
|
|||||||
platform,
|
platform,
|
||||||
now_utc_seconds: record.activated_at,
|
now_utc_seconds: record.activated_at,
|
||||||
keyring_generation: generation,
|
keyring_generation: generation,
|
||||||
protocol_major: decoded.manifest.protocol_major,
|
// Anchor compatibility to the separately signed, qualified
|
||||||
state_schema: decoded.manifest.state_schema,
|
// bootstrap. A signed successor cannot attest its own decoder
|
||||||
|
// compatibility by supplying both sides of this comparison.
|
||||||
|
protocol_major: baseline_protocol_major,
|
||||||
|
state_schema: baseline_state_schema,
|
||||||
updater_version: 1,
|
updater_version: 1,
|
||||||
minimum_release_sequence: record.activation_floor,
|
minimum_release_sequence: record.activation_floor,
|
||||||
active_release: Some(ActiveRelease {
|
active_release: Some(ActiveRelease {
|
||||||
@@ -786,6 +803,9 @@ mod tests {
|
|||||||
active: Vec<u8>,
|
active: Vec<u8>,
|
||||||
}
|
}
|
||||||
fn fixture() -> Fixture {
|
fn fixture() -> Fixture {
|
||||||
|
fixture_target_contract(1, 1)
|
||||||
|
}
|
||||||
|
fn fixture_target_contract(protocol_major: u32, state_schema: u32) -> Fixture {
|
||||||
let release = SigningKey::from_bytes(&[71; 32]); // public synthetic TEST seed
|
let release = SigningKey::from_bytes(&[71; 32]); // public synthetic TEST seed
|
||||||
let jobs = SigningKey::from_bytes(&[72; 32]);
|
let jobs = SigningKey::from_bytes(&[72; 32]);
|
||||||
let health = SigningKey::from_bytes(&[73; 32]);
|
let health = SigningKey::from_bytes(&[73; 32]);
|
||||||
@@ -801,8 +821,13 @@ mod tests {
|
|||||||
let Action::UpdateAgent { update } = &mut job.action else {
|
let Action::UpdateAgent { update } = &mut job.action else {
|
||||||
panic!("fixture action")
|
panic!("fixture action")
|
||||||
};
|
};
|
||||||
let target = envelope(update.manifest().unwrap(), 2, &release);
|
let mut target_manifest = update.manifest().unwrap();
|
||||||
|
target_manifest.protocol_major = protocol_major;
|
||||||
|
target_manifest.state_schema = state_schema;
|
||||||
|
let target = envelope(target_manifest, 2, &release);
|
||||||
let mut old = target.decode().unwrap().manifest;
|
let mut old = target.decode().unwrap().manifest;
|
||||||
|
old.protocol_major = 1;
|
||||||
|
old.state_schema = 1;
|
||||||
old.release_id = update.predecessor.release_id;
|
old.release_id = update.predecessor.release_id;
|
||||||
old.artifacts[0].artifact_id = Uuid::from_u128(901);
|
old.artifacts[0].artifact_id = Uuid::from_u128(901);
|
||||||
old.artifacts[1].artifact_id = Uuid::from_u128(902);
|
old.artifacts[1].artifact_id = Uuid::from_u128(902);
|
||||||
@@ -1404,6 +1429,150 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn signed_successor_cannot_self_attest_compatibility_with_retained_baseline() {
|
||||||
|
// These fixtures contain genuine release, baseline, job and health
|
||||||
|
// signatures and a complete consumed/native publication chain. Only
|
||||||
|
// the successor's decoder contract differs from the original baseline.
|
||||||
|
for (protocol, schema, error) in [
|
||||||
|
(2, 1, "incompatible release protocol"),
|
||||||
|
(1, 2, "incompatible release state schema"),
|
||||||
|
] {
|
||||||
|
let f = fixture_target_contract(protocol, schema);
|
||||||
|
let before = f.db.total_changes();
|
||||||
|
let rejected = verify_history(
|
||||||
|
&f.db,
|
||||||
|
&f.guard,
|
||||||
|
&f.binding,
|
||||||
|
&f.keys,
|
||||||
|
&f.baseline,
|
||||||
|
&[],
|
||||||
|
&f.active,
|
||||||
|
)
|
||||||
|
.unwrap_err();
|
||||||
|
assert!(rejected.to_string().contains(error), "{rejected:#}");
|
||||||
|
assert_eq!(f.db.total_changes(), before);
|
||||||
|
assert_eq!(
|
||||||
|
InstalledReleaseRecord::from_bytes(&f.initial)
|
||||||
|
.unwrap()
|
||||||
|
.activation_floor,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
InstalledReleaseRecord::from_bytes(&f.active)
|
||||||
|
.unwrap()
|
||||||
|
.activation_floor,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let f = fixture();
|
||||||
|
let before = f.db.total_changes();
|
||||||
|
assert_eq!(
|
||||||
|
verify_history(
|
||||||
|
&f.db,
|
||||||
|
&f.guard,
|
||||||
|
&f.binding,
|
||||||
|
&f.keys,
|
||||||
|
&f.baseline,
|
||||||
|
&[],
|
||||||
|
&f.active,
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
.bytes()
|
||||||
|
.unwrap(),
|
||||||
|
f.active
|
||||||
|
);
|
||||||
|
assert_eq!(f.db.total_changes(), before);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn retained_predecessor_is_not_a_rollback_receipt_and_unknown_stays_closed() {
|
||||||
|
let f = fixture();
|
||||||
|
// Even a genuine release-signed exact predecessor with the retained
|
||||||
|
// higher floor is only metadata. V1 has no rollback activation witness.
|
||||||
|
let active = InstalledReleaseRecord::from_bytes(&f.active).unwrap();
|
||||||
|
let mut returned = InstalledReleaseRecord::from_bytes(&f.initial).unwrap();
|
||||||
|
returned.activation_floor = active.activation_floor;
|
||||||
|
returned.activated_at = active.activated_at + 1;
|
||||||
|
returned.previous_record_sha256 = Some(hash(&f.active));
|
||||||
|
returned.activation_evidence = active.activation_evidence.clone();
|
||||||
|
returned.rolled_back = true;
|
||||||
|
let returned = returned.bytes().unwrap();
|
||||||
|
let before = f.db.total_changes();
|
||||||
|
assert!(
|
||||||
|
verify_history(
|
||||||
|
&f.db,
|
||||||
|
&f.guard,
|
||||||
|
&f.binding,
|
||||||
|
&f.keys,
|
||||||
|
&f.baseline,
|
||||||
|
std::slice::from_ref(&f.active),
|
||||||
|
&returned,
|
||||||
|
)
|
||||||
|
.unwrap_err()
|
||||||
|
.to_string()
|
||||||
|
.contains("UPDATE_HISTORY_FLOOR_OR_ROLLBACK")
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
verify_history(
|
||||||
|
&f.db,
|
||||||
|
&f.guard,
|
||||||
|
&f.binding,
|
||||||
|
&f.keys,
|
||||||
|
&f.baseline,
|
||||||
|
&[],
|
||||||
|
&f.initial,
|
||||||
|
)
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
assert_eq!(f.db.total_changes(), before);
|
||||||
|
assert_eq!(
|
||||||
|
InstalledReleaseRecord::from_bytes(&returned)
|
||||||
|
.unwrap()
|
||||||
|
.activation_floor,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
|
// A previously stored Unknown is never reclassified from a retained
|
||||||
|
// healthy target or a proposed predecessor return. This is a synthetic
|
||||||
|
// local fixture mutation; the verifier itself performs no writes.
|
||||||
|
let unknown = serde_json::to_vec(&Outcome::unknown("synthetic unresolved update")).unwrap();
|
||||||
|
f.db.execute("UPDATE execution_evidence SET outcome=?1", [&unknown])
|
||||||
|
.unwrap();
|
||||||
|
f.db.execute("UPDATE consumed SET result=?1", [&unknown])
|
||||||
|
.unwrap();
|
||||||
|
let before = f.db.total_changes();
|
||||||
|
assert!(
|
||||||
|
verify_history(
|
||||||
|
&f.db,
|
||||||
|
&f.guard,
|
||||||
|
&f.binding,
|
||||||
|
&f.keys,
|
||||||
|
&f.baseline,
|
||||||
|
&[],
|
||||||
|
&f.active,
|
||||||
|
)
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
verify_history(
|
||||||
|
&f.db,
|
||||||
|
&f.guard,
|
||||||
|
&f.binding,
|
||||||
|
&f.keys,
|
||||||
|
&f.baseline,
|
||||||
|
std::slice::from_ref(&f.active),
|
||||||
|
&returned,
|
||||||
|
)
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
let retained: Vec<u8> =
|
||||||
|
f.db.query_row("SELECT outcome FROM execution_evidence", [], |r| r.get(0))
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(retained, unknown);
|
||||||
|
assert_eq!(f.db.total_changes(), before);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn completed_history_rejects_file_only_rollback_forks_and_tampered_activation_without_writes() {
|
fn completed_history_rejects_file_only_rollback_forks_and_tampered_activation_without_writes() {
|
||||||
let f = fixture();
|
let f = fixture();
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
# Erhaltener Decodervertrag und weiterhin gesperrte Rückkehr
|
||||||
|
|
||||||
|
Stand2026-11-15, enger lokaler Quellschnitt im bestehenden Worker. Keine neue
|
||||||
|
Journalversion, kein gestarteter Updater, keine VM- oder Applyabnahme.
|
||||||
|
|
||||||
|
## Konkreter Befund und Änderung
|
||||||
|
|
||||||
|
`history::verify_history` authentisiert die separat release-signierte
|
||||||
|
Bootstrapbaseline, die vollständige aufsteigende InstalledRecord-Kette und die
|
||||||
|
ursprünglichen Job-/Handoff-/Health-/Publikationszeugen im erhaltenen Helperledger.
|
||||||
|
Die bisherige Releaseprüfung übernahm jedoch Protokollhauptversion und
|
||||||
|
Zustandsschema aus genau dem Nachfolgermanifest, dessen Kompatibilität sie prüfte.
|
||||||
|
Eine echte Signatur authentisiert einen Releaseinhalt; sie beweist nicht, dass
|
||||||
|
dieser Inhalt den Decodervertrag des erhaltenen Zustands unterstützt.
|
||||||
|
|
||||||
|
Die bestehende Prüfung bekommt jetzt beide Vergleichswerte ausschließlich aus
|
||||||
|
dem separat signierten qualifizierten Bootstrapmanifest. Jeder historische
|
||||||
|
Nachfolger muss diese Werte erhalten. Aktuelle Keywiderrufe, Schlüsselbereiche,
|
||||||
|
Manifest-/Job-/Healthsignaturen, unveränderte Originalbytes und monotoner Floor
|
||||||
|
bleiben zusätzliche Bedingungen. Die Funktion schreibt weiterhin keine SQLzeile.
|
||||||
|
Es gibt keinen neuen Manifest-/Job-/Handoffcodec und keine Datenmigration.
|
||||||
|
|
||||||
|
Dies schließt eine konkrete Kompatibilitätslücke in einem bereits aufgerufenen
|
||||||
|
Reader: `TrustState::qualify_history` verwendet `verify_history` vor neuer
|
||||||
|
Admission sowie unter dem übernommenen Guard vor dem Austausch. Es ist keine
|
||||||
|
Aussage, dass gleiche Versionsnummern die gesamte tatsächliche Decoderfähigkeit
|
||||||
|
beweisen; diese bleibt Bestandteil der unabhängig qualifizierten Bootstrap- und
|
||||||
|
Releaseartefakte. Eine zukünftige ausdrücklich beauftragte Protokoll- oder
|
||||||
|
Zustandsmigration braucht einen eigenen Vertrag.
|
||||||
|
|
||||||
|
## Weshalb damit noch kein Rollback freigegeben ist
|
||||||
|
|
||||||
|
Im vorhandenen Datenvertrag existiert kein normierter V2-Rückkehrzeuge:
|
||||||
|
|
||||||
|
- `Handoff`, `Event` und `Journal` verstehen nur Schema1 und die Vorwärtsfolge.
|
||||||
|
Ein endgültiges `Unknown` bleibt terminal.
|
||||||
|
- `ActivationEvidence` kennt `Bootstrap` und `Updated` mit positivem Healthbeleg;
|
||||||
|
das Feld `rolled_back` allein authentisiert keine Rückkehrwirkung.
|
||||||
|
- Core verweigert `NativeEffect::RestorePredecessor` sowohl beim Claim als auch
|
||||||
|
bei der Beobachtung. Ein vorhandener Linux-Dateiport ist keine Genehmigung.
|
||||||
|
- History verweigert rückkehrende Records und alte Recorddateien, welche die
|
||||||
|
inzwischen vollständig abgeschlossenen Verbräuche/Publikationen auslassen.
|
||||||
|
|
||||||
|
Der ursprüngliche signierte Job bindet bereits
|
||||||
|
`restore_exact_predecessor_once`. Es fehlen jedoch dessen vollständig gebundene
|
||||||
|
dauerhafte Rückwegphasen, belegter eindeutiger Fehlstart, exklusive Guard-/Owner-
|
||||||
|
Übergabe, jede einzelne native Rückkehrbeobachtung, neuer Prozess-/Healthbeleg,
|
||||||
|
Record-/Floorpublikation und failed-Originaloutcome. Vor erster Applybaseline
|
||||||
|
müssen sämtliche tatsächlich installierten Agent-/General-/Fullreader genau
|
||||||
|
diesen noch fehlenden Vertrag verstehen. Das alte1.20-Paar ist kein Rückkehrziel.
|
||||||
|
Kein paralleles unbeobachtetes Journalformat wird als Ersatz eingeführt.
|
||||||
|
|
||||||
|
## Tatsächliche lokale Prüfungen und Grenzen
|
||||||
|
|
||||||
|
Die neuen Fälle verwenden synthetische, aber echte Ed25519-Release-, Baseline-,
|
||||||
|
Job- und Healthsignaturen samt vollständigen in-memory SQLiteoriginalen. Sie
|
||||||
|
prüfen inkompatible Protokoll- und Zustandsschemas, die unveränderte positive
|
||||||
|
Vorwärtskette, eine vorgeschlagene exakte Vorgängerrückkehr mit erhaltenem
|
||||||
|
höherem Floor sowie gespeichertes Unknown. Vor/nach jeder Readerprüfung bleibt
|
||||||
|
`total_changes` gleich; Unknown-Originalbytes und Floors bleiben erhalten.
|
||||||
|
|
||||||
|
Tatsächlich im vorhandenen isolierten Buildcontainer, Netzwerk aus:
|
||||||
|
|
||||||
|
```text
|
||||||
|
cargo test --release --locked --offline -p rmm-updater-worker --all-targets
|
||||||
|
cargo clippy --locked --offline -p rmm-updater-worker --all-targets -- -D warnings
|
||||||
|
cargo fmt -p rmm-updater-worker --check
|
||||||
|
```
|
||||||
|
|
||||||
|
Abschließender normal paralleler Testlauf:12/12 bestanden,0Fehler,0ignoriert;
|
||||||
|
Clippy und Formatprüfung bestanden. Eine private Quellrückmutation ausschließlich
|
||||||
|
auf den alten selbstreferenzierenden Vergleich macht den neuen signierten
|
||||||
|
Kompatibilitätstest erwartungsgemäß rot: Exit101, `unwrap_err` erhält `Ok`.
|
||||||
|
Die Produktionsquelle wurde hierfür nicht zurückgeändert. Dies belegt den
|
||||||
|
konkreten Readerfehler; es ist keine simulierte Updatewirkung.
|
||||||
|
|
||||||
|
Der erste parallele Lauf hatte10/12 bestanden; zwei vorhandene Selbstprozess-
|
||||||
|
Censusfixtures verweigerten eine während anderer Unitfälle wechselnde FD-Tabelle.
|
||||||
|
Der unveränderte Produktguard bestand im seriellen12er-Lauf. Die beiden Fixtures
|
||||||
|
laufen jetzt je in einem eigenen exakt ausgewählten Testprozess, mit unverändertem
|
||||||
|
Censuscode und echten privaten Thread-FD-/mmap-Proben. Danach bestand der normale
|
||||||
|
parallele12er-Lauf. Der erste Clippylauf fand zwei unnötige Testdatenklone;
|
||||||
|
sie wurden ohne Warnungsunterdrückung entfernt. Alte Fehlerlogs bleiben erhalten.
|
||||||
|
|
||||||
|
Geschützter lokaler Belegpfad:
|
||||||
|
`devstate/updater-history-contract-73511ace-428f-4aaf-8742-720619459907/`.
|
||||||
|
Native Linux-/Windowsqualifikation, Codeaustausch und WebUI-genehmigter Updatejob
|
||||||
|
sind nicht ausgeführt. Frühere native Censusberichte qualifizieren nicht die
|
||||||
|
neue Testbinary. Notebook bleibt ausschließlich Entwicklungsrechner.
|
||||||
Reference in New Issue
Block a user