-
Notifications
You must be signed in to change notification settings - Fork 503
Harden setup JavaScript input and I/O boundaries #54691
New issue
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
Changes from all commits
65ee405
0884c14
486f53c
87c3eaa
c54fb47
7d97ae2
1c29e61
65adcd0
f9d5d7b
c06c597
b5e393b
f95f21f
d08ebd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,20 @@ function selectLatestRelevantChecks(checkRuns, options = {}) { | |
| continue; | ||
| } | ||
| const existing = latestByName.get(run.name); | ||
| if (!existing || new Date(run.started_at ?? 0) > new Date(existing.started_at ?? 0)) { | ||
| if (!existing) { | ||
| latestByName.set(run.name, run); | ||
| continue; | ||
| } | ||
| const runStartedAt = Date.parse(run.started_at ?? ""); | ||
| const existingStartedAt = Date.parse(existing.started_at ?? ""); | ||
| if (!Number.isFinite(runStartedAt)) { | ||
| continue; | ||
| } | ||
| if (!Number.isFinite(existingStartedAt)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing the old comparison with an unconditional 💡 Why this matters and how to fix itThe previous code still allowed a valid newer run to replace an entry whose timestamp parsed badly because A safer fallback is to treat an invalid if (!Number.isFinite(runStartedAt)) {
continue;
}
if (!Number.isFinite(existingStartedAt) || runStartedAt > existingStartedAt) {
latestByName.set(run.name, run);
}That preserves the goal of skipping malformed incoming runs without pinning the map to a bad existing entry. |
||
| latestByName.set(run.name, run); | ||
| continue; | ||
| } | ||
| if (runStartedAt > existingStartedAt) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L49-55: shrink: two separate |
||
| latestByName.set(run.name, run); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1222,7 +1222,12 @@ function isOnOrAfter(timestamp, threshold) { | |
| if (!threshold) return true; | ||
| const a = Date.parse(timestamp); | ||
| const b = Date.parse(threshold); | ||
| if (!Number.isFinite(a) || !Number.isFinite(b)) return false; | ||
| if (!Number.isFinite(a)) { | ||
| return false; | ||
| } | ||
| if (!Number.isFinite(b)) { | ||
| return false; | ||
| } | ||
| return a >= b; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L1225-1231: shrink: split into two ifs from a single combined check. |
||
| } | ||
|
|
||
|
|
||
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.
Bug: valid-timestamp run is silently dropped when existing entry has an invalid date
When
existingStartedAtisNaN(the stored entry has a malformedstarted_at) butrunStartedAtis a valid timestamp, the current guard:silently discards the valid incoming run and retains the entry with the unusable date. The correct behaviour is to prefer the valid-date run:
@copilot please address this.