-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C++: Refactor of UncheckedLeapYearAfterModification #21292
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
Open
bdrodes
wants to merge
10
commits into
github:main
Choose a base branch
from
microsoft:UncheckedLeaprYearAfterModification_Refactor_Upstream
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,150
−166
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6c171c8
C++: Add more tests for modified years with and without leap year che…
bdrodes 95d4a54
C++: Refactor leap year logic for UncheckedLeapYearAfterYearModificat…
bdrodes d9feadc
C++. Accept test changes. One false positive introduced, and one fals…
bdrodes ca18179
C++: Correct false positive. Only TimeConversionFunction that do not …
bdrodes a534d26
C++: Accept test changes.
bdrodes 2b806ad
C++: Add missing DateTime models for PTIME_FIELDS and TIME_FIELDS
bdrodes 36cc209
C++: Accept test changes (removing false negative)
bdrodes 1796bc0
C++: Add change note.
bdrodes 8e36316
C++: Addressing Copilot PR suggestions.
bdrodes 98b5114
C++: Change log missing .md extension.
bdrodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
cpp/ql/lib/change-notes/2026-02-06-UncheckedLeapYearAfterModification_Refactor.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Refactor of UncheckedLeapYearAfterYearModification.ql to address large numbers of false positives. Reduced alerts from 40k to 2k. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -308,3 +308,35 @@ private module PossibleYearArithmeticOperationCheckConfig implements DataFlow::C | |||||
|
|
||||||
| module PossibleYearArithmeticOperationCheckFlow = | ||||||
| TaintTracking::Global<PossibleYearArithmeticOperationCheckConfig>; | ||||||
|
|
||||||
| /** | ||||||
| * This list of APIs should check for the return value to detect problems during the conversion. | ||||||
|
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.
Suggested change
|
||||||
| */ | ||||||
| class TimeConversionFunction extends Function { | ||||||
| boolean autoLeapYearCorrecting; | ||||||
|
|
||||||
| TimeConversionFunction() { | ||||||
| autoLeapYearCorrecting = false and | ||||||
| ( | ||||||
| this.getName() = | ||||||
| [ | ||||||
| "FileTimeToSystemTime", "SystemTimeToFileTime", "SystemTimeToTzSpecificLocalTime", | ||||||
| "SystemTimeToTzSpecificLocalTimeEx", "TzSpecificLocalTimeToSystemTime", | ||||||
| "TzSpecificLocalTimeToSystemTimeEx", "RtlLocalTimeToSystemTime", | ||||||
| "RtlTimeToSecondsSince1970", "_mkgmtime", "SetSystemTime", "VarUdateFromDate", "from_tm" | ||||||
| ] | ||||||
| or | ||||||
| // Matches all forms of GetDateFormat, e.g. GetDateFormatA/W/Ex | ||||||
| this.getName().matches("GetDateFormat%") | ||||||
| ) | ||||||
| or | ||||||
| autoLeapYearCorrecting = true and | ||||||
| this.getName() = | ||||||
| ["mktime", "_mktime32", "_mktime64", "SystemTimeToVariantTime", "VariantTimeToSystemTime"] | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Holds if the function is expected to auto convert a bad leap year date. | ||||||
| */ | ||||||
| predicate isAutoLeapYearCorrecting() { autoLeapYearCorrecting = true } | ||||||
| } | ||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The number of alerts is nice, but will be meaningless to a general audience.