Skip to content

Commit 385ad65

Browse files
Base image and Dependency Upgrades
1 parent 2951814 commit 385ad65

File tree

9 files changed

+72
-59
lines changed

9 files changed

+72
-59
lines changed

.drone.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ steps:
1414
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/dind
1515
commands:
1616
- apk add curl bash wget tar
17-
- n=0; while [ "$n" -lt 60 ] && [ ! docker stats --no-stream ]; do n=$(( n + 1 )); sleep 1; done
17+
- /usr/local/bin/wait
1818
- ./ci-build.sh
1919
environment:
2020
GEOIP_ACCOUNT_ID:
@@ -27,17 +27,23 @@ steps:
2727
- push
2828
- tag
2929

30-
- name: anchore_scan
31-
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/anchore-submission:latest
30+
- name: trivy_scan
31+
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/trivy/client:latest
32+
pull: always
3233
environment:
3334
IMAGE_NAME: ngx:latest
34-
WHITELIST: CVE-2019-5827 # Red Hat won't fix - https://access.redhat.com/security/cve/cve-2019-5827
35-
depends_on:
36-
- build_and_test_image
35+
LOCAL_IMAGE: true
36+
ALLOW_CVE_LIST_FILE: whitelist
37+
SEVERITY: HIGH,CRITICAL
38+
# Prevent build failure due to self-signed cert private key detection.
39+
# This is a non-production key generated at build time for testing.
40+
FAIL_ON_DETECTION: false
3741
when:
3842
event:
3943
- push
4044
- pull_request
45+
depends_on:
46+
- build_and_test_image
4147

4248
- name: push_image_to_artifactory
4349
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/dind
@@ -52,7 +58,7 @@ steps:
5258
DOCKER_REPO: artifactory-internal.digital.homeoffice.gov.uk
5359
DOCKER_USERNAME: docker-nginx-proxy-robot
5460
depends_on:
55-
- build_and_test_image
61+
- trivy_scan
5662
when:
5763
event:
5864
- tag
@@ -70,17 +76,11 @@ steps:
7076
DOCKER_REPO: quay.io
7177
DOCKER_USERNAME: ukhomeofficedigital+nginx_proxy
7278
depends_on:
73-
- build_and_test_image
79+
- trivy_scan
7480
when:
7581
event:
7682
- tag
7783

7884
services:
7985
- name: docker
8086
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/dind
81-
82-
- name: anchore-submission-server
83-
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/anchore-submission:latest
84-
pull: always
85-
commands:
86-
- /run.sh server

Dockerfile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
FROM quay.io/ukhomeofficedigital/centos-base:latest
1+
FROM almalinux:9.5
2+
3+
RUN dnf update -y && \
4+
dnf autoremove -y && \
5+
dnf clean all && \
6+
rm -rf /var/cache/dnf
27

38
ARG GEOIP_ACCOUNT_ID
49
ARG GEOIP_LICENSE_KEY
@@ -7,17 +12,17 @@ WORKDIR /root
712
ADD ./build.sh /root/
813
RUN ./build.sh
914

10-
RUN yum install -y openssl && \
11-
yum clean all && \
15+
RUN dnf install -y openssl && \
16+
dnf clean all && \
1217
mkdir -p /etc/keys && \
1318
openssl req -x509 -newkey rsa:2048 -keyout /etc/keys/key -out /etc/keys/crt -days 360 -nodes -subj '/CN=test' && \
14-
chmod 644 /etc/keys/key
19+
chmod 600 /etc/keys/key
1520

1621
# This takes a while so best to do it during build
1722
RUN openssl dhparam -out /usr/local/openresty/nginx/conf/dhparam.pem 2048
1823

19-
RUN yum install -y bind-utils dnsmasq && \
20-
yum clean all
24+
RUN dnf install -y bind-utils dnsmasq diffutils && \
25+
dnf clean all
2126

2227
ADD ./naxsi/location.rules /usr/local/openresty/naxsi/location.template
2328
ADD ./nginx*.conf /usr/local/openresty/nginx/conf/
@@ -35,14 +40,14 @@ ADD ./readyness.sh /
3540
ADD ./helper.sh /
3641
ADD ./refresh_geoip.sh /
3742

38-
RUN yum remove -y kernel-headers && \
39-
yum clean all
43+
RUN dnf remove -y kernel-headers && \
44+
dnf clean all
4045

4146
RUN useradd -u 1000 nginx && \
4247
install -o nginx -g nginx -d \
4348
/usr/local/openresty/naxsi/locations \
4449
/usr/local/openresty/nginx/{client_body,fastcgi,proxy,scgi,uwsgi}_temp && \
45-
chown -R nginx:nginx /usr/local/openresty/nginx/{conf,logs} /usr/share/GeoIP
50+
chown -R nginx:nginx /usr/local/openresty/nginx/{conf,logs} /usr/share/GeoIP /etc/keys
4651

4752
WORKDIR /usr/local/openresty
4853

build.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ GEOIP_LICENSE_KEY="${GEOIP_LICENSE_KEY:-xxxxxx}"
1515
GEOIP_CITY_URL="https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${GEOIP_LICENSE_KEY}&suffix=tar.gz"
1616
GEOIP_COUNTRY_URL="https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=${GEOIP_LICENSE_KEY}&suffix=tar.gz"
1717
GEOIP_MOD_URL='https://github.com/leev/ngx_http_geoip2_module/archive/3.3.tar.gz'
18-
GEOIP_UPDATE_CLI='https://github.com/maxmind/geoipupdate/releases/download/v4.7.1/geoipupdate_4.7.1_linux_amd64.tar.gz'
18+
GEOIP_UPDATE_CLI='https://github.com/maxmind/geoipupdate/releases/download/v7.1.0/geoipupdate_7.1.0_linux_amd64.tar.gz'
1919
GEOIP_URL='https://github.com/maxmind/libmaxminddb/releases/download/1.6.0/libmaxminddb-1.6.0.tar.gz'
2020
LUAROCKS_URL='https://luarocks.github.io/luarocks/releases/luarocks-3.7.0.tar.gz'
2121
NAXSI_URL='https://github.com/nbs-system/naxsi/archive/1.3.tar.gz'
@@ -25,7 +25,7 @@ STATSD_URL='https://github.com/UKHomeOffice/nginx-statsd/archive/0.0.1-ngxpatch.
2525
MAXMIND_PATH='/usr/share/GeoIP'
2626

2727
# Install dependencies to build from source
28-
yum -y install \
28+
dnf -y install \
2929
gcc-c++ \
3030
gcc \
3131
git \
@@ -39,7 +39,8 @@ yum -y install \
3939
readline-devel \
4040
tar \
4141
unzip \
42-
wget
42+
wget \
43+
zlib-devel
4344

4445
mkdir -p openresty luarocks naxsi nginx-statsd geoip geoipupdate ngx_http_geoip2_module
4546

@@ -107,10 +108,11 @@ popd
107108
echo "Installing luarocks packages"
108109
luarocks install uuid
109110
luarocks install luasocket
111+
luarocks install lua-resty-openssl
110112

111113
echo "Removing unnecessary developer tooling"
112114
rm -fr openresty naxsi nginx-statsd geoip luarocks ngx_http_geoip2_module
113-
yum -y remove \
115+
dnf -y remove \
114116
gcc-c++ \
115117
gcc \
116118
git \
@@ -121,4 +123,4 @@ yum -y remove \
121123
pcre-devel \
122124
readline-devel
123125

124-
yum clean all
126+
dnf clean all

ci-build.sh

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ start_test "Start with minimal settings" "${STD_CMD} \
122122
-e \"PROXY_SERVICE_PORT=443\""
123123

