mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 09:14:58 +00:00
Add random suffix when writing diagnostics to avoid filename collisions
This commit is contained in:
3
lib/analyze-action.js
generated
3
lib/analyze-action.js
generated
@@ -107892,10 +107892,11 @@ function writeDiagnostic(config, language, diagnostic) {
|
||||
);
|
||||
try {
|
||||
(0, import_fs.mkdirSync)(diagnosticsPath, { recursive: true });
|
||||
const uniqueSuffix = Math.floor(Math.random() * 4294967296).toString(16).padStart(8, "0");
|
||||
const jsonPath = import_path.default.resolve(
|
||||
diagnosticsPath,
|
||||
// Remove colons from the timestamp as these are not allowed in Windows filenames.
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}.json`
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}-${uniqueSuffix}.json`
|
||||
);
|
||||
(0, import_fs.writeFileSync)(jsonPath, JSON.stringify(diagnostic));
|
||||
} catch (err) {
|
||||
|
||||
3
lib/init-action-post.js
generated
3
lib/init-action-post.js
generated
@@ -165811,10 +165811,11 @@ function writeDiagnostic(config, language, diagnostic) {
|
||||
);
|
||||
try {
|
||||
(0, import_fs.mkdirSync)(diagnosticsPath, { recursive: true });
|
||||
const uniqueSuffix = Math.floor(Math.random() * 4294967296).toString(16).padStart(8, "0");
|
||||
const jsonPath = import_path.default.resolve(
|
||||
diagnosticsPath,
|
||||
// Remove colons from the timestamp as these are not allowed in Windows filenames.
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}.json`
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}-${uniqueSuffix}.json`
|
||||
);
|
||||
(0, import_fs.writeFileSync)(jsonPath, JSON.stringify(diagnostic));
|
||||
} catch (err) {
|
||||
|
||||
3
lib/init-action.js
generated
3
lib/init-action.js
generated
@@ -105397,10 +105397,11 @@ function writeDiagnostic(config, language, diagnostic) {
|
||||
);
|
||||
try {
|
||||
(0, import_fs.mkdirSync)(diagnosticsPath, { recursive: true });
|
||||
const uniqueSuffix = Math.floor(Math.random() * 4294967296).toString(16).padStart(8, "0");
|
||||
const jsonPath = import_path.default.resolve(
|
||||
diagnosticsPath,
|
||||
// Remove colons from the timestamp as these are not allowed in Windows filenames.
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}.json`
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}-${uniqueSuffix}.json`
|
||||
);
|
||||
(0, import_fs.writeFileSync)(jsonPath, JSON.stringify(diagnostic));
|
||||
} catch (err) {
|
||||
|
||||
3
lib/setup-codeql-action.js
generated
3
lib/setup-codeql-action.js
generated
@@ -105467,10 +105467,11 @@ function writeDiagnostic(config, language, diagnostic) {
|
||||
);
|
||||
try {
|
||||
(0, import_fs.mkdirSync)(diagnosticsPath, { recursive: true });
|
||||
const uniqueSuffix = Math.floor(Math.random() * 4294967296).toString(16).padStart(8, "0");
|
||||
const jsonPath = import_path.default.resolve(
|
||||
diagnosticsPath,
|
||||
// Remove colons from the timestamp as these are not allowed in Windows filenames.
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}.json`
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}-${uniqueSuffix}.json`
|
||||
);
|
||||
(0, import_fs.writeFileSync)(jsonPath, JSON.stringify(diagnostic));
|
||||
} catch (err) {
|
||||
|
||||
3
lib/upload-lib.js
generated
3
lib/upload-lib.js
generated
@@ -107502,10 +107502,11 @@ function writeDiagnostic(config, language, diagnostic) {
|
||||
);
|
||||
try {
|
||||
(0, import_fs.mkdirSync)(diagnosticsPath, { recursive: true });
|
||||
const uniqueSuffix = Math.floor(Math.random() * 4294967296).toString(16).padStart(8, "0");
|
||||
const jsonPath = import_path.default.resolve(
|
||||
diagnosticsPath,
|
||||
// Remove colons from the timestamp as these are not allowed in Windows filenames.
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}.json`
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}-${uniqueSuffix}.json`
|
||||
);
|
||||
(0, import_fs.writeFileSync)(jsonPath, JSON.stringify(diagnostic));
|
||||
} catch (err) {
|
||||
|
||||
3
lib/upload-sarif-action.js
generated
3
lib/upload-sarif-action.js
generated
@@ -108258,10 +108258,11 @@ function writeDiagnostic(config, language, diagnostic) {
|
||||
);
|
||||
try {
|
||||
(0, import_fs.mkdirSync)(diagnosticsPath, { recursive: true });
|
||||
const uniqueSuffix = Math.floor(Math.random() * 4294967296).toString(16).padStart(8, "0");
|
||||
const jsonPath = import_path.default.resolve(
|
||||
diagnosticsPath,
|
||||
// Remove colons from the timestamp as these are not allowed in Windows filenames.
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}.json`
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}-${uniqueSuffix}.json`
|
||||
);
|
||||
(0, import_fs.writeFileSync)(jsonPath, JSON.stringify(diagnostic));
|
||||
} catch (err) {
|
||||
|
||||
@@ -167,10 +167,16 @@ function writeDiagnostic(
|
||||
// Create the directory if it doesn't exist yet.
|
||||
mkdirSync(diagnosticsPath, { recursive: true });
|
||||
|
||||
// Include a random suffix to avoid filename collisions between diagnostics
|
||||
// produced within the same millisecond. This doesn't need to be
|
||||
// cryptographically secure, so `Math.random` is fine.
|
||||
const uniqueSuffix = Math.floor(Math.random() * 0x100000000)
|
||||
.toString(16)
|
||||
.padStart(8, "0");
|
||||
const jsonPath = path.resolve(
|
||||
diagnosticsPath,
|
||||
// Remove colons from the timestamp as these are not allowed in Windows filenames.
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}.json`,
|
||||
`codeql-action-${diagnostic.timestamp.replaceAll(":", "")}-${uniqueSuffix}.json`,
|
||||
);
|
||||
|
||||
writeFileSync(jsonPath, JSON.stringify(diagnostic));
|
||||
|
||||
Reference in New Issue
Block a user