Skip to content

Update dependencies + hardening CI/CD #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 68 commits into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
310b270
chore(deps): update timoa/nodejs-encryption-api-example digest to f73…
renovate-bot May 14, 2022
4a4678d
chore(deps): update dependency mocha to v10
renovate-bot May 14, 2022
2d36281
Merge pull request #94 from timoa/fix/deps/mocha-10.x
timoa May 16, 2022
013fc04
fix(deps): update dependency @snyk/protect to v1.915.0
renovate-bot May 16, 2022
ce5ba65
chore(deps): update github/codeql-action action to v2.1.11
renovate-bot May 17, 2022
556d9db
fix(deps): update dependency @snyk/protect to v1.917.0
renovate-bot May 18, 2022
653ad31
fix(deps): update dependency @snyk/protect to v1.918.0
renovate-bot May 19, 2022
429764a
fix(deps): update dependency @snyk/protect to v1.919.0
renovate-bot May 20, 2022
b98e794
fix(deps): update dependency @snyk/protect to v1.921.0
renovate-bot May 20, 2022
285934f
chore(deps): update docker/build-push-action action to v3
renovate-bot May 20, 2022
c65f6a0
chore(deps): update docker/login-action action to v2
renovate-bot May 20, 2022
fd9841d
Merge pull request #95 from timoa/fix/deps/docker-build-push-action-3.x
timoa May 21, 2022
70b37ec
Merge pull request #96 from timoa/fix/deps/docker-login-action-2.x
timoa May 21, 2022
5f2909a
chore(deps): update docker/metadata-action action to v4
renovate-bot May 21, 2022
b27b3bd
Merge pull request #97 from timoa/fix/deps/docker-metadata-action-4.x
timoa May 21, 2022
87c1cbd
chore(deps): update docker/setup-buildx-action action to v2
renovate-bot May 21, 2022
3682b94
chore(deps): update docker/setup-qemu-action action to v2
renovate-bot May 21, 2022
6aa308b
Merge pull request #98 from timoa/fix/deps/docker-setup-buildx-action…
timoa May 21, 2022
ff39af1
Merge pull request #99 from timoa/fix/deps/docker-setup-qemu-action-2.x
timoa May 21, 2022
10d64fc
fix(deps): update dependency @snyk/protect to v1.922.0
renovate-bot May 21, 2022
aac0108
chore(deps): update dependency espree to v9.3.2
renovate-bot May 21, 2022
14bba27
chore(deps): update dependency eslint to v8.15.0
renovate-bot May 21, 2022
ff098c2
chore(deps): update mongo digest to 50d8918
renovate-bot May 24, 2022
343b91a
fix(deps): update dependency @snyk/protect to v1.924.0
renovate-bot May 24, 2022
537ef49
chore(cicd): add the Harden Runner GitHub Action (audit)
timoa May 25, 2022
b7cdb3c
chore(deps): update step-security/harden-runner digest to dd5681a
renovate-bot May 25, 2022
43a35c3
fix(deps): update dependency @snyk/protect to v1.925.0
renovate-bot May 25, 2022
3a397cd
fix(deps): update dependency @fastify/helmet to v8.0.1
renovate-bot May 25, 2022
6c7c9af
fix(deps): update dependency @snyk/protect to v1.927.0
renovate-bot May 26, 2022
eed31d8
fix(deps): update dependency @snyk/protect to v1.928.0
renovate-bot May 27, 2022
4776543
fix(deps): update dependency @snyk/protect to v1.929.0
renovate-bot May 28, 2022
8a7e37d
fix(deps): update dependency @snyk/protect to v1.931.0
renovate-bot May 28, 2022
38771ad
chore(deps): update actions/setup-node action to v3.2.0
renovate-bot May 31, 2022
099574c
chore(deps): update github/codeql-action action to v2.1.12
renovate-bot Jun 1, 2022
4706f3c
chore(deps): update mongo digest to d8f4897
renovate-bot Jun 2, 2022
58297fc
chore(deps): update dependency eslint-plugin-react to v7.30.0
renovate-bot Jun 2, 2022
7879982
fix(deps): update dependency @snyk/protect to v1.932.0
renovate-bot Jun 3, 2022
3c4b86d
fix(deps): update dependency @snyk/protect to v1.933.0
renovate-bot Jun 3, 2022
a4e81d0
fix(deps): update dependency @snyk/protect to v1.934.0
renovate-bot Jun 3, 2022
1de671a
fix(deps): update dependency @snyk/protect to v1.935.0
renovate-bot Jun 4, 2022
c7f4e21
chore(deps): update actions/upload-artifact action to v3.1.0
renovate-bot Jun 4, 2022
a526e6d
chore(deps): update dependency eslint to v8.16.0
renovate-bot Jun 4, 2022
7ddf599
chore(cicd): update Harden GitHub Actions config after 1st audit
timoa Jun 5, 2022
c7ecce0
chore(cicd): fix domain blocked
timoa Jun 5, 2022
bd87e54
chore(deps): update mongo digest to 94cd915
renovate-bot Jun 7, 2022
20e0d9d
chore(deps): update node.js to v16.15.1
renovate-bot Jun 7, 2022
89b8206
chore(deps): update mongo digest to fdd0492
renovate-bot Jun 7, 2022
074bcb7
fix(deps): update dependency @fastify/helmet to v8.1.0
renovate-bot Jun 7, 2022
4eb66c1
fix(deps): update dependency @snyk/protect to v1.936.0
renovate-bot Jun 7, 2022
caeeec9
fix(deps): update dependency @snyk/protect to v1.939.0
renovate-bot Jun 9, 2022
9eb9994
fix(deps): update dependency @snyk/protect to v1.940.0
renovate-bot Jun 10, 2022
12d8398
chore(deps): update step-security/harden-runner digest to cdea734
renovate-bot Jun 12, 2022
c12657b
chore(deps): update mongo digest to 3745209
renovate-bot Jun 14, 2022
4f756e2
fix(deps): update dependency @snyk/protect to v1.942.0
renovate-bot Jun 14, 2022
fa99afd
fix(deps): update dependency @snyk/protect to v1.945.0
renovate-bot Jun 15, 2022
bec4b03
chore(deps): update mongo digest to 37e84d3
renovate-bot Jun 16, 2022
eed221f
chore(deps): update actions/setup-node action to v3.3.0
renovate[bot] Jun 17, 2022
4374b6a
fix(deps): update dependency @snyk/protect to v1.946.0
renovate[bot] Jun 17, 2022
0db1ccb
chore(deps): update dependency eslint to v8.17.0
renovate[bot] Jun 19, 2022
6f4c6e8
chore(cicd): add OWASP ZAP full scan
timoa Jun 19, 2022
d1613bb
fix(cicd): add wait for the app to start
timoa Jun 19, 2022
345aa34
fix(cicd): run the app in the background
timoa Jun 19, 2022
656eae4
chore(cicd): save the ZAP reports
timoa Jun 19, 2022
abda46c
chore(deps): update the Fastify Swagger dependency
timoa Jun 19, 2022
626aeaa
fix(swagger): fix package name for Fastify Swagger
timoa Jun 19, 2022
49be62f
fix(cicd): add different names for the SAST and ZAP reports
timoa Jun 19, 2022
8152e3d
fix(cicd): unblocked domains from Harden GitHub Actions
timoa Jun 19, 2022
2da9582
chore(cicd): update Harden Github Actions policy + remove unused ZAP …
timoa Jun 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
objects.githubusercontent.com:443
raw.githubusercontent.com:443
registry.npmjs.org:443
snyk.io:443

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

Expand All @@ -24,6 +36,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
objects.githubusercontent.com:443
raw.githubusercontent.com:443

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

Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,28 @@ jobs:
contents: read

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@2f58583a1b24a7d3c7034f6bf9fa506d23b1183b # tag=v2.1.10
uses: github/codeql-action/init@27ea8f8fe5977c00f5b37e076ab846c5bd783b96 # tag=v2.1.12
# 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@2f58583a1b24a7d3c7034f6bf9fa506d23b1183b # tag=v2.1.10
uses: github/codeql-action/autobuild@27ea8f8fe5977c00f5b37e076ab846c5bd783b96 # tag=v2.1.12

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@2f58583a1b24a7d3c7034f6bf9fa506d23b1183b # tag=v2.1.10
uses: github/codeql-action/analyze@27ea8f8fe5977c00f5b37e076ab846c5bd783b96 # tag=v2.1.12
157 changes: 121 additions & 36 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,26 @@ jobs:
mongodb: ['5.0']

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
auth.docker.io:443
github.com:443
objects.githubusercontent.com:443
pipelines.actions.githubusercontent.com:443
production.cloudflare.docker.com:443
registry-1.docker.io:443
registry.npmjs.org:443
snyk.io:443

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

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

- name: Save Code Coverage
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # tag=v3.0.0
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3.1.0
with:
name: code-coverage
path: coverage
Expand All @@ -49,6 +64,16 @@ jobs:
needs: tests

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
pipelines.actions.githubusercontent.com:443
sonarcloud.io:443

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

Expand All @@ -67,32 +92,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

# functional-tests:
# runs-on: ubuntu-latest
# needs: tests

# steps:
# - name: Checkout
# uses: actions/checkout@v2

# - name: Build docker image
# run: docker build -t timoa/nodejs-encryption-api-example .

# - name: Start Docker container
# run: docker-compose up -d

# - name: Check Docker container status
# run: docker ps -a

# - name: Install dependencies
# run: npm install

# - name: Run Functional tests
# run: npm run test:functional

# - name: Stop Docker container
# run: docker-compose down

# -- SAST SCAN --------------------------------------------------------------
code-security:
name: Code Security
Expand All @@ -102,32 +101,113 @@ jobs:
if: (github.actor != 'dependabot[bot]')

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
with:
egress-policy: block
allowed-endpoints: >
github.com:443
api.github.com:443
pipelines.actions.githubusercontent.com:443
registry.npmjs.org:443
pypi.org:443


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

- name: Perform Scan
uses: ShiftLeftSecurity/scan-action@master

env:
WORKSPACE: https://github.com/${{ github.repository }}/blob/${{ github.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCAN_ANNOTATE_PR: true

- uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # tag=v3.0.0
- name: Save the SCAN reports
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3.1.0
with:
name: reports
name: sast-reports
path: reports

# -- ZAP Scan ---------------------------------------------------------------
api-security:
name: API Security
runs-on: ubuntu-latest
needs: tests
# Skip any PR created by dependabot to avoid permission issues
if: (github.actor != 'dependabot[bot]')

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

steps:
- name: Harden GitHub Actions Runner
uses: step-security/harden-runner@dd5681a7d0c66fb362664d618ef4a90d656f6516
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
auth.docker.io:443
bit.ly:443
content-signature-2.cdn.mozilla.net:443
firefox.settings.services.mozilla.com:443
github.com:443
news.zaproxy.org:443
objects.githubusercontent.com:443
pipelines.actions.githubusercontent.com:443
production.cloudflare.docker.com:443
raw.githubusercontent.com:443
registry-1.docker.io:443
registry.npmjs.org:443
shavar.services.mozilla.com:443
snyk.io:443
tel.zaproxy.org:443
tracking-protection.cdn.mozilla.net:443

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

- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # tag=v3.2.0
with:
node-version: ${{ matrix.node }}
check-latest: true

- name: Install dependencies
run: npm install

- name: Start MongoDB
uses: supercharge/mongodb-github-action@e815fd8a9dfede09fd6e6c144f2c9f4875e933df # tag=1.7.0
with:
mongodb-version: ${{ matrix.mongodb }}
mongodb-db: encryptionAPI

- name: Start the app
run: npm start > /dev/null &

- name: Run ZAP Scan
uses: zaproxy/action-full-scan@v0.4.0
with:
target: http://localhost:3000

# -- PRE-RELEASE ------------------------------------------------------------
pre-release:
name: Prepare Release
runs-on: ubuntu-latest
needs:
- code-quality
- code-security
- api-security
if: github.ref == 'refs/heads/master'

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

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

Expand All @@ -144,12 +224,17 @@ jobs:
if: github.ref == 'refs/heads/master'

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

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

- name: Docker meta
id: meta
uses: docker/metadata-action@b2391d37b4157fa4aa2e118d643f417910ff3242 # tag=v3.8.0
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a # tag=v4.0.1
with:
images: ${{ github.repository }}
tags: |
Expand All @@ -163,19 +248,19 @@ jobs:
type=raw,value=latest

- name: Set up QEMU
uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # tag=v1.2.0
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # tag=v2.0.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f211e3e9ded2d9377c8cadc4489a4e38014bc4c9 # tag=v1.7.0
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # tag=v2.0.0

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

- name: Build and push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a # tag=v2.10.0
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 # tag=v3.0.0
with:
context: .
push: true
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.15.0-alpine3.15@sha256:1a9a71ea86aad332aa7740316d4111ee1bd4e890df47d3b5eff3e5bded3b3d10
FROM node:16.15.1-alpine3.15@sha256:1fafca8cf41faf035192f5df1a5387656898bec6ac2f92f011d051ac2344f5c9
ARG appPort=3000
# ARG microScannerToken

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:509d3424b92adb94f06ceedaa8044aaffed0e99015ae4b8dcb95be0a82c0a7b2
image: timoa/nodejs-encryption-api-example:latest@sha256:f73079c8045d361899b8c372566616cba1249e61edcc6288549a2f3729dd3de6
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:82a55eb6d60997007ff390087d4e064218d477e9611a7becd78664a2ab490eff
image: mongo@sha256:37e84d3dd30cdfb5472ec42b8a6b4dc6ca7cacd91ebcfa0410a54528bbc5fa6d
volumes:
- ./data:/data/db
ports:
Expand Down
Loading