Skip to content

Commit 04bc872

Browse files
committed
more static
1 parent 3eea82c commit 04bc872

File tree

8 files changed

+13
-8
lines changed

8 files changed

+13
-8
lines changed

commands/audit/audit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func CreateAuditResultsContext(serverDetails *config.ServerDetails, xrayVersion
155155

156156
// If the user requested to include vulnerabilities, or if the user didn't provide any watches, project key, artifactory repo path or git repo key, we should include vulnerabilities.
157157
func shouldIncludeVulnerabilities(includeVulnerabilities bool, watches []string, artifactoryRepoPath, projectKey, gitRepoHttpsCloneUrl string) bool {
158-
return includeVulnerabilities || len(watches) <= 0 && projectKey == "" && artifactoryRepoPath == "" && gitRepoHttpsCloneUrl == ""
158+
return includeVulnerabilities || len(watches) == 0 && projectKey == "" && artifactoryRepoPath == "" && gitRepoHttpsCloneUrl == ""
159159
}
160160

161161
func (auditCmd *AuditCommand) Run() (err error) {

commands/audit/audit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ func TestAuditWithPartialResults(t *testing.T) {
753753
t.Run(testcase.name, func(t *testing.T) {
754754
serverMock, serverDetails := validations.CreateXrayRestsMockServer(func(w http.ResponseWriter, r *http.Request) {
755755
if r.RequestURI == "/xray/api/v1/system/version" {
756-
_, err := w.Write([]byte(fmt.Sprintf(`{"xray_version": "%s", "xray_revision": "xxx"}`, utils.EntitlementsMinVersion)))
756+
_, err := fmt.Fprintf(w, `{"version":"%s", "xray_revision": "xxx"}`, utils.EntitlementsMinVersion)
757757
if !assert.NoError(t, err) {
758758
return
759759
}

commands/audit/auditparams.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (params *AuditParams) createXrayGraphScanParams() *services.XrayGraphScanPa
199199
}
200200

201201
func (params *AuditParams) ToBuildInfoBomGenParams() (bomParams technologies.BuildInfoBomGeneratorParams, err error) {
202-
serverDetails, err := params.AuditBasicParams.ServerDetails()
202+
serverDetails, err := params.ServerDetails()
203203
if err != nil {
204204
return
205205
}

sca/bom/buildinfo/technologies/gem/gem.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gem
22

33
import (
44
"bufio"
5+
"errors"
56
"fmt"
67
"os"
78
"os/exec"
@@ -195,7 +196,11 @@ func parseLockfileToInternalData(lockFilePath string) (
195196
if ioErr != nil {
196197
return nil, nil, fmt.Errorf("opening lockfile %s: %w", lockFilePath, ioErr)
197198
}
198-
defer file.Close()
199+
defer func() {
200+
if cerr := file.Close(); cerr != nil {
201+
err = errors.Join(err, fmt.Errorf("closing lockfile %s: %w", lockFilePath, cerr))
202+
}
203+
}()
199204

200205
scanner := bufio.NewScanner(file)
201206

tests/validations/test_mocks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func XrayServer(t *testing.T, params MockServerParams) (*httptest.Server, *confi
174174
if r.Method == http.MethodPost {
175175
apiCallCounts[GraphScanPostAPI]++
176176
w.WriteHeader(http.StatusCreated)
177-
_, err := w.Write([]byte(fmt.Sprintf(`{"scan_id" : "%s"}`, TestScaScanId)))
177+
_, err := fmt.Fprintf(w, `{"scan_id" : "%s"}`, TestScaScanId)
178178
if !assert.NoError(t, err) {
179179
return
180180
}

utils/results/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ func GetCveApplicabilityFieldAndFilterDisqualify(cveId string, applicabilityScan
728728
// Filter out evidences that are disqualified
729729
filteredEvidence := make([]formats.Evidence, 0, len(applicability.Evidence))
730730
for _, evidence := range applicability.Evidence {
731-
fileName := evidence.Location.File
731+
fileName := evidence.File
732732
if fileName == "" || !shouldDisqualifyEvidence(components, filepath.Clean(fileName)) {
733733
// If the file name is empty, we cannot determine if it should be disqualified
734734
// If the evidence is not disqualified, keep it

utils/results/conversion/simplejsonparser/simplejsonparser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,6 @@ func sortSourceCodeRow(rows []formats.SourceCodeRow) {
831831
if rows[i].Applicability != nil && rows[j].Applicability != nil {
832832
return jasutils.TokenValidationOrder[rows[i].Applicability.Status] < jasutils.TokenValidationOrder[rows[j].Applicability.Status]
833833
}
834-
return rows[i].Location.File > rows[j].Location.File
834+
return rows[i].File > rows[j].File
835835
})
836836
}

utils/results/conversion/summaryparser/summaryparser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (sc *CmdResultsSummaryConverter) getScaSecurityViolationHandler(parsed *dat
133133
}
134134
parsed.Add(key)
135135
// Count the violation
136-
scaSecurityHandler(sc.currentScan.Violations.ScanResultSummary.ScaResults, severity, applicabilityStatus)
136+
scaSecurityHandler(sc.currentScan.Violations.ScaResults, severity, applicabilityStatus)
137137
}
138138
return
139139
}

0 commit comments

Comments
 (0)