fix(hardening): ignore literal text in sync-call metrics

This commit is contained in:
Tam Nhu Tran committed 2026-02-12 14:45:24 +07:00
1 parent d21b5c44ee
commit 8193e9d67f
4 files changed
+29 -39

No files matched your search

+2 -2
View File
@@ -31,9 +31,9 @@ Baseline captured: `2026-02-12`.
| Metric | Baseline | | Metric | Baseline |
|---|---:| |---|---:|
| Sync fs occurrences (all) | 835 | | Sync fs occurrences (all) | 807 |
| Sync fs files affected (all) | 100 | | Sync fs files affected (all) | 100 |
| Sync fs occurrences (runtime hotpaths) | 724 | | Sync fs occurrences (runtime hotpaths) | 696 |
| Sync fs files affected (runtime hotpaths) | 89 | | Sync fs files affected (runtime hotpaths) | 89 |
| Legacy shim markers | 131 | | Legacy shim markers | 131 |
| Legacy shim files affected | 56 | | Legacy shim files affected | 56 |
+15 -25
View File
@@ -1,9 +1,9 @@
{ {
"scope": "src/**/*.{ts,tsx,js,jsx,mjs,cjs}", "scope": "src/**/*.{ts,tsx,js,jsx,mjs,cjs}",
"syncFs": { "syncFs": {
"totalOccurrences": 835, "totalOccurrences": 807,
"filesAffected": 100, "filesAffected": 100,
"hotpathOccurrences": 724, "hotpathOccurrences": 696,
"hotpathFilesAffected": 89, "hotpathFilesAffected": 89,
"topHotpathFiles": [ "topHotpathFiles": [
{ {
@@ -113,24 +113,6 @@
], ],
"markers": [] "markers": []
}, },
{
"file": "src/web-server/routes/cliproxy-stats-routes.ts",
"count": 20,
"calls": [
"closeSync",
"existsSync",
"fstatSync",
"mkdirSync",
"openSync",
"readdirSync",
"readFileSync",
"readSync",
"renameSync",
"statSync",
"writeFileSync"
],
"markers": []
},
{ {
"file": "src/web-server/routes/misc-routes.ts", "file": "src/web-server/routes/misc-routes.ts",
"count": 20, "count": 20,
@@ -162,6 +144,17 @@
"writeFileSync" "writeFileSync"
], ],
"markers": [] "markers": []
},
{
"file": "src/commands/cleanup-command.ts",
"count": 16,
"calls": [
"existsSync",
"lstatSync",
"readdirSync",
"unlinkSync"
],
"markers": []
} }
], ],
"topFilesOverall": [ "topFilesOverall": [
@@ -301,17 +294,14 @@
"markers": [] "markers": []
}, },
{ {
"file": "src/web-server/routes/cliproxy-stats-routes.ts", "file": "src/web-server/routes/misc-routes.ts",
"count": 20, "count": 20,
"calls": [ "calls": [
"closeSync", "copyFileSync",
"existsSync", "existsSync",
"fstatSync",
"mkdirSync", "mkdirSync",
"openSync",
"readdirSync", "readdirSync",
"readFileSync", "readFileSync",
"readSync",
"renameSync", "renameSync",
"statSync", "statSync",
"writeFileSync" "writeFileSync"
+3 -3
View File
@@ -6,9 +6,9 @@ Scope: `src/**/*.{ts,tsx,js,jsx,mjs,cjs}`
| Metric | Value | | Metric | Value |
|---|---:| |---|---:|
| Sync fs occurrences (all) | 835 | | Sync fs occurrences (all) | 807 |
| Sync fs files affected (all) | 100 | | Sync fs files affected (all) | 100 |
| Sync fs occurrences (runtime hotpaths) | 724 | | Sync fs occurrences (runtime hotpaths) | 696 |
| Sync fs files affected (runtime hotpaths) | 89 | | Sync fs files affected (runtime hotpaths) | 89 |
| Legacy shim markers | 131 | | Legacy shim markers | 131 |
| Legacy shim files affected | 56 | | Legacy shim files affected | 56 |
@@ -24,9 +24,9 @@ Scope: `src/**/*.{ts,tsx,js,jsx,mjs,cjs}`
| `src/utils/claude-dir-installer.ts` | 21 | copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync | | `src/utils/claude-dir-installer.ts` | 21 | copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync |
| `src/cliproxy/binary/version-cache.ts` | 20 | existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync | | `src/cliproxy/binary/version-cache.ts` | 20 | existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync |
| `src/management/recovery-manager.ts` | 20 | copyFileSync, existsSync, mkdirSync, renameSync, writeFileSync | | `src/management/recovery-manager.ts` | 20 | copyFileSync, existsSync, mkdirSync, renameSync, writeFileSync |
| `src/web-server/routes/cliproxy-stats-routes.ts` | 20 | closeSync, existsSync, fstatSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, renameSync, statSync, writeFileSync |
| `src/web-server/routes/misc-routes.ts` | 20 | copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync | | `src/web-server/routes/misc-routes.ts` | 20 | copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync |
| `src/web-server/routes/persist-routes.ts` | 17 | closeSync, copyFileSync, existsSync, lstatSync, openSync, readdirSync, readSync, renameSync, unlinkSync, writeFileSync | | `src/web-server/routes/persist-routes.ts` | 17 | closeSync, copyFileSync, existsSync, lstatSync, openSync, readdirSync, readSync, renameSync, unlinkSync, writeFileSync |
| `src/commands/cleanup-command.ts` | 16 | existsSync, lstatSync, readdirSync, unlinkSync |
## Top Legacy Shim Marker Files ## Top Legacy Shim Marker Files
+9 -9
View File
@@ -162,9 +162,9 @@ function stripComments(sourceText) {
} }
if (inSingleQuote) { if (inSingleQuote) {
output += current; output += current === '\n' || current === '\r' ? current : ' ';
if (current === '\\') { if (current === '\\') {
output += next ?? ''; output += next === '\n' || next === '\r' ? next : ' ';
index += 2; index += 2;
continue; continue;
} }
@@ -176,9 +176,9 @@ function stripComments(sourceText) {
} }
if (inDoubleQuote) { if (inDoubleQuote) {
output += current; output += current === '\n' || current === '\r' ? current : ' ';
if (current === '\\') { if (current === '\\') {
output += next ?? ''; output += next === '\n' || next === '\r' ? next : ' ';
index += 2; index += 2;
continue; continue;
} }
@@ -190,9 +190,9 @@ function stripComments(sourceText) {
} }
if (inTemplateLiteral) { if (inTemplateLiteral) {
output += current; output += current === '\n' || current === '\r' ? current : ' ';
if (current === '\\') { if (current === '\\') {
output += next ?? ''; output += next === '\n' || next === '\r' ? next : ' ';
index += 2; index += 2;
continue; continue;
} }
@@ -219,21 +219,21 @@ function stripComments(sourceText) {
if (current === "'") { if (current === "'") {
inSingleQuote = true; inSingleQuote = true;
output += current; output += ' ';
index += 1; index += 1;
continue; continue;
} }
if (current === '"') { if (current === '"') {
inDoubleQuote = true; inDoubleQuote = true;
output += current; output += ' ';
index += 1; index += 1;
continue; continue;
} }
if (current === '`') { if (current === '`') {
inTemplateLiteral = true; inTemplateLiteral = true;
output += current; output += ' ';
index += 1; index += 1;
continue; continue;
} }