Download src/evaluation/qls_for_security/python/cwe-798_HardcodedCredentials-a.ql from ManavSinghal157/NoFunEval: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/datasets/ManavSinghal157/NoFunEval/resolve/main/src/evaluation/qls_for_security/python/cwe-798_HardcodedCredentials-a.ql
- Command line
-
hf download hf://datasets/ManavSinghal157/NoFunEval/src/evaluation/qls_for_security/python/cwe-798_HardcodedCredentials-a.ql
-
curl -L -o cwe-798_HardcodedCredentials-a.ql https://huggingface.co/datasets/ManavSinghal157/NoFunEval/resolve/main/src/evaluation/qls_for_security/python/cwe-798_HardcodedCredentials-a.ql
1.06 kB
| /** | |
| * @name Check for CWE-798 in codeql-eg-HardcodedCredentials-a | |
| * @description | |
| * @kind problem | |
| * @problem.severity warning | |
| * @id custom-cpp/cwe-798_codeql-eg-HardcodedCredentials-a | |
| */ | |
| import python | |
| import semmle.python.dataflow.new.DataFlow | |
| import semmle.python.dataflow.new.TaintTracking | |
| string getACredentialRegex() { | |
| result = "(?i).*pass(wd|word|code|phrase)(?!.*question).*" | |
| //or | |
| //result = "(?i).*(puid|username|userid).*" or | |
| //result = "(?i).*(cert)(?!.*(format|name)).*" | |
| } | |
| from Compare cmp, Expr literal | |
| where | |
| literal instanceof StrConst | |
| and | |
| cmp.getOp(0) instanceof Eq | |
| and | |
| ( | |
| ( | |
| cmp.getComparator(0) =literal | |
| and | |
| cmp.getLeft().toString().regexpMatch(getACredentialRegex()) | |
| ) | |
| or | |
| ( | |
| cmp.getLeft() =literal | |
| and | |
| cmp.getComparator(0).toString().regexpMatch(getACredentialRegex()) | |
| ) | |
| ) | |
| select cmp, "cwe-798: "+cmp.toString()+ " at line "+ cmp.getLocation().getStartLine()+ | |
| " is a password comparison with a string literal" |