Skip to content

Commit

Permalink
Merge pull request #154 from timoa/develop
Browse files Browse the repository at this point in the history
Update to Node v18.x + security updates
  • Loading branch information
timoa authored Feb 5, 2023
2 parents 3fc08ce + 63955b2 commit f283a37
Show file tree
Hide file tree
Showing 13 changed files with 2,175 additions and 1,553 deletions.
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"platformAutomerge": true,
"branchPrefix": "fix/deps/",
"addLabels": [
"deps",
"dependencies",
"security"
],
"assignees": [
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
uses: step-security/harden-runner@8f144f8401c4e3693085dff03603f617f566ec6b
with:
egress-policy: block
allowed-endpoints: >
Expand All @@ -23,7 +23,7 @@ jobs:
snyk.io:443
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Run ESLint
uses: reviewdog/action-eslint@d3395027ea2cfc5cf8f460b1ea939b6c86fea656 # tag=v1.17.0
Expand All @@ -37,7 +37,7 @@ jobs:

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
uses: step-security/harden-runner@8f144f8401c4e3693085dff03603f617f566ec6b
with:
egress-policy: block
allowed-endpoints: >
Expand All @@ -47,9 +47,9 @@ jobs:
raw.githubusercontent.com:443
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Run hadolint
uses: reviewdog/action-hadolint@55be5d2c4b0b80d439247b128a9ded3747f92a29 # tag=v1.33.0
uses: reviewdog/action-hadolint@141ffd8d2f0b75e6fc7c87341331985448b62aa4 # v1.34.1
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 6 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,28 @@ jobs:

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
uses: step-security/harden-runner@8f144f8401c4e3693085dff03603f617f566ec6b
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
objects.githubusercontent.com:443
- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@27ea8f8fe5977c00f5b37e076ab846c5bd783b96 # tag=v2.1.12
uses: github/codeql-action/init@a34ca99b4610d924e04c68db79e503e1f79f9f02 # v2.1.39
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@27ea8f8fe5977c00f5b37e076ab846c5bd783b96 # tag=v2.1.12
uses: github/codeql-action/autobuild@a34ca99b4610d924e04c68db79e503e1f79f9f02 # v2.1.39

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -66,4 +67,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@27ea8f8fe5977c00f5b37e076ab846c5bd783b96 # tag=v2.1.12
uses: github/codeql-action/analyze@a34ca99b4610d924e04c68db79e503e1f79f9f02 # v2.1.39
72 changes: 43 additions & 29 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:

strategy:
matrix:
node: ['16']
node: ['18']
mongodb: ['5.0']

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
uses: step-security/harden-runner@8f144f8401c4e3693085dff03603f617f566ec6b
with:
egress-policy: block
allowed-endpoints: >
Expand All @@ -29,12 +29,15 @@ jobs:
registry-1.docker.io:443
registry.npmjs.org:443
snyk.io:443
docker.io:443
auth.docker.io:443
production.cloudflare.docker.com:443
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # tag=v3.3.0
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ matrix.node }}
check-latest: true
Expand All @@ -52,7 +55,7 @@ jobs:
run: npm run test:coverage

- name: Save Code Coverage
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3.1.0
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: code-coverage
path: coverage
Expand All @@ -65,20 +68,21 @@ jobs:

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
uses: step-security/harden-runner@8f144f8401c4e3693085dff03603f617f566ec6b
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
pipelines.actions.githubusercontent.com:443
sonarcloud.io:443
scanner.sonarcloud.io:443
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Download Code Coverage
uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # tag=v3.0.0
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: code-coverage
path: coverage
Expand All @@ -102,19 +106,25 @@ jobs:

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
uses: step-security/harden-runner@8f144f8401c4e3693085dff03603f617f566ec6b
with:
egress-policy: block
allowed-endpoints: >
github.com:443
api.github.com:443
pipelines.actions.githubusercontent.com:443
registry.npmjs.org:443
registry-1.docker.io:443
osv-vulnerabilities.storage.googleapis.com:443
nvd.nist.gov:443
pypi.org:443
location.services.mozilla.com:443
docker.io:443
auth.docker.io:443
production.cloudflare.docker.com:443
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Perform Scan
uses: ShiftLeftSecurity/scan-action@master
Expand All @@ -124,7 +134,7 @@ jobs:
SCAN_ANNOTATE_PR: true

- name: Save the SCAN reports
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3.1.0
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: sast-reports
path: reports
Expand All @@ -139,21 +149,24 @@ jobs:

