Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ee77df4
docs(sccm): plan advanced server capture
adamgell Aug 5, 2026
f0cae19
docs(sccm): rework advanced capture plan flow
adamgell Aug 5, 2026
1be899e
docs(sccm): bound advanced capture provenance
adamgell Aug 5, 2026
434b854
feat(sccm): validate advanced capture provenance
adamgell Aug 5, 2026
c2ee66b
feat(sccm): add single-use advanced capture collector
adamgell Aug 5, 2026
fb882a8
feat(sccm): expose bounded advanced capture flow
adamgell Aug 5, 2026
e035b67
fix(sccm): preserve inert future-role intake
adamgell Aug 5, 2026
a21b130
fix(sccm): tighten advanced capture manifest flow
adamgell Aug 5, 2026
9b7c1e7
fix(sccm): enforce advanced capture source budgets
adamgell Aug 5, 2026
1c2ae98
fix(sccm): cancel abandoned advanced authorization
adamgell Aug 5, 2026
bd24892
test(sccm): cover authorization replacement race
adamgell Aug 5, 2026
1d7f06b
fix(parser): cap advanced capture source totals
adamgell Aug 5, 2026
d31ae86
merge: integrate current main into SCCM advanced capture
adamgell Aug 5, 2026
0788929
fix(ci): gate advanced SCCM integration tests
adamgell Aug 5, 2026
18d6d92
docs: plan advanced capture main integration
adamgell Aug 5, 2026
9f9bbf3
merge: integrate current main into advanced capture
adamgell Aug 5, 2026
e566984
fix(sccm): bind advanced capture to observed files
adamgell Aug 5, 2026
eec5390
fix(sccm): normalize Windows final path forms
adamgell Aug 5, 2026
2cd7157
Merge main into SCCM advanced capture rework
adamgell Aug 5, 2026
acec6ef
fix(sccm): preserve configured root provenance
adamgell Aug 5, 2026
76b6f6b
Merge commit 'f08d041936682ac59eff2652200c2b3a7d06c4e6' into codex/sc…
adamgell Aug 5, 2026
f4d3536
Merge commit '83351b29' into codex/sccm-advanced-server-capture
adamgell Aug 5, 2026
ecfdb9e
Merge remote-tracking branch 'origin/main' into repair/sccm-advanced-…
adamgell Aug 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

564 changes: 501 additions & 63 deletions crates/cmtraceopen-parser/src/sccm/server/windows/intake.rs

Large diffs are not rendered by default.

307 changes: 306 additions & 1 deletion crates/cmtraceopen-parser/tests/sccm_server_intake.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use cmtraceopen_parser::models::log_entry::Severity;
use cmtraceopen_parser::sccm::server::windows::{
assess_server_intake, declared_server_source_catalog, SccmServerArtifactPayload,
assess_server_intake, declared_server_source_catalog, normalize_server_bundle,
SccmServerAdvancedProvenance, SccmServerArtifactPayload, SccmServerConfiguredPathState,
SccmServerIntakeError, SccmServerSourceKind,
};
use cmtraceopen_parser::sccm::{
Expand All @@ -15,6 +16,310 @@ fn intake_root() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/sccm/server/intake")
}

