We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
os.WriteFile() is called with various permission masks, should standardize them with a constant
here's the output from `go sec ./...` [/zarf/src/pkg/packager/common.go:378] - G306 (CWE-276): Expect WriteFile permissions to be 0600 or less (Confidence: HIGH, Severity: MEDIUM) 377: message.Debug(status) > 378: if err := os.WriteFile(path, chunk, 0644); err != nil { 379: return fmt.Errorf("unable to write the file %s: %w", path, err)
Here are examples of the inconsistencies: we're using at least 0640, 0600, 0644 unclear if we ever need to get group or other access.
os.MkdirAll() os.Mkdir() os.Chmod() should all be consistent.
➜ zarf git:(main) ✗ find . -name "*.go" | xargs grep os.WriteFile ./src/cmd/prepare.go: err = os.WriteFile(fileName, []byte(processedText), 0640) ./src/cmd/tools/zarf.go: if err := os.WriteFile("tls.ca", pki.CA, 0644); err != nil { ./src/cmd/tools/zarf.go: if err := os.WriteFile("tls.crt", pki.Cert, 0644); err != nil { ./src/cmd/tools/zarf.go: if err := os.WriteFile("tls.key", pki.Key, 0600); err != nil { ./src/cmd/tools/zarf.go: if err := os.WriteFile(prvKeyFileName, keyBytes.PrivateBytes, 0600); err != nil { ./src/cmd/tools/zarf.go: if err := os.WriteFile(pubKeyFileName, keyBytes.PublicBytes, 0644); err != nil { ./src/pkg/packager/common.go: if err := os.WriteFile(path, chunk, 0644); err != nil { ./src/pkg/utils/io.go: return os.WriteFile(path, []byte(text), 0600) ./src/pkg/utils/image.go: return os.WriteFile(indexPath, indexJSONBytes, 0600) ./src/pkg/utils/json.go: return os.WriteFile(path, data, 0644) ./src/pkg/utils/yaml.go: return os.WriteFile(path, content, perm)
The text was updated successfully, but these errors were encountered:
Fixed in #2235 by src/pkg/utils/helpers/io.go
src/pkg/utils/helpers/io.go
Sorry, something went wrong.
No branches or pull requests
Describe what should be investigated or refactored
os.WriteFile() is called with various permission masks, should standardize them with a constant
Here are examples of the inconsistencies:
we're using at least 0640, 0600, 0644
unclear if we ever need to get group or other access.
os.MkdirAll() os.Mkdir() os.Chmod() should all be consistent.
The text was updated successfully, but these errors were encountered: