Skip to content

Commit 77c2f19

Browse files
authored
Merge branch 'dev' into docker-curation-supprot
2 parents ae9c166 + 6ea4636 commit 77c2f19

File tree

16 files changed

+111
-120
lines changed

16 files changed

+111
-120
lines changed

cli/docs/flags.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ var commandFlags = map[string][]string{
237237
var flagsMap = map[string]components.Flag{
238238
// Common commands flags
239239
ServerId: components.NewStringFlag(ServerId, "Server ID configured using the config command."),
240-
Url: components.NewStringFlag(Url, "JFrog URL."),
241-
XrayUrl: components.NewStringFlag(XrayUrl, "JFrog Xray URL."),
242-
user: components.NewStringFlag(user, "JFrog username."),
243-
password: components.NewStringFlag(password, "JFrog password."),
244-
accessToken: components.NewStringFlag(accessToken, "JFrog access token."),
240+
Url: components.NewStringFlag(Url, "Specifies the URL of the JFrog platform."),
241+
XrayUrl: components.NewStringFlag(XrayUrl, "Specifies the URL of your Xray server."),
242+
user: components.NewStringFlag(user, "Specifies the user name of your JFrog platform."),
243+
password: components.NewStringFlag(password, "Specifies the user password of your JFrog platform."),
244+
accessToken: components.NewStringFlag(accessToken, "Specifies the access token of your JFrog platform."),
245245
Threads: components.NewStringFlag(Threads, "The number of parallel threads used to scan the source code project.", components.WithIntDefaultValue(cliutils.Threads)),
246246
// Xray flags
247247
LicenseId: components.NewStringFlag(LicenseId, "Xray license ID.", components.SetMandatory(), components.WithHelpValue("Xray license ID")),

commands/audit/audit_test.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ func TestAuditWithConfigProfile(t *testing.T) {
261261
},
262262
},
263263
}},
264-
IsDefault: false,
265264
},
266265
expectedScaIssues: 15,
267266
},
@@ -293,7 +292,6 @@ func TestAuditWithConfigProfile(t *testing.T) {
293292
},
294293
},
295294
}},
296-
IsDefault: false,
297295
},
298296
expectedScaIssues: 0,
299297
},
@@ -324,7 +322,6 @@ func TestAuditWithConfigProfile(t *testing.T) {
324322
},
325323
},
326324
}},
327-
IsDefault: false,
328325
},
329326
expectedCaNotCovered: 15,
330327
},
@@ -356,7 +353,6 @@ func TestAuditWithConfigProfile(t *testing.T) {
356353
},
357354
},
358355
}},
359-
IsDefault: false,
360356
},
361357
expectedSecretsIssues: 16,
362358
},
@@ -381,14 +377,13 @@ func TestAuditWithConfigProfile(t *testing.T) {
381377
},
382378
SecretsScannerConfig: services.SecretsScannerConfig{
383379
EnableSecretsScan: true,
384-
ExcludePatterns: []string{"*api_secrets*"},
380+
ExcludePatterns: []string{"**/*api_secrets*/**"},
385381
},
386382
IacScannerConfig: services.IacScannerConfig{
387383
EnableIacScan: false,
388384
},
389385
},
390386
}},
391-
IsDefault: false,
392387
},
393388
expectedSecretsIssues: 7,
394389
},
@@ -419,7 +414,6 @@ func TestAuditWithConfigProfile(t *testing.T) {
419414
},
420415
},
421416
}},
422-
IsDefault: false,
423417
},
424418
expectedSastIssues: 4,
425419
},
@@ -441,7 +435,7 @@ func TestAuditWithConfigProfile(t *testing.T) {
441435
},
442436
SastScannerConfig: services.SastScannerConfig{
443437
EnableSastScan: true,
444-
ExcludePatterns: []string{"*flask_webgoat*"},
438+
ExcludePatterns: []string{"**/*flask_webgoat*/**"},
445439
},
446440
SecretsScannerConfig: services.SecretsScannerConfig{
447441
EnableSecretsScan: false,
@@ -451,15 +445,14 @@ func TestAuditWithConfigProfile(t *testing.T) {
451445
},
452446
},
453447
}},
454-
IsDefault: false,
455448
},
456449
expectedSastIssues: 0,
457450
},
458451
{
459452
name: "Enable only IaC scanner",
460453
testDirPath: filepath.Join("..", "..", "tests", "testdata", "projects", "jas", "jas"),
461454
configProfile: services.ConfigProfile{
462-
ProfileName: "only-sast",
455+
ProfileName: "only-iac",
463456
Modules: []services.Module{{
464457
ModuleId: 1,
465458
ModuleName: "only-iac-module",
@@ -482,7 +475,6 @@ func TestAuditWithConfigProfile(t *testing.T) {
482475
},
483476
},
484477
}},
485-
IsDefault: false,
486478
},
487479
expectedIacIssues: 9,
488480
},
@@ -510,11 +502,10 @@ func TestAuditWithConfigProfile(t *testing.T) {
510502
},
511503
IacScannerConfig: services.IacScannerConfig{
512504
EnableIacScan: true,
513-
ExcludePatterns: []string{"*iac/gcp*"},
505+
ExcludePatterns: []string{"**/*iac/gcp*/**"},
514506
},
515507
},
516508
}},
517-
IsDefault: false,
518509
},
519510
expectedIacIssues: 0,
520511
},
@@ -545,7 +536,6 @@ func TestAuditWithConfigProfile(t *testing.T) {
545536
},
546537
},
547538
}},
548-
IsDefault: false,
549539
},
550540
expectedSastIssues: 4,
551541
expectedSecretsIssues: 16,
@@ -570,18 +560,17 @@ func TestAuditWithConfigProfile(t *testing.T) {
570560
},
571561
SastScannerConfig: services.SastScannerConfig{
572562
EnableSastScan: true,
573-
ExcludePatterns: []string{"*flask_webgoat*"},
563+
ExcludePatterns: []string{"**/*flask_webgoat*/**"},
574564
},
575565
SecretsScannerConfig: services.SecretsScannerConfig{
576566
EnableSecretsScan: true,
577-
ExcludePatterns: []string{"*api_secrets*"},
567+
ExcludePatterns: []string{"**/*api_secrets*/**"},
578568
},
579569
IacScannerConfig: services.IacScannerConfig{
580570
EnableIacScan: true,
581571
},
582572
},
583573
}},
584-
IsDefault: false,
585574
},
586575
expectedSastIssues: 0,
587576
expectedSecretsIssues: 7,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/jfrog/jfrog-apps-config v1.0.1
1818
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20251211075913-35ebcd308e93
1919
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251210085744-f8481d179ac5
20-
github.com/jfrog/jfrog-client-go v1.55.1-0.20251211124639-306f15dbcf29
20+
github.com/jfrog/jfrog-client-go v1.55.1-0.20251217080430-c92b763b7465
2121
github.com/magiconair/properties v1.8.10
2222
github.com/owenrumney/go-sarif/v3 v3.2.3
2323
github.com/package-url/packageurl-go v0.1.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20251211075913-35ebcd308e93 h1:r
158158
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20251211075913-35ebcd308e93/go.mod h1:7cCaRhXorlbyXZgiW5bplCExFxlnROaG21K12d8inpQ=
159159
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251210085744-f8481d179ac5 h1:GYE67ubwl+ZRw3CcXFUi49EwwQp6k+qS8sX0QuHDHO8=
160160
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251210085744-f8481d179ac5/go.mod h1:BMoGi2rG0udCCeaghqlNgiW3fTmT+TNnfTnBoWFYgcg=
161-
github.com/jfrog/jfrog-client-go v1.55.1-0.20251211124639-306f15dbcf29 h1:u+FMai2cImOJExJ1Ehe8JsrpAXmPyRaDXwM60wV3bPA=
162-
github.com/jfrog/jfrog-client-go v1.55.1-0.20251211124639-306f15dbcf29/go.mod h1:WQ5Y+oKYyHFAlCbHN925bWhnShTd2ruxZ6YTpb76fpU=
161+
github.com/jfrog/jfrog-client-go v1.55.1-0.20251217080430-c92b763b7465 h1:Ff3BlNPndrAfa1xFI/ORFzfWTxQxF0buWG61PEJwd3U=
162+
github.com/jfrog/jfrog-client-go v1.55.1-0.20251217080430-c92b763b7465/go.mod h1:WQ5Y+oKYyHFAlCbHN925bWhnShTd2ruxZ6YTpb76fpU=
163163
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
164164
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
165165
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=

