Skip to content

Commit 0eb2b6d

Browse files
🔒 security: fix Docker Scout vulnerabilities by updating Node.js, Bun, and picomatch (#67)
* 🔒 security: update Node.js to 22.22-alpine3.23 and Bun to 1.3.13 Agent-Logs-Url: https://github.com/wgtechlabs/unthread-webhook-server/sessions/b22da671-f0fe-4da2-856d-4bb5aca647cf Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com> * 🔧 update (Dockerfile): fix Alpine version comment and introduce BUN_VERSION ARG Agent-Logs-Url: https://github.com/wgtechlabs/unthread-webhook-server/sessions/13d815f3-892d-48e1-84f2-29177dd94303 Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com> * 🔒 security (Dockerfile): strip devDependencies from final image package.json to fix picomatch Docker Scout alert Agent-Logs-Url: https://github.com/wgtechlabs/unthread-webhook-server/sessions/913ef26f-a27f-4de6-94aa-bf6e4880fbcd Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
1 parent 662938d commit 0eb2b6d

5 files changed

Lines changed: 23 additions & 13 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup Bun
1919
uses: oven-sh/setup-bun@v2
2020
with:
21-
bun-version: 1.3.11
21+
bun-version: 1.3.13
2222

2323
- name: Setup Node.js
2424
uses: actions/setup-node@v6
@@ -71,7 +71,7 @@ jobs:
7171

7272
# Build Arguments
7373
build-args: |
74-
NODE_VERSION=22.21-alpine3.23
74+
NODE_VERSION=22.22-alpine3.23
7575
RAILWAY_SERVICE_ID=${{ secrets.RAILWAY_SERVICE_ID }}
7676
7777
# Labels

‎.github/workflows/container.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
# Build Arguments
4040
build-args: |
41-
NODE_VERSION=22.21-alpine3.23
41+
NODE_VERSION=22.22-alpine3.23
4242
RAILWAY_SERVICE_ID=${{ secrets.RAILWAY_SERVICE_ID }}
4343
4444
# Labels

‎.github/workflows/validate.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup Bun
1717
uses: oven-sh/setup-bun@v2
1818
with:
19-
bun-version: 1.3.11
19+
bun-version: 1.3.13
2020

2121
- name: Setup Node.js
2222
uses: actions/setup-node@v6

‎Dockerfile‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@
1818

1919
# syntax=docker/dockerfile:1
2020

21-
# Use Node.js 22.21 LTS Alpine with security patches
22-
ARG NODE_VERSION=22.21-alpine3.23
21+
# Use Node.js 22.22 LTS Alpine with security patches
22+
ARG NODE_VERSION=22.22-alpine3.23
23+
24+
# Bun version used in build stages (must match packageManager in package.json)
25+
ARG BUN_VERSION=1.3.13
2326

2427
# Get Railway service ID for cache mounts
2528
ARG RAILWAY_SERVICE_ID
2629

2730
# =============================================================================
2831
# STAGE 1: Base Image
2932
# =============================================================================
30-
# Alpine Linux 3.21 base for minimal image size with latest security updates
33+
# Alpine Linux 3.23 base for minimal image size with latest security updates
3134
FROM node:${NODE_VERSION} AS base
3235

3336
# Install security updates for Alpine packages
@@ -45,9 +48,11 @@ WORKDIR /usr/src/app
4548
# image, keeping the production image smaller and reducing attack surface.
4649
FROM base AS bun-base
4750

51+
# Re-declare ARG so the global value is accessible in this stage
52+
ARG BUN_VERSION
53+
4854
# Install Bun for dependency management
49-
# Note: Version must match packageManager field in package.json (currently 1.3.11)
50-
RUN npm install --global bun@1.3.11
55+
RUN npm install --global bun@${BUN_VERSION}
5156

5257
# =============================================================================
5358
# STAGE 2: Production Dependencies
@@ -78,6 +83,10 @@ RUN --mount=type=bind,source=package.json,target=package.json \
7883
COPY . .
7984
RUN bun run build
8085

86+
# Create a production-only package.json (strip devDependencies so Docker Scout
87+
# does not flag transitive dev-only packages like picomatch@^2.x from nodemon)
88+
RUN node -e "const p=require('./package.json');delete p.devDependencies;process.stdout.write(JSON.stringify(p,null,2));" > /tmp/package-prod.json
89+
8190
# =============================================================================
8291
# STAGE 4: Final Runtime Image
8392
# =============================================================================
@@ -92,8 +101,9 @@ ENV NODE_ENV=production \
92101
RUN addgroup -g 1001 -S nodejs && \
93102
adduser -S nodejs -u 1001 -G nodejs
94103

95-
# Copy package.json for package manager commands
96-
COPY --chown=nodejs:nodejs package.json .
104+
# Copy production-only package.json (no devDependencies) to avoid Docker Scout
105+
# false-positives from dev dep chains that reference picomatch@^2.x
106+
COPY --from=build --chown=nodejs:nodejs /tmp/package-prod.json ./package.json
97107

98108
# Copy production dependencies and built application
99109
COPY --from=deps --chown=nodejs:nodejs /usr/src/app/node_modules ./node_modules

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"main": "dist/app.js",
2222
"engines": {
2323
"node": ">=22.0.0",
24-
"bun": "1.3.11"
24+
"bun": "1.3.13"
2525
},
2626
"scripts": {
2727
"build": "tsc",
@@ -65,5 +65,5 @@
6565
"flatted": "3.4.2",
6666
"picomatch": "4.0.4"
6767
},
68-
"packageManager": "bun@1.3.11"
68+
"packageManager": "bun@1.3.13"
6969
}

0 commit comments

Comments
 (0)