@@ -15,11 +15,26 @@ jobs:
1515 mongodb : ['5.0']
1616
1717 steps :
18+ - name : Harden GitHub Actions Runner
19+ uses : step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
20+ with :
21+ egress-policy : block
22+ allowed-endpoints : >
23+ api.github.com:443
24+ auth.docker.io:443
25+ github.com:443
26+ objects.githubusercontent.com:443
27+ pipelines.actions.githubusercontent.com:443
28+ production.cloudflare.docker.com:443
29+ registry-1.docker.io:443
30+ registry.npmjs.org:443
31+ snyk.io:443
32+
1833 - name : Checkout
1934 uses : actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
2035
2136 - name : Setup Node.js ${{ matrix.node }}
22- uses : actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # tag=v3.1.1
37+ uses : actions/setup-node@eeb10cff27034e7acf239c5d29f62154018672fd # tag=v3.3.0
2338 with :
2439 node-version : ${{ matrix.node }}
2540 check-latest : true
3752 run : npm run test:coverage
3853
3954 - name : Save Code Coverage
40- uses : actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # tag=v3.0 .0
55+ uses : actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3.1 .0
4156 with :
4257 name : code-coverage
4358 path : coverage
4964 needs : tests
5065
5166 steps :
67+ - name : Harden GitHub Actions Runner
68+ uses : step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
69+ with :
70+ egress-policy : block
71+ allowed-endpoints : >
72+ api.github.com:443
73+ github.com:443
74+ pipelines.actions.githubusercontent.com:443
75+ sonarcloud.io:443
76+
5277 - name : Checkout
5378 uses : actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
5479
6792 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6893 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
6994
70- # functional-tests:
71- # runs-on: ubuntu-latest
72- # needs: tests
73-
74- # steps:
75- # - name: Checkout
76- # uses: actions/checkout@v2
77-
78- # - name: Build docker image
79- # run: docker build -t timoa/nodejs-encryption-api-example .
80-
81- # - name: Start Docker container
82- # run: docker-compose up -d
83-
84- # - name: Check Docker container status
85- # run: docker ps -a
86-
87- # - name: Install dependencies
88- # run: npm install
89-
90- # - name: Run Functional tests
91- # run: npm run test:functional
92-
93- # - name: Stop Docker container
94- # run: docker-compose down
95-
9695 # -- SAST SCAN --------------------------------------------------------------
9796 code-security :
9897 name : Code Security
@@ -102,32 +101,113 @@ jobs:
102101 if : (github.actor != 'dependabot[bot]')
103102
104103 steps :
104+ - name : Harden GitHub Actions Runner
105+ uses : step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
106+ with :
107+ egress-policy : block
108+ allowed-endpoints : >
109+ github.com:443
110+ api.github.com:443
111+ pipelines.actions.githubusercontent.com:443
112+ registry.npmjs.org:443
113+ pypi.org:443
114+
115+
105116 - name : Checkout
106117 uses : actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
107118
108119 - name : Perform Scan
109120 uses : ShiftLeftSecurity/scan-action@master
110-
111121 env :
112122 WORKSPACE : https://github.com/${{ github.repository }}/blob/${{ github.sha }}
113123 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
114124 SCAN_ANNOTATE_PR : true
115125
116- - uses : actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # tag=v3.0.0
126+ - name : Save the SCAN reports
127+ uses : actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3.1.0
117128 with :
118- name : reports
129+ name : sast- reports
119130 path : reports
120131
132+ # -- ZAP Scan ---------------------------------------------------------------
133+ api-security :
134+ name : API Security
135+ runs-on : ubuntu-latest
136+ needs : tests
137+ # Skip any PR created by dependabot to avoid permission issues
138+ if : (github.actor != 'dependabot[bot]')
139+
140+ strategy :
141+ matrix :
142+ node : ['16']
143+ mongodb : ['5.0']
144+
145+ steps :
146+ - name : Harden GitHub Actions Runner
147+ uses : step-security/harden-runner@dd5681a7d0c66fb362664d618ef4a90d656f6516
148+ with :
149+ egress-policy : block
150+ allowed-endpoints : >
151+ api.github.com:443
152+ auth.docker.io:443
153+ bit.ly:443
154+ content-signature-2.cdn.mozilla.net:443
155+ firefox.settings.services.mozilla.com:443
156+ github.com:443
157+ news.zaproxy.org:443
158+ objects.githubusercontent.com:443
159+ pipelines.actions.githubusercontent.com:443
160+ production.cloudflare.docker.com:443
161+ raw.githubusercontent.com:443
162+ registry-1.docker.io:443
163+ registry.npmjs.org:443
164+ shavar.services.mozilla.com:443
165+ snyk.io:443
166+ tel.zaproxy.org:443
167+ tracking-protection.cdn.mozilla.net:443
168+
169+ - name : Checkout
170+ uses : actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
171+
172+ - name : Setup Node.js ${{ matrix.node }}
173+ uses : actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048 # tag=v3.2.0
174+ with :
175+ node-version : ${{ matrix.node }}
176+ check-latest : true
177+
178+ - name : Install dependencies
179+ run : npm install
180+
181+ - name : Start MongoDB
182+ uses : supercharge/mongodb-github-action@e815fd8a9dfede09fd6e6c144f2c9f4875e933df # tag=1.7.0
183+ with :
184+ mongodb-version : ${{ matrix.mongodb }}
185+ mongodb-db : encryptionAPI
186+
187+ - name : Start the app
188+ run : npm start > /dev/null &
189+
190+ - name : Run ZAP Scan
191+ 192+ with :
193+ target : http://localhost:3000
194+
121195 # -- PRE-RELEASE ------------------------------------------------------------
122196 pre-release :
123197 name : Prepare Release
124198 runs-on : ubuntu-latest
125199 needs :
126200 - code-quality
127201 - code-security
202+ - api-security
128203 if : github.ref == 'refs/heads/master'
129204
130205 steps :
206+ - name : Harden GitHub Actions Runner
207+ uses : step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
208+ with :
209+ egress-policy : audit
210+
131211 - name : Checkout
132212 uses : actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
133213
@@ -144,12 +224,17 @@ jobs:
144224 if : github.ref == 'refs/heads/master'
145225
146226 steps :
227+ - name : Harden GitHub Actions Runner
228+ uses : step-security/harden-runner@cdea734fa57747b9831aa9d6fcb274c5f9669557
229+ with :
230+ egress-policy : audit
231+
147232 - name : Checkout
148233 uses : actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
149234
150235 - name : Docker meta
151236 id : meta
152- uses : docker/metadata-action@b2391d37b4157fa4aa2e118d643f417910ff3242 # tag=v3.8.0
237+ uses : docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a # tag=v4.0.1
153238 with :
154239 images : ${{ github.repository }}
155240 tags : |
@@ -163,19 +248,19 @@ jobs:
163248 type=raw,value=latest
164249
165250 - name : Set up QEMU
166- uses : docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # tag=v1.2 .0
251+ uses : docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8 # tag=v2.0 .0
167252
168253 - name : Set up Docker Buildx
169- uses : docker/setup-buildx-action@f211e3e9ded2d9377c8cadc4489a4e38014bc4c9 # tag=v1.7 .0
254+ uses : docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # tag=v2.0 .0
170255
171256 - name : Login to DockerHub
172- uses : docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7 # tag=v1.14.1
257+ uses : docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # tag=v2.0.0
173258 with :
174259 username : ${{ secrets.DOCKER_USERNAME }}
175260 password : ${{ secrets.DOCKER_PASSWORD }}
176261
177262 - name : Build and push
178- uses : docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a # tag=v2.10 .0
263+ uses : docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 # tag=v3.0 .0
179264 with :
180265 context : .
181266 push : true
0 commit comments