mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-09 23:24:44 +00:00
Tighten file permissions on pidfile creation
Fixes report from gosec: "G306: Expect WriteFile permissions to be 0600 or less." Also, use new octal number formatting.
This commit is contained in:
parent
e71b45b28f
commit
c9199d62e4
1 changed files with 2 additions and 2 deletions
|
@ -35,10 +35,10 @@ func New(path string) (*PIDFile, error) {
|
|||
return nil, err
|
||||
}
|
||||
// Note MkdirAll returns nil if a directory already exists
|
||||
if err := MkdirAll(filepath.Dir(path), os.FileMode(0755)); err != nil {
|
||||
if err := MkdirAll(filepath.Dir(path), os.FileMode(0o755)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := ioutil.WriteFile(path, []byte(fmt.Sprintf("%d", os.Getpid())), 0644); err != nil {
|
||||
if err := ioutil.WriteFile(path, []byte(fmt.Sprintf("%d", os.Getpid())), 0o600); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue