Skip to content

Commit 6c07edc

Browse files
committed
am 199 - fix jfrog sast name
1 parent b4d178a commit 6c07edc

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

audit_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ func TestXrayAuditJasSarif(t *testing.T) {
621621
Undetermined: 1,
622622
NotCovered: 1,
623623
NotApplicable: 2,
624+
625+
SastDescSuffix: "JFrog SAST",
624626
})
625627
}
626628

jas/analyzermanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
ApplicabilityFeatureId = "contextual_analysis"
2626
AnalyzerManagerZipName = "analyzerManager.zip"
27-
defaultAnalyzerManagerVersion = "1.9.8"
27+
defaultAnalyzerManagerVersion = "1.9.9"
2828
analyzerManagerDownloadPath = "xsc-gen-exe-analyzer-manager-local/v1"
2929
analyzerManagerDirName = "analyzerManager"
3030
analyzerManagerExecutableName = "analyzerManager"

jas/sast/sastscanner.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,16 @@ type sastScanConfig struct {
7676
}
7777

7878
type scanConfiguration struct {
79-
Roots []string `yaml:"roots,omitempty"`
80-
Type string `yaml:"type,omitempty"`
81-
Language string `yaml:"language,omitempty"`
82-
ExcludePatterns []string `yaml:"exclude_patterns,omitempty"`
83-
ExcludedRules []string `yaml:"excluded-rules,omitempty"`
84-
SignedDescriptions bool `yaml:"signed_descriptions,omitempty"`
79+
Roots []string `yaml:"roots,omitempty"`
80+
Type string `yaml:"type,omitempty"`
81+
Language string `yaml:"language,omitempty"`
82+
ExcludePatterns []string `yaml:"exclude_patterns,omitempty"`
83+
ExcludedRules []string `yaml:"excluded-rules,omitempty"`
84+
SastParameters sastParameters `yaml:"sast_parameters,omitempty"`
85+
}
86+
87+
type sastParameters struct {
88+
SignedDescriptions bool `yaml:"signed_descriptions,omitempty"`
8589
}
8690

8791
func (ssm *SastScanManager) createConfigFile(module jfrogappsconfig.Module, signedDescriptions bool, exclusions ...string) error {
@@ -96,12 +100,12 @@ func (ssm *SastScanManager) createConfigFile(module jfrogappsconfig.Module, sign
96100
configFileContent := sastScanConfig{
97101
Scans: []scanConfiguration{
98102
{
99-
Type: sastScannerType,
100-
Roots: roots,
101-
Language: sastScanner.Language,
102-
ExcludedRules: sastScanner.ExcludedRules,
103-
SignedDescriptions: signedDescriptions,
104-
ExcludePatterns: jas.GetExcludePatterns(module, &sastScanner.Scanner, exclusions...),
103+
Type: sastScannerType,
104+
Roots: roots,
105+
Language: sastScanner.Language,
106+
ExcludedRules: sastScanner.ExcludedRules,
107+
SastParameters: sastParameters{SignedDescriptions: signedDescriptions},
108+
ExcludePatterns: jas.GetExcludePatterns(module, &sastScanner.Scanner, exclusions...),
105109
},
106110
},
107111
}

utils/validations/test_validate_sarif.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515
)
1616

1717
const (
18-
SastToolName = "USAF"
18+
//TODO: Validate if we need a frog emoji before the name
19+
SastToolName = " JFrog SAST"
1920
IacToolName = "JFrog Terraform scanner"
2021
// #nosec G101 -- Not credentials.
2122
SecretsToolName = "JFrog Secrets scanner"
@@ -50,7 +51,9 @@ func ValidateSarifIssuesCount(t *testing.T, params ValidationParams, report *sar
5051
secrets := sarifutils.GetResultsLocationCount(sarifutils.GetRunsByToolName(report, SecretsToolName)...)
5152
secrets += sarifutils.GetResultsLocationCount(sarifutils.GetRunsByToolName(report, sarifparser.BinarySecretScannerToolName)...)
5253
vulnerabilities += secrets
53-
sast := sarifutils.GetResultsLocationCount(sarifutils.GetRunsByToolName(report, SastToolName)...)
54+
55+
sastRuns := sarifutils.GetRunsByToolName(report, SastToolName)
56+
sast := sarifutils.GetResultsLocationCount(sastRuns...)
5457
vulnerabilities += sast
5558

5659
scaRuns := sarifutils.GetRunsByToolName(report, sarifparser.ScaScannerToolName)
@@ -88,6 +91,13 @@ func ValidateSarifIssuesCount(t *testing.T, params ValidationParams, report *sar
8891
}
8992
}
9093

94+
for _, run := range sastRuns {
95+
for _, rule := range run.Tool.Driver.Rules {
96+
ValidateContent(t, false,
97+
StringValidation{Expected: params.SastDescSuffix, Actual: *rule.ShortDescription.Text, Msg: "rule description does not contain expected substring"},
98+
)
99+
}
100+
}
91101
ValidateContent(t, params.ExactResultsMatch,
92102
CountValidation[int]{Expected: params.Sast, Actual: sast, Msg: GetValidationCountErrMsg("sast", "sarif report", params.ExactResultsMatch, params.Sast, sast)},
93103
CountValidation[int]{Expected: params.Iac, Actual: iac, Msg: GetValidationCountErrMsg("Iac", "sarif report", params.ExactResultsMatch, params.Iac, iac)},

utils/validations/test_validation.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type ValidationParams struct {
2828
Expected interface{}
2929
// If provided, the test will check exact values and not only the minimum values / existence.
3030
ExactResultsMatch bool
31+
// The Sast scanner addition to the description.
32+
SastDescSuffix string
3133
// Expected issues for each type to check if the content has the correct amount of issues.
3234
Vulnerabilities int
3335
Licenses int

0 commit comments

Comments
 (0)