From f89982278ee5660194490c566a22c92865ec646c Mon Sep 17 00:00:00 2001 From: DmitriyLewen Date: Tue, 26 Mar 2024 13:38:48 +0600 Subject: [PATCH] fix(fs): use 0600 perms for tmp files for post analyzers --- pkg/fanal/analyzer/fs.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/fanal/analyzer/fs.go b/pkg/fanal/analyzer/fs.go index d578d6e6d06d..28880b6b0339 100644 --- a/pkg/fanal/analyzer/fs.go +++ b/pkg/fanal/analyzer/fs.go @@ -55,7 +55,8 @@ func (c *CompositeFS) CopyFileToTemp(opener Opener, info os.FileInfo) (string, e return "", xerrors.Errorf("copy error: %w", err) } - if err = os.Chmod(f.Name(), info.Mode()); err != nil { + // Use 0600 instead of file permissions to avoid errors when a file uses incorrect permissions (e.g. 0044). + if err = os.Chmod(f.Name(), 0600); err != nil { return "", xerrors.Errorf("chmod error: %w", err) }