Skip to content

Commit 92beddd

Browse files
authored
Merge branch 'dev' into exclude_patterns_expension
2 parents 5e2a089 + 7405e49 commit 92beddd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1869
-838
lines changed

.github/actions/install-and-setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ runs:
88
- name: Setup Go
99
uses: actions/setup-go@v5
1010
with:
11-
go-version: 1.23.x
11+
go-version: 1.24.x
1212
# - name: Setup Go with cache
1313
# uses: jfrog/.github/actions/install-go-with-cache@main
1414

commands/audit/audit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func createJasScansTasks(auditParallelRunner *utils.SecurityParallelRunner, scan
357357
Module: *module,
358358
ConfigProfile: auditParams.AuditBasicParams.GetConfigProfile(),
359359
ScansToPerform: auditParams.ScansToPerform(),
360-
SourceResultsToCompare: scanner.GetResultsToCompare(utils.GetRelativePath(targetResult.Target, scanResults.GetCommonParentPath())),
360+
SourceResultsToCompare: scanner.GetResultsToCompareByRelativePath(utils.GetRelativePath(targetResult.Target, scanResults.GetCommonParentPath())),
361361
SecretsScanType: secrets.SecretsScannerType,
362362
DirectDependencies: auditParams.DirectDependencies(),
363363
ThirdPartyApplicabilityScan: auditParams.thirdPartyApplicabilityScan,

commands/audit/audit_test.go

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ package audit
22

33
import (
44
"fmt"
5-
commonCommands "github.com/jfrog/jfrog-cli-core/v2/common/commands"
6-
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
7-
configTests "github.com/jfrog/jfrog-cli-security/tests"
8-
securityTestUtils "github.com/jfrog/jfrog-cli-security/tests/utils"
9-
clientTests "github.com/jfrog/jfrog-client-go/utils/tests"
105
"net/http"
116
"path/filepath"
127
"sort"
138
"strings"
149
"testing"
1510

11+
"github.com/CycloneDX/cyclonedx-go"
12+
commonCommands "github.com/jfrog/jfrog-cli-core/v2/common/commands"
13+
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
14+
configTests "github.com/jfrog/jfrog-cli-security/tests"
15+
securityTestUtils "github.com/jfrog/jfrog-cli-security/tests/utils"
16+
clientTests "github.com/jfrog/jfrog-client-go/utils/tests"
17+
1618
"github.com/stretchr/testify/assert"
1719

1820
"github.com/jfrog/jfrog-cli-security/tests/validations"
@@ -957,25 +959,30 @@ func TestAudit_DiffScanFlow(t *testing.T) {
957959
Target: tempDirPath,
958960
Technology: techutils.Pip,
959961
},
960-
Sbom: results.Sbom{
961-
Components: []results.SbomEntry{
962-
{
963-
Component: "werkzeug",
964-
Version: "1.0.2",
965-
Type: "Python",
966-
XrayType: "pypi",
967-
},
968-
{
969-
Component: "pyyaml",
970-
Version: "5.2",
971-
Type: "Python",
972-
XrayType: "pypi",
973-
},
974-
{
975-
Component: "wasabi",
976-
Version: "1.1.3",
977-
Type: "Python",
978-
XrayType: "pypi",
962+
ScaResults: &results.ScaScanResults{
963+
Sbom: &cyclonedx.BOM{
964+
Components: &[]cyclonedx.Component{
965+
{
966+
PackageURL: "pkg:pypi/[email protected]",
967+
BOMRef: "pypi:[email protected]",
968+
Name: "werkzeug",
969+
Version: "1.0.2",
970+
Type: "Python",
971+
},
972+
{
973+
PackageURL: "pkg:pypi/[email protected]",
974+
BOMRef: "pypi:[email protected]",
975+
Name: "pyyaml",
976+
Version: "5.2",
977+
Type: "Python",
978+
},
979+
{
980+
PackageURL: "pkg:pypi/[email protected]",
981+
BOMRef: "pypi:[email protected]",
982+
Name: "wasabi",
983+
Version: "1.1.3",
984+
Type: "Python",
985+
},
979986
},
980987
},
981988
},

commands/audit/scarunner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func buildDepTreeAndRunScaScan(auditParallelRunner *utils.SecurityParallelRunner
9393
// First scan, no diff to compare
9494
log.Debug(fmt.Sprintf("Diff scan - calculated dependencies tree for target %s, skipping scan part", targetResult.Target))
9595
continue
96-
} else if treeResult, bdtErr = buildinfo.GetDiffDependencyTree(targetResult, results.SearchTargetResultsByPath(utils.GetRelativePath(targetResult.Target, cmdResults.GetCommonParentPath()), auditParams.resultsToCompare), treeResult.FullDepTrees...); bdtErr != nil {
96+
} else if treeResult, bdtErr = buildinfo.GetDiffDependencyTree(targetResult, results.SearchTargetResultsByRelativePath(utils.GetRelativePath(targetResult.Target, cmdResults.GetCommonParentPath()), auditParams.resultsToCompare), treeResult.FullDepTrees...); bdtErr != nil {
9797
_ = targetResult.AddTargetError(fmt.Errorf("failed to build diff dependency tree in source branch: %s", bdtErr.Error()), auditParams.AllowPartialResults())
9898
continue
9999
}

commands/scan/scan.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ const (
5353
BypassArchiveLimitsMinXrayVersion = "3.59.0"
5454
indexingCommand = "graph"
5555
fileNotSupportedExitCode = 3
56-
typeJASPackageScanTypeDocker = "docker"
57-
typeJASPackageScanTypeGeneric = "generic"
5856
)
5957

6058
type ScanCommand struct {

go.mod

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
module github.com/jfrog/jfrog-cli-security
22

3-
go 1.23.7
3+
go 1.24.2
44

55
require (
6+
github.com/CycloneDX/cyclonedx-go v0.9.2
67
github.com/beevik/etree v1.4.0
78
github.com/go-git/go-git/v5 v5.14.0
89
github.com/google/go-github/v56 v56.0.0
@@ -15,7 +16,8 @@ require (
1516
github.com/jfrog/jfrog-cli-core/v2 v2.59.0
1617
github.com/jfrog/jfrog-client-go v1.54.1
1718
github.com/magiconair/properties v1.8.9
18-
github.com/owenrumney/go-sarif/v2 v2.3.0
19+
github.com/owenrumney/go-sarif/v3 v3.1.4
20+
github.com/package-url/packageurl-go v0.1.3
1921
github.com/stretchr/testify v1.10.0
2022
github.com/urfave/cli v1.22.16
2123
github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74
@@ -28,7 +30,6 @@ require (
2830
require (
2931
dario.cat/mergo v1.0.1 // indirect
3032
github.com/BurntSushi/toml v1.4.0 // indirect
31-
github.com/CycloneDX/cyclonedx-go v0.9.2 // indirect
3233
github.com/Microsoft/go-winio v0.6.2 // indirect
3334
github.com/ProtonMail/go-crypto v1.1.6 // indirect
3435
github.com/VividCortex/ewma v1.2.0 // indirect
@@ -97,6 +98,9 @@ require (
9798
github.com/vbauerster/mpb/v8 v8.9.1 // indirect
9899
github.com/xanzy/go-gitlab v0.110.0 // indirect
99100
github.com/xanzy/ssh-agent v0.3.3 // indirect
101+
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
102+
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
103+
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
100104
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
101105
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
102106
go.uber.org/multierr v1.11.0 // indirect

go.sum

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7X
1919
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
2020
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
2121
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
22-
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
2322
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
2423
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
2524
github.com/beevik/etree v1.4.0 h1:oz1UedHRepuY3p4N5OjE0nK1WLCqtzHf25bxplKOHLs=
@@ -85,11 +84,8 @@ github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w
8584
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
8685
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
8786
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
88-
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
89-
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
9087
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
9188
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
92-
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
9389
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
9490
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
9591
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
@@ -189,9 +185,10 @@ github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9l
189185
github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
190186
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
191187
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
192-
github.com/owenrumney/go-sarif v1.1.1/go.mod h1:dNDiPlF04ESR/6fHlPyq7gHKmrM0sHUvAGjsoh8ZH0U=
193-
github.com/owenrumney/go-sarif/v2 v2.3.0 h1:wP5yEpI53zr0v5cBmagXzLbHZp9Oylyo3AJDpfLBITs=
194-
github.com/owenrumney/go-sarif/v2 v2.3.0/go.mod h1:MSqMMx9WqlBSY7pXoOZWgEsVB4FDNfhcaXDA1j6Sr+w=
188+
github.com/owenrumney/go-sarif/v3 v3.1.4 h1:lqx5Cb7162BC+FuAgJZq8A8XXP4XMw7XoAPZl9iqlQs=
189+
github.com/owenrumney/go-sarif/v3 v3.1.4/go.mod h1:Olt8kHDlC+ruWzRfmgIQUD+2hoAk6A6vT+ljDUbae2s=
190+
github.com/package-url/packageurl-go v0.1.3 h1:4juMED3hHiz0set3Vq3KeQ75KD1avthoXLtmE3I0PLs=
191+
github.com/package-url/packageurl-go v0.1.3/go.mod h1:nKAWB8E6uk1MHqiS/lQb9pYBGH2+mdJ2PJc2s50dQY0=
195192
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
196193
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
197194
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
@@ -241,8 +238,8 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
241238
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
242239
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
243240
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
241+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
244242
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
245-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
246243
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
247244
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
248245
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
@@ -262,12 +259,11 @@ github.com/vbauerster/mpb/v8 v8.9.1 h1:LH5R3lXPfE2e3lIGxN7WNWv3Hl5nWO6LRi2B0L0ER
262259
github.com/vbauerster/mpb/v8 v8.9.1/go.mod h1:4XMvznPh8nfe2NpnDo1QTPvW9MVkUhbG90mPWvmOzcQ=
263260
github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 h1:JwtAtbp7r/7QSyGz8mKUbYJBg2+6Cd7OjM8o/GNOcVo=
264261
github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74/go.mod h1:RmMWU37GKR2s6pgrIEB4ixgpVCt/cf7dnJv3fuH1J1c=
265-
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
266-
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
267262
github.com/xanzy/go-gitlab v0.110.0 h1:hsFIFp01v/0D0sdUXoZfRk6CROzZbHQplk6NzKSFKhc=
268263
github.com/xanzy/go-gitlab v0.110.0/go.mod h1:wKNKh3GkYDMOsGmnfuX+ITCmDuSDWFO0G+C4AygL9RY=
269264
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
270265
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
266+
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
271267
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
272268
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
273269
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
@@ -281,7 +277,6 @@ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJu
281277
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
282278
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
283279
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
284-
github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
285280
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
286281
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
287282
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -299,9 +294,7 @@ golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
299294
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
300295
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
301296
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
302-
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
303297
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
304-
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
305298
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
306299
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
307300
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
@@ -359,9 +352,7 @@ golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
359352
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
360353
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
361354
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
362-
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
363355
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
364-
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
365356
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
366357
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
367358
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
@@ -380,7 +371,6 @@ golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ
380371
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
381372
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
382373
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
383-
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
384374
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
385375
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
386376
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

jas/applicability/applicabilitymanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
clientutils "github.com/jfrog/jfrog-client-go/utils"
1313
"github.com/jfrog/jfrog-client-go/utils/log"
1414
"github.com/jfrog/jfrog-client-go/xray/services"
15-
"github.com/owenrumney/go-sarif/v2/sarif"
15+
"github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif"
1616
"golang.org/x/exp/maps"
1717
"golang.org/x/exp/slices"
1818
)

jas/applicability/applicabilitymanager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func TestParseResults_NewApplicabilityStatuses(t *testing.T) {
317317
if tc.name == "new applicability statuses" {
318318
assert.Len(t, vulnerabilitiesResults[0].Tool.Driver.Rules, len(tc.expectedApplicabilityStatuses))
319319
for i, value := range tc.expectedApplicabilityStatuses {
320-
assert.Equal(t, value, vulnerabilitiesResults[0].Tool.Driver.Rules[i].Properties["applicability"])
320+
assert.Equal(t, value, vulnerabilitiesResults[0].Tool.Driver.Rules[i].Properties.Properties["applicability"])
321321
}
322322
}
323323
}

jas/common.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"github.com/jfrog/jfrog-client-go/utils/log"
3030
"github.com/jfrog/jfrog-client-go/xray"
3131
"github.com/jfrog/jfrog-client-go/xray/services"
32-
"github.com/owenrumney/go-sarif/v2/sarif"
32+
"github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif"
3333
"github.com/stretchr/testify/assert"
3434
"golang.org/x/exp/slices"
3535
"gopkg.in/yaml.v3"
@@ -140,8 +140,8 @@ func getJasEnvVars(serverDetails *config.ServerDetails, validateSecrets bool, di
140140
return utils.MergeMaps(utils.ToEnvVarsMap(os.Environ()), amBasicVars, vars), nil
141141
}
142142

143-
func (js *JasScanner) GetResultsToCompare(target string) (resultsToCompare *results.TargetResults) {
144-
return results.SearchTargetResultsByPath(target, js.ResultsToCompare)
143+
func (js *JasScanner) GetResultsToCompareByRelativePath(relativeTarget string) (resultsToCompare *results.TargetResults) {
144+
return results.SearchTargetResultsByRelativePath(relativeTarget, js.ResultsToCompare)
145145
}
146146

147147
func CreateJFrogAppsConfig(workingDirs []string) (*jfrogappsconfig.JFrogAppsConfig, error) {
@@ -233,7 +233,7 @@ func processSarifRuns(sarifRuns []*sarif.Run, wd string, informationUrlSuffix st
233233
if len(sarifRun.Invocations) == 0 {
234234
sarifRun.Invocations = append(sarifRun.Invocations, sarif.NewInvocation().WithWorkingDirectory(sarif.NewArtifactLocation()))
235235
}
236-
sarifRun.Invocations[0].WorkingDirectory.WithUri(utils.ToURI(wd))
236+
sarifRun.Invocations[0].WorkingDirectory.WithURI(utils.ToURI(wd))
237237
// Process runs values
238238
fillMissingRequiredDriverInformation(utils.BaseDocumentationURL+informationUrlSuffix, GetAnalyzerManagerVersion(), sarifRun)
239239
sarifRun.Results = excludeSuppressResults(sarifRun.Results)
@@ -279,9 +279,9 @@ func excludeMinSeverityResults(sarifResults []*sarif.Result, minSeverity severit
279279
}
280280
results := []*sarif.Result{}
281281
for _, sarifResult := range sarifResults {
282-
resultSeverity, err := severityutils.ParseSeverity(sarifutils.GetResultLevel(sarifResult), true)
282+
resultSeverity, err := severityutils.ParseSeverity(sarifResult.Level, true)
283283
if err != nil {
284-
log.Warn(fmt.Sprintf("Failed to parse Sarif level %s: %s", sarifutils.GetResultLevel(sarifResult), err.Error()))
284+
log.Warn(fmt.Sprintf("Failed to parse Sarif level %s: %s", sarifResult.Level, err.Error()))
285285
resultSeverity = severityutils.Unknown
286286
}
287287
// Exclude results with severity lower than the minimum severity
@@ -294,27 +294,25 @@ func excludeMinSeverityResults(sarifResults []*sarif.Result, minSeverity severit
294294

295295
func addScoreToRunRules(sarifRun *sarif.Run) {
296296
for _, sarifResult := range sarifRun.Results {
297-
if rule, err := sarifRun.GetRuleById(sarifutils.GetResultRuleId(sarifResult)); err == nil {
297+
if rule := sarifutils.GetRuleById(sarifRun, sarifutils.GetResultRuleId(sarifResult)); rule != nil {
298298
// Add to the rule security-severity score based on results severity
299-
severity, err := severityutils.ParseSeverity(sarifutils.GetResultLevel(sarifResult), true)
299+
severity, err := severityutils.ParseSeverity(sarifResult.Level, true)
300300
if err != nil {
301-
log.Warn(fmt.Sprintf("Failed to parse Sarif level %s: %s", sarifutils.GetResultLevel(sarifResult), err.Error()))
301+
log.Warn(fmt.Sprintf("Failed to parse Sarif level %s: %s", sarifResult.Level, err.Error()))
302302
severity = severityutils.Unknown
303303
}
304304
score := severityutils.GetSeverityScore(severity, jasutils.Applicable)
305305
if rule.Properties == nil {
306-
rule.WithProperties(sarif.NewPropertyBag().Properties)
306+
rule.WithProperties(sarif.NewPropertyBag())
307307
}
308-
rule.Properties[severityutils.SarifSeverityRuleProperty] = fmt.Sprintf("%.1f", score)
308+
// Add the score to the rule properties
309+
rule.Properties.Add(severityutils.SarifSeverityRuleProperty, fmt.Sprintf("%.1f", score))
309310
}
310311
}
311312
}
312313

313314
func SaveScanResultsToCompareAsReport(fileName string, runs ...*sarif.Run) error {
314-
report, err := sarifutils.NewReport()
315-
if err != nil {
316-
return err
317-
}
315+
report := sarif.NewReport()
318316
report.Runs = runs
319317
sarifData, err := utils.GetAsJsonBytes(report, false, false)
320318
if err != nil {

0 commit comments

Comments
 (0)