Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions cli/docs/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ const (
Iac = "iac"
Sast = "sast"
Secrets = "secrets"
Services = "services"
WithoutCA = "without-contextual-analysis"

auditSca = auditPrefix + Sca
auditIac = auditPrefix + Iac
auditSast = auditPrefix + Sast
auditSecrets = auditPrefix + Secrets
auditServices = auditPrefix + Services
auditWithoutCA = auditPrefix + WithoutCA
binarySca = scanPrefix + Sca
binarySecrets = scanPrefix + Secrets
Expand Down Expand Up @@ -210,7 +212,7 @@ var commandFlags = map[string][]string{
Url, XrayUrl, user, password, accessToken, ServerId, InsecureTls, scanProjectKey, Watches, RepoPath, Snippet, Sbom, Licenses, OutputFormat, ExcludeTestDeps,
useWrapperAudit, DepType, RequirementsFile, Fail, ExtendedTable, WorkingDirs, ExclusionsAudit, Mvn, Gradle, Npm,
Pnpm, Yarn, Go, Swift, Cocoapods, Nuget, Pip, Pipenv, Poetry, MinSeverity, FixableOnly, ThirdPartyContextualAnalysis, Threads,
auditSca, auditIac, auditSast, auditSecrets, auditWithoutCA, SecretValidation, ScanVuln, OutputDir, SkipAutoInstall, AllowPartialResults, MaxTreeDepth,
auditSca, auditIac, auditSast, auditSecrets, auditServices, auditWithoutCA, SecretValidation, ScanVuln, OutputDir, SkipAutoInstall, AllowPartialResults, MaxTreeDepth,
StaticSca, XrayLibPluginBinaryCustomPath, AnalyzerManagerCustomPath, UploadRtRepoPath, UseIncludedBuilds, AddSastRules,
},
UploadCdx: {
Expand All @@ -223,7 +225,7 @@ var commandFlags = map[string][]string{
scanProjectKey, Watches, Snippet, ScanVuln, Fail,
// Scan params
Threads, ExclusionsAudit, WorkingDirs, Workspace,
auditSca, auditIac, auditSast, auditSecrets, auditWithoutCA, SecretValidation, Sbom, UseConfigProfile,
auditSca, auditIac, auditSast, auditSecrets, auditServices, auditWithoutCA, SecretValidation, Sbom, UseConfigProfile,
// Output params
Licenses, OutputFormat, ExtendedTable, OutputDir, UploadRtRepoPath,
// Scan Logic params
Expand Down Expand Up @@ -359,10 +361,11 @@ var flagsMap = map[string]components.Flag{
binarySca: components.NewBoolFlag(Sca, fmt.Sprintf("Selective scanners mode: Execute SCA (Software Composition Analysis) sub-scan. Use --%s to run both SCA and Contextual Analysis. Use --%s --%s to to run SCA. Can be combined with --%s.", Sca, Sca, WithoutCA, Secrets)),
binarySecrets: components.NewBoolFlag(Secrets, fmt.Sprintf("Selective scanners mode: Execute Secrets sub-scan. Can be combined with --%s.", Sca)),
binaryWithoutCA: components.NewBoolFlag(WithoutCA, fmt.Sprintf("Selective scanners mode: Disable Contextual Analysis scanner after SCA. Relevant only with --%s flag.", Sca)),
auditSca: components.NewBoolFlag(Sca, fmt.Sprintf("Selective scanners mode: Execute SCA (Software Composition Analysis) sub-scan. Use --%s to run both SCA and Contextual Analysis. Use --%s --%s to to run SCA. Can be combined with --%s, --%s, --%s.", Sca, Sca, WithoutCA, Secrets, Sast, Iac)),
auditIac: components.NewBoolFlag(Iac, fmt.Sprintf("Selective scanners mode: Execute IaC sub-scan. Can be combined with --%s, --%s and --%s.", Sca, Secrets, Sast)),
auditSast: components.NewBoolFlag(Sast, fmt.Sprintf("Selective scanners mode: Execute SAST sub-scan. Can be combined with --%s, --%s and --%s.", Sca, Secrets, Iac)),
auditSecrets: components.NewBoolFlag(Secrets, fmt.Sprintf("Selective scanners mode: Execute Secrets sub-scan. Can be combined with --%s, --%s and --%s.", Sca, Sast, Iac)),
auditSca: components.NewBoolFlag(Sca, fmt.Sprintf("Selective scanners mode: Execute SCA (Software Composition Analysis) sub-scan. Use --%s to run both SCA and Contextual Analysis. Use --%s --%s to to run SCA. Can be combined with --%s, --%s, --%s and --%s.", Sca, Sca, WithoutCA, Secrets, Sast, Iac, Services)),
auditIac: components.NewBoolFlag(Iac, fmt.Sprintf("Selective scanners mode: Execute IaC sub-scan. Can be combined with --%s, --%s, --%s and --%s", Sca, Secrets, Sast, Services)),
auditSast: components.NewBoolFlag(Sast, fmt.Sprintf("Selective scanners mode: Execute SAST sub-scan. Can be combined with --%s, --%s, --%s and --%s", Sca, Secrets, Iac, Services)),
auditSecrets: components.NewBoolFlag(Secrets, fmt.Sprintf("Selective scanners mode: Execute Secrets sub-scan. Can be combined with --%s, --%s, --%s and --%s", Sca, Sast, Iac, Services)),
auditServices: components.NewBoolFlag(Services, fmt.Sprintf("Selective scanners mode: Execute Services sub-scan. Can be combined with --%s, --%s, --%s and --%s", Sca, Secrets, Sast, Iac)),
auditWithoutCA: components.NewBoolFlag(WithoutCA, fmt.Sprintf("Selective scanners mode: Disable Contextual Analysis scanner after SCA. Relevant only with --%s flag.", Sca)),
SecretValidation: components.NewBoolFlag(SecretValidation, fmt.Sprintf("Selective scanners mode: Triggers token validation on found secrets. Relevant only with --%s flag.", Secrets)),

Expand Down
43 changes: 35 additions & 8 deletions commands/audit/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,32 @@ func TestShouldGenerateSbom(t *testing.T) {
scanResults: &results.TargetResults{ScanTarget: results.ScanTarget{CentralConfigModules: configProfileModulesWithoutSca}},
expectSbom: false,
},
// {
// name: "services detection only",
// params: func() *AuditParams {
// params := NewAuditParams().SetResultsContext(results.ResultContext{IncludeServicesDetection: true})
// params.SetScansToPerform([]utils.SubScanType{utils.SastScan})
// return params
// }(),
// expectSbom: true,
// },
{
name: "services enabled in config profile without sca",
params: func() *AuditParams {
params := NewAuditParams().SetResultsContext(results.ResultContext{})
params.SetScansToPerform([]utils.SubScanType{utils.SastScan})
params.SetConfigProfile(&services.ConfigProfile{
Modules: []services.Module{{
ScanConfig: services.ScanConfig{
ScaScannerConfig: services.ScaScannerConfig{EnableScaScan: false},
ServicesScannerConfig: services.ServicesScannerConfig{EnableServicesScan: true},
},
}},
})
return params
}(),
expectSbom: true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is Sbom related?

},
}

for _, testCase := range testCases {
Expand Down Expand Up @@ -1320,14 +1346,15 @@ func TestCreateResultsContext(t *testing.T) {
testCases := []struct {
name string

artifactoryRepoPath string
httpCloneUrl string
watches []string
jfrogProjectKey string
includeVulnerabilities bool
includeLicenses bool
includeSbom bool
includeSnippetDetection bool
artifactoryRepoPath string
httpCloneUrl string
watches []string
jfrogProjectKey string
includeVulnerabilities bool
includeLicenses bool
includeSbom bool
includeSnippetDetection bool
includeServicesDetection bool

expectedArtifactoryRepoPath string
expectedHttpCloneUrl string
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
)

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go master
//orto17:missconfiguration-service
replace github.com/jfrog/jfrog-client-go => github.com/orto17/jfrog-client-go v0.0.0-20260728132717-7306d020619b

// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 master

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260722060859-50ee96befe5c h1:e
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260722060859-50ee96befe5c/go.mod h1:1vxzqW7jHBSuTNqO2vxEnhbniwq4dj5wveDuCMJX7Yo=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260724083402-361ba4a2ecdb h1:OW2W8ryV0FiCq1DKfRXPLwuB8OB+1wWebVG/sQPaF3Y=
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260724083402-361ba4a2ecdb/go.mod h1:9R90mhbczGXwW5EGlDs7F08ejQU/xdoDhYHMvzBiqgE=
github.com/jfrog/jfrog-client-go v1.55.1-0.20260722075451-613a6b6a7603 h1:gwxRPCQRsbwt8rIWQ6LDu09aH4I2F1DFYObBpx1KDHw=
github.com/jfrog/jfrog-client-go v1.55.1-0.20260722075451-613a6b6a7603/go.mod h1:FHpjN1nTDoj96xd6obe27EOgGErqzU0rQgC96L3Ch9E=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
github.com/kevinburke/ssh_config v1.6.0 h1:J1FBfmuVosPHf5GRdltRLhPJtJpTlMdKTBjRgTaQBFY=
Expand Down Expand Up @@ -244,6 +242,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
github.com/orto17/jfrog-client-go v0.0.0-20260728132717-7306d020619b h1:rh4paVkuikqXHTJ0NpRq/yhbhfW2BXzevV2NWGBCf7w=
github.com/orto17/jfrog-client-go v0.0.0-20260728132717-7306d020619b/go.mod h1:FHpjN1nTDoj96xd6obe27EOgGErqzU0rQgC96L3Ch9E=
github.com/owenrumney/go-sarif/v3 v3.2.3 h1:n6mdX5ugKwCrZInvBsf6WumXmpAe3mbmQXgkXlIq34U=
github.com/owenrumney/go-sarif/v3 v3.2.3/go.mod h1:1bV7t8SZg7pX41spaDkEUs8/yEjzk9JapztMoX1XNjg=
github.com/package-url/packageurl-go v0.1.3 h1:4juMED3hHiz0set3Vq3KeQ75KD1avthoXLtmE3I0PLs=
Expand Down
21 changes: 21 additions & 0 deletions jas/runner/jasrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/jfrog/jfrog-cli-security/jas/iac"
"github.com/jfrog/jfrog-cli-security/jas/sast"
"github.com/jfrog/jfrog-cli-security/jas/secrets"
jfrogServices "github.com/jfrog/jfrog-cli-security/jas/services"
"github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-cli-security/utils/jasutils"
"github.com/jfrog/jfrog-cli-security/utils/results"
Expand Down Expand Up @@ -89,6 +90,10 @@ func AddJasScannersTasks(params JasRunnerParams) error {
// Scan task addition failure should not impact the other scanners tasks addition, therefore we accumulate the errors and return the overall error at the end.
errorsCollection = errors.Join(errorsCollection, generalError)
}

if generalError := addJasScanTaskForModuleIfNeeded(params, utils.ServicesScan, runServicesScan(&params)); generalError != nil {
errorsCollection = errors.Join(errorsCollection, generalError)
}
return errorsCollection
}

Expand Down Expand Up @@ -201,6 +206,22 @@ func runSastScan(params *JasRunnerParams) parallel.TaskFunc {
}
}

func runServicesScan(params *JasRunnerParams) parallel.TaskFunc {
return func(threadId int) (err error) {
defer func() {
params.Runner.JasScannersWg.Done()
}()
vulnerabilitiesResults, violationsResults, err := jfrogServices.RunServicesScan(params.Scanner, params.Module, params.TargetCount, threadId, getSourceRunsToCompare(params, jasutils.Services)...)
params.Runner.ResultsMu.Lock()
defer params.Runner.ResultsMu.Unlock()
params.ScanResults.AddJasScanResults(jasutils.Services, vulnerabilitiesResults, violationsResults, jas.GetAnalyzerManagerExitCode(err))
if err = jas.ParseAnalyzerManagerError(jasutils.Services, err); err != nil {
return fmt.Errorf("%s%s", clientutils.GetLogMsgPrefix(threadId, false), err.Error())
}
return dumpSarifRunToFileIfNeeded(params.TargetOutputDir, jasutils.Services, threadId, vulnerabilitiesResults, violationsResults)
}
}

func runContextualScan(params *JasRunnerParams) parallel.TaskFunc {
return func(threadId int) (err error) {
defer func() {
Expand Down
108 changes: 108 additions & 0 deletions jas/services/servicesscanner.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package services

import (
"path/filepath"
"time"

jfrogappsconfig "github.com/jfrog/jfrog-apps-config/go"
"github.com/jfrog/jfrog-cli-security/jas"
"github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-cli-security/utils/formats/sarifutils"
"github.com/jfrog/jfrog-cli-security/utils/jasutils"
"github.com/jfrog/jfrog-client-go/utils/log"
"github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif"
)

const (
servicesScannerType = "services-scan"
servicesScanCommand = "svc"
servicesDocsUrlSuffix = "services-scans"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No such URL as https://docs.jfrog.com/security/docs/services-scans
IMO should be:

(i.e misconfigurations-scans-1#services-scans---services-configuration-security or just misconfigurations-scans-1, similar to IaC)
Confirm this with tech writer

)

type ServicesScanManager struct {
scanner *jas.JasScanner

resultsToCompareFileName string
configFileName string
resultsFileName string
}
Comment on lines +22 to +28

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjust the file to have 2 ways to run (similar to the other scanners)

  • Deprecated with apps config module
  • New with scantarget (and config profile)

see sastscanner.go for more details:

func (sastScanManager *SastScanManager) runSastScan(params SastScanParams) (vulnerabilitiesResults []*sarif.Run, violationsResults []*sarif.Run, err error) {
	if params.Target.DeprecatedAppsConfigModule == nil {
		return sastScanManager.scanner.Run(sastScanManager, params.Target)
	}
	return sastScanManager.scanner.DeprecatedRun(sastScanManager, *params.Target.DeprecatedAppsConfigModule, params.Target.GetCentralConfigExclusions(utils.SastScan))
}


func RunServicesScan(scanner *jas.JasScanner, module jfrogappsconfig.Module, targetCount, threadId int, resultsToCompare ...*sarif.Run) (vulnerabilitiesResults []*sarif.Run, violationsResults []*sarif.Run, err error) {
var scannerTempDir string
if scannerTempDir, err = jas.CreateScannerTempDirectory(scanner, jasutils.Services.String(), threadId); err != nil {
return
}
servicesScanManager, err := newServicesScanManager(scanner, scannerTempDir, resultsToCompare...)
if err != nil {
return
}
startTime := time.Now()
log.Info(jas.GetStartJasScanLog(utils.ServicesScan, threadId, &module, targetCount))
if vulnerabilitiesResults, violationsResults, err = servicesScanManager.scanner.Run(servicesScanManager, results.ScanTarget{Module: &module}); err != nil {

Check failure on line 41 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Static-Check

undefined: results

Check failure on line 41 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Static-Check

cannot use servicesScanManager (variable of type *ServicesScanManager) as jas.ScannerCmd value in argument to servicesScanManager.scanner.Run: *ServicesScanManager does not implement jas.ScannerCmd (missing method DeprecatedRun)

Check failure on line 41 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint ubuntu

undefined: results

Check failure on line 41 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint ubuntu

cannot use servicesScanManager (variable of type *ServicesScanManager) as jas.ScannerCmd value in argument to servicesScanManager.scanner.Run: *ServicesScanManager does not implement jas.ScannerCmd (missing method DeprecatedRun)

Check failure on line 41 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint macos

undefined: results

Check failure on line 41 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint macos

cannot use servicesScanManager (variable of type *ServicesScanManager) as jas.ScannerCmd value in argument to servicesScanManager.scanner.Run: *ServicesScanManager does not implement jas.ScannerCmd (missing method DeprecatedRun)

Check failure on line 41 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Go-Sec

undefined: results

Check failure on line 41 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Go-Sec

cannot use servicesScanManager (variable of type *ServicesScanManager) as jas.ScannerCmd value in argument to servicesScanManager.scanner.Run: *ServicesScanManager does not implement jas.ScannerCmd (missing method DeprecatedRun)

Check failure on line 41 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint windows

undefined: results

Check failure on line 41 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint windows

cannot use servicesScanManager (variable of type *ServicesScanManager) as jas.ScannerCmd value in argument to servicesScanManager.scanner.Run: *ServicesScanManager does not implement jas.ScannerCmd (missing method DeprecatedRun)
return
}
log.Info(utils.GetScanFindingsLog(utils.ServicesScan, sarifutils.GetResultsLocationCount(vulnerabilitiesResults...), startTime, threadId))
return
}

func newServicesScanManager(scanner *jas.JasScanner, scannerTempDir string, resultsToCompare ...*sarif.Run) (manager *ServicesScanManager, err error) {
manager = &ServicesScanManager{
scanner: scanner,
configFileName: filepath.Join(scannerTempDir, "config.yaml"),
resultsFileName: filepath.Join(scannerTempDir, "results.sarif"),
}
if len(resultsToCompare) == 0 {
return
}
log.Debug("Diff mode - Services results to compare provided")
manager.resultsToCompareFileName = filepath.Join(scannerTempDir, "target.sarif")
if err = jas.SaveScanResultsToCompareAsReport(manager.resultsToCompareFileName, resultsToCompare...); err != nil {
return
}
Comment on lines +57 to +61

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure Diff logic is implemented in the AM (so Frogbot Scan PR can show only added issues for services).

return
}

func (ssm *ServicesScanManager) Run(module jfrogappsconfig.Module) (vulnerabilitiesSarifRuns []*sarif.Run, violationsSarifRuns []*sarif.Run, err error) {
if err = ssm.createConfigFile(module, ssm.scanner.ScannersExclusions.ServicesExcludePatterns, ssm.scanner.Exclusions...); err != nil {

Check failure on line 66 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Static-Check

ssm.scanner.ScannersExclusions undefined (type *jas.JasScanner has no field or method ScannersExclusions)

Check failure on line 66 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint ubuntu

ssm.scanner.ScannersExclusions undefined (type *jas.JasScanner has no field or method ScannersExclusions)

Check failure on line 66 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint macos

ssm.scanner.ScannersExclusions undefined (type *jas.JasScanner has no field or method ScannersExclusions)

Check failure on line 66 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Go-Sec

ssm.scanner.ScannersExclusions undefined (type *jas.JasScanner has no field or method ScannersExclusions)

Check failure on line 66 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint windows

ssm.scanner.ScannersExclusions undefined (type *jas.JasScanner has no field or method ScannersExclusions)
return
}
if err = ssm.runAnalyzerManager(); err != nil {
return
}
return jas.ReadJasScanRunsFromFile(ssm.resultsFileName, module.SourceRoot, servicesDocsUrlSuffix, ssm.scanner.MinSeverity)

Check failure on line 72 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Static-Check

cannot use ssm.scanner.MinSeverity (variable of string type severityutils.Severity) as string value in argument to jas.ReadJasScanRunsFromFile

Check failure on line 72 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint ubuntu

cannot use ssm.scanner.MinSeverity (variable of string type severityutils.Severity) as string value in argument to jas.ReadJasScanRunsFromFile

Check failure on line 72 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint macos

cannot use ssm.scanner.MinSeverity (variable of string type severityutils.Severity) as string value in argument to jas.ReadJasScanRunsFromFile

Check failure on line 72 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Go-Sec

cannot use ssm.scanner.MinSeverity (variable of string type severityutils.Severity) as string value in argument to jas.ReadJasScanRunsFromFile

Check failure on line 72 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint windows

cannot use ssm.scanner.MinSeverity (variable of string type severityutils.Severity) as string value in argument to jas.ReadJasScanRunsFromFile
}

type servicesScanConfig struct {
Scans []servicesScanConfiguration `yaml:"scans"`
}

type servicesScanConfiguration struct {
Roots []string `yaml:"roots"`
Output string `yaml:"output"`
PathToResultsToCompare string `yaml:"target-result-file,omitempty"`
Type string `yaml:"type"`
SkippedDirs []string `yaml:"skipped-folders"`
}

func (ssm *ServicesScanManager) createConfigFile(module jfrogappsconfig.Module, centralConfigExclusions []string, exclusions ...string) error {
roots, err := jas.GetSourceRoots(module, nil)
if err != nil {
return err
}
configFileContent := servicesScanConfig{
Scans: []servicesScanConfiguration{
{
Roots: roots,
Output: ssm.resultsFileName,
PathToResultsToCompare: ssm.resultsToCompareFileName,
Type: servicesScannerType,
SkippedDirs: jas.GetExcludePatterns(module, nil, centralConfigExclusions, exclusions...),

Check failure on line 99 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Static-Check

undefined: jas.GetExcludePatterns

Check failure on line 99 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint ubuntu

undefined: jas.GetExcludePatterns

Check failure on line 99 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint macos

undefined: jas.GetExcludePatterns

Check failure on line 99 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Go-Sec

undefined: jas.GetExcludePatterns

Check failure on line 99 in jas/services/servicesscanner.go

View workflow job for this annotation

GitHub Actions / Lint windows

undefined: jas.GetExcludePatterns
},
},
}
return jas.CreateScannersConfigFile(ssm.configFileName, configFileContent, jasutils.Services)
}

func (ssm *ServicesScanManager) runAnalyzerManager() error {
return ssm.scanner.AnalyzerManager.Exec(ssm.configFileName, servicesScanCommand, filepath.Dir(ssm.scanner.AnalyzerManager.AnalyzerManagerFullPath), ssm.scanner.ServerDetails, ssm.scanner.EnvVars)
}
19 changes: 15 additions & 4 deletions policy/enforcer/policyenforcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ func dumpViolationsResponseToFileIfNeeded(generatedViolations *services.Violatio
func convertToViolations(cmdResults *results.SecurityCommandResults, generatedViolations []services.XrayViolation) (convertedViolations violationutils.Violations, err error) {
convertedViolations = violationutils.Violations{}
for _, violation := range generatedViolations {
switch getViolationType(violation) {
violationScanType := getViolationType(violation)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should adjust:
func getViolationType(violation services.XrayViolation) utils.SubScanType {

to detect the actual type between Secrets scan and Services scan results returning from Xray API

switch violationScanType {
case utils.ScaScan:
switch violation.Type {
case xrayUtils.SecurityViolation:
Expand All @@ -164,9 +165,13 @@ func convertToViolations(cmdResults *results.SecurityCommandResults, generatedVi
if sastViolation := convertToJasViolation(cmdResults, jasutils.Sast, violation); sastViolation != nil {
convertedViolations.Sast = append(convertedViolations.Sast, *sastViolation)
}
case utils.SecretsScan:
if secretsViolation := convertToJasViolation(cmdResults, jasutils.Secrets, violation); secretsViolation != nil {
convertedViolations.Secrets = append(convertedViolations.Secrets, *secretsViolation)
case utils.SecretsScan, utils.ServicesScan:
if exposuresViolation := convertToExposuresViolation(cmdResults, violationScanType, violation); exposuresViolation != nil {
if violationScanType == utils.SecretsScan {
convertedViolations.Secrets = append(convertedViolations.Secrets, *exposuresViolation)
} else {
convertedViolations.Services = append(convertedViolations.Services, *exposuresViolation)
}
}
default:
log.Warn(fmt.Sprintf("Skipping violation with unknown scan type for violation ID %s", violation.Id))
Expand Down Expand Up @@ -253,6 +258,8 @@ func getJasViolationType(jasType jasutils.JasScanType) violationutils.ViolationI
return violationutils.SastViolationType
case jasutils.Secrets:
return violationutils.SecretsViolationType
case jasutils.Services:
return violationutils.ServicesViolationType
case jasutils.IaC:
return violationutils.IacViolationType
default:
Expand Down Expand Up @@ -334,6 +341,10 @@ func locateBomVulnerabilityInfo(cmdResults *results.SecurityCommandResults, issu
return
}

func convertToExposuresViolation(cmdResults *results.SecurityCommandResults, scanType utils.SubScanType, violation services.XrayViolation) *violationutils.JasViolation {
return convertToJasViolation(cmdResults, jasutils.SubScanTypeToJasScanType(scanType), violation)
}

Comment on lines +344 to +347

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this one line func?

func convertToJasViolation(cmdResults *results.SecurityCommandResults, jasType jasutils.JasScanType, violation services.XrayViolation) (jasViolations *violationutils.JasViolation) {
match := locateJasVulnerabilityInfo(cmdResults, jasType, violation)
if match.rule == nil || match.result == nil || match.location == nil {
Expand Down
Loading
Loading