Skip to content

Commit

Permalink
Fix[CI](SAST): gosec nosec
Browse files Browse the repository at this point in the history
  • Loading branch information
yunginnanet committed Oct 19, 2023
1 parent d88ed90 commit 7f3d401
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions internal/config/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
)

// StartLogger instantiates an instance of our zerolog loggger so we can hook it in our main package.
// While this does return a logger, it should not be used for additional retrievals of the logger. Use GetLogger()
// While this does return a logger, it should not be used for additional retrievals of the logger. Use GetLogger().
func StartLogger() zerolog.Logger {
logDir = snek.GetString("logger.directory")
if !strings.HasSuffix(logDir, "/") {
Expand All @@ -41,8 +41,9 @@ func StartLogger() zerolog.Logger {

var err error

/* #nosec */
if logFile, err = os.OpenFile(CurrentLogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o666); err != nil {
// this is not a security issue, we are not using user input to create the file
//goland:noinspection GoCommentLeadingSpace
if logFile, err = os.OpenFile(CurrentLogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666); err != nil { //#nosec
println("cannot create log file: " + err.Error())
os.Exit(1)
}
Expand All @@ -52,7 +53,7 @@ func StartLogger() zerolog.Logger {
return logger
}

// GetLogger retrieves our global logger object
// GetLogger retrieves our global logger object.
func GetLogger() *zerolog.Logger {
// future logic here
return &logger
Expand Down
3 changes: 2 additions & 1 deletion internal/util/speedometer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func writeStuff(t *testing.T, target io.Writer, count int) error {
return nil
}

//nolint:funlen
func Test_Speedometer(t *testing.T) {
type results struct {
total int64
Expand Down Expand Up @@ -286,7 +287,7 @@ func Test_Speedometer(t *testing.T) {
err error
)
//goland:noinspection GoCommentLeadingSpace
if server, err = net.Listen("tcp", ":8080"); err != nil { // #nosec G102 - this is a unit test.
if server, err = net.Listen("tcp", ":8080"); err != nil { // #nosec:G102 - this is a unit test.
t.Fatalf("Failed to start server: %v", err)
}
defer func(server net.Listener) {
Expand Down

0 comments on commit 7f3d401

Please sign in to comment.