Skip to content

Commit ec03d8e

Browse files
Merge pull request #7738 from BitGo/VL-3832-adding-sfw-support
build: add Socket Security (SFW) integration with configurable vulnerability scanning
2 parents 55aef4f + 7ff3bba commit ec03d8e

3 files changed

Lines changed: 44 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ permissions:
1414
contents: read
1515
pull-requests: read
1616

17+
env:
18+
SOCKET_SECURITY_MODE: monitor # Options: monitor (non-blocking) or block (fails on vulnerabilities)
19+
1720
jobs:
1821
unit-test:
1922
runs-on: ubuntu-latest
@@ -24,6 +27,10 @@ jobs:
2427
node-version: [20.x, 22.x, 24.x]
2528

2629
steps:
30+
- uses: socketdev/action@v1
31+
with:
32+
mode: firewall-free
33+
2734
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2835
with:
2936
ref: ${{ github.event.pull_request.head.sha }}
@@ -58,7 +65,7 @@ jobs:
5865

5966
- name: Install Packages
6067
if: steps.lerna-cache.outputs.cache-hit != 'true' || contains( github.event.pull_request.labels.*.name, 'SKIP_CACHE')
61-
run: yarn install --with-frozen-lockfile --ignore-scripts
68+
run: sfw yarn install --with-frozen-lockfile --ignore-scripts
6269

6370
- name: Check In-Repo Package Versions
6471
run: yarn run check-versions
@@ -90,6 +97,10 @@ jobs:
9097
check: ['lint', 'format', 'commit-lint', 'dependencies']
9198

9299
steps:
100+
- uses: socketdev/action@v1
101+
with:
102+
mode: firewall-free
103+
93104
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
94105
with:
95106
ref: ${{ github.event.pull_request.head.sha }}
@@ -110,7 +121,7 @@ jobs:
110121

111122
- name: Install Packages
112123
if: steps.lerna-cache.outputs.cache-hit != 'true' || contains( github.event.pull_request.labels.*.name, 'SKIP_CACHE')
113-
run: yarn install --with-frozen-lockfile --ignore-scripts
124+
run: sfw yarn install --with-frozen-lockfile --ignore-scripts
114125

115126
- name: Lint Source Code
116127
if: matrix.check == 'lint'
@@ -137,6 +148,10 @@ jobs:
137148
runs-on: ubuntu-latest
138149

139150
steps:
151+
- uses: socketdev/action@v1
152+
with:
153+
mode: firewall-free
154+
140155
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
141156

142157
- name: Setup node 22
@@ -155,7 +170,7 @@ jobs:
155170

156171
- name: Install Packages
157172
if: steps.lerna-cache.outputs.cache-hit != 'true'
158-
run: yarn install --with-frozen-lockfile --ignore-scripts
173+
run: sfw yarn install --with-frozen-lockfile --ignore-scripts
159174

160175
- name: build packages
161176
env:
@@ -174,6 +189,10 @@ jobs:
174189
runs-on: ubuntu-22.04
175190

176191
steps:
192+
- uses: socketdev/action@v1
193+
with:
194+
mode: firewall-free
195+
177196
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
178197
with:
179198
ref: ${{ github.event.pull_request.head.sha }}
@@ -248,7 +267,7 @@ jobs:
248267

249268
- name: Install Packages
250269
if: steps.lerna-cache.outputs.cache-hit != 'true' || contains( github.event.pull_request.labels.*.name, 'SKIP_CACHE')
251-
run: yarn install --with-frozen-lockfile
270+
run: sfw yarn install --with-frozen-lockfile
252271

253272
- name: build packages
254273
if: steps.lerna-cache.outputs.cache-hit == 'true'
@@ -294,6 +313,7 @@ jobs:
294313
VERSION=${{ steps.build-info.outputs.version }}
295314
BUILD_DATE=${{ steps.build-info.outputs.date }}
296315
GIT_HASH=${{ github.sha }}
316+
SOCKET_SECURITY_MODE=${{ env.SOCKET_SECURITY_MODE }}
297317
298318
- name: Test Express Docker image
299319
id: docker-test
@@ -337,6 +357,10 @@ jobs:
337357
runs-on: ubuntu-latest
338358

