Skip to content

Commit ecc665a

Browse files
Merge pull request #315 from vitalykorolev/MLE-17162_enhancements
MLE-17162 security enhancements
2 parents 5a5bfaa + ee0bbe9 commit ecc665a

7 files changed

+43
-18
lines changed

Jenkinsfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void resultNotification(message) {
110110
"<b>Lint Output: </b><br/>" +
111111
"<pre><code>${LINT_OUTPUT}</code></pre><br/>" +
112112
"<b>Vulnerabilities: </b><pre><code>${SCAN_OUTPUT}</code></pre><br/>" +
113-
"<b><a href='${env.BUILD_URL}artifact/scan/report.json'>Full scan report.</a></b><br/>" +
113+
"<b><a href='${env.BUILD_URL}artifact/scan/report-${env.dockerImageType}.json'>Full scan report.</a></b><br/>" +
114114
"<b>Image Size: <br/></b>${IMAGE_SIZE} <br/>" +
115115
"<pre><code>docker pull ${dockerRegistry}/${latestTag}</code></pre><br/><br/>"
116116
if (params.DOCKER_TESTS) {
@@ -253,14 +253,14 @@ void lint() {
253253

254254
void vulnerabilityScan() {
255255
sh """
256-
make scan current_image=marklogic/marklogic-server-${dockerImageType}:${marklogicVersion}-${env.dockerImageType}-${env.dockerVersion} Jenkins=true
256+
make scan current_image=marklogic/marklogic-server-${dockerImageType}:${marklogicVersion}-${env.dockerImageType}-${env.dockerVersion} docker_image_type=${dockerImageType} Jenkins=true
257257
"""
258-
SCAN_OUTPUT = sh(returnStdout: true, script: 'cat scan/report.txt')
258+
SCAN_OUTPUT = sh(returnStdout: true, script: "cat scan/report-${env.dockerImageType}.txt")
259259
sh 'echo "SCAN_OUTPUT: ${SCAN_OUTPUT}"'
260260
if (SCAN_OUTPUT.size()) {
261261
mail charset: 'UTF-8', mimeType: 'text/html', to: "${emailSecList}", body: "<br/>Jenkins pipeline for ${env.JOB_NAME} <br/>Build Number: ${env.BUILD_NUMBER} <br/>Vulnerabilities: <pre><code>${SCAN_OUTPUT}</code></pre>", subject: "Critical or High Security Vulnerabilities Found: ${env.JOB_NAME} #${env.BUILD_NUMBER}"
262262
}
263-
archiveArtifacts artifacts: 'scan/report.txt,scan/report.json', onlyIfSuccessful: true
263+
archiveArtifacts artifacts: 'scan/*', onlyIfSuccessful: true
264264
}
265265

266266
void publishToInternalRegistry() {

Makefile

+12-9
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,18 @@ lint:
108108
.PHONY: scan
109109
scan:
110110
ifeq ($(Jenkins),true)
111-
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}/scan:/scan anchore/grype:latest --output json --file /scan/report.json ${current_image}
111+
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}/scan:/scan anchore/grype:latest --output json --file /scan/report-${docker_image_type}.json ${current_image}
112112
sudo chown -R builder.ml-eng scan
113-
echo -e "Grype scan summary\n------------------" > scan/report.txt
114-
jq '.matches[].vulnerability.severity' scan/report.json | sort | uniq -c >> scan/report.txt
115-
echo -e "\nGrype vulnerability list sorted by severity" >> scan/report.txt
116-
echo -e "PACKAGE\tVERSION\tCVE\tSEVERITY" >> scan/report.tmp
117-
jq -r '[(.matches[] | [.artifact.name, .artifact.version, .vulnerability.id, .vulnerability.severity])] | .[] | @tsv' scan/report.json | sort -k4 >> scan/report.tmp
118-
cat scan/report.tmp | column -t >> scan/report.txt
119-
rm scan/report.tmp
113+
echo -e "Grype scan summary\n------------------" > scan/report-${docker_image_type}.txt
114+
jq '.matches[].vulnerability.severity' scan/report-${docker_image_type}.json | sort | uniq -c >> scan/report-${docker_image_type}.txt
115+
echo -e "\nGrype vulnerability list sorted by severity.\n" >> scan/report-${docker_image_type}.txt
116+
echo -e "PACKAGE\tVERSION\tCVE\tSEVERITY" >> scan/report-${docker_image_type}.tmp
117+
# generate txt file
118+
jq -r '[(.matches[] | [.artifact.name, .artifact.version, .vulnerability.id, .vulnerability.severity])] | .[] | @tsv' scan/report-${docker_image_type}.json | sort -k4 >> scan/report-${docker_image_type}.tmp
119+
cat scan/report-${docker_image_type}.tmp | column -t >> scan/report-${docker_image_type}.txt
120+
rm scan/report-${docker_image_type}.tmp
121+
# generate csv file
122+
jq -r '["ID", "Severity", "CVSS Base Score", "Link", "Package"], (.matches[] | [.vulnerability.id, .vulnerability.severity, (.vulnerability.cvss[0].metrics.baseScore // "N/A"), (.relatedVulnerabilities[]?.dataSource // .vulnerability.dataSource), .artifact.name]) | @csv' scan/report-${docker_image_type}.json > scan/report-${docker_image_type}.csv
120123
else
121124
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock anchore/grype:latest ${current_image}
122125
endif
@@ -133,7 +136,7 @@ else
133136
unzip -p scap-security-guide-${open_scap_version}.zip scap-security-guide-${open_scap_version}/ssg-rhel8-ds.xml > scap/ssg-rhel-ds.xml
134137
endif
135138
docker run -itd --name scap-scan -v $(PWD)/scap:/scap ${current_image}
136-
docker exec -u root scap-scan /bin/bash -c "microdnf install -y openscap-scanner"
139+
docker exec -u root scap-scan /bin/bash -c "microdnf update -y; microdnf install -y openscap-scanner"
137140
# ensure the file is owned by root in order to avoid permission issues
138141
docker exec -u root scap-scan /bin/bash -c "chown root:root /scap/ssg-rhel-ds.xml"
139142
docker exec -u root scap-scan /bin/bash -c "oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis --results /scap/scap_scan_results.xml --report /scap/scap_scan_report.html /scap/ssg-rhel-ds.xml > /scap/command-output.txt 2>&1" || true

dockerFiles/marklogic-deps-ubi9:base

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN microdnf -y update \
2121
###############################################################
2222
# hadolint ignore=DL3006
2323
RUN echo "NETWORKING=yes" > /etc/sysconfig/network \
24-
&& microdnf -y install gdb nss libtool-ltdl cpio tzdata \
24+
&& microdnf -y install --setopt install_weak_deps=0 gdb nss libtool-ltdl cpio tzdata util-linux \
2525
&& microdnf clean all
2626

2727

dockerFiles/marklogic-deps-ubi:base

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN microdnf -y update \
2121
###############################################################
2222
# hadolint ignore=DL3006
2323
RUN echo "NETWORKING=yes" > /etc/sysconfig/network \
24-
&& microdnf -y install gdb.x86_64 glibc.i686 libstdc++.i686 libgcc.i686 initscripts redhat-lsb-core.x86_64 tzdata \
24+
&& microdnf -y install --setopt install_weak_deps=0 gdb redhat-lsb-core initscripts tzdata \
2525
&& microdnf clean all
2626

2727

dockerFiles/marklogic-server-ubi-rootless-hardened:base

+9-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ RUN mkdir -p ${MARKLOGIC_DATA_DIR} \
139139
###############################################################
140140

141141
COPY rhel-script-cis.sh /tmp/rhel-script-cis.sh
142-
RUN chmod +x /tmp/rhel-script-cis.sh \
142+
RUN touch /.dockerenv \
143+
&& chmod +x /tmp/rhel-script-cis.sh \
143144
&& /tmp/rhel-script-cis.sh
144145

145146
###############################################################
@@ -149,6 +150,13 @@ WORKDIR /
149150
COPY ${ML_CONVERTERS} /tmp/converters.rpm
150151
RUN chown ${ML_USER}:users /tmp/converters.rpm
151152

153+
###############################################################
154+
# Remove optional packages that have known vulnerabilities
155+
###############################################################
156+
RUN for package in vim-minimal cups-client cups-libs tar python3-pip-wheel platform-python python3-libs platform-python-setuptools avahi-libs binutils expat libarchive python3 python3-libs python-unversioned-command; \
157+
do rpm -e --nodeps $package || true; \
158+
done;
159+
152160
###############################################################
153161
# expose MarkLogic server ports
154162
###############################################################

dockerFiles/marklogic-server-ubi-rootless:base

+7
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ ENV MARKLOGIC_INSTALL_DIR=/opt/MarkLogic \
131131

132132
RUN microdnf -y reinstall tzdata
133133

134+
###############################################################
135+
# Remove optional packages that have known vulnerabilities
136+
###############################################################
137+
RUN for package in vim-minimal cups-client cups-libs tar python3-pip-wheel platform-python python3-libs platform-python-setuptools avahi-libs binutils expat libarchive python3 python3-libs python-unversioned-command; \
138+
do rpm -e --nodeps $package || true; \
139+
done;
140+
134141
################################################################
135142
# Set appropriate authorisation to MARKLOGIC_DATA_DIR
136143
################################################################

dockerFiles/marklogic-server-ubi:base

+9-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ COPY scripts/start-marklogic.sh /usr/local/bin/start-marklogic.sh
2727
COPY ${ML_RPM} /tmp/marklogic-server.rpm
2828
RUN rpm -i /tmp/marklogic-server.rpm \
2929
&& rm /tmp/marklogic-server.rpm \
30-
&& microdnf -y install sudo \
30+
&& microdnf -y install --setopt install_weak_deps=0 sudo \
3131
&& microdnf -y clean all \
3232
&& rm -rf ./opt/MarkLogic/mlcmd/lib/* \
3333
&& rm -rf ./opt/MarkLogic/mlcmd/ext/*
@@ -108,6 +108,13 @@ ENV MARKLOGIC_INSTALL_DIR=/opt/MarkLogic \
108108

109109
RUN microdnf -y reinstall tzdata
110110

111+
###############################################################
112+
# Remove optional packages that have known vulnerabilities
113+
###############################################################
114+
RUN for package in vim-minimal cups-client cups-libs tar python3-pip-wheel platform-python python3-libs platform-python-setuptools avahi-libs binutils expat libarchive python3 python3-libs python-unversioned-command; \
115+
do rpm -e --nodeps $package || true; \
116+
done;
117+
111118
###############################################################
112119
# expose MarkLogic server ports
113120
###############################################################
@@ -136,4 +143,4 @@ VOLUME /var/opt/MarkLogic
136143
###############################################################
137144
# set entrypoint
138145
###############################################################
139-
ENTRYPOINT ["/tini", "--", "/usr/local/bin/start-marklogic.sh"]
146+
ENTRYPOINT ["/tini", "--", "/usr/local/bin/start-marklogic.sh"]

0 commit comments

Comments
 (0)