|
10 | 10 | */
|
11 | 11 |
|
12 | 12 | import csharp
|
13 |
| -import DataFlow::PathGraph |
| 13 | +import UnsafeYearCreationFromArithmetic::PathGraph |
14 | 14 |
|
15 |
| -class UnsafeYearCreationFromArithmeticConfiguration extends TaintTracking::Configuration { |
16 |
| - UnsafeYearCreationFromArithmeticConfiguration() { |
17 |
| - this = "UnsafeYearCreationFromArithmeticConfiguration" |
18 |
| - } |
19 |
| - |
20 |
| - override predicate isSource(DataFlow::Node source) { |
| 15 | +module UnsafeYearCreationFromArithmeticConfig implements DataFlow::ConfigSig { |
| 16 | + predicate isSource(DataFlow::Node source) { |
21 | 17 | exists(ArithmeticOperation ao, PropertyAccess pa | ao = source.asExpr() |
|
22 | 18 | pa = ao.getAChild*() and
|
23 | 19 | pa.getProperty().hasQualifiedName("System.DateTime", "Year")
|
24 | 20 | )
|
25 | 21 | }
|
26 | 22 |
|
27 |
| - override predicate isSink(DataFlow::Node sink) { |
| 23 | + predicate isSink(DataFlow::Node sink) { |
28 | 24 | exists(ObjectCreation oc |
|
29 | 25 | sink.asExpr() = oc.getArgumentForName("year") and
|
30 | 26 | oc.getObjectType().getABaseType*().hasQualifiedName("System", "DateTime")
|
31 | 27 | )
|
32 | 28 | }
|
33 | 29 | }
|
34 | 30 |
|
| 31 | +module UnsafeYearCreationFromArithmetic = |
| 32 | + TaintTracking::Global<UnsafeYearCreationFromArithmeticConfig>; |
| 33 | + |
35 | 34 | from
|
36 |
| - UnsafeYearCreationFromArithmeticConfiguration config, DataFlow::PathNode source, |
37 |
| - DataFlow::PathNode sink |
38 |
| -where config.hasFlowPath(source, sink) |
| 35 | + UnsafeYearCreationFromArithmetic::PathNode source, UnsafeYearCreationFromArithmetic::PathNode sink |
| 36 | +where UnsafeYearCreationFromArithmetic::flowPath(source, sink) |
39 | 37 | select sink, source, sink,
|
40 | 38 | "This $@ based on a 'System.DateTime.Year' property is used in a construction of a new 'System.DateTime' object, flowing to the 'year' argument.",
|
41 | 39 | source, "arithmetic operation"
|
0 commit comments