-
Notifications
You must be signed in to change notification settings - Fork 324
chore(lint): update golangci lint version #7445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@@ -78,7 +78,7 @@ | |||
fullPath := filepath.Join(path, filename) | |||
t := template.Must(template.New("report.tmpl").Funcs(templateFuncs).Parse(htmlTemplate)) | |||
|
|||
f, err := os.OpenFile(filepath.Clean(fullPath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) | |||
f, err := os.OpenFile(filepath.Clean(fullPath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) //nolint:gosec |
Check failure
Code scanning / gosec
Expect file permissions to be 0600 or less Error
@@ -67,7 +67,7 @@ | |||
} | |||
|
|||
func saveFile(filePath string, content []byte) error { | |||
f, err := os.OpenFile(filepath.Clean(filePath), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm) | |||
f, err := os.OpenFile(filepath.Clean(filePath), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm) //nolint:gosec |
Check failure
Code scanning / gosec
Expect file permissions to be 0600 or less Error
@@ -40,7 +40,7 @@ | |||
func (info *k8sAPICall) saveK8sResources(kind, k8sResourcesContent, apiVersionFolder string) { | |||
file := filepath.Join(apiVersionFolder, kind+"s"+".yaml") | |||
|
|||
f, err := os.OpenFile(filepath.Clean(file), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) | |||
f, err := os.OpenFile(filepath.Clean(file), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) //nolint:gosec |
Check failure
Code scanning / gosec
Expect file permissions to be 0600 or less Error
@@ -90,12 +97,12 @@ | |||
return err | |||
} | |||
} else if filepath.Dir(logPath) != "." { | |||
if createErr := os.MkdirAll(filepath.Dir(logPath), os.ModePerm); createErr != nil { | |||
if createErr := os.MkdirAll(filepath.Dir(logPath), os.ModePerm); createErr != nil { //nolint:gosec |
Check failure
Code scanning / gosec
Expect directory permissions to be 0750 or less Error
return createErr | ||
} | ||
} | ||
|
||
loggerFile, err = os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY, os.ModePerm) | ||
loggerFile, err = os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY, os.ModePerm) //nolint:gosec |
Check failure
Code scanning / gosec
Potential file inclusion via variable Error
@@ -58,7 +58,7 @@ | |||
filepath.Clean(originalFileName) | |||
// create temporary file | |||
tmpFile := filepath.Join(os.TempDir(), "temporary-remediation-"+utils.NextRandom()+"-"+filepath.Base(originalFileName)) | |||
f, err := os.OpenFile(tmpFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) | |||
f, err := os.OpenFile(tmpFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) //nolint:gosec |
Check failure
Code scanning / gosec
Expect file permissions to be 0600 or less Error
@@ -114,7 +114,7 @@ | |||
func CreateTempFile(filePathCopyFrom, tmpFilePath string) string { | |||
filepath.Clean(filePathCopyFrom) | |||
filepath.Clean(tmpFilePath) | |||
f, err := os.OpenFile(tmpFilePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) | |||
f, err := os.OpenFile(tmpFilePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) //nolint:gosec |
Check failure
Code scanning / gosec
Expect file permissions to be 0600 or less Error
@@ -92,7 +92,7 @@ | |||
} | |||
fullPath := filepath.Join(path, filename) | |||
|
|||
f, err := os.OpenFile(filepath.Clean(fullPath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) | |||
f, err := os.OpenFile(filepath.Clean(fullPath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) //nolint:gosec |
Check failure
Code scanning / gosec
Expect file permissions to be 0600 or less Error
@@ -124,7 +124,7 @@ | |||
} | |||
|
|||
fullPath := filepath.Join(path, filename) | |||
f, err := os.OpenFile(filepath.Clean(fullPath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) | |||
f, err := os.OpenFile(filepath.Clean(fullPath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) //nolint:gosec |
Check failure
Code scanning / gosec
Expect file permissions to be 0600 or less Error
@@ -92,7 +92,7 @@ | |||
fullPath := filepath.Join(path, filename) | |||
t := template.Must(template.New("report.tmpl").Funcs(templateFuncs).Parse(htmlTemplate)) | |||
|
|||
f, err := os.OpenFile(filepath.Clean(fullPath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) | |||
f, err := os.OpenFile(filepath.Clean(fullPath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) //nolint:gosec |
Check failure
Code scanning / gosec
Expect file permissions to be 0600 or less Error
@@ -17,7 +17,7 @@ | |||
filePath := filepath.Join("output", filename) | |||
fullPath := filepath.Join(cwd, filePath) | |||
|
|||
csvFile, err := os.Open(fullPath) | |||
csvFile, err := os.Open(fullPath) //nolint:gosec |
Check failure
Code scanning / gosec
Potential file inclusion via variable Error
@@ -30,7 +30,7 @@ | |||
// HTMLValidation executes many asserts to validate the HTML Report | |||
func HTMLValidation(t *testing.T, file string) { | |||
// Read & Parse Expected HTML Report | |||
expectHTMLString, errExpStr := os.ReadFile(filepath.Join("fixtures", file)) | |||
expectHTMLString, errExpStr := os.ReadFile(filepath.Join("fixtures", file)) //nolint:gosec |
Check failure
Code scanning / gosec
Potential file inclusion via variable Error
@@ -81,7 +81,7 @@ | |||
if filepath.Ext(flags.GetStrFlag(flags.OutputPathFlag)) != "" { | |||
flags.SetStrFlag(flags.OutputPathFlag, filepath.Join(flags.GetStrFlag(flags.OutputPathFlag), string(os.PathSeparator))) | |||
} | |||
if err := os.MkdirAll(flags.GetStrFlag(flags.OutputPathFlag), os.ModePerm); err != nil { | |||
if err := os.MkdirAll(flags.GetStrFlag(flags.OutputPathFlag), os.ModePerm); err != nil { //nolint:gosec |
Check failure
Code scanning / gosec
Expect directory permissions to be 0750 or less Error
require.NoError(t, errExpStr, "Opening Expected HTML File should not yield an error") | ||
expectedHTML, errExp := html.Parse(strings.NewReader(string(expectHTMLString))) | ||
require.NoError(t, errExp, "Opening Expected HTML File should not yield an error") | ||
|
||
// Read & Parse Output HTML Report | ||
actualHTMLString, errActStr := os.ReadFile(filepath.Join("output", file)) | ||
actualHTMLString, errActStr := os.ReadFile(filepath.Join("output", file)) //nolint:gosec |
Check failure
Code scanning / gosec
Potential file inclusion via variable Error
return err | ||
} | ||
} | ||
if flags.GetStrFlag(flags.PayloadPathFlag) != "" && filepath.Dir(flags.GetStrFlag(flags.PayloadPathFlag)) != "." { | ||
if err := os.MkdirAll(filepath.Dir(flags.GetStrFlag(flags.PayloadPathFlag)), os.ModePerm); err != nil { | ||
if err := os.MkdirAll(filepath.Dir(flags.GetStrFlag(flags.PayloadPathFlag)), os.ModePerm); err != nil { //nolint:gosec |
Check failure
Code scanning / gosec
Expect directory permissions to be 0750 or less Error
@@ -134,7 +134,7 @@ | |||
} | |||
|
|||
if library != kicsDefault { | |||
byteContent, err := os.ReadFile(library) | |||
byteContent, err := os.ReadFile(library) //nolint:gosec |
Check failure
Code scanning / gosec
Potential file inclusion via variable Error
@@ -90,7 +90,7 @@ | |||
|
|||
apiVersionFolder := filepath.Join(info.destinationPath, apiVersion) | |||
|
|||
if err := os.MkdirAll(apiVersionFolder, os.ModePerm); err != nil { | |||
if err := os.MkdirAll(apiVersionFolder, os.ModePerm); err != nil { //nolint:gosec |
Check failure
Code scanning / gosec
Expect directory permissions to be 0750 or less Error
@@ -205,7 +205,7 @@ | |||
destFolderName := fmt.Sprintf("kics-extract-kuberneter-%s", time.Now().Format("01-02-2006")) | |||
destination := filepath.Join(destinationPath, destFolderName) | |||
|
|||
if err := os.MkdirAll(destination, os.ModePerm); err != nil { | |||
if err := os.MkdirAll(destination, os.ModePerm); err != nil { //nolint:gosec |
Check failure
Code scanning / gosec
Expect directory permissions to be 0750 or less Error
@@ -27,7 +27,7 @@ | |||
} | |||
|
|||
func getCertificateInfo(filePath string) (certInfo, error) { | |||
certPEM, err := os.ReadFile(filePath) | |||
certPEM, err := os.ReadFile(filePath) //nolint:gosec |
Check failure
Code scanning / gosec
Potential file inclusion via variable Error
@@ -140,7 +140,7 @@ | |||
|
|||
func exportCSVReport(path, filename string, body []reportModel.CSVReport) error { | |||
fullPath := filepath.Join(path, filename) | |||
f, err := os.OpenFile(filepath.Clean(fullPath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) | |||
f, err := os.OpenFile(filepath.Clean(fullPath), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) //nolint:gosec |
Check failure
Code scanning / gosec
Expect file permissions to be 0600 or less Error
@@ -212,7 +212,7 @@ | |||
return nil, ErrNotSupportedFile | |||
} | |||
|
|||
c, errOpenFile := os.Open(scanPath) | |||
c, errOpenFile := os.Open(scanPath) //nolint:gosec |
Check failure
Code scanning / gosec
Potential file inclusion via variable Error
@@ -152,7 +152,7 @@ | |||
} | |||
|
|||
func parseFile(filename string, shouldReplaceDataSource bool) (*hcl.File, error) { | |||
file, err := os.ReadFile(filename) | |||
file, err := os.ReadFile(filename) //nolint:gosec |
Check failure
Code scanning / gosec
Potential file inclusion via variable Error
@@ -202,7 +202,7 @@ | |||
|
|||
func getSecretsRegexRules(regexRulesPath string) (regexRulesContent string, err error) { | |||
if regexRulesPath != "" { | |||
b, err := os.ReadFile(regexRulesPath) | |||
b, err := os.ReadFile(regexRulesPath) //nolint:gosec |
Check failure
Code scanning / gosec
Potential file inclusion via variable Error
Reason for Proposed Changes
Proposed Changes
I submit this contribution under the Apache-2.0 license.