Skip to content

Commit

Permalink
Merge branch 'main' into new_exposure_analysis_first_branch
Browse files Browse the repository at this point in the history
  • Loading branch information
shireenf-ibm authored Feb 15, 2024
2 parents da21e1b + 3c064ff commit a7a9eb2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
39 changes: 29 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,50 +53,69 @@ linters-settings:
allowStrs: '"",".","-","/","\n","\n\n","\t","error","true","false"'
allowInts: "0,1,2,404"
allowFloats: "0.0,0.,1.0,1.,2.0,2."
tagliatelle:
case:
rules:
json: snake

linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- contextcheck
- dogsled
- dupl
- durationcheck
- errcheck
- errorlint
- exportloopref
- funlen
- ginkgolinter
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- gomnd
- gomoddirectives
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- importas
- ineffassign
- lll
- loggercheck
- makezero
- misspell
- nakedret
- nilerr
- noctx
- nolintlint
- nosprintfhostport
- prealloc
- predeclared
- promlinter
- reassign
- revive
- staticcheck
- stylecheck
- tagliatelle
- tenv
- testableexamples
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace
- revive

# don't enable:
# - gochecknoglobals
# - gocognit
# - goerr113
# - nestif
# - testpackage
# - wsl

issues:
exclude-rules:
- path: _test\.go
Expand All @@ -108,4 +127,4 @@ issues:
- errcheck

run:
timeout: 5m
timeout: 5m
2 changes: 1 addition & 1 deletion pkg/cli/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func updatePolicyEngineObjectsFromDirPath(pe *eval.PolicyEngine, podNames []type
objectsList, processingErrs := parser.ResourceInfoListToK8sObjectsList(rList, elogger, false)
for _, err := range processingErrs {
if err.IsFatal() || (stopOnFirstError && err.IsSevere()) {
return fmt.Errorf("scan dir path %s had processing errors: %v", dirPath, err.Error())
return fmt.Errorf("scan dir path %s had processing errors: %w", dirPath, err.Error())
}
}
objectsList = parser.FilterObjectsList(objectsList, podNames)
Expand Down
5 changes: 4 additions & 1 deletion pkg/manifests/fsscanner/manifests.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package fsscanner

import (
"errors"

utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/cli-runtime/pkg/resource"
)
Expand All @@ -13,7 +15,8 @@ func GetResourceInfosFromDirPath(paths []string, recursive, stopOnErr bool) ([]*
infos, err := resourceResult.Infos()
errs := []error{}
if err != nil {
if agg, ok := err.(utilerrors.Aggregate); ok {
var agg utilerrors.Aggregate
if ok := errors.As(err, &agg); ok {
errs = agg.Errors()
} else {
errs = []error{err}
Expand Down
2 changes: 1 addition & 1 deletion pkg/manifests/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func resourceInfoToK8sObject(info *resource.Info, l logger.Logger, muteErrsAndWa
if resourceStr != "" {
errStr += " with " + resourceStr
}
fpErr := malformedYamlDoc(info.Source, 0, -1, fmt.Errorf("%s: %s", errStr, err))
fpErr := malformedYamlDoc(info.Source, 0, -1, fmt.Errorf("%s: %w", errStr, err))
logError(l, fpErr, muteErrsAndWarns)
return nil, fpErr
}
Expand Down

0 comments on commit a7a9eb2

Please sign in to comment.