Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
Run protected Excel-focused V6 source tests and bounded production npm dependency vulnerability audit
davoodmehraban89 committed
Oct 18, 2026 at 14:21 UTC
2cf04d94555ab8a47adfe60d330a27fc258a38a0
1 file changed
+99
.github/workflows/v6-excel-targeted-unit-audit-once.yml
new
+99
@@ -0,0 +1,99 @@
1
+name: V6 targeted Excel import/export unit and production dependency audit (NOT V7)
2
+on:
3
+ push:
4
+ branches: ['ci/public-windows-bridge-probe-20261017']
5
+ paths: ['.github/workflows/v6-excel-targeted-unit-audit-once.yml']
6
+permissions:
7
+ contents: read
8
+jobs:
9
+ excel-and-security:
10
+ runs-on: ubuntu-22.04
11
+ timeout-minutes: 15
12
+ env:
13
+ BANK_ADAPTER_MODE: disabled
14
+ TREASURYFLOW_ENABLE_MAYAN_EXTERNAL_READ: '0'
15
+ TREASURYFLOW_MAYAN_ENABLE_EXTERNAL_READ: '0'
16
+ TREASURYFLOW_ENABLE_SQL_LAB: '0'
17
+ steps:
18
+ - name: Retrieve and verify immutable private source with read-only token
19
+ env:
20
+ GH_TOKEN: ${{ secrets.TF_VALIDATION_READ_TOKEN }}
21
+ shell: bash
22
+ run: |
23
+ set -euo pipefail
24
+ test -n "$GH_TOKEN"
25
+ gh release download validation-inputs-20261017 --repo davoodmehraban89/TreasuryFlow-Validation-Private --pattern TreasuryFlow_Validation_Staging_20261017.zip --dir "$RUNNER_TEMP" >/dev/null 2>&1
26
+ f="$RUNNER_TEMP/TreasuryFlow_Validation_Staging_20261017.zip"
27
+ test "$(sha256sum "$f" | cut -d' ' -f1)" = 9ce46ce2d2a437e08cbf28146b2cf2ac0ed078c71f1aeb537764390cdd3c552f
28
+ mkdir -p "$RUNNER_TEMP/private-stage"
29
+ unzip -q "$f" -d "$RUNNER_TEMP/private-stage"
30
+ echo "TF_ROOT=$RUNNER_TEMP/private-stage" >> "$GITHUB_ENV"
31
+ echo 'GATE_PASS_PRIVATE_STAGING_SHA256'
32
+ - name: Setup Node 22
33
+ uses: actions/setup-node@v4
34
+ with:
35
+ node-version: '22'
36
+ - name: Run only Excel-related existing test suites with private output redacted
37
+ shell: bash
38
+ run: |
39
+ set -euo pipefail
40
+ cd "$TF_ROOT"
41
+ npm ci --no-audit --no-fund > "$RUNNER_TEMP/private-npm-ci.log" 2>&1 || { echo 'PRIVATE_NPM_CI_FAILED'; exit 1; }
42
+ cat > "$RUNNER_TEMP/private-excel-suite-runner.mjs" <<'NODE'
43
+ import fs from 'node:fs';
44
+ import path from 'node:path';
45
+ import {spawnSync} from 'node:child_process';
46
+ const root=process.env.TF_ROOT;
47
+ const tests=[];
48
+ function scan(dir){
49
+ if(!fs.existsSync(dir))return;
50
+ for(const ent of fs.readdirSync(dir,{withFileTypes:true})){
51
+ if(['node_modules','.next','.git','release'].includes(ent.name))continue;
52
+ const p=path.join(dir,ent.name);
53
+ if(ent.isDirectory())scan(p);
54
+ else if(/[.](?:test|spec)[.][cm]?[jt]sx?$/.test(ent.name)&&fs.statSync(p).size<100000){
55
+ const str=fs.readFileSync(p,'utf8');
56
+ if(/xlsx|excel|spreadsheet|workbook/i.test(str))tests.push(p);
57
+ }
58
+ }
59
+ }
60
+ scan(path.join(root,'src'));scan(path.join(root,'qa'));
61
+ console.log('EXCEL_RELATED_TEST_FILE_COUNT='+tests.length);
62
+ if(tests.length<1)process.exit(11);
63
+ const report=path.join(process.env.RUNNER_TEMP,'private-targeted-excel.json');
64
+ const args=['vitest','run',...tests,'--reporter=json','--outputFile='+report];
65
+ const child=spawnSync(path.join(root,'node_modules','.bin','vitest'),args.slice(2),{cwd:root,env:process.env,encoding:'utf8',timeout:180000});
66
+ if(!fs.existsSync(report)){console.log('EXCEL_TEST_REPORT_MISSING=true');process.exit(12)}
67
+ const data=JSON.parse(fs.readFileSync(report,'utf8'));
68
+ console.log('EXCEL_TEST_TOTAL='+Number(data.numTotalTests||0));
69
+ console.log('EXCEL_TEST_PASS='+Number(data.numPassedTests||0));
70
+ console.log('EXCEL_TEST_FAIL='+Number(data.numFailedTests||0));
71
+ console.log('EXCEL_TEST_PENDING='+Number(data.numPendingTests||0));
72
+ if(child.status!==0||Number(data.numFailedTests||0)!==0)process.exit(13);
73
+ console.log('GATE_PASS_EXCEL_RELATED_TEST_SUITES');
74
+ NODE
75
+ node "$RUNNER_TEMP/private-excel-suite-runner.mjs"
76
+ - name: Run bounded production dependency vulnerability audit
77
+ shell: bash
78
+ run: |
79
+ cd "$TF_ROOT"
80
+ set +e
81
+ npm audit --omit=dev --json > "$RUNNER_TEMP/private-production-audit.json" 2> "$RUNNER_TEMP/private-audit-stderr.log"
82
+ auditCode=$?
83
+ set -e
84
+ AUDIT_CODE="$auditCode" node -e '
85
+ const fs=require("fs");
86
+ let x;
87
+ try { x=JSON.parse(fs.readFileSync(process.env.RUNNER_TEMP+"/private-production-audit.json","utf8")); }
88
+ catch { console.log("PRODUCTION_AUDIT_PARSEABLE=false"); process.exit(2); }
89
+ if(!x.metadata?.vulnerabilities){console.log("PRODUCTION_AUDIT_HAS_COUNTS=false");process.exit(3)}
90
+ const v=x.metadata.vulnerabilities;
91
+ for(const k of ["critical","high","moderate","low","total"])console.log("PRODUCTION_AUDIT_"+k.toUpperCase()+"="+Number(v[k]||0));
92
+ if(Number(v.critical||0)>0||Number(v.high||0)>0){console.log("PRODUCTION_DEPENDENCY_HIGH_OR_CRITICAL_BLOCKER=true");process.exit(4)}
93
+ console.log("GATE_PASS_NO_PRODUCTION_HIGH_OR_CRITICAL_VULNS");
94
+ '
95
+ - name: Strict scope summary
96
+ if: always()
97
+ run: |
98
+ echo 'TEST_DATA=EXISTING_PRIVATE_UNIT_FIXTURES; EXCEL_GUI=NOT_TESTED; SOURCE_AND_RAW_LOGS=NOT_UPLOADED'
99
+ echo 'V7_FINAL=NOT_TESTED; SQL_SERVER_ADAPTER=NOT_TESTED; BANK_DISABLED=true'