124124
echo "Test it's up and working..."
125-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/
125+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}/
126126
echo "Test limited protcol and SSL cipher... "
127-
docker run --link ${INSTANCE}:${INSTANCE}--rm --entrypoint bash ngx -c "echo GET / | /usr/bin/openssl s_client -cipher 'AES256+EECDH' -tls1_2 -connect ${INSTANCE}:10443" &> /dev/null;
127+
docker run --link ${INSTANCE}:${INSTANCE} --rm --entrypoint bash ngx -c "echo GET / | /usr/bin/openssl s_client -cipher 'AES256+EECDH' -tls1_2 -connect ${INSTANCE}:10443" &> /dev/null;
128128
echo "Test sslv2 not accepted...."
129-
if docker run --link ${INSTANCE}:${INSTANCE}--rm --entrypoint bash ngx -c "echo GET / | /usr/bin/openssl s_client -ssl2 -connect ${INSTANCE}:10443" &> /dev/null; then
129+
if docker run --link ${INSTANCE}:${INSTANCE} --rm --entrypoint bash ngx -c "echo GET / | /usr/bin/openssl s_client -ssl2 -connect ${INSTANCE}:10443" &> /dev/null; then
130130
echo "FAIL SSL defaults settings allow ssl2 ......"
131131
exit 2
132132
fi
@@ -151,7 +151,7 @@ start_test "Test GEODB settings can reject..." "${STD_CMD} \
151151
-e \"ADD_NGINX_LOCATION_CFG=error_page 403 /nginx-proxy/50x.shtml;\" \
152152
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
153153
echo "Test GeoIP config IS rejected..."
154-
if ! curl -v -k -H "X-Forwarded-For: 1.1.1.1" https://${DOCKER_HOST_NAME}:${PORT}/ 2>&1 \/ | grep '403 Forbidden' ; then
154+
if ! curl -v -k -H "X-Forwarded-For: 8.8.8.8" https://${DOCKER_HOST_NAME}:${PORT}/ 2>&1 \/ | grep '403 Forbidden' ; then
155155
echo "We were expecting to be rejected with 403 error here - we are not in the Congo!"
156156
exit 2
157157
else
@@ -224,8 +224,7 @@ start_test "Start we auto add a protocol " "${STD_CMD} \
224224
-e \"PROXY_SERVICE_PORT=80\""
225225

226226
echo "Test it works if we do not define the protocol.."
227-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/
228-
227+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}/
229228

230229
start_test "Start with multi locations settings" "${STD_CMD} \
231230
-e \"LOCATIONS_CSV=/,/wiki/Wikipedia:About\" \
@@ -236,9 +235,9 @@ start_test "Start with multi locations settings" "${STD_CMD} \
236235

237236

238237
echo "Test for location 1 @ /..."
239-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/
238+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}/
240239
echo "Test for wikipedia about page..."
241-
wget -O /dev/null --quiet --no-check-certificate --header="Host: en.wikipedia.org" https://${DOCKER_HOST_NAME}:${PORT}/wiki/Wikipedia:About
240+
curl -sk -o /dev/null -H "Host: en.wikipedia.org" https://${DOCKER_HOST_NAME}:${PORT}/wiki/Wikipedia:About
242241

243242
start_test "Start with Multiple locations, single proxy and NAXSI download." "${STD_CMD} \
244243
-e \"PROXY_SERVICE_HOST=https://en.wikipedia.org\" \
@@ -248,7 +247,7 @@ start_test "Start with Multiple locations, single proxy and NAXSI download." "${
248247
-e \"NAXSI_RULES_MD5_CSV_1=3b3c24ed61683ab33d8441857c315432\""
249248

250249
echo "Test for all OK..."
251-
wget -O /dev/null --quiet --no-check-certificate --header="Host: en.wikipedia.org" https://${DOCKER_HOST_NAME}:${PORT}/
250+
curl -sk -o /dev/null -H "Host: en.wikipedia.org" https://${DOCKER_HOST_NAME}:${PORT}/
252251

253252
echo "Test client certs..."
254253
cd ./client_certs/
@@ -265,19 +264,20 @@ start_test "Start with Client CA, and single proxy. Block unauth for /standards"
265264
-e \"CLIENT_CERT_REQUIRED_2=TRUE\" "
266265

267266
echo "Test access OK for basic area..."
268-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/
267+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}/
269268

