fixed more flaky pointers in loops (resultshandling)

Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
This commit is contained in:
Frédéric BIDON
2022-12-19 12:29:12 +01:00
parent afce43add6
commit 22052f5869
3 changed files with 6 additions and 59 deletions

View File

@@ -1,56 +0,0 @@
linters-settings:
govet:
check-shadowing: true
maligned:
suggest-new: true
dupl:
threshold: 200
goconst:
min-len: 3
min-occurrences: 2
forbidigo:
forbid:
- ^print.*$
- 'fmt\.Print.*'
gocognit:
min-complexity: 65 # This is super high value. We should gradually lower it to 30-40.
linters:
enable:
- gosec
disable:
- typecheck
- errcheck
- govet
- staticcheck
- gosimple
- deadcode
- gofmt
- goimports
- bodyclose
- dupl
#- forbidigo # <- see later
- gocognit
- gocritic
- goimports
- nakedret
#- nolintlint
- revive
- stylecheck
- unconvert
- unparam
- maligned
- lll
- gochecknoinits
- gochecknoglobals
issues:
exclude-rules:
- linters:
- revive
text: "var-naming"
- linters:
- revive
text: "type name will be used as (.+?) by other packages, and that stutters"
- linters:
- stylecheck
text: "ST1003"

View File

@@ -319,11 +319,13 @@ func (m *Metrics) setResourcesCounters(
resources map[string]workloadinterface.IMetadata,
results map[string]resourcesresults.Result) {
for resourceID, result := range results {
for resourceID, toPin := range results {
r, ok := resources[resourceID]
if !ok {
continue
}
result := toPin
passed, excluded, failed := resourceControlStatusCounters(&result)
mrc := mResources{}
@@ -339,5 +341,4 @@ func (m *Metrics) setResourcesCounters(
m.listResources = append(m.listResources, mrc)
}
}

View File

@@ -129,7 +129,9 @@ func (sp *SARIFPrinter) ActionPrint(opaSessionObj *cautils.OPASessionObj) {
logger.L().Debug("failed to create location resolver", helpers.Error(err))
}
for _, ac := range result.AssociatedControls {
for _, toPin := range result.AssociatedControls {
ac := toPin
if ac.GetStatus(nil).IsFailed() {
ctl := opaSessionObj.Report.SummaryDetails.Controls.GetControl(reportsummary.EControlCriteriaID, ac.GetID())
location := sp.resolveFixLocation(opaSessionObj, locationResolver, &ac, resourceID)