|
1 | 1 | import csharp |
2 | 2 | private import semmle.code.csharp.commons.Util |
3 | 3 | private import semmle.code.csharp.dataflow.internal.DataFlowPrivate |
| 4 | +private import semmle.code.csharp.dataflow.internal.DataFlowImplCommon |
| 5 | +private import semmle.code.csharp.dataflow.internal.DataFlowDispatch |
4 | 6 |
|
5 | 7 | private predicate isRelevantForModels(Callable api) { not api instanceof MainMethod } |
6 | 8 |
|
@@ -71,3 +73,33 @@ predicate isRelevantContent(DataFlow::Content f) { |
71 | 73 | isRelevantType(f.(DataFlow::FieldContent).getField().getType()) or |
72 | 74 | f instanceof DataFlow::ElementContent |
73 | 75 | } |
| 76 | + |
| 77 | +private predicate isPrimitiveTypeUsedForBulkData(Type t) { |
| 78 | + t.getName().regexpMatch("byte|char|Byte|Char") |
| 79 | +} |
| 80 | + |
| 81 | +private string parameterAccess(Parameter p) { |
| 82 | + if |
| 83 | + p.getType() instanceof ArrayType and |
| 84 | + not isPrimitiveTypeUsedForBulkData(p.getType().(ArrayType).getElementType()) |
| 85 | + then result = "Argument[" + p.getPosition() + "].Element" |
| 86 | + else result = "Argument[" + p.getPosition() + "]" |
| 87 | +} |
| 88 | + |
| 89 | +string parameterNodeAsInput(DataFlow::ParameterNode p) { |
| 90 | + result = parameterAccess(p.asParameter()) |
| 91 | + or |
| 92 | + result = "Argument[Qualifier]" and p instanceof InstanceParameterNode |
| 93 | +} |
| 94 | + |
| 95 | +string returnNodeAsOutput(ReturnNodeExt node) { |
| 96 | + if node.getKind() instanceof ValueReturnKind |
| 97 | + then result = "ReturnValue" |
| 98 | + else |
| 99 | + exists(ParameterPosition pos | pos = node.getKind().(ParamUpdateReturnKind).getPosition() | |
| 100 | + result = parameterAccess(node.getEnclosingCallable().getParameter(pos.getPosition())) |
| 101 | + or |
| 102 | + pos.isThisParameter() and |
| 103 | + result = "Argument[Qualifier]" |
| 104 | + ) |
| 105 | +} |
0 commit comments