@@ -10,26 +10,46 @@ import (
1010
1111// TestCompareVulnerabilityFindings now sets up data and calls the assertion helper.
1212func TestCompareVulnerabilityFindings (t * testing.T ) {
13- //repoDataSource := `{"targetType": 1, "uri": {"path": "file://user.go"}, "fileFindingLocationData": {"startLine": 50, "endLine": 55}, "sourceCodeMetadata": {"repositoryUrl": "https://github.com/my-org/my-repo", "reference": "refs/heads/main"}}`
1413 containerDataSource := `{"targetType": 2, "uri": {"path": "pkg:docker/my-app@sha256:f1..."}, "fileFindingLocationData": {"startLine": 1, "endLine": 1}, "ociPackageMetadata": {"packageUrl": "my-registry/my-app", "tag": "1.2.3"}}`
15- //websiteDataSource := `{"targetType": 3, "uri": {"path": "https://example.com/login"}, "fileFindingLocationData": {"startLine": 25, "endLine": 30}, "websiteMetadata": {"url": "https://example.com/login"}}`
1614
1715 expectedFindings := []* ocsf.VulnerabilityFinding {
1816 {
19- FindingInfo : & ocsf.FindingInfo {Uid : "G102" , Title : "Outdated Container" , DataSources : []string {containerDataSource }},
17+ FindingInfo : & ocsf.FindingInfo {
18+ Uid : "G102" ,
19+ Title : "Outdated Container" ,
20+ ProductUid : utils .Ptr ("gosec" ),
21+ DataSources : []string {containerDataSource },
22+ },
2023 Vulnerabilities : []* ocsf.Vulnerability {{
21- // Cve: &ocsf.Cve{Uid: "2023-1234"},
22- AffectedCode : []* ocsf.AffectedCode {{File : & ocsf.File {Name : "pkg:docker/my-app@sha256:f1..." }, StartLine : utils .Ptr (int32 (1 ))}},
24+ AffectedCode : []* ocsf.AffectedCode {
25+ {
26+ File : & ocsf.File {
27+ Name : "pkg:docker/my-app@sha256:f1..." ,
28+ },
29+ StartLine : utils .Ptr (int32 (1 )),
30+ },
31+ },
2332 }},
2433 },
2534 }
2635
2736 actualFindings := []* ocsf.VulnerabilityFinding {
2837 { // Matches G102 perfectly
29- FindingInfo : & ocsf.FindingInfo {Uid : "G102" , Title : "Outdated Container" , DataSources : []string {containerDataSource }},
38+ FindingInfo : & ocsf.FindingInfo {
39+ Uid : "G102" ,
40+ Title : "Outdated Container" ,
41+ ProductUid : utils .Ptr ("gosec" ),
42+ DataSources : []string {containerDataSource },
43+ },
3044 Vulnerabilities : []* ocsf.Vulnerability {{
31- // Cve: &ocsf.Cve{Uid: "2023-1234"},
32- AffectedCode : []* ocsf.AffectedCode {{File : & ocsf.File {Name : "pkg:docker/my-app@sha256:f1..." }, StartLine : utils .Ptr (int32 (1 ))}},
45+ AffectedCode : []* ocsf.AffectedCode {
46+ {
47+ File : & ocsf.File {
48+ Name : "pkg:docker/my-app@sha256:f1..." ,
49+ },
50+ StartLine : utils .Ptr (int32 (1 )),
51+ },
52+ },
3353 }},
3454 },
3555 }
@@ -42,8 +62,9 @@ func TestVulnerabilityFindingValidation(t *testing.T) {
4262 // A valid finding that should pass all assertions
4363 validFinding := & ocsf.VulnerabilityFinding {
4464 FindingInfo : & ocsf.FindingInfo {
45- Uid : "G112" ,
46- Title : "Uncontrolled Resource Consumption" ,
65+ Uid : "G112" ,
66+ Title : "Uncontrolled Resource Consumption" ,
67+ ProductUid : utils .Ptr ("gosec" ),
4768 // --- CORRECTED: JSON string is now a single object, not an array ---
4869 DataSources : []string {`{
4970 "targetType": 1,
0 commit comments