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

Probe compatible production dependency audit fixes and rerun protected V6 tests, typecheck, lint and build

davoodmehraban89 committed Oct 18, 2026 at 14:23 UTC d5fd39bf7c475c3c9dcce606e7e8618bc764fccc
1 file changed +95
.github/workflows/v6-private-audit-fix-probe-once.yml new
+95
@@ -0,0 +1,95 @@
1 +name: V6 production dependency vulnerability safe fix probe (NOT V7)
2 +on:
3 + push:
4 + branches: ['ci/public-windows-bridge-probe-20261017']
5 + paths: ['.github/workflows/v6-private-audit-fix-probe-once.yml']
6 +permissions:
7 + contents: read
8 +jobs:
9 + audit:
10 + runs-on: ubuntu-22.04
11 + timeout-minutes: 20
12 + env:
13 + BANK_ADAPTER_MODE: disabled
14 + TREASURYFLOW_ENABLE_MAYAN_EXTERNAL_READ: '0'
15 + TREASURYFLOW_MAYAN_ENABLE_EXTERNAL_READ: '0'
16 + steps:
17 + - name: Receive SHA256 verified private V6 staging with step scoped read-only token
18 + env:
19 + GH_TOKEN: ${{ secrets.TF_VALIDATION_READ_TOKEN }}
20 + shell: bash
21 + run: |
22 + set -euo pipefail
23 + test -n "$GH_TOKEN"
24 + gh release download validation-inputs-20261017 --repo davoodmehraban89/TreasuryFlow-Validation-Private --pattern TreasuryFlow_Validation_Staging_20261017.zip --dir "$RUNNER_TEMP" >/dev/null 2>&1
25 + f="$RUNNER_TEMP/TreasuryFlow_Validation_Staging_20261017.zip"
26 + test "$(sha256sum "$f" | cut -d' ' -f1)" = '9ce46ce2d2a437e08cbf28146b2cf2ac0ed078c71f1aeb537764390cdd3c552f'
27 + mkdir -p "$RUNNER_TEMP/private-v6-audit"
28 + unzip -q "$f" -d "$RUNNER_TEMP/private-v6-audit"
29 + echo "TF_STAGE=$RUNNER_TEMP/private-v6-audit" >> "$GITHUB_ENV"
30 + echo 'GATE_PASS_PRIVATE_INPUT_SHA256'
31 + - name: Setup Node 22
32 + uses: actions/setup-node@v4
33 + with:
34 + node-version: '22'
35 + - name: Run package audit and compatible fix without exposing private package lock or advisories
36 + shell: bash
37 + run: |
38 + set -euo pipefail
39 + cd "$TF_STAGE"
40 + npm ci --no-audit --no-fund > "$RUNNER_TEMP/private-npm.log" 2>&1
41 + npm audit --omit=dev --json > "$RUNNER_TEMP/private-audit-before.json" 2>/dev/null || true
42 + cat > "$RUNNER_TEMP/audit-report.mjs" <<'NODE'
43 + import fs from 'node:fs';
44 + import path from 'node:path';
45 + const file=process.argv[2],prefix=process.argv[3];
46 + const x=JSON.parse(fs.readFileSync(file,'utf8'));
47 + const v=x.metadata?.vulnerabilities;
48 + if(!v)process.exit(12);
49 + for(const k of ['critical','high','moderate','low','total'])console.log(prefix+'_COUNT_'+k.toUpperCase()+'='+Number(v[k]||0));
50 + const security=x.vulnerabilities||{};
51 + const affected=Object.entries(security).filter(([name,item])=>item.severity==='high'||item.severity==='critical');
52 + console.log(prefix+'_HIGH_PACKAGE_COUNT='+affected.length);
53 + const known=['xlsx','exceljs','next','react','mssql','axios','tar','glob','minimatch','undici','ws','node-forge','xml2js','form-data','lodash','lodash.merge','follow-redirects'];
54 + for(const [name,item] of affected) {
55 + const label=known.includes(name)?name:'UNLISTED_DEPENDENCY';
56 + console.log(prefix+'_HIGH_PACKAGE='+label);
57 + console.log(prefix+'_HIGH_FIX_AVAILABLE='+Boolean(item.fixAvailable));
58 + console.log(prefix+'_HIGH_IS_DIRECT='+Boolean(item.isDirect));
59 + }
60 + NODE
61 + node "$RUNNER_TEMP/audit-report.mjs" "$RUNNER_TEMP/private-audit-before.json" BEFORE
62 + set +e
63 + npm audit fix --omit=dev --no-fund > "$RUNNER_TEMP/private-audit-fix.log" 2>&1
64 + exitCode=$?
65 + set -e
66 + echo "COMPATIBLE_AUDIT_FIX_EXIT_ZERO=$([ "$exitCode" -eq 0 ] && echo true || echo false)"
67 + npm install --package-lock-only --ignore-scripts --no-audit --no-fund > "$RUNNER_TEMP/private-lock-refresh.log" 2>&1
68 + npm ci --no-audit --no-fund > "$RUNNER_TEMP/private-reinstall.log" 2>&1
69 + npm audit --omit=dev --json > "$RUNNER_TEMP/private-audit-after.json" 2>/dev/null || true
70 + node "$RUNNER_TEMP/audit-report.mjs" "$RUNNER_TEMP/private-audit-after.json" AFTER
71 + cat > "$RUNNER_TEMP/lock-compare.mjs" <<'NODE'
72 + import fs from 'node:fs';
73 + const p=JSON.parse(fs.readFileSync(process.argv[2],'utf8'));
74 + console.log('LOCK_POST_FIX_FORMAT='+Number(p.lockfileVersion||0));
75 + NODE
76 + node "$RUNNER_TEMP/lock-compare.mjs" package-lock.json
77 + - name: Retest source after compatible security fixes
78 + shell: bash
79 + run: |
80 + set -euo pipefail
81 + cd "$TF_STAGE"
82 + npm test -- --reporter=dot > "$RUNNER_TEMP/private-tests-after-audit-fix.log" 2>&1 || { echo 'AFTER_FIX_UNIT_TESTS_FAILED'; exit 1; }
83 + echo 'GATE_PASS_AFTER_FIX_UNIT_TESTS'
84 + npm run typecheck > "$RUNNER_TEMP/private-typecheck-after-audit.log" 2>&1 || { echo 'AFTER_FIX_TYPECHECK_FAILED'; exit 1; }
85 + echo 'GATE_PASS_AFTER_FIX_TYPECHECK'
86 + npm run lint > "$RUNNER_TEMP/private-lint-after-audit.log" 2>&1 || { echo 'AFTER_FIX_LINT_FAILED'; exit 1; }
87 + echo 'GATE_PASS_AFTER_FIX_LINT'
88 + npm run build > "$RUNNER_TEMP/private-build-after-audit.log" 2>&1 || { echo 'AFTER_FIX_NEXT_BUILD_FAILED'; exit 1; }
89 + echo 'GATE_PASS_AFTER_FIX_NEXT_BUILD'
90 + - name: No public upload or acceptance claim
91 + if: always()
92 + run: |
93 + echo 'SCOPE=EPHEMERAL_PACKAGE_LOCK_COMPATIBLE_SECURITY_FIX_PROBE'
94 + echo 'PRIVATE_PACKAGE_LOCK_BINARY_SOURCE_AND_LOGS=NOT_UPLOADED'
95 + echo 'V7_RELEASE=BLOCKED_PENDING_PATCHED_PRIVATE_ASSET_AND_ACCEPTANCE'