mirror of
https://github.com/Momoko-Ayase/Senbei.git
synced 2026-11-24 02: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);
|
||||
|
||||
+25
-1
@@ -318,7 +318,9 @@ fn metadata_outcome(data: &[u8]) -> (Option<u32>, ProtectionProfile, MetadataTra
|
||||
profile.push_warning("metadata is already de-obfuscated; no tokens were rewritten");
|
||||
}
|
||||
Err(error) => {
|
||||
profile.recognition = RecognitionStatus::Recognized;
|
||||
// A version/magic match plus a failed transform cannot establish
|
||||
// that protected method fields were present in this input.
|
||||
profile.recognition = RecognitionStatus::Blocked;
|
||||
profile.candidates = vec![LayoutAttempt {
|
||||
layout: route,
|
||||
outcome: AttemptOutcome::Failed,
|
||||
@@ -333,6 +335,28 @@ fn metadata_outcome(data: &[u8]) -> (Option<u32>, ProtectionProfile, MetadataTra
|
||||
(version, profile, result)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod metadata_profile_tests {
|
||||
use super::*;
|
||||
use senbei_engine::{RecognitionStatus, RecoveryStatus, ValidationStatus};
|
||||
|
||||
#[test]
|
||||
fn failed_metadata_transform_has_no_protection_verdict() {
|
||||
for version in [31u32, 999] {
|
||||
let mut input = 0xFAB1_1BAFu32.to_le_bytes().to_vec();
|
||||
input.extend_from_slice(&version.to_le_bytes());
|
||||
let (observed, profile, result) = metadata_outcome(&input);
|
||||
assert!(result.is_err());
|
||||
assert_eq!(observed, 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Outcome of [`deobfuscate_metadata_reported`].
|
||||
#[wasm_bindgen]
|
||||
pub struct MetadataReport {
|
||||
|
||||
Reference in new issue
Block a user