You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/11/24 12:53:06 UTC

[camel-k] 18/19: fix(gosec): expect directory permissions to be 0750 or less (G301)

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit d537ccf09e6413d4433a71349cf1090ab5343195
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Tue Nov 23 10:56:35 2021 +0100

    fix(gosec): expect directory permissions to be 0750 or less (G301)
---
 pkg/util/util.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/pkg/util/util.go b/pkg/util/util.go
index 36d98ce..b468db4 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -230,7 +230,11 @@ func CopyFile(src, dst string) (nBytes int64, err error) {
 		err = Close(err, source)
 	}()
 
-	err = os.MkdirAll(path.Dir(dst), 0o700)
+	// we need to have group and other to be able to access the directory as the user
+	//in the container may not be the same as the one owning the files
+	//
+	// #nosec G301
+	err = os.MkdirAll(path.Dir(dst), 0o755)
 	if err != nil {
 		return
 	}
@@ -334,7 +338,8 @@ func CreateDirectory(directory string) error {
 		}
 
 		if !directoryExists {
-			err := os.MkdirAll(directory, 0o700)
+			// #nosec G301
+			err := os.MkdirAll(directory, 0o755)
 			if err != nil {
 				return err
 			}