Propagate source evidence sensitivity through history

This commit is contained in:
2026-10-15 16:00:01 +00:00
parent fed591183b
commit 1e47ee21cd
4 changed files with 128 additions and 44 deletions

View File

@@ -92,6 +92,40 @@ func TestInheritanceSensitivityIncludesSchemaTaggedSource(t *testing.T) {
}
}
func TestSourceVersionEvidenceSensitivityFollowsInheritanceAndDisplacedHistory(t *testing.T) {
const canary = "EVIDENCE-INHERITANCE-CANARY"
input := parseCompositionDocument(t, "source-1", "parent: {branch: {token: "+canary+", plain: visible}}\nchild: {extends: parent, branch: public}\n")
inspection, _ := inheritanceInspectionForTest(t, input)
secretPath := Keys("parent", "branch", "token")
evidence := &sourceVersionEvidence{
path: secretPath.clone(), resolvedPath: secretPath.clone(),
version: Version{Present: true, Text: canary},
ancestors: []sourceVersionAncestor{{}, {path: Keys("parent")}, {path: Keys("parent", "branch")}, {path: secretPath.clone()}},
}
inspection.secrets = classifySecretPathsWithEvidence(nil, func(path Path) bool {
return path.String() == secretPath.String()
}, inspection.metadata, inspection.final, inspection.applications, []*sourceVersionEvidence{evidence}, inspection.input)
path := Keys("child", "branch", "token")
explanation, found := inspection.Explain(path)
if !found || explanation.Effective.Present {
t.Fatalf("displaced inherited path = %#v, %v", explanation, found)
}
for _, change := range explanation.History {
if strings.Contains(change.Before.YAML, canary) || strings.Contains(change.After.YAML, canary) ||
(change.After.Present && !change.After.Redacted) {
t.Fatalf("displaced inherited canary escaped redaction: %#v", explanation.History)
}
}
plain, found := inspection.Explain(Keys("parent", "branch", "plain"))
if !found || plain.Effective.Redacted || plain.Effective.YAML != "visible\n" {
t.Fatalf("neighboring value was classified with evidence: %#v, %v", plain, found)
}
if _, found := inspection.Metadata().Lookup(Keys("evidence-only")); found {
t.Fatal("evidence classification created a metadata path")
}
}
func TestInheritedSecretReferencesResolveOnlyAfterExpansion(t *testing.T) {
type entry struct {
Credential Secret `yaml:"credential"`