| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityEven with the random suffix, writeFileSync will still overwrite an existing diagnostic file if a (rare) collision occurs (same timestamp + same random suffix). To fully prevent losing diagnostics, consider writing with an exclusive flag (e.g. flag: "wx") and retrying with a new suffix on EEXIST (bounded retries) so we never overwrite a previous diagnostic.
See below for a potential fix:
// We should only need to remove colons, but to be defensive, only allow a restricted set of // characters. const sanitizedTimestamp = diagnostic.timestamp.replace( /[^a-zA-Z0-9.-]/g, "", ); const maxWriteAttempts = 10; let lastError: unknown; for (let attempt = 0; attempt < maxWriteAttempts; attempt++) { // 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, `codeql-action-${sanitizedTimestamp}-${uniqueSuffix}.json`, ); try { writeFileSync(jsonPath, JSON.stringify(diagnostic), { flag: "wx" }); lastError = undefined; break; } catch (err) { if ((err as NodeJS.ErrnoException).code === "EEXIST") { lastError = err; continue; } throw err; } } if (lastError !== undefined) { throw lastError; }Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.