Skip to content

Commit e73c940

Browse files
committed
Defensively sanitize timestamp
1 parent cdb655d commit e73c940

7 files changed

Lines changed: 37 additions & 14 deletions

File tree

lib/analyze-action.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action-post.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/setup-codeql-action.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-sarif-action.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/diagnostics.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,15 @@ function writeDiagnostic(
173173
const uniqueSuffix = Math.floor(Math.random() * 0x100000000)
174174
.toString(16)
175175
.padStart(8, "0");
176+
// We should only need to remove colons, but to be defensive, only allow a restricted set of
177+
// characters.
178+
const sanitizedTimestamp = diagnostic.timestamp.replace(
179+
/[^a-zA-Z0-9.-]/g,
180+
"",
181+
);
176182
const jsonPath = path.resolve(
177183
diagnosticsPath,
178-
// Remove colons from the timestamp as these are not allowed in Windows filenames.
179-
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}-${uniqueSuffix}.json`,
184+
`codeql-action-${sanitizedTimestamp}-${uniqueSuffix}.json`,
180185
);
181186

182187
writeFileSync(jsonPath, JSON.stringify(diagnostic));

0 commit comments

Comments
 (0)