mirror of
https://github.com/Momoko-Ayase/Senbei.git
synced 2026-11-24 18:52:47 +08:00
fix(report): leave failed metadata protection recognition unresolved
This commit is contained in:
1 parent
df81163b3d
commit
05a4337a5e
2 files changed
+47
-2
No files matched your search
+22
-1
@@ -741,7 +741,9 @@ pub(crate) fn metadata_failed_profile(
|
||||
let mut profile = ProtectionProfile::new(senbei_engine::ObservedTarget::metadata(
|
||||
identity.map(|identity| identity.raw_version),
|
||||
));
|
||||
profile.recognition = RecognitionStatus::Recognized;
|
||||
// An attempted transform that did not validate establishes no protection
|
||||
// verdict, even when the metadata header identifies a known version.
|
||||
profile.recognition = RecognitionStatus::Blocked;
|
||||
profile.candidates = vec![senbei_engine::LayoutAttempt {
|
||||
layout: route,
|
||||
outcome: AttemptOutcome::Failed,
|
||||
@@ -765,6 +767,25 @@ mod tests {
|
||||
input
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_failed_metadata_transform_cannot_claim_protection() {
|
||||
for version in [31u32, 999] {
|
||||
let mut header = 0xFAB1_1BAFu32.to_le_bytes().to_vec();
|
||||
header.extend_from_slice(&version.to_le_bytes());
|
||||
let profile = metadata_failed_profile(
|
||||
senbei_metadata::identify(&header),
|
||||
LayoutKind::MetadataStructural,
|
||||
"transform did not validate",
|
||||
);
|
||||
assert_eq!(profile.observed.metadata_version, Some(version));
|
||||
assert_eq!(profile.recognition, RecognitionStatus::Blocked);
|
||||
assert!(profile.evidence.is_empty());
|
||||
assert_eq!(profile.recovery, RecoveryStatus::Failed);
|
||||
assert_eq!(profile.static_validation, ValidationStatus::NotRun);
|
||||
assert!(profile.selected.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn report_round_trips_through_json_with_a_version_field() {
|
||||
let mut collector = Collector::new(Mode::DryRun);
|
||||
|
||||
Reference in new issue
Block a user