Python: Model sensitive data from subscripts

This commit is contained in:
Rasmus Wriedt Larsen
2021-06-03 14:21:07 +02:00
parent d6532e280a
commit 925e67d734
2 changed files with 13 additions and 1 deletions

View File

@@ -126,6 +126,18 @@ private module SensitiveDataModeling {
override SensitiveDataClassification getClassification() { result = classification }
}
/** A subscript, where the key indicates the result will be sensitive data. */
class SensitiveSubscript extends SensitiveDataSource::Range {
SensitiveDataClassification classification;
SensitiveSubscript() {
this.asCfgNode().(SubscriptNode).getIndex() =
sensitiveLookupStringConst(classification).asCfgNode()
}
override SensitiveDataClassification getClassification() { result = classification }
}
/** A call to `get` on an object, where the key indicates the result will be sensitive data. */
class SensitiveGetCall extends SensitiveDataSource::Range, DataFlow::CallCfgNode {
SensitiveDataClassification classification;

View File

@@ -34,7 +34,7 @@ password = some_function()
print(password) # $ MISSING: SensitiveUse=password
# Special handling of lookups of sensitive properties
request.args["password"], # $ MISSING: SensitiveDataSource=password
request.args["password"], # $ SensitiveDataSource=password
request.args.get("password") # $ SensitiveDataSource=password
x = "password"