Merge branch 'v9.3.0.x' into amf-1831-version-length-930
This commit is contained in:
@@ -13,11 +13,11 @@
|
||||
# limitations under the License.
|
||||
|
||||
ARG BASE_IMAGE=registry.access.redhat.com/ubi8/ubi-minimal
|
||||
ARG BASE_TAG=8.7-1031
|
||||
ARG BASE_TAG=8.7-1049.1675784874
|
||||
ARG BUILDER_IMAGE=registry.access.redhat.com/ubi8/go-toolset
|
||||
ARG BUILDER_TAG=1.17.12-11
|
||||
ARG GO_WORKDIR=/opt/app-root/src/go/src/github.com/ibm-messaging/mq-container
|
||||
ARG MQ_URL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/9.3.0.3-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxX64.tar.gz"
|
||||
ARG MQ_URL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/9.3.0.4-IBM-MQ-Advanced-for-Developers-Non-Install-LinuxX64.tar.gz"
|
||||
###############################################################################
|
||||
# Build stage to build Go code
|
||||
###############################################################################
|
||||
|
||||
37
Makefile
37
Makefile
@@ -1,4 +1,4 @@
|
||||
# © Copyright IBM Corporation 2017, 2022
|
||||
# © Copyright IBM Corporation 2017, 2023
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -70,8 +70,6 @@ VOLUME_MOUNT_OPTIONS ?= :Z
|
||||
###############################################################################
|
||||
# Other variables
|
||||
###############################################################################
|
||||
# Build doesn't work if BuildKit is enabled
|
||||
DOCKER_BUILDKIT=0
|
||||
# Lock Docker API version for compatibility with Podman and with the Docker version in Travis' Ubuntu Bionic
|
||||
DOCKER_API_VERSION=1.40
|
||||
GO_PKG_DIRS = ./cmd ./internal ./test
|
||||
@@ -345,7 +343,7 @@ endef
|
||||
|
||||
# Build using a separate container to host the MQ download files.
|
||||
# To minimize the layers in the resulting image, the download files can't be part of the build context.
|
||||
# The "docker build" command (and "podman build" on macOS) don't allow you to mount a directory into the build, so a
|
||||
# The "docker build" command (and "podman build" on macOS) don't allow you to mount a directory into the build, so a
|
||||
# separate container is used to host a web server.
|
||||
# Note that for Podman, this means that you need to be using the "rootful" mode, because the rootless mode doesn't allow
|
||||
# much control of networking, so the containers can't talk to each other.
|
||||
@@ -359,7 +357,7 @@ define build-mq-using-web-server
|
||||
--detach \
|
||||
registry.access.redhat.com/ubi8/nginx-120 nginx -g "daemon off;" || ($(COMMAND) network rm $(BUILD_SERVER_NETWORK) && exit 1)
|
||||
BUILD_SERVER_IP=$$($(COMMAND) inspect -f '{{ .NetworkSettings.Networks.$(BUILD_SERVER_NETWORK).IPAddress }}' $(BUILD_SERVER_CONTAINER)); \
|
||||
$(call build-mq-command,$1,$2,$3,--network build --build-arg MQ_URL=http://$$BUILD_SERVER_IP:8080/$4,$5) || ($(COMMAND) rm -f $(BUILD_SERVER_CONTAINER) && $(COMMAND) network rm $(BUILD_SERVER_NETWORK) && exit 1)
|
||||
DOCKER_BUILDKIT=0 $(call build-mq-command,$1,$2,$3,--network build --build-arg MQ_URL=http://$$BUILD_SERVER_IP:8080/$4,$5) || ($(COMMAND) rm -f $(BUILD_SERVER_CONTAINER) && $(COMMAND) network rm $(BUILD_SERVER_NETWORK) && exit 1)
|
||||
$(COMMAND) rm -f $(BUILD_SERVER_CONTAINER)
|
||||
$(COMMAND) network rm $(BUILD_SERVER_NETWORK)
|
||||
endef
|
||||
@@ -569,29 +567,16 @@ lint: $(addsuffix /$(wildcard *.go), $(GO_PKG_DIRS))
|
||||
.PHONY: gosec
|
||||
gosec:
|
||||
$(info $(SPACER)$(shell printf "Running gosec test"$(END)))
|
||||
@gosec -fmt=json -out=gosec_results.json cmd/... internal/... 2> /dev/null ;\
|
||||
cat "gosec_results.json" ;\
|
||||
cat gosec_results.json | grep HIGH | grep severity > /dev/null ;\
|
||||
if [ $$? -eq 0 ]; then \
|
||||
printf "\nFAILURE: gosec found files containing HIGH severity issues - see results.json\n" ;\
|
||||
@gosecrc=0; gosec -fmt=json -out=gosec_results.json cmd/... internal/... 2> /dev/null || gosecrc=$$?; \
|
||||
cat gosec_results.json | jq '{"GolangErrors": (.["Golang errors"]|length>0),"Issues":(.Issues|length>0)}' | grep 'true' >/dev/null ;\
|
||||
if [ $$? -eq 0 ] || [ $$gosecrc -ne 0 ]; then \
|
||||
printf "FAILURE: Issues found running gosec - see gosec_results.json\n" ;\
|
||||
cat "gosec_results.json" ;\
|
||||
exit 1 ;\
|
||||
else \
|
||||
printf "\ngosec found no HIGH severity issues\n" ;\
|
||||
fi ;\
|
||||
cat gosec_results.json | grep MEDIUM | grep severity > /dev/null ;\
|
||||
if [ $$? -eq 0 ]; then \
|
||||
printf "\nFAILURE: gosec found files containing MEDIUM severity issues - see results.json\n" ;\
|
||||
exit 1 ;\
|
||||
else \
|
||||
printf "\ngosec found no MEDIUM severity issues\n" ;\
|
||||
fi ;\
|
||||
cat gosec_results.json | grep LOW | grep severity > /dev/null;\
|
||||
if [ $$? -eq 0 ]; then \
|
||||
printf "\nFAILURE: gosec found files containing LOW severity issues - see results.json\n" ;\
|
||||
exit 1;\
|
||||
else \
|
||||
printf "\ngosec found no LOW severity issues\n" ;\
|
||||
fi ;\
|
||||
printf "gosec found no issues\n" ;\
|
||||
cat "gosec_results.json" ;\
|
||||
fi
|
||||
|
||||
.PHONY: update-release-information
|
||||
update-release-information:
|
||||
|
||||
@@ -77,6 +77,7 @@ func logTermination(args ...interface{}) {
|
||||
// Write the message to the termination log. This is not the default place
|
||||
// that Kubernetes will look for termination information.
|
||||
log.Debugf("Writing termination message: %v", msg)
|
||||
// #nosec G306 - its a read by owner/s group, and pose no harm.
|
||||
err := ioutil.WriteFile("/run/termination-log", []byte(msg), 0660)
|
||||
if err != nil {
|
||||
log.Debug(err)
|
||||
|
||||
@@ -46,6 +46,7 @@ func logTermination(args ...interface{}) {
|
||||
// Write the message to the termination log. This is not the default place
|
||||
// that Kubernetes will look for termination information.
|
||||
log.Debugf("Writing termination message: %v", msg)
|
||||
// #nosec G306 - its a read by owner/s group, and pose no harm.
|
||||
err := ioutil.WriteFile("/run/termination-log", []byte(msg), 0660)
|
||||
if err != nil {
|
||||
log.Debug(err)
|
||||
|
||||
@@ -95,6 +95,7 @@ func mirrorLog(ctx context.Context, wg *sync.WaitGroup, path string, fromStart b
|
||||
// the file is open before the queue manager is created or started.
|
||||
// Otherwise, there would be the potential for a nearly-full file to
|
||||
// rotate before the goroutine had a chance to open it.
|
||||
// #nosec G304 - no harm, we open readonly and check error.
|
||||
f, err = os.OpenFile(path, os.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -122,6 +123,7 @@ func mirrorLog(ctx context.Context, wg *sync.WaitGroup, path string, fromStart b
|
||||
return
|
||||
}
|
||||
log.Debugf("File exists: %v, %v", path, fi.Size())
|
||||
// #nosec G304 - no harm, we open readonly and check error.
|
||||
f, err = os.OpenFile(path, os.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
@@ -169,6 +171,7 @@ func mirrorLog(ctx context.Context, wg *sync.WaitGroup, path string, fromStart b
|
||||
}
|
||||
// Re-open file
|
||||
log.Debugf("Re-opening error log file %v", path)
|
||||
// #nosec G304 - no harm, we open readonly and check error.
|
||||
f, err = os.OpenFile(path, os.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
|
||||
@@ -286,7 +286,8 @@ func updateQMini(qmname string) error {
|
||||
if strings.Contains(qminiConfigStr, "ServiceComponent:") {
|
||||
var re = regexp.MustCompile(`(?m)^.*ServiceComponent.*$\s^.*Service.*$\s^.*Name.*$\s^.*Module.*$\s^.*ComponentDataSize.*$`)
|
||||
curFile := re.ReplaceAllString(qminiConfigStr, "")
|
||||
// #nosec G304 - qmgrDir filepath is derived from dspmqinf
|
||||
// #nosec G304 G306 - qmgrDir filepath is derived from dspmqinf and
|
||||
// its a read by owner/s group, and pose no harm.
|
||||
err := ioutil.WriteFile(qmgrDir, []byte(curFile), 0660)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
###########################################################################################################################################################
|
||||
|
||||
# MQ_VERSION is the fully qualified MQ version number to build
|
||||
MQ_VERSION ?= 9.3.0.3
|
||||
MQ_VERSION ?= 9.3.0.4
|
||||
|
||||
###########################################################################################################################################################
|
||||
|
||||
@@ -16,5 +16,5 @@ docker run \
|
||||
--env LICENSE=accept \
|
||||
--env MQ_QMGR_NAME=QM1 \
|
||||
--detach \
|
||||
ibm-mqadvanced-server:9.3.0.3-amd64
|
||||
ibm-mqadvanced-server:9.3.0.4-amd64
|
||||
```
|
||||
|
||||
@@ -24,7 +24,7 @@ make advancedserver
|
||||
You can specify the image to use directly by using the `MQ_IMAGE_ADVANCEDSERVER` or `MQ_IMAGE_DEVSERVER` variables, for example:
|
||||
|
||||
```
|
||||
MQ_IMAGE_ADVANCEDSERVER=ibm-mqadvanced-server:9.3.0.3-amd64 make test-advancedserver
|
||||
MQ_IMAGE_ADVANCEDSERVER=ibm-mqadvanced-server:9.3.0.4-amd64 make test-advancedserver
|
||||
```
|
||||
|
||||
You can pass parameters to `go test` with an environment variable. For example, to run the "TestGoldenPath" test, run the following command:
|
||||
|
||||
@@ -25,4 +25,4 @@ sudo apt-get update || :
|
||||
sudo apt-get install -y jq
|
||||
|
||||
go install golang.org/x/lint/golint@latest
|
||||
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $GOPATH/bin 2.0.0 || echo "Gosec not installed. Platform may not be supported."
|
||||
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $GOPATH/bin v2.14.0 || echo "Gosec not installed. Platform may not be supported."
|
||||
|
||||
@@ -36,12 +36,15 @@ func CopyFileMode(src, dest string, perm os.FileMode) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open %s for copy: %v", src, err)
|
||||
}
|
||||
// #nosec G307 - local to this function, pose no harm.
|
||||
defer in.Close()
|
||||
|
||||
// #nosec G304 - this func creates based on the input filemode.
|
||||
out, err := os.OpenFile(dest, os.O_CREATE|os.O_WRONLY, perm)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open %s for copy: %v", dest, err)
|
||||
}
|
||||
// #nosec G307 - local to this function, pose no harm.
|
||||
defer out.Close()
|
||||
|
||||
_, err = io.Copy(out, in)
|
||||
|
||||
@@ -108,5 +108,6 @@ func (htpfile mapHtPasswd) updateHtPasswordFile(isTest bool) error {
|
||||
if isTest {
|
||||
file = "my.htpasswd"
|
||||
}
|
||||
// #nosec G306 - its a read by owner/s group, and pose no harm.
|
||||
return ioutil.WriteFile(file, htpfile.GetBytes(), 0660)
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ const (
|
||||
|
||||
var (
|
||||
metricsEnabled = false
|
||||
// #nosec G112 - this needs investigation to find reasonable timeout.
|
||||
// git-issue 233 to cover this..
|
||||
metricsServer = &http.Server{Addr: ":" + defaultPort}
|
||||
)
|
||||
|
||||
|
||||
@@ -48,8 +48,10 @@ func ProcessTemplateFile(templateFile, destFile string, data interface{}, log *l
|
||||
return err
|
||||
}
|
||||
}
|
||||
// #nosec G302
|
||||
|
||||
// #nosec G302 G304 G306 - its a read by owner/s group, and pose no harm.
|
||||
f, err := os.OpenFile(destFile, os.O_CREATE|os.O_WRONLY, 0660)
|
||||
// #nosec G307 - local to this function, pose no harm.
|
||||
defer f.Close()
|
||||
err = t.Execute(f, data)
|
||||
if err != nil {
|
||||
|
||||
@@ -53,6 +53,7 @@ func Clear() error {
|
||||
// Set lets any subsequent calls to `CheckReady` know that the queue
|
||||
// manager has finished its configuration step
|
||||
func Set() error {
|
||||
// #nosec G306 - this gives permissions to owner/s group only.
|
||||
return ioutil.WriteFile(fileName, []byte("1"), 0770)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
© Copyright IBM Corporation 2019, 2021
|
||||
© Copyright IBM Corporation 2019, 2023
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -235,6 +235,7 @@ func processKeys(tlsStore *TLSStore, keystoreDir string, keyDir string) (string,
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Failed to encode PKCS#12 Keystore %s: %v", keySet.Name()+".p12", err)
|
||||
}
|
||||
// #nosec G306 - this gives permissions to owner/s group only.
|
||||
err = ioutil.WriteFile(filepath.Join(keystoreDir, keySet.Name()+".p12"), file, 0644)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Failed to write PKCS#12 Keystore %s: %v", filepath.Join(keystoreDir, keySet.Name()+".p12"), err)
|
||||
@@ -538,6 +539,7 @@ func generateRandomPassword() string {
|
||||
validcharArray := []byte(validChars)
|
||||
password := ""
|
||||
for i := 0; i < 12; i++ {
|
||||
// #nosec G404 - this is only for internal keystore and using math/rand pose no harm.
|
||||
password = password + string(validcharArray[pwr.Intn(len(validcharArray))])
|
||||
}
|
||||
|
||||
@@ -582,10 +584,13 @@ func getCertificateFingerprint(block *pem.Block) (string, error) {
|
||||
|
||||
// writeCertificatesToFile writes a list of certificates to a file
|
||||
func writeCertificatesToFile(file string, certificates []*pem.Block) error {
|
||||
|
||||
// #nosec G304 - this is a temporary pem file to write certs.
|
||||
f, err := os.Create(file)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to create file %s: %v", file, err)
|
||||
}
|
||||
// #nosec G307 - local to this function, pose no harm.
|
||||
defer f.Close()
|
||||
|
||||
w := bufio.NewWriter(f)
|
||||
|
||||
Reference in New Issue
Block a user