339359
steps:
360+
- uses: socketdev/action@v1
361+
with:
362+
mode: firewall-free
363+
340364
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
341365
with:
342366
ref: ${{ github.event.pull_request.head.sha }}
@@ -357,7 +381,7 @@ jobs:
357381

358382
- name: Install Packages
359383
if: steps.lerna-cache.outputs.cache-hit != 'true' || contains( github.event.pull_request.labels.*.name, 'SKIP_CACHE')
360-
run: yarn install --with-frozen-lockfile --ignore-scripts
384+
run: sfw yarn install --with-frozen-lockfile --ignore-scripts
361385

362386
- name: Check Dockerfile is up to date
363387
run: |

.github/workflows/publish.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ permissions:
1111
concurrency:
1212
group: ${{ github.workflow }}-${{ github.ref }}
1313

14+
env:
15+
SOCKET_SECURITY_MODE: monitor # Options: monitor (non-blocking) or block (fails on vulnerabilities)
16+
1417
jobs:
1518
publish:
1619
name: Publish Release
1720
runs-on: ubuntu-latest
1821

1922
steps:
23+
- uses: socketdev/action@v1
24+
with:
25+
mode: firewall-free
26+
2027
- name: Checkout repository
2128
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2229

@@ -26,7 +33,7 @@ jobs:
2633
node-version-file: .nvmrc
2734

2835
- name: Install BitGoJS
29-
run: yarn install --with-frozen-lockfile
36+
run: sfw yarn install --with-frozen-lockfile
3037

3138
- name: Audit Dependencies
3239
run: yarn run improved-yarn-audit --min-severity high
@@ -59,7 +66,7 @@ jobs:
5966
npx tsx ./scripts/prepare-release.ts ${{ env.preid }}
6067
6168
- name: Rebuild packages
62-
run: yarn
69+
run: sfw yarn
6370

6471
- name: Commit Local Changes
6572
run: git commit -am "Auto updated ${{ env.preid }} branch" --no-verify || echo "No changes to commit"

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,23 @@ COPY modules ./modules
1313
RUN find modules \! -name "package.json" -mindepth 2 -maxdepth 2 -print | xargs rm -rf
1414

1515
FROM node:22.22.0-bookworm-slim@sha256:f86be15afa9a8277608e141ce2a8aa55d3d9c40845921b8511f4fb7897be2554 AS builder
16+
ARG SOCKET_SECURITY_MODE=monitor
17+
ENV SOCKET_SECURITY_MODE=${SOCKET_SECURITY_MODE}
1618
RUN apt-get update && apt-get install -y git python3 make g++ libtool autoconf automake
19+
RUN npm i -g sfw
1720
WORKDIR /tmp/bitgo
1821
COPY --from=filter-packages-json /tmp/bitgo .
1922
# (skip postinstall) https://github.com/yarnpkg/yarn/issues/4100#issuecomment-388944260
20-
RUN NOYARNPOSTINSTALL=1 yarn install --pure-lockfile --network-timeout 120000
23+
RUN NOYARNPOSTINSTALL=1 sfw yarn install --pure-lockfile --network-timeout 120000
2124

2225
COPY . .
2326
RUN \
2427
# clean up unnecessary local node_modules and dist
2528
rm -rf modules/**/node_modules modules/**/dist && \
2629
# install with dev deps so we can run the prepare script
27-
yarn install --frozen-lockfile && \
30+
sfw yarn install --frozen-lockfile && \
2831
# install again to prune dev deps
29-
yarn install --production --frozen-lockfile --non-interactive --ignore-scripts && \
32+
sfw yarn install --production --frozen-lockfile --non-interactive --ignore-scripts && \
3033
# remove any src code leftover (we only want dist)
3134
rm -r modules/*/src
3235

0 commit comments

Comments
 (0)