Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out non-applicable violations if requested by policy #257

Closed
wants to merge 102 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
650cc2b
comments
eranturgeman Nov 17, 2024
8c2e4bd
Added new field for violation results to ApplicabilityScanManager + a…
eranturgeman Nov 18, 2024
7a4f5a1
Added new field for violation results to IacScanManager + added the n…
eranturgeman Nov 18, 2024
c664895
Added new field for violation results to SastScanManager + added the …
eranturgeman Nov 18, 2024
dcd923e
Added new field for violation results to SecretScanManager + added th…
eranturgeman Nov 18, 2024
03d0904
added parsing and processing for violations results (similar to vulne…
eranturgeman Nov 18, 2024
a16d7f2
updated all Run***Scan functions to return the violation results + ad…
eranturgeman Nov 18, 2024
8d3cd77
simplified interface calls
eranturgeman Nov 18, 2024
2c0b972
deleted un-used field from sastScanManager and fixed all tests refere…
eranturgeman Nov 19, 2024
748a9b0
deleted un-used field from applicabilityScanManager and fixed all tes…
eranturgeman Nov 19, 2024
20eba2b
deleted un-used field from iacScanManager and fixed all tests references
eranturgeman Nov 19, 2024
1c43d27
deleted un-used field from SecretScanManager and fixed all tests refe…
eranturgeman Nov 19, 2024
cc4720c
fixed broken tests dur to changes
eranturgeman Nov 19, 2024
6065dd2
remove comment
eranturgeman Nov 19, 2024
bb89eec
simplified interface and added temp func for testing
eranturgeman Nov 19, 2024
49617de
adjusted all functions to new interface changes and logic changes
eranturgeman Nov 19, 2024
256064d
added new struct to replace the old JasScansResults and re-wrote all …
eranturgeman Nov 19, 2024
5a7bf61
removed comment
eranturgeman Nov 19, 2024
88074b8
Merge branch 'dev' of https://github.com/jfrog/jfrog-cli-security int…
eranturgeman Nov 19, 2024
42b2fde
updated applicability scanner to ignore violations logic since this s…
eranturgeman Nov 19, 2024
0698069
comments
eranturgeman Nov 19, 2024
10e85c0
starting to replace all old JasScansResults references (struct is onl…
eranturgeman Nov 19, 2024
586aaa3
replaced old functions usages and commented all old functions (need t…
eranturgeman Nov 19, 2024
1a9f913
fixing breaks after structs changes and started initial changes in pa…
eranturgeman Nov 19, 2024
3173b9e
added a new parsing func for jas vuln & violations (parseRequiredJasR…
eranturgeman Nov 21, 2024
638c075
changed name in Sast to SastVulnerabilities in SimpleJsonResults and …
eranturgeman Nov 21, 2024
12ae850
fixed reference in broken test
eranturgeman Nov 21, 2024
1283811
changed name in Iacs to IacsVulnerabilities in SimpleJsonResults and …
eranturgeman Nov 21, 2024
c71e6a1
comment
eranturgeman Nov 21, 2024
6778de2
comment
eranturgeman Nov 21, 2024
7b9a482
comment
eranturgeman Nov 21, 2024
0f94b02
changed name in Secrets to SecretsVulnerabilities in SimpleJsonResult…
eranturgeman Nov 21, 2024
e10abad
minor change in func description
eranturgeman Nov 24, 2024
dac3af2
changing function name
eranturgeman Nov 24, 2024
df8e5c2
applying secrets violations parsing in Simple Json and adding the res…
eranturgeman Nov 24, 2024
f8257b5
applying secrets violations parsing in Table parser
eranturgeman Nov 24, 2024
2588355
applying secrets violations parsing in Summery parser
eranturgeman Nov 24, 2024
72fbe1f
applying secrets violations parsing in Sarif parser
eranturgeman Nov 24, 2024
ffa905f
applied changes of ParseSecrets
eranturgeman Nov 24, 2024
fdd290f
applying Iacs violations parsing in Simple Json parser
eranturgeman Nov 24, 2024
f16184c
applying Iacs violations parsing in Table parser
eranturgeman Nov 24, 2024
dd56650
applying Iacs violations parsing in Summery parser
eranturgeman Nov 24, 2024
e429235
applying Iacs violations parsing in Sarif parser
eranturgeman Nov 24, 2024
468b368
applied changes of ParseIacs
eranturgeman Nov 24, 2024
8ad6e2c
minor fix in Summery ParseIacs
eranturgeman Nov 24, 2024
26a350f
applying Sast violations parsing in Simple Json parser
eranturgeman Nov 24, 2024
ffbf1d0
applying Sast violations parsing in Table parser
eranturgeman Nov 24, 2024
4a2f2e9
applying Sast violations parsing in Summery parser
eranturgeman Nov 24, 2024
87749e0
applying Sast violations parsing in Sarif parser
eranturgeman Nov 24, 2024
154fc6b
applied changes of ParseSast
eranturgeman Nov 24, 2024
04596c4
removing comments
eranturgeman Nov 24, 2024
68f608f
fixing breaks from 'go vet ./..' . TestDetectScansToPreform requires fix
eranturgeman Nov 24, 2024
af658ab
add inject git url content
attiasas Nov 24, 2024
a69b532
fix static
attiasas Nov 24, 2024
892fa96
start cleaning
attiasas Nov 25, 2024
501cdf7
Merge remote-tracking branch 'upstream/dev' into pr/eranturgeman/241
attiasas Nov 25, 2024
2f850a4
update
attiasas Nov 25, 2024
8b7aba3
fmt
attiasas Nov 25, 2024
0c83518
Merge remote-tracking branch 'upstream/dev' into pr/eranturgeman/241
attiasas Nov 25, 2024
9faea6d
update after merge
attiasas Nov 25, 2024
069dbae
update client go
attiasas Nov 25, 2024
98971f6
fix
attiasas Nov 25, 2024
8231b90
ca result are general, clean todo and refactor
attiasas Nov 26, 2024
952d30d
fix for tests
attiasas Nov 26, 2024
e580111
some bug fixes
attiasas Nov 26, 2024
aff7661
parse violations
attiasas Nov 27, 2024
34b3781
Merge remote-tracking branch 'upstream/dev' into pr/eranturgeman/241
attiasas Nov 27, 2024
0a118f4
fix after merge
attiasas Nov 27, 2024
50721c7
fix some tests
attiasas Nov 28, 2024
bb0f250
Merge remote-tracking branch 'upstream/dev' into pr/eranturgeman/241
attiasas Nov 28, 2024
87e3b39
fix vet
attiasas Nov 28, 2024
c5d16fa
remove redundant set
attiasas Nov 28, 2024
e9b5e38
fix logs remove attrib and fix static
attiasas Nov 28, 2024
c5989a8
Merge remote-tracking branch 'upstream/dev' into pr/eranturgeman/241
attiasas Nov 28, 2024
0b8810b
show all errors if fail test
attiasas Nov 28, 2024
c40a287
fix some more tests
attiasas Nov 28, 2024
e277cff
Merge remote-tracking branch 'upstream/dev' into pr/eranturgeman/241
attiasas Nov 28, 2024
f2ed7e9
update client
attiasas Nov 28, 2024
1583071
remove unused jas finding logs func
attiasas Nov 28, 2024
13c5bc3
remove comment
attiasas Nov 28, 2024
b90ff34
fix static
attiasas Nov 28, 2024
c2a2622
add watch attrib to simple-json
attiasas Dec 2, 2024
22f8cb4
revert local change from assafa
eranturgeman Dec 2, 2024
d7f05a9
added logic to skip non-applicable violations by policy demand
eranturgeman Dec 2, 2024
9e979de
updated go mod
eranturgeman Dec 2, 2024
a10364b
fix spell
attiasas Dec 2, 2024
a20fa43
add LicenseViolationRow
attiasas Dec 3, 2024
f9060e5
Merge remote-tracking branch 'upstream/dev' into pr/eranturgeman/241
attiasas Dec 3, 2024
465007d
Merge branch 'jas-violations-support' of https://github.com/eranturge…
eranturgeman Dec 3, 2024
4511a0f
added test and fixed logs
eranturgeman Dec 3, 2024
2e4a959
add violation context and attribs to simple-json and sarif
attiasas Dec 3, 2024
e1256a4
added audit integration test to check the new skipNotApplicable flow
eranturgeman Dec 3, 2024
e1ece98
updated go mod
eranturgeman Dec 3, 2024
7ddaea5
update go mod
eranturgeman Dec 3, 2024
d9dde38
update go mod
eranturgeman Dec 3, 2024
6614703
add status code to each scan and to simple-json
attiasas Dec 3, 2024
5f7f30e
format
attiasas Dec 3, 2024
7753671
Merge branch 'jas-violations-support' of https://github.com/eranturge…
eranturgeman Dec 4, 2024
5910589
improve test to check sub attribs in validations
attiasas Dec 4, 2024
1ab19ef
clean
attiasas Dec 4, 2024
e901cd4
cwe is list
attiasas Dec 4, 2024
cf0714e
Merge branch 'jas-violations-support' of https://github.com/eranturge…
eranturgeman Dec 4, 2024
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
244 changes: 125 additions & 119 deletions audit_test.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions cli/scancommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
"github.com/jfrog/jfrog-client-go/utils/log"
"github.com/jfrog/jfrog-client-go/xray/services"
"github.com/urfave/cli"
"os"
"strings"
Expand Down Expand Up @@ -407,6 +408,8 @@ func AuditCmd(c *components.Context) error {
return pluginsCommon.PrintHelpAndReturnError(fmt.Sprintf("flag '--%s' cannot be used without '--%s'", flags.SecretValidation, flags.Secrets), c)
}

auditCmd.SetGitInfoContext(&services.XscGitInfoContext{GitRepoHttpsCloneUrl: "github.com/jfrog/jfrog-cli-security.git"})

allSubScans := utils.GetAllSupportedScans()
subScans := []utils.SubScanType{}
for _, subScan := range allSubScans {
Expand Down
38 changes: 29 additions & 9 deletions commands/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/jfrog/jfrog-client-go/xray"
"github.com/jfrog/jfrog-client-go/xray/services"
xscservices "github.com/jfrog/jfrog-client-go/xsc/services"
xscutils "github.com/jfrog/jfrog-client-go/xsc/services/utils"
)

type AuditCommand struct {
Expand Down Expand Up @@ -125,6 +126,7 @@ func (auditCmd *AuditCommand) Run() (err error) {
SetFixableOnly(auditCmd.fixableOnly).
SetGraphBasicParams(auditCmd.AuditBasicParams).
SetCommonGraphScanParams(auditCmd.CreateCommonGraphScanParams()).
SetGitInfoContext(auditCmd.gitInfoContext).
SetThirdPartyApplicabilityScan(auditCmd.thirdPartyApplicabilityScan).
SetThreads(auditCmd.Threads).
SetScansResultsOutputDir(auditCmd.scanResultsOutputDir).SetStartTime(startTime).SetMultiScanId(multiScanId)
Expand All @@ -150,7 +152,7 @@ func (auditCmd *AuditCommand) Run() (err error) {
SetOutputFormat(auditCmd.OutputFormat()).
SetPrintExtendedTable(auditCmd.PrintExtendedTable).
SetExtraMessages(messages).
SetSubScansPreformed(auditCmd.ScansToPerform()).
SetSubScansPerformed(auditCmd.ScansToPerform()).
PrintScanResults(); err != nil {
return errors.Join(err, auditResults.GetErrors())
}
Expand All @@ -171,7 +173,7 @@ func (auditCmd *AuditCommand) CommandName() string {
}

func (auditCmd *AuditCommand) HasViolationContext() bool {
return len(auditCmd.watches) > 0 || auditCmd.projectKey != "" || auditCmd.targetRepoPath != ""
return len(auditCmd.watches) > 0 || auditCmd.projectKey != "" || auditCmd.targetRepoPath != "" || (auditCmd.gitInfoContext != nil && auditCmd.gitInfoContext.GitRepoHttpsCloneUrl != "")
}

// Runs an audit scan based on the provided auditParams.
Expand All @@ -192,14 +194,14 @@ func RunAudit(auditParams *AuditParams) (cmdResults *results.SecurityCommandResu
var jasScanner *jas.JasScanner
var generalJasScanErr error
if jasScanner, generalJasScanErr = RunJasScans(auditParallelRunner, auditParams, cmdResults, jfrogAppsConfig); generalJasScanErr != nil {
cmdResults.AddGeneralError(fmt.Errorf("An error has occurred during JAS scan process. JAS scan is skipped for the following directories: %s\n%s", strings.Join(cmdResults.GetTargetsPaths(), ","), generalJasScanErr.Error()), auditParams.AllowPartialResults())
cmdResults.AddGeneralError(fmt.Errorf("error has occurred during JAS scan process. JAS scan is skipped for the following directories: %s\n%s", strings.Join(cmdResults.GetTargetsPaths(), ","), generalJasScanErr.Error()), auditParams.AllowPartialResults())
}
if auditParams.Progress() != nil {
auditParams.Progress().SetHeadlineMsg("Scanning for issues")
}
// The sca scan doesn't require the analyzer manager, so it can run separately from the analyzer manager download routine.
if generalScaScanError := buildDepTreeAndRunScaScan(auditParallelRunner, auditParams, cmdResults); generalScaScanError != nil {
cmdResults.AddGeneralError(fmt.Errorf("An error has occurred during SCA scan process. SCA scan is skipped for the following directories: %s\n%s", strings.Join(cmdResults.GetTargetsPaths(), ","), generalScaScanError.Error()), auditParams.AllowPartialResults())
cmdResults.AddGeneralError(fmt.Errorf("error has occurred during SCA scan process. SCA scan is skipped for the following directories: %s\n%s", strings.Join(cmdResults.GetTargetsPaths(), ","), generalScaScanError.Error()), auditParams.AllowPartialResults())
}
go func() {
auditParallelRunner.ScaScansWg.Wait()
Expand Down Expand Up @@ -234,7 +236,18 @@ func RunJasScans(auditParallelRunner *utils.SecurityParallelRunner, auditParams
return
}
auditParallelRunner.ResultsMu.Lock()
jasScanner, err = jas.CreateJasScanner(serverDetails, scanResults.SecretValidation, auditParams.minSeverityFilter, jas.GetAnalyzerManagerXscEnvVars(auditParams.GetMultiScanId(), scanResults.GetTechnologies()...), auditParams.Exclusions()...)
jasScanner, err = jas.CreateJasScanner(
serverDetails,
scanResults.SecretValidation,
auditParams.minSeverityFilter,
jas.GetAnalyzerManagerXscEnvVars(
auditParams.GetMultiScanId(),
getGitRepoUrlKey(auditParams.gitInfoContext),
auditParams.commonGraphScanParams.Watches,
scanResults.GetTechnologies()...,
),
auditParams.Exclusions()...,
)
auditParallelRunner.ResultsMu.Unlock()
if err != nil {
generalError = fmt.Errorf("failed to create jas scanner: %s", err.Error())
Expand All @@ -252,6 +265,13 @@ func RunJasScans(auditParallelRunner *utils.SecurityParallelRunner, auditParams
return
}

func getGitRepoUrlKey(gitInfoContext *services.XscGitInfoContext) string {
if gitInfoContext == nil {
return ""
}
return xscutils.GetGitRepoUrlKey(gitInfoContext.GitRepoHttpsCloneUrl)
}

func createJasScansTasks(auditParallelRunner *utils.SecurityParallelRunner, scanResults *results.SecurityCommandResults,
serverDetails *config.ServerDetails, auditParams *AuditParams, scanner *jas.JasScanner, jfrogAppsConfig *jfrogappsconfig.JFrogAppsConfig) parallel.TaskFunc {
return func(threadId int) (generalError error) {
Expand All @@ -276,7 +296,7 @@ func createJasScansTasks(auditParallelRunner *utils.SecurityParallelRunner, scan
Scanner: scanner,
Module: *module,
ConfigProfile: auditParams.configProfile,
ScansToPreform: auditParams.ScansToPerform(),
ScansToPerform: auditParams.ScansToPerform(),
SecretsScanType: secrets.SecretsScannerType,
DirectDependencies: auditParams.DirectDependencies(),
ThirdPartyApplicabilityScan: auditParams.thirdPartyApplicabilityScan,
Expand Down Expand Up @@ -334,7 +354,7 @@ func initAuditCmdResults(params *AuditParams) (cmdResults *results.SecurityComma
if err != nil {
return
}
log.Info(fmt.Sprintf("Preforming scans on %d targets:\n%s", len(cmdResults.Targets), scanInfo))
log.Info(fmt.Sprintf("Performing scans on %d targets:\n%s", len(cmdResults.Targets), scanInfo))
return
}

Expand All @@ -350,14 +370,14 @@ func detectScanTargets(cmdResults *results.SecurityCommandResults, params *Audit
log.Warn("Couldn't detect technologies in", requestedDirectory, "directory.", err.Error())
continue
}
// Create scans to preform
// Create scans to perform
for tech, workingDirs := range techToWorkingDirs {
if tech == techutils.Dotnet {
// We detect Dotnet and Nuget the same way, if one detected so does the other.
// We don't need to scan for both and get duplicate results.
continue
}
// No technology was detected, add scan without descriptors. (so no sca scan will be preformed and set at target level)
// No technology was detected, add scan without descriptors. (so no sca scan will be performed and set at target level)
if len(workingDirs) == 0 {
// Requested technology (from params) descriptors/indicators were not found or recursive scan with NoTech value, add scan without descriptors.
cmdResults.NewScanResults(results.ScanTarget{Target: requestedDirectory, Technology: tech})
Expand Down
58 changes: 28 additions & 30 deletions commands/audit/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package audit

import (
"fmt"
commonCommands "github.com/jfrog/jfrog-cli-core/v2/common/commands"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
configTests "github.com/jfrog/jfrog-cli-security/tests"
securityTestUtils "github.com/jfrog/jfrog-cli-security/tests/utils"
clientTests "github.com/jfrog/jfrog-client-go/utils/tests"
"net/http"
"path/filepath"
"sort"
"strings"
"testing"

commonCommands "github.com/jfrog/jfrog-cli-core/v2/common/commands"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
configTests "github.com/jfrog/jfrog-cli-security/tests"
securityTestUtils "github.com/jfrog/jfrog-cli-security/tests/utils"
clientTests "github.com/jfrog/jfrog-client-go/utils/tests"

"github.com/stretchr/testify/assert"

"github.com/jfrog/jfrog-cli-security/utils"
Expand All @@ -32,7 +33,7 @@ import (
"github.com/jfrog/jfrog-client-go/xsc/services"
)

func TestDetectScansToPreform(t *testing.T) {
func TestDetectScansToPerform(t *testing.T) {

dir, cleanUp := createTestDir(t)

Expand All @@ -56,14 +57,14 @@ func TestDetectScansToPreform(t *testing.T) {
ScanTarget: results.ScanTarget{
Target: filepath.Join(dir, "Nuget"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
},
{
ScanTarget: results.ScanTarget{
Technology: techutils.Go,
Target: filepath.Join(dir, "dir", "go"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
ScaResults: &results.ScaScanResults{
Descriptors: []string{filepath.Join(dir, "dir", "go", "go.mod")},
},
Expand All @@ -73,7 +74,7 @@ func TestDetectScansToPreform(t *testing.T) {
Technology: techutils.Maven,
Target: filepath.Join(dir, "dir", "maven"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
ScaResults: &results.ScaScanResults{
Descriptors: []string{
filepath.Join(dir, "dir", "maven", "maven-sub", "pom.xml"),
Expand All @@ -87,7 +88,7 @@ func TestDetectScansToPreform(t *testing.T) {
Technology: techutils.Npm,
Target: filepath.Join(dir, "dir", "npm"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
ScaResults: &results.ScaScanResults{
Descriptors: []string{filepath.Join(dir, "dir", "npm", "package.json")},
},
Expand All @@ -97,7 +98,7 @@ func TestDetectScansToPreform(t *testing.T) {
ScanTarget: results.ScanTarget{
Target: filepath.Join(dir, "yarn"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
},
},
},
Expand All @@ -115,7 +116,7 @@ func TestDetectScansToPreform(t *testing.T) {
Technology: techutils.Nuget,
Target: filepath.Join(dir, "Nuget"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
ScaResults: &results.ScaScanResults{
Descriptors: []string{filepath.Join(dir, "Nuget", "Nuget-sub", "project.csproj"), filepath.Join(dir, "Nuget", "project.sln")},
},
Expand All @@ -125,7 +126,7 @@ func TestDetectScansToPreform(t *testing.T) {
Technology: techutils.Go,
Target: filepath.Join(dir, "dir", "go"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
ScaResults: &results.ScaScanResults{
Descriptors: []string{filepath.Join(dir, "dir", "go", "go.mod")},
},
Expand All @@ -135,7 +136,7 @@ func TestDetectScansToPreform(t *testing.T) {
Technology: techutils.Maven,
Target: filepath.Join(dir, "dir", "maven"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
ScaResults: &results.ScaScanResults{
Descriptors: []string{
filepath.Join(dir, "dir", "maven", "maven-sub", "pom.xml"),
Expand All @@ -149,7 +150,7 @@ func TestDetectScansToPreform(t *testing.T) {
Technology: techutils.Npm,
Target: filepath.Join(dir, "dir", "npm"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
ScaResults: &results.ScaScanResults{
Descriptors: []string{filepath.Join(dir, "dir", "npm", "package.json")},
},
Expand All @@ -159,7 +160,7 @@ func TestDetectScansToPreform(t *testing.T) {
Technology: techutils.Yarn,
Target: filepath.Join(dir, "yarn"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
ScaResults: &results.ScaScanResults{
Descriptors: []string{filepath.Join(dir, "yarn", "package.json")},
},
Expand All @@ -169,7 +170,7 @@ func TestDetectScansToPreform(t *testing.T) {
Technology: techutils.Pip,
Target: filepath.Join(dir, "yarn", "Pip"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
ScaResults: &results.ScaScanResults{
Descriptors: []string{filepath.Join(dir, "yarn", "Pip", "requirements.txt")},
},
Expand All @@ -179,7 +180,7 @@ func TestDetectScansToPreform(t *testing.T) {
Technology: techutils.Pipenv,
Target: filepath.Join(dir, "yarn", "Pipenv"),
},
JasResults: &results.JasScansResults{},
JasResults: &results.JasScansResults{JasVulnerabilities: results.JasScanResults{}, JasViolations: results.JasScanResults{}},
ScaResults: &results.ScaScanResults{
Descriptors: []string{filepath.Join(dir, "yarn", "Pipenv", "Pipfile")},
},
Expand Down Expand Up @@ -435,27 +436,24 @@ func TestAuditWithConfigProfile(t *testing.T) {
auditResults := RunAudit(auditParams)
assert.NoError(t, auditResults.GetErrors())

summary, err := conversion.NewCommandResultsConvertor(conversion.ResultConvertParams{IncludeVulnerabilities: true, HasViolationContext: true}).ConvertToSummary(auditResults)
summary, err := conversion.NewCommandResultsConvertor(conversion.ResultConvertParams{IncludeVulnerabilities: true}).ConvertToSummary(auditResults)
assert.NoError(t, err)

var ScaResultsCount int
var scaResultsCount int
// When checking Applicability results with ExactResultsMatch = true, the sum of all statuses should equal total Sca results amount. Else, we check the provided Sca issues amount
if testcase.expectedCaApplicable > 0 || testcase.expectedCaNotApplicable > 0 || testcase.expectedCaNotCovered > 0 || testcase.expectedCaUndetermined > 0 {
ScaResultsCount = testcase.expectedCaApplicable + testcase.expectedCaNotApplicable + testcase.expectedCaNotCovered + testcase.expectedCaUndetermined
scaResultsCount = testcase.expectedCaApplicable + testcase.expectedCaNotApplicable + testcase.expectedCaNotCovered + testcase.expectedCaUndetermined
} else {
ScaResultsCount = testcase.expectedScaIssues
scaResultsCount = testcase.expectedScaIssues
}
validations.ValidateCommandSummaryOutput(t, validations.ValidationParams{
Actual: summary,
ExactResultsMatch: true,
Vulnerabilities: testcase.expectedSastIssues + testcase.expectedSecretsIssues + testcase.expectedIacIssues + ScaResultsCount,
Sast: testcase.expectedSastIssues,
Secrets: testcase.expectedSecretsIssues,
Iac: testcase.expectedIacIssues,
Applicable: testcase.expectedCaApplicable,
NotApplicable: testcase.expectedCaNotApplicable,
NotCovered: testcase.expectedCaNotCovered,
Undetermined: testcase.expectedCaUndetermined,
Total: &validations.TotalCount{Vulnerabilities: testcase.expectedSastIssues + testcase.expectedSecretsIssues + testcase.expectedIacIssues + scaResultsCount},
Vulnerabilities: &validations.VulnerabilityCount{
ValidateScan: &validations.ScanCount{Sca: scaResultsCount, Sast: testcase.expectedSastIssues, Secrets: testcase.expectedSecretsIssues, Iac: testcase.expectedIacIssues},
ValidateApplicabilityStatus: &validations.ApplicabilityStatusCount{Applicable: testcase.expectedCaApplicable, NotApplicable: testcase.expectedCaNotApplicable, NotCovered: testcase.expectedCaNotCovered, Undetermined: testcase.expectedCaUndetermined},
},
})
})
}
Expand Down
18 changes: 15 additions & 3 deletions commands/audit/auditparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/jfrog/jfrog-cli-security/utils/severityutils"
"github.com/jfrog/jfrog-cli-security/utils/xray/scangraph"
"github.com/jfrog/jfrog-client-go/xray/services"
clientservices "github.com/jfrog/jfrog-client-go/xsc/services"
xscservices "github.com/jfrog/jfrog-client-go/xsc/services"
)

type AuditParams struct {
Expand All @@ -22,9 +22,11 @@ type AuditParams struct {
// Include third party dependencies source code in the applicability scan.
thirdPartyApplicabilityScan bool
threads int
configProfile *clientservices.ConfigProfile
configProfile *xscservices.ConfigProfile
scanResultsOutputDir string
startTime time.Time
// Git params
gitInfoContext *services.XscGitInfoContext
}

func NewAuditParams() *AuditParams {
Expand Down Expand Up @@ -112,7 +114,7 @@ func (params *AuditParams) SetCommonGraphScanParams(commonParams *scangraph.Comm
return params
}

func (params *AuditParams) SetConfigProfile(configProfile *clientservices.ConfigProfile) *AuditParams {
func (params *AuditParams) SetConfigProfile(configProfile *xscservices.ConfigProfile) *AuditParams {
params.configProfile = configProfile
return params
}
Expand All @@ -122,6 +124,15 @@ func (params *AuditParams) SetScansResultsOutputDir(outputDir string) *AuditPara
return params
}

func (params *AuditParams) SetGitInfoContext(gitInfoContext *services.XscGitInfoContext) *AuditParams {
params.gitInfoContext = gitInfoContext
return params
}

func (params *AuditParams) GetGitInfoContext() *services.XscGitInfoContext {
return params.gitInfoContext
}

func (params *AuditParams) createXrayGraphScanParams() *services.XrayGraphScanParams {
return &services.XrayGraphScanParams{
RepoPath: params.commonGraphScanParams.RepoPath,
Expand All @@ -130,5 +141,6 @@ func (params *AuditParams) createXrayGraphScanParams() *services.XrayGraphScanPa
ProjectKey: params.commonGraphScanParams.ProjectKey,
IncludeVulnerabilities: params.commonGraphScanParams.IncludeVulnerabilities,
IncludeLicenses: params.commonGraphScanParams.IncludeLicenses,
XscGitInfoContext: params.gitInfoContext,
}
}
Loading
Loading