jas/applicability/applicabilitymanager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func newApplicabilityScanManager(directDependenciesCves, indirectDependenciesCve
8888
}
8989

9090
func (asm *ApplicabilityScanManager) Run(module jfrogappsconfig.Module) (vulnerabilitiesSarifRuns []*sarif.Run, violationsSarifRuns []*sarif.Run, err error) {
91-
if err = asm.createConfigFile(module, append(asm.scanner.Exclusions, asm.scanner.ScannersExclusions.ContextualAnalysisExcludePatterns...)...); err != nil {
91+
if err = asm.createConfigFile(module, asm.scanner.ScannersExclusions.ContextualAnalysisExcludePatterns, asm.scanner.Exclusions...); err != nil {
9292
return
9393
}
9494
if err = asm.runAnalyzerManager(); err != nil {
@@ -116,12 +116,12 @@ type scanConfiguration struct {
116116
ScanType string `yaml:"scantype"`
117117
}
118118

119-
func (asm *ApplicabilityScanManager) createConfigFile(module jfrogappsconfig.Module, exclusions ...string) error {
119+
func (asm *ApplicabilityScanManager) createConfigFile(module jfrogappsconfig.Module, centralConfigExclusions []string, exclusions ...string) error {
120120
roots, err := jas.GetSourceRoots(module, nil)
121121
if err != nil {
122122
return err
123123
}
124-
excludePatterns := jas.GetExcludePatterns(module, nil, exclusions...)
124+
excludePatterns := jas.GetExcludePatterns(module, nil, centralConfigExclusions, exclusions...)
125125
if asm.thirdPartyScan {
126126
log.Info("Including node modules folder in applicability scan")
127127
excludePatterns = removeElementFromSlice(excludePatterns, utils.NodeModulesPattern)

jas/applicability/applicabilitymanager_test.go

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

176176
currWd, err := coreutils.GetWorkingDirectory()
177177
assert.NoError(t, err)
178-
err = applicabilityManager.createConfigFile(jfrogappsconfig.Module{SourceRoot: currWd})
178+
err = applicabilityManager.createConfigFile(jfrogappsconfig.Module{SourceRoot: currWd}, []string{})
179179
assert.NoError(t, err)
180180

181181
defer func() {

jas/common.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -420,37 +420,39 @@ func GetSourceRoots(module jfrogappsconfig.Module, scanner *jfrogappsconfig.Scan
420420
return roots, nil
421421
}
422422

423-
func GetExcludePatterns(module jfrogappsconfig.Module, scanner *jfrogappsconfig.Scanner, exclusions ...string) []string {
424-
if len(exclusions) > 0 {
425-
return filterUniqueAndConvertToFilesExcludePatterns(exclusions)
423+
func GetExcludePatterns(module jfrogappsconfig.Module, scanner *jfrogappsconfig.Scanner, centralConfigExclusions []string, cliExclusions ...string) []string {
424+
uniqueExcludePatterns := datastructures.MakeSet[string]()
425+
if len(cliExclusions) > 0 || len(centralConfigExclusions) > 0 {
426+
// Adding exclusions from CLI requires to convert them to file exclude patterns
427+
uniqueExcludePatterns.AddElements(convertToFilesExcludePatterns(cliExclusions)...)
428+
// Adding exclusions from centralized config, no need to convert
429+
uniqueExcludePatterns.AddElements(centralConfigExclusions...)
430+
return uniqueExcludePatterns.ToSlice()
426431
}
427-
428432
// Adding exclusions from jfrog-apps-config IF no exclusions provided from other source (flags, env vars, config profile)
429-
excludePatterns := module.ExcludePatterns
433+
uniqueExcludePatterns.AddElements(module.ExcludePatterns...)
430434
if scanner != nil {
431-
excludePatterns = append(excludePatterns, scanner.ExcludePatterns...)
435+
uniqueExcludePatterns.AddElements(scanner.ExcludePatterns...)
432436
}
433-
if len(excludePatterns) == 0 {
437+
if uniqueExcludePatterns.Size() == 0 {
434438
return utils.DefaultJasExcludePatterns
435439
}
436-
return excludePatterns
440+
return uniqueExcludePatterns.ToSlice()
437441
}
438442

439443
// This function convert every exclude pattern to a file exclude pattern form.
440444
// Checks are being made since some of the exclude patters we get here might already be in a file exclude pattern
441-
// Additionally, we keep patterns without duplications
442-
func filterUniqueAndConvertToFilesExcludePatterns(excludePatterns []string) []string {
443-
uniqueExcludePatterns := datastructures.MakeSet[string]()
445+
func convertToFilesExcludePatterns(excludePatterns []string) (converted []string) {
444446
for _, excludePattern := range excludePatterns {
445447
if !strings.HasPrefix(excludePattern, "**/") {
446448
excludePattern = "**/" + excludePattern
447449
}
448450
if !strings.HasSuffix(excludePattern, "/**") {
449451
excludePattern += "/**"
450452
}
451-
uniqueExcludePatterns.Add(excludePattern)
453+
converted = append(converted, excludePattern)
452454
}
453-
return uniqueExcludePatterns.ToSlice()
455+
return converted
454456
}
455457

456458
func CheckForSecretValidation(xrayManager *xray.XrayServicesManager, xrayVersion string, validateSecrets bool) bool {

jas/common_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func TestGetExcludePatterns(t *testing.T) {
127127
for _, testCase := range getExcludePatternsCases {
128128
t.Run("", func(t *testing.T) {
129129
scanner := testCase.scanner
130-
actualExcludePatterns := GetExcludePatterns(module, scanner)
130+
actualExcludePatterns := GetExcludePatterns(module, scanner, []string{})
131131
if scanner == nil {
132132
assert.ElementsMatch(t, module.ExcludePatterns, actualExcludePatterns)
133133
return
@@ -280,7 +280,7 @@ func TestAddScoreToRunRules(t *testing.T) {
280280
}
281281
}
282282

283-
func TestFilterUniqueAndConvertToFilesExcludePatterns(t *testing.T) {
283+
func TestConvertToFilesExcludePatterns(t *testing.T) {
284284
tests := []struct {
285285
name string
286286
excludePatterns []string
@@ -297,7 +297,7 @@ func TestFilterUniqueAndConvertToFilesExcludePatterns(t *testing.T) {
297297
}
298298

299299
for _, test := range tests {
300-
filteredExcludePatterns := filterUniqueAndConvertToFilesExcludePatterns(test.excludePatterns)
300+
filteredExcludePatterns := convertToFilesExcludePatterns(test.excludePatterns)
301301
// Sort is needed since we create the response slice from a Set (unordered)
302302
slices.Sort(filteredExcludePatterns)
303303
assert.EqualValues(t, test.expectedOutput, filteredExcludePatterns)

jas/iac/iacscanner.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func newIacScanManager(scanner *jas.JasScanner, scannerTempDir string, resultsTo
7070
}
7171

7272
func (iac *IacScanManager) Run(module jfrogappsconfig.Module) (vulnerabilitiesSarifRuns []*sarif.Run, violationsSarifRuns []*sarif.Run, err error) {
73-
if err = iac.createConfigFile(module, append(iac.scanner.Exclusions, iac.scanner.ScannersExclusions.IacExcludePatterns...)...); err != nil {
73+
if err = iac.createConfigFile(module, iac.scanner.ScannersExclusions.IacExcludePatterns, iac.scanner.Exclusions...); err != nil {
7474
return
7575
}
7676
if err = iac.runAnalyzerManager(); err != nil {
@@ -91,7 +91,7 @@ type iacScanConfiguration struct {
9191
SkippedDirs []string `yaml:"skipped-folders"`
9292
}
9393

94-
func (iac *IacScanManager) createConfigFile(module jfrogappsconfig.Module, exclusions ...string) error {
94+
func (iac *IacScanManager) createConfigFile(module jfrogappsconfig.Module, centralConfigExclusions []string, exclusions ...string) error {
9595
roots, err := jas.GetSourceRoots(module, module.Scanners.Iac)
9696
if err != nil {
9797
return err
@@ -103,7 +103,7 @@ func (iac *IacScanManager) createConfigFile(module jfrogappsconfig.Module, exclu
103103
Output: iac.resultsFileName,
104104
PathToResultsToCompare: iac.resultsToCompareFileName,
105105
Type: iacScannerType,
106-
SkippedDirs: jas.GetExcludePatterns(module, module.Scanners.Iac, exclusions...),
106+
SkippedDirs: jas.GetExcludePatterns(module, module.Scanners.Iac, centralConfigExclusions, exclusions...),
107107
},
108108
},
109109
}

jas/iac/iacscanner_test.go

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

6868
currWd, err := coreutils.GetWorkingDirectory()
6969
assert.NoError(t, err)
70-
err = iacScanManager.createConfigFile(jfrogappsconfig.Module{SourceRoot: currWd})
70+
err = iacScanManager.createConfigFile(jfrogappsconfig.Module{SourceRoot: currWd}, []string{})
7171

7272
defer func() {
7373
err = os.Remove(iacScanManager.configFileName)

0 commit comments

Comments
 (0)