|
4 | 4 | * @id csharp/utils/model-generator/summary-models |
5 | 5 | */ |
6 | 6 |
|
7 | | -import CaptureSummaryModels |
| 7 | +private import CaptureSummaryModels |
8 | 8 |
|
| 9 | +/** |
| 10 | + * Capture fluent APIs that return `this`. |
| 11 | + * Example of a fluent API: |
| 12 | + * ``` |
| 13 | + * public class BasicFlow { |
| 14 | + * public BasicFlow ReturnThis(object input) |
| 15 | + * { |
| 16 | + * // some side effect |
| 17 | + * return this; |
| 18 | + * } |
| 19 | + * ``` |
| 20 | + * Captured Model: |
| 21 | + * ``` |
| 22 | + * Summaries;BasicFlow;false;ReturnThis;(System.Object);Argument[Qualifier];ReturnValue;value |
| 23 | + * ``` |
| 24 | + * Capture APIs that transfer taint from an input parameter to an output return |
| 25 | + * value or parameter. |
| 26 | + * Allows a sequence of read steps followed by a sequence of store steps. |
| 27 | + * |
| 28 | + * Examples: |
| 29 | + * |
| 30 | + * ``` |
| 31 | + * public class BasicFlow { |
| 32 | + * private string tainted; |
| 33 | + * |
| 34 | + * public String ReturnField() |
| 35 | + * { |
| 36 | + * return tainted; |
| 37 | + * } |
| 38 | + * |
| 39 | + * public void AssignFieldToArray(object[] target) |
| 40 | + * { |
| 41 | + * target[0] = tainted; |
| 42 | + * } |
| 43 | + * } |
| 44 | + * ``` |
| 45 | + * Captured Models: |
| 46 | + * ``` |
| 47 | + * Summaries;BasicFlow;false;ReturnField;();Argument[Qualifier];ReturnValue;taint | |
| 48 | + * Summaries;BasicFlow;false;AssignFieldToArray;(System.Object[]);Argument[Qualifier];Argument[0].Element;taint |
| 49 | + * ``` |
| 50 | + * |
| 51 | + * ``` |
| 52 | + * public class BasicFlow { |
| 53 | + * private string tainted; |
| 54 | + * |
| 55 | + * public void SetField(string s) |
| 56 | + * { |
| 57 | + * tainted = s; |
| 58 | + * } |
| 59 | + * } |
| 60 | + * ``` |
| 61 | + * Captured Model: |
| 62 | + * `Summaries;BasicFlow;false;SetField;(System.String);Argument[0];Argument[Qualifier];taint` |
| 63 | + * |
| 64 | + * ``` |
| 65 | + * public class BasicFlow { |
| 66 | + * public void ReturnSubstring(string s) |
| 67 | + * { |
| 68 | + * return s.Substring(0, 1); |
| 69 | + * } |
| 70 | + * } |
| 71 | + * ``` |
| 72 | + * Captured Model: |
| 73 | + * `Summaries;BasicFlow;false;ReturnSubstring;(System.String);Argument[0];ReturnValue;taint` |
| 74 | + * |
| 75 | + * ``` |
| 76 | + * public class BasicFlow { |
| 77 | + * public void AssignToArray(int data, int[] target) |
| 78 | + * { |
| 79 | + * target[0] = data; |
| 80 | + * } |
| 81 | + * } |
| 82 | + * ``` |
| 83 | + * Captured Model: |
| 84 | + * `Summaries;BasicFlow;false;AssignToArray;(System.Int32,System.Int32[]);Argument[0];Argument[1].Element;taint` |
| 85 | + */ |
9 | 86 | private string captureFlow(TargetAPI api) { |
10 | 87 | result = captureQualifierFlow(api) or |
11 | 88 | result = captureThroughFlow(api) |
|
0 commit comments