Skip to content

Commit

Permalink
Merge pull request #16876 from GeekMasher/py-hardcoded-creds-mad
Browse files Browse the repository at this point in the history
Python: Add Hardcoded Credentials MaD support
  • Loading branch information
RasmusWL authored Jul 1, 2024
2 parents d9b337c + 96048f9 commit 2b2c381
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/ql/src/Security/CWE-798/HardcodedCredentials.ql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import semmle.python.dataflow.new.TaintTracking
import semmle.python.filters.Tests
private import semmle.python.dataflow.new.internal.DataFlowDispatch as DataFlowDispatch
private import semmle.python.dataflow.new.internal.Builtins::Builtins as Builtins
private import semmle.python.frameworks.data.ModelsAsData

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

class CredentialSink extends DataFlow::Node {
CredentialSink() {
exists(string s | s.matches("credentials-%") |
// Actual sink-type will be things like `credentials-password` or `credentials-username`
this = ModelOutput::getASinkNode(s).asSink()
)
or
exists(string name |
name.regexpMatch(getACredentialRegex()) and
not name.matches("%file")
Expand Down
4 changes: 4 additions & 0 deletions python/ql/src/change-notes/2024-06-28-cred-hardcoded.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Adding Python support for Hardcoded Credentials as Models as Data

0 comments on commit 2b2c381

Please sign in to comment.