Skip to content

Commit a4294ee

Browse files
committed
fix(worker): restrict CORS to configured origins; comply with npm-avoidant policy
Follow-up fixes for CI findings on PR #19: - Security (CWE-942 / Hypatia js_wildcard_cors, critical): replace the hardcoded wildcard Access-Control-Allow-Origin with an env-configurable allowlist (CORS_ALLOW_ORIGIN), defaulting to the portal origin. CORS headers are now applied centrally in fetch(); request Origin is echoed only when allowlisted. Added 3 CORS tests (default origin, echo-allowed, never-wildcard). - Governance (npm-avoidant policy / standards JS-RUNTIME-POLICY): stop tracking worker/package-lock.json (now gitignored) and pin devDependencies to exact versions for reproducibility; CI uses `npm install` instead of `npm ci`. - Workflows: add timeout-minutes to worker-ci, worker-deploy and boj-build (Hypatia workflow_audit). Verified: 33/33 tests pass, eslint + prettier clean, wrangler dry-run OK, no tracked package-lock.json. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCnxjXkN6uDj9YSANuGEgR
1 parent cb0771b commit a4294ee

9 files changed

Lines changed: 97 additions & 3638 deletions

File tree

.github/workflows/boj-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
jobs:
88
trigger-boj:
99
runs-on: ubuntu-latest
10+
timeout-minutes: 5
1011
steps:
1112
- name: Checkout
1213
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

.github/workflows/worker-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
build-test:
2727
name: Lint, format, test, bundle
2828
runs-on: ubuntu-latest
29+
timeout-minutes: 15
2930
steps:
3031
- name: Checkout repository
3132
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -34,11 +35,10 @@ jobs:
3435
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
3536
with:
3637
node-version: '22'
37-
cache: npm
38-
cache-dependency-path: worker/package-lock.json
3938

39+
# No tracked package-lock.json (npm-avoidant policy) → npm install, not npm ci.
4040
- name: Install dependencies
41-
run: npm ci
41+
run: npm install --no-audit --no-fund
4242

4343
- name: Lint (eslint)
4444
run: npm run lint

.github/workflows/worker-deploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
deploy:
3535
name: Deploy
3636
runs-on: ubuntu-latest
37+
timeout-minutes: 15
3738
# Manual dispatch picks the env (production requires approval if the
3839
# "production" GitHub Environment has protection rules); push → staging.
3940
environment: ${{ github.event_name == 'workflow_dispatch' && inputs.environment || 'staging' }}
@@ -45,11 +46,10 @@ jobs:
4546
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
4647
with:
4748
node-version: '22'
48-
cache: npm
49-
cache-dependency-path: worker/package-lock.json
5049

50+
# No tracked package-lock.json (npm-avoidant policy) → npm install, not npm ci.
5151
- name: Install dependencies
52-
run: npm ci
52+
run: npm install --no-audit --no-fund
5353

5454
- name: Test before deploy
5555
run: npm test

worker/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Node toolchain (dev-only; not part of the deployed Worker)
22
node_modules/
3+
# npm lockfiles are not tracked (hyperpolymath npm-avoidant policy);
4+
# devDependencies are pinned to exact versions in package.json instead.
5+
package-lock.json
36
# Wrangler local dev / Miniflare state
47
.wrangler/
58
# Test coverage

0 commit comments

Comments
 (0)