|
6 | 6 |
|
7 | 7 | import python |
8 | 8 | private import experimental.dataflow.DataFlow |
9 | | -private import experimental.semmle.python.Frameworks |
10 | 9 | private import experimental.dataflow.RemoteFlowSources |
| 10 | +private import experimental.dataflow.TaintTracking |
| 11 | +private import experimental.semmle.python.Frameworks |
11 | 12 |
|
12 | 13 | /** |
13 | 14 | * A data-flow node that executes an operating system command, |
@@ -165,6 +166,55 @@ module Decoding { |
165 | 166 | } |
166 | 167 | } |
167 | 168 |
|
| 169 | +/** |
| 170 | + * A data-flow node that encodes data to a binary or textual format. This |
| 171 | + * is intended to include serialization, marshalling, encoding, pickling, |
| 172 | + * compressing, encrypting, etc. |
| 173 | + * |
| 174 | + * Doing so should normally preserve taint. |
| 175 | + * |
| 176 | + * Extend this class to refine existing API models. If you want to model new APIs, |
| 177 | + * extend `Encoding::Range` instead. |
| 178 | + */ |
| 179 | +class Encoding extends DataFlow::Node { |
| 180 | + Encoding::Range range; |
| 181 | + |
| 182 | + Encoding() { this = range } |
| 183 | + |
| 184 | + /** Gets an input that is encoded by this function. */ |
| 185 | + DataFlow::Node getAnInput() { result = range.getAnInput() } |
| 186 | + |
| 187 | + /** Gets the output that contains the encoded data produced by this function. */ |
| 188 | + DataFlow::Node getOutput() { result = range.getOutput() } |
| 189 | + |
| 190 | + /** Gets an identifier for the format this function decodes from, such as "JSON". */ |
| 191 | + string getFormat() { result = range.getFormat() } |
| 192 | +} |
| 193 | + |
| 194 | +/** Provides a class for modeling new encoding mechanisms. */ |
| 195 | +module Encoding { |
| 196 | + /** |
| 197 | + * A data-flow node that encodes data to a binary or textual format. This |
| 198 | + * is intended to include serialization, marshalling, encoding, pickling, |
| 199 | + * compressing, encrypting, etc. |
| 200 | + * |
| 201 | + * Doing so should normally preserve taint. |
| 202 | + * |
| 203 | + * Extend this class to model new APIs. If you want to refine existing API models, |
| 204 | + * extend `Encoding` instead. |
| 205 | + */ |
| 206 | + abstract class Range extends DataFlow::Node { |
| 207 | + /** Gets an input that is encoded by this function. */ |
| 208 | + abstract DataFlow::Node getAnInput(); |
| 209 | + |
| 210 | + /** Gets the output that contains the encoded data produced by this function. */ |
| 211 | + abstract DataFlow::Node getOutput(); |
| 212 | + |
| 213 | + /** Gets an identifier for the format this function decodes from, such as "JSON". */ |
| 214 | + abstract string getFormat(); |
| 215 | + } |
| 216 | +} |
| 217 | + |
168 | 218 | /** |
169 | 219 | * A data-flow node that dynamically executes Python code. |
170 | 220 | * |
|
0 commit comments