зеркало из https://github.com/github/codeql.git
CPP: Clean up duplication in Adding365DaysPerYear.ql.
This commit is contained in:
Родитель
7fca220eda
Коммит
69533a7fd3
|
@ -258,22 +258,33 @@ class PossibleYearArithmeticOperationCheckConfiguration extends DataFlow::Config
|
|||
}
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists( Expr e, Operation op |
|
||||
e = source.asExpr() |
|
||||
op.getAChild*().getValue().toInt()=365
|
||||
and op.getAChild*() = e
|
||||
)
|
||||
exists(Operation op |
|
||||
op = source.asExpr() |
|
||||
op.getAChild*().getValue().toInt() = 365 and
|
||||
not op.getParent() instanceof Expr
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
// flow from anything on the RHS of an assignment to a time/date structure to that
|
||||
// assignment.
|
||||
exists(StructLikeClass dds, FieldAccess fa, AssignExpr aexpr, Expr e |
|
||||
e = node1.asExpr() and
|
||||
aexpr = node2.asExpr() |
|
||||
(dds instanceof FileTimeStruct or dds instanceof DateDataStruct)
|
||||
and fa.getQualifier().getUnderlyingType() = dds
|
||||
and aexpr.getLValue() = fa
|
||||
and aexpr.getRValue().getAChild*() = e
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists( StructLikeClass dds, FieldAccess fa, AssignExpr aexpr, Expr e |
|
||||
e = sink.asExpr() |
|
||||
(dds instanceof FileTimeStruct
|
||||
or dds instanceof DateDataStruct)
|
||||
and fa.getQualifier().getUnderlyingType() = dds
|
||||
and fa.isModified()
|
||||
and aexpr.getAChild() = fa
|
||||
and aexpr.getChild(1).getAChild*() = e
|
||||
exists(StructLikeClass dds, FieldAccess fa, AssignExpr aexpr |
|
||||
aexpr = sink.asExpr() |
|
||||
(dds instanceof FileTimeStruct or dds instanceof DateDataStruct)
|
||||
and fa.getQualifier().getUnderlyingType() = dds
|
||||
and fa.isModified()
|
||||
and aexpr.getLValue() = fa
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
| test.cpp:173:29:173:38 | qwLongTime | This arithmetic operation $@ uses a constant value of 365 ends up modifying the date/time located at $@, without considering leap year scenarios. | test.cpp:170:2:170:47 | ... += ... | ... += ... | test.cpp:173:29:173:38 | qwLongTime | qwLongTime |
|
||||
| test.cpp:174:30:174:39 | qwLongTime | This arithmetic operation $@ uses a constant value of 365 ends up modifying the date/time located at $@, without considering leap year scenarios. | test.cpp:170:2:170:47 | ... += ... | ... += ... | test.cpp:174:30:174:39 | qwLongTime | qwLongTime |
|
||||
| test.cpp:193:15:193:18 | days | This arithmetic operation $@ uses a constant value of 365 ends up modifying the date/time located at $@, without considering leap year scenarios. | test.cpp:193:15:193:18 | days | days | test.cpp:193:15:193:18 | days | days |
|
||||
| test.cpp:193:15:193:24 | ... / ... | This arithmetic operation $@ uses a constant value of 365 ends up modifying the date/time located at $@, without considering leap year scenarios. | test.cpp:193:15:193:24 | ... / ... | ... / ... | test.cpp:193:15:193:24 | ... / ... | ... / ... |
|
||||
| test.cpp:193:22:193:24 | 365 | This arithmetic operation $@ uses a constant value of 365 ends up modifying the date/time located at $@, without considering leap year scenarios. | test.cpp:193:22:193:24 | 365 | 365 | test.cpp:193:22:193:24 | 365 | 365 |
|
||||
| test.cpp:173:2:173:52 | ... = ... | This arithmetic operation $@ uses a constant value of 365 ends up modifying the date/time located at $@, without considering leap year scenarios. | test.cpp:170:2:170:47 | ... += ... | ... += ... | test.cpp:173:2:173:52 | ... = ... | ... = ... |
|
||||
| test.cpp:174:2:174:46 | ... = ... | This arithmetic operation $@ uses a constant value of 365 ends up modifying the date/time located at $@, without considering leap year scenarios. | test.cpp:170:2:170:47 | ... += ... | ... += ... | test.cpp:174:2:174:46 | ... = ... | ... = ... |
|
||||
| test.cpp:193:2:193:24 | ... = ... | This arithmetic operation $@ uses a constant value of 365 ends up modifying the date/time located at $@, without considering leap year scenarios. | test.cpp:193:2:193:24 | ... = ... | ... = ... | test.cpp:193:2:193:24 | ... = ... | ... = ... |
|
||||
|
|
Загрузка…
Ссылка в новой задаче