Skip to content

Commit f1ed03b

Browse files
committed
fix gosec issue
1 parent 7ccc177 commit f1ed03b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

internal/cmd/gtrace/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,15 @@ func main() {
6767
// We should respect Go suffixes like `_linux.go`.
6868
name, tags, ext := splitOSArchTags(&buildCtx, gofile)
6969
openFile := func(name string) (*os.File, func()) {
70-
p := filepath.Join(workDir, name)
7170
var f *os.File
7271
// nolint: gofumpt
7372
// nolint: nolintlint
74-
f, err = os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
73+
// nolint: gosec
74+
f, err = os.OpenFile(
75+
filepath.Join(workDir, filepath.Clean(name)),
76+
os.O_WRONLY|os.O_CREATE|os.O_TRUNC,
77+
0600,
78+
)
7579
if err != nil {
7680
log.Fatal(err)
7781
}

0 commit comments

Comments
 (0)