@@ -149,7 +149,7 @@ func TestEvaluateSimplifiedPolicies(t *testing.T) {
149149 assert .Contains (t , string (result .Result .Violations [0 ]), "at least 2 components" )
150150 })
151151
152- t .Run ("violations with finding_type use unified format matching attestation storage " , func (t * testing.T ) {
152+ t .Run ("structured findings are returned separately from string violations " , func (t * testing.T ) {
153153 opts := & EvalOptions {
154154 PolicyPath : "testdata/sbom-structured-vuln-policy.yaml" ,
155155 MaterialPath : sbomPath ,
@@ -160,23 +160,23 @@ func TestEvaluateSimplifiedPolicies(t *testing.T) {
160160 require .NotNil (t , result )
161161 assert .False (t , result .Result .Skipped )
162162
163- // Single unified violations field with full violation objects (same as attestation)
163+ // violations contains string messages
164164 require .Len (t , result .Result .Violations , 1 )
165-
166- var v map [ string ] any
167- require . NoError ( t , json . Unmarshal ( result . Result . Violations [ 0 ], & v ))
168- assert . Nil (t , v [ "subject" ], "subject should be excluded from eval output" )
169- assert . Contains ( t , v [ "message" ], "Vulnerability found in test-component@1.0.0" )
170-
171- vuln , ok := v ["vulnerability" ].(map [string ]any )
172- require .True (t , ok , "expected vulnerability finding in violation object " )
165+ assert . Contains ( t , result . Result . Violations [ 0 ], "Vulnerability found in test-component@1.0.0" )
166+
167+ // findings contains the structured data
168+ require . Len (t , result . Result . Findings , 1 )
169+ var f map [ string ] any
170+ require . NoError ( t , json . Unmarshal ( result . Result . Findings [ 0 ], & f ))
171+ vuln , ok := f ["vulnerability" ].(map [string ]any )
172+ require .True (t , ok , "expected vulnerability finding" )
173173 assert .Equal (t , "CVE-2024-1234" , vuln ["external_id" ])
174174 assert .Equal (t , "pkg:generic/test-component@1.0.0" , vuln ["package_purl" ])
175175 assert .Equal (t , "HIGH" , vuln ["severity" ])
176176 assert .InDelta (t , 7.5 , vuln ["cvss_v3_score" ], 0.001 )
177177 })
178178
179- t .Run ("violations without finding_type use same unified format " , func (t * testing.T ) {
179+ t .Run ("plain string violations have no findings " , func (t * testing.T ) {
180180 opts := & EvalOptions {
181181 PolicyPath : "testdata/sbom-min-components-policy.yaml" ,
182182 MaterialPath : sbomPath ,
@@ -186,12 +186,8 @@ func TestEvaluateSimplifiedPolicies(t *testing.T) {
186186 require .NoError (t , err )
187187 require .NotNil (t , result )
188188 require .Len (t , result .Result .Violations , 1 )
189-
190- // Same structure as attestation: object with message (subject excluded in eval)
191- var v map [string ]any
192- require .NoError (t , json .Unmarshal (result .Result .Violations [0 ], & v ))
193- assert .Nil (t , v ["subject" ], "subject should be excluded from eval output" )
194- assert .Contains (t , v ["message" ], "at least 2 components" )
189+ assert .Contains (t , result .Result .Violations [0 ], "at least 2 components" )
190+ assert .Empty (t , result .Result .Findings )
195191 })
196192
197193 t .Run ("sbom metadata component policy" , func (t * testing.T ) {
0 commit comments