Skip to content

Commit 3ba543e

Browse files
committed
More heuristics for culling non-gregorian year calculations.
1 parent 7ff7006 commit 3ba543e

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

cpp/ql/src/Likely Bugs/Leap Year/UncheckedLeapYearAfterYearModification.ql

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,20 @@ class IgnorableFunction extends Function {
5858
// conversion operations (from one time structure to another) are generally ignorable
5959
this.getName() = "localsub"
6060
or
61-
// Hijri years are not applicable for gregorian leap year checks
61+
// Indication of a calendar not applicable to
62+
// gregorian leap year, e.g., Hijri, Persian, Hebrew
6263
this.getName().toLowerCase().matches("%hijri%")
6364
or
6465
this.getFile().getBaseName().toLowerCase().matches("%hijri%")
6566
or
66-
// Persian calendar conversions are not applicable for gregorian leap year checks
6767
this.getName().toLowerCase().matches("%persian%")
6868
or
6969
this.getFile().getBaseName().toLowerCase().matches("%persian%")
7070
or
71+
this.getName().toLowerCase().matches("%hebrew%")
72+
or
73+
this.getFile().getBaseName().toLowerCase().matches("%hebrew%")
74+
or
7175
// misc. from string/char converters heuristic
7276
this.getName()
7377
.toLowerCase()
@@ -357,9 +361,11 @@ module OperationToYearAssignmentConfig implements DataFlow::ConfigSig {
357361
n.asExpr() instanceof IgnorableOperation
358362
or
359363
// Flowing into variables that indicate likely non-gregorian years are barriers
360-
// e.g., names similar to hijri, persian, lunar, chinese, etc.
364+
// e.g., names similar to hijri, persian, lunar, chinese, hebrew, etc.
361365
exists(Variable v |
362-
v.getName().toLowerCase().matches(["%hijri%", "%persian%", "%lunar%", "%chinese%"]) and
366+
v.getName()
367+
.toLowerCase()
368+
.matches(["%hijri%", "%persian%", "%lunar%", "%chinese%", "%hebrew%"]) and
363369
v.getAnAccess() = [n.asIndirectExpr(), n.asExpr()]
364370
)
365371
or

0 commit comments

Comments
 (0)