Skip to content

Commit 74fc2ef

Browse files
committed
fix static
1 parent d632cb7 commit 74fc2ef

File tree

5 files changed

+46
-48
lines changed

5 files changed

+46
-48
lines changed

utils/results/conversion/convertor_test.go

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,44 +39,44 @@ func TestConvertResults(t *testing.T) {
3939
// dockerScanInputResults := testUtils.ReadCmdScanResults(t, filepath.Join(testDataDir, "dockerscan", "docker_results.json"))
4040

4141
testCases := []struct {
42-
cmdType utils.CommandType
43-
contentFormat conversionFormat
42+
cmdType utils.CommandType
43+
contentFormat conversionFormat
4444
// inputResults *results.SecurityCommandResults
4545
expectedContentPath string
4646
}{
4747
{
48-
cmdType: utils.SourceCode,
49-
contentFormat: SimpleJson,
48+
cmdType: utils.SourceCode,
49+
contentFormat: SimpleJson,
5050
// inputResults: auditInputResults,
5151
expectedContentPath: filepath.Join(testDataDir, "audit", "audit_simple_json.json"),
5252
},
5353
{
54-
cmdType: utils.SourceCode,
55-
contentFormat: Sarif,
54+
cmdType: utils.SourceCode,
55+
contentFormat: Sarif,
5656
// inputResults: auditInputResults,
5757
expectedContentPath: filepath.Join(testDataDir, "audit", "audit_sarif.json"),
5858
},
5959
{
60-
cmdType: utils.SourceCode,
61-
contentFormat: Summary,
60+
cmdType: utils.SourceCode,
61+
contentFormat: Summary,
6262
// inputResults: auditInputResults,
6363
expectedContentPath: filepath.Join(testDataDir, "audit", "audit_summary.json"),
6464
},
6565
{
66-
cmdType: utils.DockerImage,
67-
contentFormat: SimpleJson,
66+
cmdType: utils.DockerImage,
67+
contentFormat: SimpleJson,
6868
// inputResults: dockerScanInputResults,
6969
expectedContentPath: filepath.Join(testDataDir, "dockerscan", "docker_simple_json.json"),
7070
},
7171
{
72-
cmdType: utils.DockerImage,
73-
contentFormat: Sarif,
72+
cmdType: utils.DockerImage,
73+
contentFormat: Sarif,
7474
// inputResults: dockerScanInputResults,
7575
expectedContentPath: filepath.Join(testDataDir, "dockerscan", "docker_sarif.json"),
7676
},
7777
{
78-
cmdType: utils.DockerImage,
79-
contentFormat: Summary,
78+
cmdType: utils.DockerImage,
79+
contentFormat: Summary,
8080
// inputResults: dockerScanInputResults,
8181
expectedContentPath: filepath.Join(testDataDir, "dockerscan", "docker_summary.json"),
8282
},
@@ -85,7 +85,7 @@ func TestConvertResults(t *testing.T) {
8585
for _, testCase := range testCases {
8686
t.Run(fmt.Sprintf("%s convert to %s", testCase.cmdType, testCase.contentFormat), func(t *testing.T) {
8787
var validationParams validations.ValidationParams
88-
var inputResults *results.SecurityCommandResults
88+
var inputResults *results.SecurityCommandResults
8989
switch testCase.cmdType {
9090
case utils.SourceCode:
9191
inputResults, validationParams = getAuditTestResults(testCase.contentFormat == Summary)
@@ -156,7 +156,7 @@ func validateSummaryConversion(t *testing.T, expectedResults formats.ResultsSumm
156156
// content, err := utils.GetAsJsonBytes(actualResults, true, true)
157157
// assert.NoError(t, err)
158158
// os.WriteFile("/Users/assafa/Documents/code/jfrog-projects/jfrog-cli-security/tests/testdata/output/dockerscan/docker_summary.json", content, 0644)
159-
159+
160160
validations.ValidateCommandSummaryOutput(t, validationParams)
161161
}
162162

@@ -225,9 +225,9 @@ func getAuditTestResults(unique bool) (*results.SecurityCommandResults, validati
225225
}},
226226
},
227227
},
228-
IssueId: "XRAY-609848",
228+
IssueId: "XRAY-609848",
229229
ExtendedInformation: &services.ExtendedInformation{
230-
ShortDescription: "ReDoS in Async may lead to denial of service while parsing",
230+
ShortDescription: "ReDoS in Async may lead to denial of service while parsing",
231231
JfrogResearchSeverity: "Low",
232232
JfrogResearchSeverityReasons: []services.JfrogResearchSeverityReason{
233233
{Name: "The reported CVSS was either wrongly calculated", Description: "The reported CVSS does not reflect the severity of the vulnerability", IsPositive: true},
@@ -237,7 +237,7 @@ func getAuditTestResults(unique bool) (*results.SecurityCommandResults, validati
237237
},
238238
{
239239
Cves: []services.Cve{{
240-
Id: "CVE-2020-8203",
240+
Id: "CVE-2020-8203",
241241
CvssV2Score: "5.8",
242242
CvssV3Score: "7.4",
243243
}},
@@ -301,7 +301,7 @@ func getAuditTestResults(unique bool) (*results.SecurityCommandResults, validati
301301
},
302302
Violations: []services.Violation{
303303
{
304-
ViolationType: utils.ViolationTypeSecurity.String(),
304+
ViolationType: utils.ViolationTypeSecurity.String(),
305305
Cves: []services.Cve{{
306306
Id: "CVE-2024-39249",
307307
}},
@@ -322,7 +322,7 @@ func getAuditTestResults(unique bool) (*results.SecurityCommandResults, validati
322322
ExtendedInformation: &services.ExtendedInformation{JfrogResearchSeverity: "Low"},
323323
},
324324
{
325-
ViolationType: utils.ViolationTypeSecurity.String(),
325+
ViolationType: utils.ViolationTypeSecurity.String(),
326326
Cves: []services.Cve{{
327327
Id: "CVE-2018-3721",
328328
}},
@@ -343,9 +343,9 @@ func getAuditTestResults(unique bool) (*results.SecurityCommandResults, validati
343343
},
344344
{
345345
ViolationType: utils.ViolationTypeLicense.String(),
346-
LicenseKey: "MIT",
347-
LicenseName: "MIT full name",
348-
Severity: severityutils.High.String(),
346+
LicenseKey: "MIT",
347+
LicenseName: "MIT full name",
348+
Severity: severityutils.High.String(),
349349
Components: map[string]services.Component{
350350
"npm://lodash:4.17.0": {
351351
ImpactPaths: [][]services.ImpactPathNode{{
@@ -361,8 +361,8 @@ func getAuditTestResults(unique bool) (*results.SecurityCommandResults, validati
361361
},
362362
Licenses: []services.License{
363363
{
364-
Key: "MIT",
365-
Name: "MIT full name",
364+
Key: "MIT",
365+
Name: "MIT full name",
366366
Components: map[string]services.Component{
367367
"npm://lodash:4.17.0": {
368368
ImpactPaths: [][]services.ImpactPathNode{{
@@ -522,11 +522,11 @@ func getDockerScanTestResults(unique bool) (*results.SecurityCommandResults, val
522522
{ComponentId: "docker://platform.jfrog.io/swamp-docker/swamp:latest"},
523523
{
524524
ComponentId: "generic://sha256:f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595/sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
525-
FullPath: "sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
525+
FullPath: "sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
526526
},
527527
{
528528
ComponentId: "deb://debian:bookworm:libssl3:3.0.13-1~deb12u1",
529-
FullPath: "libssl3:3.0.13-1~deb12u1",
529+
FullPath: "libssl3:3.0.13-1~deb12u1",
530530
},
531531
}},
532532
},
@@ -546,11 +546,11 @@ func getDockerScanTestResults(unique bool) (*results.SecurityCommandResults, val
546546
{ComponentId: "docker://platform.jfrog.io/swamp-docker/swamp:latest"},
547547
{
548548
ComponentId: "generic://sha256:f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595/sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
549-
FullPath: "sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
549+
FullPath: "sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
550550
},
551551
{
552552
ComponentId: "deb://debian:bookworm:libssl3:3.0.13-1~deb12u1",
553-
FullPath: "libssl3:3.0.13-1~deb12u1",
553+
FullPath: "libssl3:3.0.13-1~deb12u1",
554554
},
555555
}},
556556
},
@@ -559,11 +559,11 @@ func getDockerScanTestResults(unique bool) (*results.SecurityCommandResults, val
559559
{ComponentId: "docker://platform.jfrog.io/swamp-docker/swamp:latest"},
560560
{
561561
ComponentId: "generic://sha256:f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595/sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
562-
FullPath: "sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
562+
FullPath: "sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
563563
},
564564
{
565565
ComponentId: "deb://debian:bookworm:openssl:3.0.13-1~deb12u1",
566-
FullPath: "openssl:3.0.13-1~deb12u1",
566+
FullPath: "openssl:3.0.13-1~deb12u1",
567567
},
568568
}},
569569
FixedVersions: []string{"[3.0.14-1~deb12u2]"},
@@ -575,7 +575,7 @@ func getDockerScanTestResults(unique bool) (*results.SecurityCommandResults, val
575575
},
576576
Violations: []services.Violation{
577577
{
578-
ViolationType: utils.ViolationTypeSecurity.String(),
578+
ViolationType: utils.ViolationTypeSecurity.String(),
579579
Cves: []services.Cve{{
580580
Id: "CVE-2024-6119",
581581
}},
@@ -587,19 +587,19 @@ func getDockerScanTestResults(unique bool) (*results.SecurityCommandResults, val
587587
{ComponentId: "docker://platform.jfrog.io/swamp-docker/swamp:latest"},
588588
{
589589
ComponentId: "generic://sha256:f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595/sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
590-
FullPath: "sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
590+
FullPath: "sha256__f21c087a3964a446bce1aa4e3ec7cf82020dd77ad14f1cf4ea49cbb32eda1595.tar",
591591
},
592592
{
593593
ComponentId: "deb://debian:bookworm:libssl3:3.0.13-1~deb12u1",
594-
FullPath: "libssl3:3.0.13-1~deb12u1",
594+
FullPath: "libssl3:3.0.13-1~deb12u1",
595595
},
596596
}},
597597
},
598598
},
599599
IssueId: "XRAY-632747",
600600
ExtendedInformation: &services.ExtendedInformation{JfrogResearchSeverity: "Medium"},
601-
WatchName: "security-watch",
602-
Policies: []services.Policy{{Policy: "debian-security"}},
601+
WatchName: "security-watch",
602+
Policies: []services.Policy{{Policy: "debian-security"}},
603603
},
604604
},
605605
ScannedStatus: "completed",
@@ -614,7 +614,7 @@ func getDockerScanTestResults(unique bool) (*results.SecurityCommandResults, val
614614
),
615615
},
616616
Invocations: []*sarif.Invocation{sarif.NewInvocation().WithWorkingDirectory(sarif.NewSimpleArtifactLocation("temp/folders/T/jfrog.cli.temp.-11-11"))},
617-
Results: []*sarif.Result{validations.CreateDummyApplicableResults("CVE-2024-6119", formats.Location{File: "file:///usr/local/bin/node"})},
617+
Results: []*sarif.Result{validations.CreateDummyApplicableResults("CVE-2024-6119", formats.Location{File: "file:///usr/local/bin/node"})},
618618
},
619619
)
620620
// Secrets scan results

utils/results/conversion/sarifparser/sarifparser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type currentTargetState struct {
7070
type scaParseParams struct {
7171
CmdType utils.CommandType
7272
IssueId, Summary, MarkdownDescription, CveScore, ImpactedPackagesName, ImpactedPackagesVersion string
73-
Watch string
73+
Watch string
7474
GenerateTitleFunc func(depName string, version string, issueId string, watch string) string
7575
Cves []formats.CveRow
7676
Severity severityutils.Severity
@@ -352,7 +352,7 @@ func addSarifScaSecurityViolation(cmdType utils.CommandType, sarifResults *[]*sa
352352
currentResults, currentRule := parseScaToSarifFormat(scaParseParams{
353353
CmdType: cmdType,
354354
IssueId: violation.IssueId,
355-
Watch: violation.WatchName,
355+
Watch: violation.WatchName,
356356
Summary: violation.Summary,
357357
MarkdownDescription: markdownDescription,
358358
CveScore: maxCveScore,
@@ -391,7 +391,7 @@ func addSarifScaLicenseViolation(cmdType utils.CommandType, sarifResults *[]*sar
391391
}
392392
currentResults, currentRule := parseScaToSarifFormat(scaParseParams{
393393
CmdType: cmdType,
394-
Watch: violation.WatchName,
394+
Watch: violation.WatchName,
395395
IssueId: violation.LicenseKey,
396396
Summary: getLicenseViolationSummary(impactedPackagesName, impactedPackagesVersion, violation.LicenseKey),
397397
MarkdownDescription: markdownDescription,

utils/results/conversion/summaryparser/summaryparser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,4 @@ func getJasScansWatches(scans ...results.ScanResult[[]*sarif.Run]) (watches []st
369369
}
370370
}
371371
return
372-
}
372+
}

utils/validations/test_mocks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func CreateDummySecretResult(id string, status jasutils.TokenValidationStatus, m
224224
return &sarif.Result{
225225
Message: *sarif.NewTextMessage(fmt.Sprintf("Secret %s were found", id)),
226226
RuleID: utils.NewStrPtr(id),
227-
Level: utils.NewStrPtr(severityutils.LevelInfo.String()),
227+
Level: utils.NewStrPtr(severityutils.LevelInfo.String()),
228228
Locations: []*sarif.Location{
229229
sarifutils.CreateLocation(location.File, location.StartLine, location.StartColumn, location.EndLine, location.EndColumn, location.Snippet),
230230
},
@@ -268,4 +268,4 @@ func CreateDummySastViolationResult(id string, level severityutils.SarifSeverity
268268
result.PropertyBag.Properties[sarifutils.JasIssueIdSarifPropertyKey] = issueId
269269
result.PropertyBag.Properties[sarifutils.PoliciesSarifPropertyKey] = policies
270270
return result
271-
}
271+
}

utils/validations/test_validate_summary.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ func ValidateSummaryIssuesCount(t *testing.T, params ValidationParams, results f
6565
if scan.Vulnerabilities.SecretsResults != nil {
6666
for _, counts := range *scan.Vulnerabilities.SecretsResults {
6767
for status, count := range counts {
68-
switch status {
69-
case jasutils.Inactive.String():
68+
if status == jasutils.Inactive.String() {
7069
actualValues.InactiveSecretsVulnerabilities += count
7170
}
7271
}
@@ -95,8 +94,7 @@ func ValidateSummaryIssuesCount(t *testing.T, params ValidationParams, results f
9594
if scan.Violations.SecretsResults != nil {
9695
for _, counts := range *scan.Violations.SecretsResults {
9796
for status, count := range counts {
98-
switch status {
99-
case jasutils.Inactive.String():
97+
if status == jasutils.Inactive.String() {
10098
actualValues.InactiveSecretsViolations += count
10199
}
102100
}

0 commit comments

Comments
 (0)