Skip to content

Commit 2b2c381

Browse files
authored
Merge pull request github#16876 from GeekMasher/py-hardcoded-creds-mad
Python: Add Hardcoded Credentials MaD support
2 parents d9b337c + 96048f9 commit 2b2c381

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

python/ql/src/Security/CWE-798/HardcodedCredentials.ql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import semmle.python.dataflow.new.TaintTracking
1818
import semmle.python.filters.Tests
1919
private import semmle.python.dataflow.new.internal.DataFlowDispatch as DataFlowDispatch
2020
private import semmle.python.dataflow.new.internal.Builtins::Builtins as Builtins
21+
private import semmle.python.frameworks.data.ModelsAsData
2122

2223
bindingset[char, fraction]
2324
predicate fewer_characters_than(StringLiteral str, string char, float fraction) {
@@ -80,6 +81,11 @@ class HardcodedValueSource extends DataFlow::Node {
8081

8182
class CredentialSink extends DataFlow::Node {
8283
CredentialSink() {
84+
exists(string s | s.matches("credentials-%") |
85+
// Actual sink-type will be things like `credentials-password` or `credentials-username`
86+
this = ModelOutput::getASinkNode(s).asSink()
87+
)
88+
or
8389
exists(string name |
8490
name.regexpMatch(getACredentialRegex()) and
8591
not name.matches("%file")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Adding Python support for Hardcoded Credentials as Models as Data

0 commit comments

Comments
 (0)