270269
echo "Test access denied for /standards/..."
271-
if wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/standards/ ; then
270+
if curl -sk -o /dev/null --fail https://${DOCKER_HOST_NAME}:${PORT}/standards/ ; then
272271
echo "Error - expecting auth fail!"
273272
exit 1
274273
else
275274
echo "Passed auth fail"
276275
fi
277276
echo "Test access OK for /standards/... with client cert..."
278-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/standards/ \
279-
--certificate=./client_certs/client.crt \
280-
--private-key=./client_certs/client.key
277+
curl -sk -o /dev/null \
278+
--cert ./client_certs/client.crt \
279+
--key ./client_certs/client.key \
280+
https://${DOCKER_HOST_NAME}:${PORT}/standards/
281281

282282
echo "Test upstream client certs..."
283283
docker build -t mutual-tls:latest ${WORKDIR} -f docker-config/Dockerfile.mutual-tls
@@ -301,7 +301,7 @@ start_test "Start with upstream client certs" \
301301
--link \"${MUTUAL_TLS}:${MUTUAL_TLS}\" "
302302

303303
echo "Test it's up and working..."
304-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/
304+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}/
305305
tear_down_container "${MUTUAL_TLS}"
306306

307307
echo "Test failure to verify upstream server cert..."
@@ -365,8 +365,8 @@ start_test "Start with Custom error pages redirect off" "${STD_CMD} \
365365
-e \"ENABLE_UUID_PARAM=FALSE\" \
366366
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
367367
echo "Test All ok..."
368-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/
369-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/api/
368+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}/
369+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}/api/
370370
if curl -v -k https://${DOCKER_HOST_NAME}:${PORT}/api/dead | grep "Oh dear" ; then
371371
echo "Passed return text on error with ERROR_REDIRECT_CODES"
372372
else
@@ -431,7 +431,7 @@ start_test "Start with listen for port 80" "${STD_CMD} \
431431
-e \"HTTPS_REDIRECT_PORT=${PORT}\" \
432432
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
433433
echo "Test Redirect ok..."
434-
wget -O /dev/null --quiet --no-check-certificate http://${DOCKER_HOST_NAME}:8888/
434+
curl -s -o /dev/null http://${DOCKER_HOST_NAME}:8888/
435435

436436

437437
start_test "Test text logging format..." "${STD_CMD} \
@@ -442,7 +442,7 @@ start_test "Test text logging format..." "${STD_CMD} \
442442
-e \"ENABLE_UUID_PARAM=FALSE\" \
443443
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
444444
echo "Test request (with logging as text)..."
445-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/
445+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}/
446446
echo "Testing text logs format..."
447447
docker logs ${INSTANCE} | grep "\"GET / HTTP/1.1\" 200"
448448

@@ -453,7 +453,7 @@ start_test "Test json logging format..." "${STD_CMD} \
453453
-e \"LOG_FORMAT_NAME=json\" \
454454
-e \"ENABLE_UUID_PARAM=FALSE\" \
455455
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
456-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}?animal=cow
456+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}?animal=cow
457457
echo "Testing json logs format..."
458458
docker logs ${INSTANCE} | grep '{"proxy_proto_address":'
459459
docker logs ${INSTANCE} | grep 'animal=cow'
@@ -467,7 +467,7 @@ start_test "Test param logging off option works..." "${STD_CMD} \
467467
-e \"ENABLE_UUID_PARAM=FALSE\" \
468468
-e \"NO_LOGGING_URL_PARAMS=TRUE\" \
469469
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
470-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}?animal=cow
470+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}?animal=cow
471471
echo "Testing no logging of url params option works..."
472472
docker logs ${INSTANCE} 2>/dev/null | grep '{"proxy_proto_address":'
473473
docker logs ${INSTANCE} 2>/dev/null | grep 'animal=cow' | wc -l | grep 0
@@ -479,7 +479,7 @@ start_test "Test ENABLE_WEB_SOCKETS..." "${STD_CMD} \
479479
-e \"ENABLE_WEB_SOCKETS=TRUE\" \
480480
-e \"ENABLE_UUID_PARAM=FALSE\" \
481481
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
482-
wget -O /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/
482+
curl -sk -o /dev/null https://${DOCKER_HOST_NAME}:${PORT}/
483483

