Skip to content

Commit 925e67d

Browse files
committed
Python: Model sensitive data from subscripts
1 parent d6532e2 commit 925e67d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

python/ql/src/semmle/python/dataflow/new/SensitiveDataSources.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ private module SensitiveDataModeling {
126126
override SensitiveDataClassification getClassification() { result = classification }
127127
}
128128

129+
/** A subscript, where the key indicates the result will be sensitive data. */
130+
class SensitiveSubscript extends SensitiveDataSource::Range {
131+
SensitiveDataClassification classification;
132+
133+
SensitiveSubscript() {
134+
this.asCfgNode().(SubscriptNode).getIndex() =
135+
sensitiveLookupStringConst(classification).asCfgNode()
136+
}
137+
138+
override SensitiveDataClassification getClassification() { result = classification }
139+
}
140+
129141
/** A call to `get` on an object, where the key indicates the result will be sensitive data. */
130142
class SensitiveGetCall extends SensitiveDataSource::Range, DataFlow::CallCfgNode {
131143
SensitiveDataClassification classification;

python/ql/test/experimental/dataflow/sensitive-data/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def encrypt_password(pwd):
3434
print(password) # $ MISSING: SensitiveUse=password
3535

3636
# Special handling of lookups of sensitive properties
37-
request.args["password"], # $ MISSING: SensitiveDataSource=password
37+
request.args["password"], # $ SensitiveDataSource=password
3838
request.args.get("password") # $ SensitiveDataSource=password
3939

4040
x = "password"

0 commit comments

Comments
 (0)