mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
update log file permissions to 0644 (#511)
Signed-off-by: Christopher Angelo Phillips <christopher.phillips@anchore.com>
This commit is contained in:
parent
93d00dc340
commit
3e8afc5274
@ -3,6 +3,7 @@ package logger
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -10,6 +11,8 @@ import (
|
|||||||
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const defaultLogFilePermissions fs.FileMode = 0644
|
||||||
|
|
||||||
// LogrusConfig contains all configurable values for the Logrus logger
|
// LogrusConfig contains all configurable values for the Logrus logger
|
||||||
type LogrusConfig struct {
|
type LogrusConfig struct {
|
||||||
EnableConsole bool
|
EnableConsole bool
|
||||||
@ -38,7 +41,7 @@ func NewLogrusLogger(cfg LogrusConfig) *LogrusLogger {
|
|||||||
var output io.Writer
|
var output io.Writer
|
||||||
switch {
|
switch {
|
||||||
case cfg.EnableConsole && cfg.EnableFile:
|
case cfg.EnableConsole && cfg.EnableFile:
|
||||||
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, 0755)
|
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, defaultLogFilePermissions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("unable to setup log file: %w", err))
|
panic(fmt.Errorf("unable to setup log file: %w", err))
|
||||||
}
|
}
|
||||||
@ -46,7 +49,7 @@ func NewLogrusLogger(cfg LogrusConfig) *LogrusLogger {
|
|||||||
case cfg.EnableConsole:
|
case cfg.EnableConsole:
|
||||||
output = os.Stderr
|
output = os.Stderr
|
||||||
case cfg.EnableFile:
|
case cfg.EnableFile:
|
||||||
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, 0755)
|
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, defaultLogFilePermissions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("unable to setup log file: %w", err))
|
panic(fmt.Errorf("unable to setup log file: %w", err))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user