Treasury & Bank Transfer Management System — سامانه مدیریت خزانه‌داری و حواله‌های بانکی

1 name: V7 fix transitive MSAL advisory on isolated branch
2 on:
3 push:
4 paths:
5 - .github/workflows/v7-azure-msal-advisory-remediation-once.yml
6 permissions:
7 contents: write
8 jobs:
9 remediation:
10 runs-on: ubuntu-22.04
11 timeout-minutes: 30
12 steps:
13 - uses: actions/checkout@v4
14 with:
15 persist-credentials: true
16 fetch-depth: 1
17 - uses: actions/setup-node@v4
18 with:
19 node-version: '22'
20 - name: Re-resolve only lock file against current npm advisories
21 shell: bash
22 run: |
23 set -euo pipefail
24 test "$GITHUB_REF_NAME" = 'dev/v7-production-failclosed-20261021'
25 npm ci --ignore-scripts --no-audit --no-fund >/dev/null
26 # @azure/identity 4.14 depends on MSAL ^6.0.0, but the vendor's
27 # security patch is MSAL 7.1.0+. Explicit override is required.
28 npm pkg set 'overrides.@azure/msal-node=7.1.1'
29 npm install --package-lock-only --ignore-scripts --no-audit --no-fund > "$RUNNER_TEMP/npm-security-patch.log" 2>&1 || {
30 echo 'GATE_FAIL_EXPLICIT_MSAL_OVERRIDE_LOCK_RESOLUTION'
31 exit 1
32 }
33 node - <<'NODE'
34 const pkg=require('./package.json');
35 if(pkg.overrides?.['@azure/msal-node']!=='7.1.1')throw Error('MSAL_OVERRIDE_NOT_PINNED');
36 console.log('GATE_PASS_EXPLICIT_MSAL_7_1_1_OVERRIDE_PINNED');
37 NODE
38 node - <<'NODE'
39 const lock=require('./package-lock.json');
40 const dependency=lock.packages?.['node_modules/@azure/msal-node'];
41 if(!dependency)throw Error('MSAL_LOCK_ENTRY_MISSING');
42 const v=dependency.version.split('.').map(Number);
43 if(v[0]<7||(v[0]===7&&v[1]<1))throw Error('MSAL_LOCK_VERSION_UNPATCHED');
44 console.log('GATE_PASS_PATCHED_MSAL_VERSION_AT_LEAST_7_1_0');
45 NODE
46 - name: Fresh install plus full core gates
47 shell: bash
48 run: |
49 set -euo pipefail
50 npm ci --ignore-scripts --no-audit --no-fund > "$RUNNER_TEMP/npm-ci.log" 2>&1
51 npm audit --omit=dev --audit-level=low > "$RUNNER_TEMP/npm-audit.log" 2>&1 || {
52 echo 'GATE_FAIL_PRODUCTION_ADVISORIES_REMAIN'
53 exit 1
54 }
55 npm run typecheck > "$RUNNER_TEMP/types.log" 2>&1
56 npm run lint > "$RUNNER_TEMP/lint.log" 2>&1
57 npm test -- --reporter=dot > "$RUNNER_TEMP/tests.log" 2>&1
58 npm run build > "$RUNNER_TEMP/build.log" 2>&1
59 npm run smoke > "$RUNNER_TEMP/smoke.log" 2>&1
60 echo 'GATE_PASS_MSal_ADVISORY_ZERO_PRODUCTION_AUDIT_FULL_FINANCE_BUILD_SMOKE'
61 - name: Commit only validated dependency lock repair to isolated branch
62 shell: bash
63 run: |
64 set -euo pipefail
65 test "$GITHUB_REF_NAME" = 'dev/v7-production-failclosed-20261021'
66 test -z "$(git status --porcelain --untracked-files=no | grep -Ev 'package(-lock)?.json' || true)"
67 if git diff --quiet -- package.json package-lock.json; then
68 echo 'GATE_PASS_LOCKFILE_ALREADY_SECURE'
69 else
70 git config user.name "TreasuryFlow CI security bot"
71 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
72 git add -- package.json package-lock.json
73 git commit -m 'fix: pin patched MSAL Node transitively and validate finance suite'
74 git push origin HEAD:refs/heads/dev/v7-production-failclosed-20261021
75 echo 'GATE_PASS_VALIDATED_MSA_LOWER_BOUND_COMMITTED_ON_FEATURE_BRANCH'
76 fi