Skip to content

Commit 161cc99

Browse files
Merge branch 'main' into feat/update-pre-receive-secrets-license-logic
2 parents 23ef6c2 + d6cc44a commit 161cc99

File tree

9 files changed

+194
-32
lines changed

9 files changed

+194
-32
lines changed

go.mod

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/checkmarx/ast-cli
33
go 1.24.6
44

55
require (
6-
github.com/Checkmarx/containers-resolver v1.0.20
6+
github.com/Checkmarx/containers-resolver v1.0.21
77
github.com/Checkmarx/containers-types v1.0.9
88
github.com/Checkmarx/gen-ai-prompts v0.0.0-20240807143411-708ceec12b63
99
github.com/Checkmarx/gen-ai-wrapper v1.0.2
@@ -35,14 +35,20 @@ require (
3535
)
3636

3737
require (
38+
github.com/ncruces/go-strftime v0.1.9 // indirect
39+
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
40+
modernc.org/libc v1.66.3 // indirect
41+
modernc.org/mathutil v1.7.1 // indirect
42+
modernc.org/memory v1.11.0 // indirect
43+
modernc.org/sqlite v1.38.2 // indirect
3844
dario.cat/mergo v1.0.1 // indirect
3945
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
4046
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20240914100643-eb91380d8434 // indirect
4147
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
4248
github.com/BobuSumisu/aho-corasick v1.0.3 // indirect
4349
github.com/BurntSushi/toml v1.5.0 // indirect
4450
github.com/Checkmarx/containers-images-extractor v1.0.18
45-
github.com/Checkmarx/containers-syft-packages-extractor v1.0.16 // indirect
51+
github.com/Checkmarx/containers-syft-packages-extractor v1.0.17 // indirect
4652
github.com/CycloneDX/cyclonedx-go v0.9.2 // indirect
4753
github.com/DataDog/zstd v1.5.6 // indirect
4854
github.com/Masterminds/goutils v1.1.1 // indirect
@@ -139,7 +145,7 @@ require (
139145
github.com/go-openapi/jsonreference v0.21.0 // indirect
140146
github.com/go-openapi/swag v0.23.1 // indirect
141147
github.com/go-restruct/restruct v1.2.0-alpha // indirect
142-
github.com/go-viper/mapstructure/v2 v2.3.0 // indirect
148+
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
143149
github.com/gobwas/glob v0.2.3 // indirect
144150
github.com/gogo/protobuf v1.3.2 // indirect
145151
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
@@ -271,7 +277,7 @@ require (
271277
go.uber.org/multierr v1.11.0 // indirect
272278
go.yaml.in/yaml/v2 v2.4.2 // indirect
273279
go.yaml.in/yaml/v3 v3.0.3 // indirect
274-
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
280+
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
275281
golang.org/x/mod v0.26.0 // indirect
276282
golang.org/x/net v0.42.0 // indirect
277283
golang.org/x/oauth2 v0.30.0 // indirect

go.sum

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2
6565
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
6666
github.com/Checkmarx/containers-images-extractor v1.0.18 h1:vj22lJurK72Zw28uenlzntDKIiXK0zN993lfsMdJh+w=
6767
github.com/Checkmarx/containers-images-extractor v1.0.18/go.mod h1:n3B8u4/WZCtsIwamIz7Prz6Ktl169i+aJb9Yq5R3D2M=
68-
github.com/Checkmarx/containers-resolver v1.0.20 h1:GZgR28qjmIUDfDdGy1kYbiE1G+SZ8kbJKHZOylaCr+E=
69-
github.com/Checkmarx/containers-resolver v1.0.20/go.mod h1:pn2l9OjXa1UaivBczoeNnzmzcHnEDPufu4hk2k87jmo=
70-
github.com/Checkmarx/containers-syft-packages-extractor v1.0.16 h1:l1UvnheiUIKgRr9d3cB1XiJDNQxeLx2MNz0Cn6zQe8Y=
71-
github.com/Checkmarx/containers-syft-packages-extractor v1.0.16/go.mod h1:U7dLU/oamTZWYeJfYRd4fugyoOOCvgtQNDpNTej47Ek=
68+
github.com/Checkmarx/containers-resolver v1.0.21 h1:HFl9ZfdzH7Fh3jvdRxnTIHYotI/3ZNMJTFP70c1jZWU=
69+
github.com/Checkmarx/containers-resolver v1.0.21/go.mod h1:Kq7Jb+bvCx+BObImrydImkFIPWyhaZaX6lJyoz+IhA4=
70+
github.com/Checkmarx/containers-syft-packages-extractor v1.0.17 h1:OrqJ7Z+9Cpz+258B9uMGgxA8/prTuHmG0w7UJ+y6Fvw=
71+
github.com/Checkmarx/containers-syft-packages-extractor v1.0.17/go.mod h1:o5O/uQuZVaHTsOU4PXQyRseGSblR+HXsdfZv7Hrt5CA=
7272
github.com/Checkmarx/containers-types v1.0.9 h1:LbHDj9LZ0x3f28wDx398WC19sw0U0EfEewHMLStBwvs=
7373
github.com/Checkmarx/containers-types v1.0.9/go.mod h1:KR0w8XCosq3+6jRCfQrH7i//Nj2u11qaUJM62CREFZA=
7474
github.com/Checkmarx/gen-ai-prompts v0.0.0-20240807143411-708ceec12b63 h1:SCuTcE+CFvgjbIxUNL8rsdB2sAhfuNx85HvxImKta3g=
@@ -421,8 +421,8 @@ github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZ
421421
github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
422422
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
423423
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
424-
github.com/go-viper/mapstructure/v2 v2.3.0 h1:27XbWsHIqhbdR5TIC911OfYvgSaW93HM+dX7970Q7jk=
425-
github.com/go-viper/mapstructure/v2 v2.3.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
424+
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
425+
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
426426
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
427427
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
428428
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
@@ -1102,8 +1102,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
11021102
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
11031103
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
11041104
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
1105-
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
1106-
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
1105+
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
1106+
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
11071107
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
11081108
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
11091109
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -1586,14 +1586,32 @@ k8s.io/kubectl v0.33.3 h1:r/phHvH1iU7gO/l7tTjQk2K01ER7/OAJi8uFHHyWSac=
15861586
k8s.io/kubectl v0.33.3/go.mod h1:euj2bG56L6kUGOE/ckZbCoudPwuj4Kud7BR0GzyNiT0=
15871587
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e h1:KqK5c/ghOm8xkHYhlodbp6i6+r+ChV2vuAuVRdFbLro=
15881588
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
1589-
modernc.org/libc v1.61.13 h1:3LRd6ZO1ezsFiX1y+bHd1ipyEHIJKvuprv0sLTBwLW8=
1590-
modernc.org/libc v1.61.13/go.mod h1:8F/uJWL/3nNil0Lgt1Dpz+GgkApWh04N3el3hxJcA6E=
1589+
modernc.org/cc/v4 v4.26.2 h1:991HMkLjJzYBIfha6ECZdjrIYz2/1ayr+FL8GN+CNzM=
1590+
modernc.org/cc/v4 v4.26.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
1591+
modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU=
1592+
modernc.org/ccgo/v4 v4.28.0/go.mod h1:JygV3+9AV6SmPhDasu4JgquwU81XAKLd3OKTUDNOiKE=
1593+
modernc.org/fileutil v1.3.8 h1:qtzNm7ED75pd1C7WgAGcK4edm4fvhtBsEiI/0NQ54YM=
1594+
modernc.org/fileutil v1.3.8/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
1595+
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
1596+
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
1597+
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
1598+
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
1599+
modernc.org/libc v1.66.3 h1:cfCbjTUcdsKyyZZfEUKfoHcP3S0Wkvz3jgSzByEWVCQ=
1600+
modernc.org/libc v1.66.3/go.mod h1:XD9zO8kt59cANKvHPXpx7yS2ELPheAey0vjIuZOhOU8=
15911601
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
15921602
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
1593-
modernc.org/memory v1.8.2 h1:cL9L4bcoAObu4NkxOlKWBWtNHIsnnACGF/TbqQ6sbcI=
1594-
modernc.org/memory v1.8.2/go.mod h1:ZbjSvMO5NQ1A2i3bWeDiVMxIorXwdClKE/0SZ+BMotU=
1595-
modernc.org/sqlite v1.36.1 h1:bDa8BJUH4lg6EGkLbahKe/8QqoF8p9gArSc6fTqYhyQ=
1596-
modernc.org/sqlite v1.36.1/go.mod h1:7MPwH7Z6bREicF9ZVUR78P1IKuxfZ8mRIDHD0iD+8TU=
1603+
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
1604+
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
1605+
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
1606+
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
1607+
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
1608+
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
1609+
modernc.org/sqlite v1.38.2 h1:Aclu7+tgjgcQVShZqim41Bbw9Cho0y/7WzYptXqkEek=
1610+
modernc.org/sqlite v1.38.2/go.mod h1:cPTJYSlgg3Sfg046yBShXENNtPrWrDX8bsbAQBzgQ5E=
1611+
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
1612+
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
1613+
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
1614+
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
15971615
oras.land/oras-go/v2 v2.6.0 h1:X4ELRsiGkrbeox69+9tzTu492FMUu7zJQW6eJU+I2oc=
15981616
oras.land/oras-go/v2 v2.6.0/go.mod h1:magiQDfG6H1O9APp+rOsvCPcW1GD2MM7vgnKY0Y+u1o=
15991617
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=

internal/commands/result.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,7 @@ func exportGlSastResults(targetFile string, results *wrappers.ScanResultsCollect
16621662
if err != nil {
16631663
return errors.Wrapf(err, "%s: failed to add scan to gl-sast report", failedListingResults)
16641664
}
1665-
convertCxResultToGlSastVulnerability(results, glSast, summary.BaseURI)
1665+
convertCxResultToGlSastVulnerability(results, glSast, summary)
16661666
resultsJSON, err := json.Marshal(glSast)
16671667
if err != nil {
16681668
return errors.Wrapf(err, "%s: failed to serialize gl-sast report ", failedListingResults)
@@ -2031,10 +2031,10 @@ func convertCxResultsToSarif(results *wrappers.ScanResultsCollection) *wrappers.
20312031
return sarif
20322032
}
20332033

2034-
func convertCxResultToGlSastVulnerability(results *wrappers.ScanResultsCollection, glSast *wrappers.GlSastResultsCollection, summaryBaseURI string) {
2034+
func convertCxResultToGlSastVulnerability(results *wrappers.ScanResultsCollection, glSast *wrappers.GlSastResultsCollection, summary *wrappers.ResultSummary) {
20352035
for _, result := range results.Results {
20362036
if strings.TrimSpace(result.Type) == commonParams.SastType {
2037-
glSast = parseGlSastVulnerability(result, glSast, summaryBaseURI)
2037+
glSast = parseGlSastVulnerability(result, glSast, summary)
20382038
}
20392039
}
20402040
}
@@ -2054,7 +2054,9 @@ func convertCxResultToGlScaFiles(results *wrappers.ScanResultsCollection, glScaR
20542054
}
20552055
}
20562056
}
2057-
func parseGlSastVulnerability(result *wrappers.ScanResult, glSast *wrappers.GlSastResultsCollection, summaryBaseURI string) *wrappers.GlSastResultsCollection {
2057+
func parseGlSastVulnerability(result *wrappers.ScanResult, glSast *wrappers.GlSastResultsCollection, summary *wrappers.ResultSummary) *wrappers.GlSastResultsCollection {
2058+
hostName := parseURI(summary.BaseURI)
2059+
20582060
queryName := result.ScanResultData.QueryName
20592061
fileName := result.ScanResultData.Nodes[0].FileName
20602062
lineNumber := strconv.FormatUint(uint64(result.ScanResultData.Nodes[0].Line), 10)
@@ -2063,13 +2065,14 @@ func parseGlSastVulnerability(result *wrappers.ScanResult, glSast *wrappers.GlSa
20632065
ID := fmt.Sprintf("%s:%s:%s", queryName, fileName, lineNumber)
20642066
category := fmt.Sprintf("%s-%s", wrappers.VendorName, result.Type)
20652067
message := fmt.Sprintf("%s@%s:%s", queryName, fileName, lineNumber)
2068+
QueryDescriptionLink := fmt.Sprintf("%s/results/%s/%s/sast/description/%s/%s", hostName, summary.ScanID, summary.ProjectID, result.VulnerabilityDetails.CweID, result.ScanResultData.QueryID)
20662069

20672070
glSast.Vulnerabilities = append(glSast.Vulnerabilities, wrappers.GlVulnerabilities{
20682071
ID: ID,
20692072
Category: category,
20702073
Name: queryName,
20712074
Message: message,
2072-
Description: result.Description,
2075+
Description: result.Description + " \n" + QueryDescriptionLink,
20732076
CVE: ID,
20742077
Severity: cases.Title(language.English).String(result.Severity),
20752078
Confidence: cases.Title(language.English).String(result.Severity),
@@ -2083,7 +2086,7 @@ func parseGlSastVulnerability(result *wrappers.ScanResult, glSast *wrappers.GlSa
20832086
{
20842087
Type: "cxOneScan",
20852088
Name: "CxOne Scan",
2086-
URL: summaryBaseURI,
2089+
URL: summary.BaseURI,
20872090
Value: result.ID,
20882091
},
20892092
},
@@ -2889,6 +2892,16 @@ type ScannerResponse struct {
28892892
ErrorCode string `json:"ErrorCode,omitempty"`
28902893
}
28912894

2895+
func parseURI(summaryBaseURI string) (hostName string) {
2896+
parsedURL, err := url.Parse(summaryBaseURI)
2897+
if err != nil {
2898+
return ""
2899+
}
2900+
hostName = fmt.Sprintf("%s://%s", parsedURL.Scheme, parsedURL.Host)
2901+
2902+
return hostName
2903+
}
2904+
28922905
func printWarningIfIgnorePolicyOmiited() {
28932906
fmt.Printf("\n Warning: The --ignore-policy flag was not implemented because you don’t have the required permission.\n Only users with 'override-policy-management' permission can use this flag. \n\n")
28942907
}

internal/commands/result_test.go

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ func TestRunGetResultsByScanIdSummaryConsoleFormat_ScsCompleted_ScsCompletedInRe
10951095
"Expected SCS summary:"+scsSummary)
10961096
secretDetectionSummary := secretDetectionLine
10971097
assert.Equal(t, strings.Contains(cleanString, secretDetectionSummary), true,
1098-
"Expected Secret Detection summary:"+secretDetectionSummary)
1098+
"Expected Secret Detection summary:"+secretDetectionLine)
10991099
scorecardSummary := "| Scorecard 0 0 0 1 0 Completed |"
11001100
assert.Equal(t, strings.Contains(cleanString, scorecardSummary), true,
11011101
"Expected Scorecard summary:"+scorecardSummary)
@@ -1130,7 +1130,7 @@ func TestRunGetResultsByScanIdSummaryConsoleFormat_ScsPartial_ScsPartialInReport
11301130
"Expected SCS summary:"+scsSummary)
11311131
secretDetectionSummary := secretDetectionLine
11321132
assert.Equal(t, strings.Contains(cleanString, secretDetectionSummary), true,
1133-
"Expected Secret Detection summary:"+secretDetectionSummary)
1133+
"Expected Secret Detection summary:"+secretDetectionLine)
11341134
scorecardSummary := " | Scorecard 0 0 0 0 0 Failed |"
11351135
assert.Equal(t, strings.Contains(cleanString, scorecardSummary), true,
11361136
"Expected Scorecard summary:"+scorecardSummary)
@@ -1157,7 +1157,7 @@ func TestRunGetResultsByScanIdSummaryConsoleFormat_ScsScorecardNotScanned_Scorec
11571157
"Expected SCS summary:"+scsSummary)
11581158
secretDetectionSummary := secretDetectionLine
11591159
assert.Equal(t, strings.Contains(stdoutString, secretDetectionSummary), true,
1160-
"Expected Secret Detection summary:"+secretDetectionSummary)
1160+
"Expected Secret Detection summary:"+secretDetectionLine)
11611161
scorecardSummary := "| Scorecard - - - - - - |"
11621162
assert.Equal(t, strings.Contains(stdoutString, scorecardSummary), true,
11631163
"Expected Scorecard summary:"+scorecardSummary)
@@ -1697,3 +1697,77 @@ func TestIgnorePolicyWithPermission(t *testing.T) {
16971697
output := buf.String()
16981698
assert.Assert(t, !strings.Contains(output, "Warning: The --ignore-policy flag was not implemented because you don’t have the required permission."), "'Ignore Policy flag omitted because you dont have permission' should not be present in the output")
16991699
}
1700+
1701+
func TestParseGlSastVulnerability_QueryDescriptionLink_Succeed(t *testing.T) {
1702+
mockResult := createMockScanResult("q1234", "c5678")
1703+
glSast := &wrappers.GlSastResultsCollection{}
1704+
summary := &wrappers.ResultSummary{
1705+
BaseURI: "https://example.com/overview",
1706+
ScanID: "scanID",
1707+
ProjectID: "projectID",
1708+
}
1709+
expectedURL := "https://example.com/results/scanID/projectID/sast/description/c5678/q1234"
1710+
1711+
glSast = parseGlSastVulnerability(mockResult, glSast, summary)
1712+
1713+
assert.Assert(t, len(glSast.Vulnerabilities) > 0)
1714+
1715+
actualURL := extractURLFromDescription(glSast.Vulnerabilities[0].Description)
1716+
1717+
assert.Equal(t, actualURL, expectedURL, "QueryDescriptionLink URL does not match expected format")
1718+
}
1719+
1720+
func TestParseGlSastVulnerability_QueryDescriptionLink_Negative(t *testing.T) {
1721+
mockResult := createMockScanResult("", "")
1722+
glSast := &wrappers.GlSastResultsCollection{}
1723+
summary := &wrappers.ResultSummary{
1724+
BaseURI: "invalid-url",
1725+
ScanID: "scanID",
1726+
ProjectID: "projectID",
1727+
}
1728+
expectedPattern := "/results/scanID/projectID/sast/description//"
1729+
1730+
glSast = parseGlSastVulnerability(mockResult, glSast, summary)
1731+
1732+
assert.Assert(t, len(glSast.Vulnerabilities) > 0)
1733+
vuln := glSast.Vulnerabilities[0]
1734+
1735+
assert.Assert(t, strings.Contains(vuln.Description, expectedPattern),
1736+
"URL should contain pattern with empty values")
1737+
1738+
actualURL := extractURLFromDescription(vuln.Description)
1739+
assert.Assert(t, actualURL != "", "Extracted URL should not be empty")
1740+
}
1741+
1742+
func createMockScanResult(queryID, cweID string) *wrappers.ScanResult {
1743+
return &wrappers.ScanResult{
1744+
Type: "sast",
1745+
ScanResultData: wrappers.ScanResultData{
1746+
QueryName: "TestQuery",
1747+
QueryID: queryID,
1748+
Nodes: []*wrappers.ScanResultNode{
1749+
{
1750+
FileName: "file.go",
1751+
Line: 42,
1752+
Length: 1,
1753+
},
1754+
},
1755+
},
1756+
VulnerabilityDetails: wrappers.VulnerabilityDetails{
1757+
CweID: cweID,
1758+
},
1759+
ID: "vuln-1",
1760+
Description: "desc-",
1761+
Severity: "high",
1762+
}
1763+
}
1764+
1765+
func extractURLFromDescription(description string) string {
1766+
parts := strings.Split(description, "http")
1767+
if len(parts) == 1 {
1768+
return "http" + strings.Split(parts[0], " ")[0]
1769+
} else if len(parts) > 1 {
1770+
return "http" + strings.Split(parts[1], " ")[0]
1771+
}
1772+
return ""
1773+
}

internal/services/realtimeengine/secretsrealtime/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ type SecretsRealtimeResult struct {
1313

1414
type IgnoredSecret struct {
1515
Title string `json:"Title"`
16-
FilePath string `json:"FilePath"`
1716
SecretValue string `json:"SecretValue"`
1817
}

internal/services/realtimeengine/secretsrealtime/secrets-realtime.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func NewSecretsRealtimeService(
4545
func filterIgnoredSecrets(results []SecretsRealtimeResult, ignoreMap map[string]bool) []SecretsRealtimeResult {
4646
filtered := make([]SecretsRealtimeResult, 0, len(results))
4747
for _, r := range results {
48-
key := fmt.Sprintf("%s_%s_%s", r.Title, r.FilePath, r.SecretValue)
48+
key := fmt.Sprintf("%s_%s", r.Title, r.SecretValue)
4949
if !ignoreMap[key] {
5050
filtered = append(filtered, r)
5151
}
@@ -56,7 +56,7 @@ func filterIgnoredSecrets(results []SecretsRealtimeResult, ignoreMap map[string]
5656
func buildIgnoreMap(ignored []IgnoredSecret) map[string]bool {
5757
m := make(map[string]bool)
5858
for _, s := range ignored {
59-
key := fmt.Sprintf("%s_%s_%s", s.Title, s.FilePath, s.SecretValue)
59+
key := fmt.Sprintf("%s_%s", s.Title, s.SecretValue)
6060
m[key] = true
6161
}
6262
return m

internal/services/realtimeengine/secretsrealtime/secrets-realtime_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestRunSecretsRealtimeScan_WithIgnoreFile_FiltersResult(t *testing.T) {
7878

7979
ignoreFile := filepath.Join(tempDir, "ignored.json")
8080
ignored := []IgnoredSecret{
81-
{Title: "github-pat", FilePath: testFile, SecretValue: "ghp_1234567890abcdef123"},
81+
{Title: "github-pat", SecretValue: "ghp_1234567890abcdef123"},
8282
}
8383
data, _ := json.Marshal(ignored)
8484
assert.NoError(t, os.WriteFile(ignoreFile, data, 0644))

internal/wrappers/results-gl-sast.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const (
66
AnalyzerURL = "https://checkmarx.com/"
77
VendorName = "Checkmarx"
88
SastSchema = "https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/blob/master/dist/sast-report-format.json"
9-
SastSchemaVersion = "15.0"
9+
SastSchemaVersion = "15.0.0"
1010
)
1111

1212
type GlSastResultsCollection struct {

0 commit comments

Comments
 (0)