mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-19 21:11:18 -08:00
Refuse run ids that could leave the runs folder and stop replacements being read as patterns
AI Assisted
This commit is contained in:
1 parent
b17213322c
commit
0b6a376915
8 files changed
+37
-13
No files matched your search
@@ -230,6 +230,10 @@ export function loadAggregated(outputPath: string): AggregatedMetrics | null {
|
||||
* Returns true if written, false if a file for that run_id already existed.
|
||||
*/
|
||||
export function writeRunFile(run: RunMetrics, runsDir: string): boolean {
|
||||
// The id becomes a file name: only the collector's own shape may reach a path.
|
||||
if (!/^run-[A-Za-z0-9-]{1,64}$/.test(run.run_id)) {
|
||||
throw new Error(`Refusing run_id "${String(run.run_id).slice(0, 80)}": it is not a run-<id> name.`);
|
||||
}
|
||||
const destPath = path.join(runsDir, `${run.run_id}.json`);
|
||||
|
||||
if (fs.existsSync(destPath)) {
|
||||
|
||||
Reference in new issue
Block a user