|
3 | 3 | * |
4 | 4 | * These functions perform I/O (filesystem, config reads) to detect security issues. |
5 | 5 | */ |
6 | | -import fs from "node:fs/promises"; |
7 | 6 | import path from "node:path"; |
8 | 7 | import { clearTimeout as clearNodeTimeout, setTimeout as setNodeTimeout } from "node:timers"; |
9 | 8 | import { |
@@ -99,6 +98,10 @@ function expandTilde(p: string, env: NodeJS.ProcessEnv): string | null { |
99 | 98 | } |
100 | 99 |
|
101 | 100 | const MAX_PLUGIN_MANIFEST_BYTES = 1024 * 1024; |
| 101 | +// Skill file audit reads are bounded like other audit reads; matches the |
| 102 | +// workspace loader's DEFAULT_MAX_SKILL_FILE_BYTES so oversized SKILL.md files |
| 103 | +// cannot force an unbounded read during the code-safety scan. |
| 104 | +const MAX_SKILL_AUDIT_FILE_BYTES = 256_000; |
102 | 105 |
|
103 | 106 | async function readPluginManifestExtensions(pluginPath: string): Promise<string[]> { |
104 | 107 | const manifestPath = path.join(pluginPath, "package.json"); |
@@ -194,7 +197,10 @@ async function getSkillCodeSafetySummary(params: { |
194 | 197 | dirPath: params.dirPath, |
195 | 198 | summaryCache: params.summaryCache, |
196 | 199 | }), |
197 | | - fs.readFile(params.skillFilePath, "utf-8"), |
| 200 | + readRegularFile({ |
| 201 | + filePath: params.skillFilePath, |
| 202 | + maxBytes: MAX_SKILL_AUDIT_FILE_BYTES, |
| 203 | + }).then(({ buffer }) => buffer.toString("utf-8")), |
198 | 204 | loadSkillScannerModule(), |
199 | 205 | ]); |
200 | 206 | const skillFindings = [ |
|
0 commit comments