fn advanced_capture_manifest(
state: &str,
include_payload: bool,
) -> (String, Vec<SccmServerArtifactPayload>) {
let digest = "a".repeat(64);
let artifact_id = format!("cmtraceopen.artifact.sha256.v1:{digest}");
let capability = format!(
"cmtraceopen.capture-capability.sha256.v1:{}",
"b".repeat(64)
);
let authorization = format!(
"cmtraceopen.capture-authorization.sha256.v1:{}",
"c".repeat(64)
);
let root_handle = format!("root-{}", "d".repeat(64));
let relative_path = include_payload.then(|| {
format!(
"evidence/sccm/server/unclassified/advanced-osd-pxe/{root_handle}/current/smspxe.log"
)
});
let manifest = serde_json::json!({
"sccmManifestVersion": 1,
"syntheticFixture": false,
"proposalOnly": null,
"privacy": { "synthetic": false, "rawPaths": "redacted" },
"bundleRole": "server",
"topology": {
"captureHost": format!("cmtraceopen.host.sha256.v1:{}", "e".repeat(64)),
"siteCode": format!("cmtraceopen.site.sha256.v1:{}", "f".repeat(64)),
"rolesObserved": ["siteServer"],
"hierarchyLinks": []
},
"inputOrderIsDeliberatelyUnsorted": null,
"artifacts": [{
"artifactId": artifact_id,
"producerRole": "unclassified",
"producerHostHandle": format!("cmtraceopen.host.sha256.v1:{}", "e".repeat(64)),
"workflowSubject": null,
"sourceId": "advanced-osd-pxe",
"sourceKind": "advancedCapture",
"sourceVersion": "5.00.9141.1000",
"originalPath": "REDACTED",
"originalBasename": "smspxe.log",
"configuredPathProvenance": {
"state": "operatorDeclared",
"pathClass": null,
"pathFingerprint": format!("cmtraceopen.path.sha256.v1:{}", "1".repeat(64))
},
"captureContract": {
"cardId": "osd-pxe",
"cardVersion": "1.0.0",
"capabilityHandle": capability,
"authorizationHandle": authorization,
"roleClaim": "distributionPointPxe",
"pathClaim": "configuredRoleLogRoot",
"roleProvenance": "operatorDeclared",
"pathProvenance": "operatorDeclared"
},
"defaultCandidateState": null,
"rotation": {
"kind": "current",
"value": null,
"lineageId": format!("cmtraceopen.lineage.sha256.v1:{}", "2".repeat(64))
},
"captureState": state,
"collectionDetail": null,
"skipReason": null,
"unsupportedReason": (state == "unsupported").then(|| format!("cmtraceopen.unsupported-reason.sha256.v1:{}", "3".repeat(64))),
"encoding": include_payload.then_some("unknown"),
"collectionLimit": { "byteLimit": 4194304, "fileLimit": 2, "limitApplied": false },
"truncated": null,
"fragmentComplete": null,
"collectedUtc": "2026-08-04T20:00:00Z",
"relativePath": relative_path,
"bytesCopied": if include_payload { 8 } else { 0 }
}]
});
let payloads = include_payload
.then(|| SccmServerArtifactPayload {
manifest_artifact_id: artifact_id,
bytes: b"captured".to_vec(),
})
.into_iter()
.collect();
(serde_json::to_string(&manifest).unwrap(), payloads)
}
Comment on lines +19 to +104

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add an observed-provenance fixture.

Every advanced fixture in this file uses roleProvenance and pathProvenance of operatorDeclared. The observed branch of normalize_advanced_capture_contract is never executed. That branch carries the strictest checks in the change: role_sort_key(producer_role) == role_claim, path state limited to configured or supplied, and path_class == path_claim. The advanced-role topology gate at intake.rs lines 855 to 867 and the new SccmServerConfiguredPathClass variants are also unexercised.

Add a fixture with producerRole set to a recognized advanced role, that role present in rolesObserved, configuredPathProvenance.state of configured, and pathClass equal to the pathClaim. Then add negative cases for a mismatched pathClass and for an advanced role in rolesObserved with no advancedCapture artifact.

As per path instructions: "Verify assertions test real behavior rather than restating the implementation."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/cmtraceopen-parser/tests/sccm_server_intake.rs` around lines 19 - 104,
Extend the advanced-capture test fixtures around advanced_capture_manifest with
an observed-provenance case using a recognized advanced producer role, matching
rolesObserved, configured path state, and pathClass equal to pathClaim. Add
behavioral negative tests covering a mismatched path class and rolesObserved
containing an advanced role without a corresponding advancedCapture artifact,
asserting intake rejects each case. Ensure assertions validate accepted or
rejected intake outcomes rather than merely checking fixture fields.

Source: Path instructions


fn advanced_capture_over_budget_manifest(
tamper_handles: bool,
reverse_order: bool,
) -> (String, Vec<SccmServerArtifactPayload>) {
let (manifest, mut payloads) = advanced_capture_manifest("captured", true);
let mut manifest: Value = serde_json::from_str(&manifest).unwrap();
let mut overflow = manifest["artifacts"][0].clone();
let overflow_id = format!("cmtraceopen.artifact.sha256.v1:{}", "9".repeat(64));
overflow["artifactId"] = json!(overflow_id.clone());
overflow["originalBasename"] = json!("smspxe.lo_");
overflow["rotation"] = json!({
"kind": "lo_",
"value": null,
"lineageId": format!("cmtraceopen.lineage.sha256.v1:{}", "2".repeat(64))
});
overflow["captureState"] = json!("capped");
overflow["collectionLimit"] = json!({
"byteLimit": 4 * 1024 * 1024,
"fileLimit": 2,
"limitApplied": true
});
overflow["truncated"] = json!(true);
overflow["fragmentComplete"] = json!(false);
overflow["relativePath"] = json!(
"evidence/sccm/server/unclassified/advanced-osd-pxe/root-dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/lo_/smspxe.lo_"
);
overflow["bytesCopied"] = json!(4 * 1024 * 1024);
if tamper_handles {
overflow["captureContract"]["capabilityHandle"] = json!(format!(
"cmtraceopen.capture-capability.sha256.v1:{}",
"e".repeat(64)
));
overflow["captureContract"]["authorizationHandle"] = json!(format!(
"cmtraceopen.capture-authorization.sha256.v1:{}",
"f".repeat(64)
));
}
Comment on lines +133 to +142

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

The tamper test does not test the handle check.

With tamper_handles == true the overflow artifact still carries 4 MiB and the base artifact carries 8 bytes. The group total is 4194312 bytes, so the byte cap at intake.rs line 1096 rejects the bundle on its own. Delete the handle equality check at intake.rs lines 1085 to 1089 and advanced_capture_rejects_budget_evasion_by_tampered_handles still passes. The test restates a rejection it cannot attribute.

Make the tampered fixture fit inside the budget so only the handle mismatch can reject it. Set both artifacts to 2 MiB when tamper_handles is true, and assert the untampered 2 MiB pair succeeds.

As per path instructions: "Verify assertions test real behavior rather than restating the implementation."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/cmtraceopen-parser/tests/sccm_server_intake.rs` around lines 133 -
142, Update the tampered fixture in
advanced_capture_rejects_budget_evasion_by_tampered_handles so both artifacts
use 2 MiB when tamper_handles is true, keeping the total within the byte budget.
Ensure the untampered 2 MiB pair is asserted to succeed, so rejection is
attributable only to the mismatched capabilityHandle and authorizationHandle
values rather than the budget check.