strategy:
matrix:
node: ['16']
node: ['18']
mongodb: ['5.0']

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@dd5681a7d0c66fb362664d618ef4a90d656f6516
uses: step-security/harden-runner@8f144f8401c4e3693085dff03603f617f566ec6b
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
auth.docker.io:443
bit.ly:443
cfu.zaproxy.org:443
content-signature-2.cdn.mozilla.net:443
docker.io:443
firefox.settings.services.mozilla.com:443
github.com:443
location.services.mozilla.com:443
news.zaproxy.org:443
objects.githubusercontent.com:443
pipelines.actions.githubusercontent.com:443
Expand All @@ -167,10 +180,10 @@ jobs:
tracking-protection.cdn.mozilla.net:443
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # tag=v3.2.0
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ matrix.node }}
check-latest: true
Expand All @@ -187,10 +200,11 @@ jobs:
- name: Start the app
run: npm start > /dev/null &

- name: Run ZAP Scan
uses: zaproxy/action-full-scan@v0.4.0
- name: Run ZAP API Scan
uses: zaproxy/action-api-scan@6c29b04d78969bf586f2d4ea15c613d2dfb49d07 # tag=v0.2.0
with:
target: http://localhost:3000
target: http://localhost:3000/swagger/json
format: openapi

# -- PRE-RELEASE ------------------------------------------------------------
pre-release:
Expand All @@ -204,15 +218,15 @@ jobs:

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
uses: step-security/harden-runner@8f144f8401c4e3693085dff03603f617f566ec6b
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@8f6ceb9d5aae5578b1dcda6af00008235204e7fa # v3.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -225,16 +239,16 @@ jobs:

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
uses: step-security/harden-runner@8f144f8401c4e3693085dff03603f617f566ec6b
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0

- name: Docker meta
id: meta
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a # tag=v4.0.1
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
with:
images: ${{ github.repository }}
tags: |
Expand All @@ -248,19 +262,19 @@ jobs:
type=raw,value=latest
- name: Set up QEMU
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # tag=v2.0.0
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # tag=v2.1.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # tag=v2.0.0
uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325 # tag=v2.2.1

- name: Login to DockerHub
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # tag=v2.0.0
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # tag=v2.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 # tag=v3.0.0
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
with:
context: .
push: true
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
14 changes: 1 addition & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM node:16.15.1-alpine3.15@sha256:1fafca8cf41faf035192f5df1a5387656898bec6ac2f92f011d051ac2344f5c9
FROM node:18.14.0-alpine3.17@sha256:bc329c7332cffc30c2d4801e38df03cbfa8dcbae2a7a52a449db104794f168a3
ARG appPort=3000
# ARG microScannerToken

LABEL maintainer="Damien Laureaux <[email protected]>" \
org.label-schema.vendor="Timoa" \
Expand All @@ -20,17 +19,6 @@ RUN \
mkdir -p /opt/app && \
adduser -S app-user

# Aquasec MicroScanner support
# Search vulnerabilities under the source container
# Get an API token (free): https://microscanner.aquasec.com/signup
# Project: https://github.com/aquasecurity/microscanner

# ADD https://get.aquasec.com/microscanner /
# RUN chmod +x /microscanner && \
# /microscanner ${microScannerToken} && \
# echo "No vulnerabilities! " && \
# date

WORKDIR /opt/app/
COPY ./package.json ./
COPY ./src ./src
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.3'

services:
api:
image: timoa/nodejs-encryption-api-example:latest@sha256:f73079c8045d361899b8c372566616cba1249e61edcc6288549a2f3729dd3de6
image: timoa/nodejs-encryption-api-example:latest@sha256:33cac806d192b0c025adb464d0dae158785b13ade8826a34ca4d08a8f6a19b61
environment:
- NODE_ENV=production
- NODE_HOST=0.0.0.0
Expand All @@ -17,7 +17,7 @@ services:
- mongo
mongo:
container_name: mongo
image: mongo@sha256:37e84d3dd30cdfb5472ec42b8a6b4dc6ca7cacd91ebcfa0410a54528bbc5fa6d
image: mongo@sha256:134e3f2db743d46bdb7f3eb6bcfa4b8e3dde578c9ff8a10742ce29d706acf9b2
volumes:
- ./data:/data/db
ports:
Expand Down
Loading

0 comments on commit f283a37

Please sign in to comment.