cleanup: address golangci 'gosec' issues

The golangci 'gosec' linter complains about permissions that could be
more secure. These have been modified or annotated on.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos 2025-04-29 12:37:33 +02:00 committed by mergify[bot]
parent 5941371c4b
commit 4ffa1d6c89
4 changed files with 4 additions and 1 deletions

View File

@ -432,6 +432,7 @@ func getBackingSnapshotRoot(
snapshotsBase := path.Join(stagingTargetPath, ".snap") snapshotsBase := path.Join(stagingTargetPath, ".snap")
//nolint:gosec // intended use of a variable for the path
dir, err := os.Open(snapshotsBase) dir, err := os.Open(snapshotsBase)
if err != nil { if err != nil {
log.ErrorLog(ctx, "failed to open %s when searching for snapshot root: %v", snapshotsBase, err) log.ErrorLog(ctx, "failed to open %s when searching for snapshot root: %v", snapshotsBase, err)

View File

@ -115,7 +115,7 @@ func (hcm *healthCheckManager) createChecker(volumeID, path string, ct CheckerTy
// startFileChecker initializes the fileChecker and starts it. // startFileChecker initializes the fileChecker and starts it.
func (hcm *healthCheckManager) startFileChecker(volumeID, path string, shared bool) error { func (hcm *healthCheckManager) startFileChecker(volumeID, path string, shared bool) error {
workdir := filepath.Join(path, ".csi") workdir := filepath.Join(path, ".csi")
err := os.Mkdir(workdir, 0o755) err := os.Mkdir(workdir, 0o750)
if err != nil && !os.IsExist(err) { if err != nil && !os.IsExist(err) {
return fmt.Errorf("failed to created workdir %q for health-checker: %w", workdir, err) return fmt.Errorf("failed to created workdir %q for health-checker: %w", workdir, err)
} }

View File

@ -120,6 +120,7 @@ func SetPIDLimit(limit int) error {
return err return err
} }
//nolint:gosec // pidsMax is the intended file to use
f, err := os.Create(pidsMax) f, err := os.Create(pidsMax)
if err != nil { if err != nil {
return err return err

View File

@ -98,6 +98,7 @@ func writeArtifact(artifact deploymentArtifact) {
dir := path.Dir(artifact.filename) dir := path.Dir(artifact.filename)
_, err := os.Stat(dir) _, err := os.Stat(dir)
if os.IsNotExist(err) { if os.IsNotExist(err) {
//nolint:gosec // 0o750 is recommended, but the contents should be public
err = os.MkdirAll(dir, 0o775) err = os.MkdirAll(dir, 0o775)
if err != nil { if err != nil {
panic(fmt.Sprintf("failed to create directory %q: %v", dir, err)) panic(fmt.Sprintf("failed to create directory %q: %v", dir, err))