Source: Path instructions

manifest["artifacts"].as_array_mut().unwrap().push(overflow);
payloads.push(SccmServerArtifactPayload {
manifest_artifact_id: overflow_id,
bytes: vec![b'x'; 4 * 1024 * 1024],
});
if reverse_order {
manifest["artifacts"].as_array_mut().unwrap().reverse();
payloads.reverse();
}
(serde_json::to_string(&manifest).unwrap(), payloads)
}

fn advanced_capture_distinct_source_manifest() -> (String, Vec<SccmServerArtifactPayload>) {
let (manifest, mut payloads) = advanced_capture_manifest("captured", true);
let mut manifest: Value = serde_json::from_str(&manifest).unwrap();
let mut separate_source = manifest["artifacts"][0].clone();
let separate_id = format!("cmtraceopen.artifact.sha256.v1:{}", "9".repeat(64));
separate_source["artifactId"] = json!(separate_id.clone());
separate_source["configuredPathProvenance"]["pathFingerprint"] =
json!(format!("cmtraceopen.path.sha256.v1:{}", "3".repeat(64)));
separate_source["captureContract"]["capabilityHandle"] = json!(format!(
"cmtraceopen.capture-capability.sha256.v1:{}",
"e".repeat(64)
));
separate_source["captureContract"]["authorizationHandle"] = json!(format!(
"cmtraceopen.capture-authorization.sha256.v1:{}",
"f".repeat(64)
));
separate_source["captureState"] = json!("capped");
separate_source["collectionLimit"] = json!({
"byteLimit": 4 * 1024 * 1024,
"fileLimit": 2,
"limitApplied": true
});
separate_source["truncated"] = json!(true);
separate_source["fragmentComplete"] = json!(false);
separate_source["relativePath"] = json!(
"evidence/sccm/server/unclassified/advanced-osd-pxe/root-eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee/current/smspxe.log"
);
separate_source["bytesCopied"] = json!(4 * 1024 * 1024);
manifest["artifacts"]
.as_array_mut()
.unwrap()
.push(separate_source);
payloads.push(SccmServerArtifactPayload {
manifest_artifact_id: separate_id,
bytes: vec![b'x'; 4 * 1024 * 1024],
});
(serde_json::to_string(&manifest).unwrap(), payloads)
}

#[test]
fn advanced_capture_operator_declared_payload_is_preserved_but_parser_ineligible() {
let (manifest, payloads) = advanced_capture_manifest("captured", true);
let assessment = normalize_server_bundle(&manifest, &payloads).expect("advanced capture");

let artifact = &assessment.artifacts[0];
assert_eq!(
artifact.producer_role,
SccmRole::Unknown("unclassified".to_owned())
);
assert!(!artifact.parser_eligible);
assert_eq!(
artifact.capture_contract.as_ref().unwrap().role_provenance,
SccmServerAdvancedProvenance::OperatorDeclared
);
assert_eq!(
assessment.coverage[0].capture_contract,
artifact.capture_contract
);
assert!(assessment.evidence.is_empty());
assert!(assessment.findings.is_empty());
}