484484
start_test "Test ADD_NGINX_LOCATION_CFG param..." "${STD_CMD} \
485485
-e \"PROXY_SERVICE_HOST=http://${MOCKSERVER}\" \
@@ -490,7 +490,7 @@ start_test "Test ADD_NGINX_LOCATION_CFG param..." "${STD_CMD} \
490490
-e \"ENABLE_UUID_PARAM=FALSE\" \
491491
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
492492
echo "Test extra param works"
493-
wget -O - -o /dev/null --quiet --no-check-certificate https://${DOCKER_HOST_NAME}:${PORT}/wow | grep "NICE"
493+
curl -sk https://${DOCKER_HOST_NAME}:${PORT}/wow | grep "NICE"
494494

495495

496496
start_test "Test UUID GET param logging option works..." "${STD_CMD} \
@@ -523,7 +523,7 @@ start_test "Test UUID header logging option works..." "${STD_CMD} \
523523
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
524524
curl -sk https://${DOCKER_HOST_NAME}:${PORT}
525525
echo "Testing no logging of url params option works..."
526-
docker logs "${MOCKSERVER}" | grep 'Nginxid:'
526+
docker logs "${MOCKSERVER}" | grep 'nginxid->'
527527
docker logs ${INSTANCE} | grep '"nginx_uuid": "'
528528

529529
start_test "Test UUID header logging option passes through supplied value..." "${STD_CMD} \
@@ -534,7 +534,7 @@ start_test "Test UUID header logging option passes through supplied value..." "$
534534
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
535535
curl -sk -H "nginxId: 00000000-1111-2222-3333-444455556666" https://${DOCKER_HOST_NAME}:${PORT}
536536
echo "Testing no logging of url params option works..."
537-
docker logs "${MOCKSERVER}" | grep 'Nginxid:00000000-1111-2222-3333-444455556666'
537+
docker logs "${MOCKSERVER}" | grep 'nginxid->00000000-1111-2222-3333-444455556666'
538538
docker logs ${INSTANCE} | grep '"nginx_uuid": "00000000-1111-2222-3333-444455556666"'
539539

540540
start_test "Test VERBOSE_ERROR_PAGES=TRUE displays debug info" "${STD_CMD} \
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
FROM quii/mockingjay-server:1.9.0
1+
FROM quii/mockingjay-server:1.12.0
22

33
COPY test-servers.yaml /test-servers.yaml
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM quii/mockingjay-server:1.9.0
1+
FROM quii/mockingjay-server:1.12.0
22

33
COPY test-servers.yaml /test-servers.yaml
44
COPY monkey-business.yaml /monkey-business.yaml

lua/set_uuid.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ if os.getenv("LOG_UUID") == "FALSE" then
33
else
44
local uuid_str = ""
55
if ngx.req.get_headers()["nginxId"] == nil then
6-
local socket = require("socket")
76
local uuid = require("uuid")
8-
uuid.randomseed(socket.gettime()*10000)
7+
local unpack = unpack or table.unpack
8+
9+
uuid.set_rng(function()
10+
local random_bytes = require("resty.openssl.rand").bytes(16)
11+
return random_bytes
12+
end)
13+
914
uuid_str = uuid()
1015
else
11-
uuid_str = ngx.req.get_headers()["nginxId"]
16+
uuid_str = ngx.req.get_headers()["nginxId"]
1217
end
1318
ngx.var.uuid = uuid_str
1419
ngx.var.uuid_log_opt = " nginxId=" .. uuid_str

publish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ tag_n_push() {
4747
tag_n_push "${PATCH}"
4848
tag_n_push "${MINOR}"
4949
tag_n_push "${MAJOR}"
50-
tag_n_push "latest"
50+
#tag_n_push "latest"

whitelist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)