mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
C#: Re-factor UnsafeYearConstruction to use the new API.
This commit is contained in:
@@ -10,21 +10,17 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
import DataFlow::PathGraph
|
||||
import UnsafeYearCreationFromArithmetic::PathGraph
|
||||
|
||||
class UnsafeYearCreationFromArithmeticConfiguration extends TaintTracking::Configuration {
|
||||
UnsafeYearCreationFromArithmeticConfiguration() {
|
||||
this = "UnsafeYearCreationFromArithmeticConfiguration"
|
||||
}
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
module UnsafeYearCreationFromArithmeticConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
exists(ArithmeticOperation ao, PropertyAccess pa | ao = source.asExpr() |
|
||||
pa = ao.getAChild*() and
|
||||
pa.getProperty().hasQualifiedName("System.DateTime", "Year")
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
exists(ObjectCreation oc |
|
||||
sink.asExpr() = oc.getArgumentForName("year") and
|
||||
oc.getObjectType().getABaseType*().hasQualifiedName("System", "DateTime")
|
||||
@@ -32,10 +28,12 @@ class UnsafeYearCreationFromArithmeticConfiguration extends TaintTracking::Confi
|
||||
}
|
||||
}
|
||||
|
||||
module UnsafeYearCreationFromArithmetic =
|
||||
TaintTracking::Global<UnsafeYearCreationFromArithmeticConfig>;
|
||||
|
||||
from
|
||||
UnsafeYearCreationFromArithmeticConfiguration config, DataFlow::PathNode source,
|
||||
DataFlow::PathNode sink
|
||||
where config.hasFlowPath(source, sink)
|
||||
UnsafeYearCreationFromArithmetic::PathNode source, UnsafeYearCreationFromArithmetic::PathNode sink
|
||||
where UnsafeYearCreationFromArithmetic::flowPath(source, sink)
|
||||
select sink, source, sink,
|
||||
"This $@ based on a 'System.DateTime.Year' property is used in a construction of a new 'System.DateTime' object, flowing to the 'year' argument.",
|
||||
source, "arithmetic operation"
|
||||
|
||||
Reference in New Issue
Block a user