#[test]
fn advanced_capture_operator_declared_missing_candidate_stays_unsupported() {
let (manifest, payloads) = advanced_capture_manifest("unsupported", false);
let assessment = normalize_server_bundle(&manifest, &payloads).expect("coverage row");

assert_eq!(
assessment.artifacts[0].state,
SccmCoverageState::Unsupported
);
assert_eq!(assessment.coverage[0].state, SccmCoverageState::Unsupported);
assert_eq!(
assessment.artifacts[0].configured_path_state,
SccmServerConfiguredPathState::OperatorDeclared
);
assert!(assessment.artifacts[0].configured_path_class.is_none());
}

#[test]
fn advanced_capture_requires_a_closed_capture_contract() {
let (manifest, payloads) = advanced_capture_manifest("captured", true);
let mut value: serde_json::Value = serde_json::from_str(&manifest).unwrap();
value["artifacts"][0]
.as_object_mut()
.unwrap()
.remove("captureContract");
assert_eq!(
normalize_server_bundle(&serde_json::to_string(&value).unwrap(), &payloads),
Err(SccmServerIntakeError::InvalidArtifact)
);
}

#[test]
fn advanced_capture_rejects_card_source_and_provenance_mismatches() {
let (manifest, payloads) = advanced_capture_manifest("captured", true);
for (pointer, replacement) in [
(
"/artifacts/0/captureContract/cardId",
serde_json::json!("reporting"),
),
(
"/artifacts/0/captureContract/pathProvenance",
serde_json::json!("observed"),
),
("/artifacts/0/producerRole", serde_json::json!("siteServer")),
(
"/artifacts/0/configuredPathProvenance/pathClass",
serde_json::json!("siteServerLogs"),
),
] {
let mut value: serde_json::Value = serde_json::from_str(&manifest).unwrap();
*value.pointer_mut(pointer).unwrap() = replacement;
assert_eq!(
normalize_server_bundle(&serde_json::to_string(&value).unwrap(), &payloads),
Err(SccmServerIntakeError::InvalidArtifact),
"mutation {pointer} must fail closed"
);
}
}

#[test]
fn advanced_capture_contract_participates_in_duplicate_identity() {
let (manifest, payloads) = advanced_capture_manifest("captured", true);
let mut value: serde_json::Value = serde_json::from_str(&manifest).unwrap();
let mut duplicate = value["artifacts"][0].clone();
duplicate["artifactId"] =
serde_json::json!(format!("cmtraceopen.artifact.sha256.v1:{}", "9".repeat(64)));
value["artifacts"].as_array_mut().unwrap().push(duplicate);
let mut payloads = payloads;
payloads.push(SccmServerArtifactPayload {
manifest_artifact_id: format!("cmtraceopen.artifact.sha256.v1:{}", "9".repeat(64)),
bytes: b"captured".to_vec(),
});
assert_eq!(
normalize_server_bundle(&serde_json::to_string(&value).unwrap(), &payloads),
Err(SccmServerIntakeError::DuplicateArtifact)
);
}

#[test]
fn advanced_capture_rejects_total_budget_overage_regardless_of_order() {
for reverse_order in [false, true] {
let (manifest, payloads) = advanced_capture_over_budget_manifest(false, reverse_order);
assert_eq!(
normalize_server_bundle(&manifest, &payloads),
Err(SccmServerIntakeError::InvalidArtifact),
"over-budget current + lo_ must fail regardless of input order"
);
}
}

#[test]
fn advanced_capture_rejects_budget_evasion_by_tampered_handles() {
let (manifest, payloads) = advanced_capture_over_budget_manifest(true, true);
assert_eq!(
normalize_server_bundle(&manifest, &payloads),
Err(SccmServerIntakeError::InvalidArtifact)
);
}

#[test]
fn advanced_capture_keeps_distinct_sources_outside_each_others_budget() {
let (manifest, payloads) = advanced_capture_distinct_source_manifest();
let assessment = normalize_server_bundle(&manifest, &payloads).expect("separate sources");
assert_eq!(assessment.artifacts.len(), 2);
}

fn load_bundle(scenario: &str) -> (String, Vec<SccmServerArtifactPayload>) {
let scenario_root = intake_root().join(scenario);
let manifest_json =
Expand Down
Loading