Updates to resolve issues identified by gosec (#330)

* Updates to resolve issues identified by gosec
This commit is contained in:
Stephen Marshall
2019-06-07 11:51:34 +01:00
committed by GitHub
parent ee4351e55d
commit 3f9fc0eaa5
13 changed files with 163 additions and 40 deletions

View File

@@ -23,7 +23,7 @@ import (
"syscall"
"github.com/ibm-messaging/mq-container/internal/command"
containerruntimelogger "github.com/ibm-messaging/mq-container/internal/containerruntimelogger"
"github.com/ibm-messaging/mq-container/internal/containerruntimelogger"
"github.com/ibm-messaging/mq-container/internal/logger"
"github.com/ibm-messaging/mq-container/internal/mqtemplate"
"github.com/ibm-messaging/mq-container/internal/name"

View File

@@ -24,7 +24,7 @@ import (
"os"
"sync"
containerruntimelogger "github.com/ibm-messaging/mq-container/internal/containerruntimelogger"
"github.com/ibm-messaging/mq-container/internal/containerruntimelogger"
"github.com/ibm-messaging/mq-container/internal/metrics"
"github.com/ibm-messaging/mq-container/internal/name"
"github.com/ibm-messaging/mq-container/internal/ready"

View File

@@ -33,7 +33,10 @@ func postInit(name, keylabel string, p12Trust tls.KeyStoreData) error {
// Start the web server, in the background (if installed)
// WARNING: No error handling or health checking available for the web server
go func() {
startWebServer(keystore, p12Trust.Password)
err = startWebServer(keystore, p12Trust.Password)
if err != nil {
log.Printf("Error starting web server: %v", err)
}
}()
}
return nil

View File

@@ -171,8 +171,10 @@ func configureQueueManager() error {
abs := filepath.Join(configDir, file.Name())
// #nosec G204
verify := exec.Command("runmqsc", "-v", "-e")
// #nosec G204 - command is fixed, no injection vector
cmd := exec.Command("runmqsc")
// Read mqsc file into variable
// #nosec G304 - filename variable is derived from contents of 'configDir' which is a defined constant
mqsc, err := ioutil.ReadFile(abs)
if err != nil {
log.Printf("Error reading file %v: %v", abs, err)

View File

@@ -38,6 +38,7 @@ func startWebServer(keystore, keystorepw string) error {
return nil
}
log.Println("Starting web server")
// #nosec G204 - command is fixed, no injection vector
cmd := exec.Command("strmqweb")
// Set a default app password for the web server, if one isn't already set
_, set := os.LookupEnv("MQ_APP_PASSWORD")
@@ -175,6 +176,7 @@ func configureWebServer(keyLabel string, p12Trust tls.KeyStoreData) (string, err
}
if info.IsDir() {
if !exists {
// #nosec G301 - write group permissions are required
err := os.MkdirAll(to, 0770)
if err != nil {
return err