-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement GOSec for security scanning Fix vulnerabilities #227
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,11 +65,23 @@ func (ks *KeyStore) Create() error { | |
stashFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".sth" | ||
rdbFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".rdb" | ||
crlFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".crl" | ||
os.Remove(stashFile) | ||
os.Remove(rdbFile) | ||
os.Remove(crlFile) | ||
err = os.Remove(stashFile) | ||
if err != nil { | ||
log.Debugf("Error removing %s: %v", stashFile, err) | ||
} | ||
err = os.Remove(rdbFile) | ||
if err != nil { | ||
log.Debugf("Error removing %s: %v", rdbFile, err) | ||
} | ||
err = os.Remove(crlFile) | ||
if err != nil { | ||
log.Debugf("Error removing %s: %v", crlFile, err) | ||
} | ||
} | ||
err = os.Remove(ks.Filename) | ||
if err != nil { | ||
log.Debugf("Error removing %s: %v", ks.Filename, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log normally |
||
} | ||
os.Remove(ks.Filename) | ||
} else if !os.IsNotExist(err) { | ||
// If the keystore exists but cannot be accessed then return the error | ||
return err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,17 @@ import ( | |
var log *logger.Logger | ||
|
||
func setPassword(user string, password string) error { | ||
// #nosec G204 | ||
cmd := exec.Command("chpasswd") | ||
stdin, err := cmd.StdinPipe() | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Fprintf(stdin, "%s:%s", user, password) | ||
stdin.Close() | ||
err = stdin.Close() | ||
if err != nil { | ||
log.Debugf("Error closing password stdin: %v", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log normally |
||
} | ||
_, _, err = command.RunCmd(cmd) | ||
if err != nil { | ||
return err | ||
|
@@ -165,6 +169,10 @@ func main() { | |
osExit(1) | ||
} else { | ||
// Replace this process with runmqserver | ||
syscall.Exec("/usr/local/bin/runmqserver", []string{"runmqserver"}, os.Environ()) | ||
// #nosec G204 | ||
err = syscall.Exec("/usr/local/bin/runmqserver", []string{"runmqserver"}, os.Environ()) | ||
if err != nil { | ||
log.Debugf("Error replacing this process with runmqserver: %v", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log normally |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,10 @@ func updateMQSC(appPasswordRequired bool) error { | |
return err | ||
} | ||
} else { | ||
os.Remove(mqsc) | ||
err := os.Remove(mqsc) | ||
if err != nil { | ||
log.Debugf("Error removing file %s: %v", mqsc, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log normally |
||
} | ||
} | ||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,10 @@ func mirrorLog(ctx context.Context, wg *sync.WaitGroup, path string, fromStart b | |
// Always start at the beginning if we've been told to go from the start | ||
if offset != 0 && !fromStart { | ||
log.Debugf("Seeking offset %v in file %v", offset, path) | ||
f.Seek(offset, 0) | ||
_, err = f.Seek(offset, 0) | ||
if err != nil { | ||
log.Errorf("Unable to return to offset %v: %v", offset, err) | ||
} | ||
} | ||
closing := false | ||
for { | ||
|
@@ -159,7 +162,10 @@ func mirrorLog(ctx context.Context, wg *sync.WaitGroup, path string, fromStart b | |
// could skip all those messages. This could happen with a very small | ||
// MQ error log size. | ||
mirrorAvailableMessages(f, mf) | ||
f.Close() | ||
err = f.Close() | ||
if err != nil { | ||
log.Debugf("Unable to close mirror file handle: %v", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normal log entry |
||
} | ||
// Re-open file | ||
log.Debugf("Re-opening error log file %v", path) | ||
f, err = os.OpenFile(path, os.O_RDONLY, 0) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,13 +90,15 @@ func configureQueueManager() error { | |
for _, file := range files { | ||
if strings.HasSuffix(file.Name(), ".mqsc") { | ||
abs := filepath.Join(configDir, file.Name()) | ||
// #nosec G204 | ||
cmd := exec.Command("runmqsc") | ||
stdin, err := cmd.StdinPipe() | ||
if err != nil { | ||
log.Println(err) | ||
return err | ||
} | ||
// Open the MQSC file for reading | ||
// #nosec G304 | ||
f, err := os.Open(abs) | ||
if err != nil { | ||
log.Printf("Error opening %v: %v", abs, err) | ||
|
@@ -106,8 +108,14 @@ func configureQueueManager() error { | |
if err != nil { | ||
log.Printf("Error reading %v: %v", abs, err) | ||
} | ||
f.Close() | ||
stdin.Close() | ||
err = f.Close() | ||
if err != nil { | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
log.Debugf("Failed to close MQSC file handle: %v", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log normally |
||
} | ||
err = stdin.Close() | ||
if err != nil { | ||
log.Debugf("Failed to close MQSC stdin: %v", err) | ||
} | ||
// Run the command and wait for completion | ||
out, err := cmd.CombinedOutput() | ||
if err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should be regular log messages, not debug ones. Also, in the case of removing files failing, maybe we should just fail.