mirror of
https://github.com/github/codeql.git
synced 2025-12-24 12:46:34 +01:00
Merge pull request #1310 from xiemaisi/js/fix-hardcoded-pw-fps
Approved by asger-semmle
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
| Expression has no effect | Fewer false-positive results | This rule now treats uses of `Object.defineProperty` more conservatively. |
|
||||
| Incomplete regular expression for hostnames | More results | This rule now tracks regular expressions for host names further. |
|
||||
| Incomplete string escaping or encoding | More results | This rule now considers the flow of regular expressions literals, and it no longer flags the removal of trailing newlines. |
|
||||
| Password in configuration file | Fewer false positive results | This query now excludes passwords that are inserted into the configuration file using a templating mechanism. |
|
||||
| Password in configuration file | Fewer false positive results | This query now excludes passwords that are inserted into the configuration file using a templating mechanism or read from environment variables. |
|
||||
| Replacement of a substring with itself | More results | This rule now considers the flow of regular expressions literals. |
|
||||
| Server-side URL redirect | Fewer false-positive results | This rule now treats URLs as safe in more cases where the hostname cannot be tampered with. |
|
||||
| Type confusion through parameter tampering | Fewer false-positive results | This rule now recognizes additional emptiness checks. |
|
||||
|
||||
@@ -35,10 +35,14 @@ predicate config(string key, string val, Locatable valElement) {
|
||||
|
||||
/**
|
||||
* Holds if file `f` should be excluded because it looks like it may be
|
||||
* a dictionary file, or a test or example.
|
||||
* an API specification, a dictionary file, or a test or example.
|
||||
*/
|
||||
predicate exclude(File f) {
|
||||
f.getRelativePath().regexpMatch(".*(^|/)(lang(uage)?s?|locales?|tests?|examples?)/.*")
|
||||
f.getRelativePath().regexpMatch("(?i).*(^|/)(lang(uage)?s?|locales?|tests?|examples?|i18n)/.*")
|
||||
or
|
||||
f.getStem().regexpMatch("(?i)translations?")
|
||||
or
|
||||
f.getExtension().toLowerCase() = "raml"
|
||||
}
|
||||
|
||||
from string key, string val, Locatable valElement
|
||||
@@ -48,11 +52,14 @@ where
|
||||
// exclude possible templates
|
||||
not val.regexpMatch(Templating::getDelimiterMatchingRegexp()) and
|
||||
(
|
||||
key.toLowerCase() = "password"
|
||||
key.toLowerCase() = "password" and
|
||||
// exclude interpolations of environment variables
|
||||
not val.regexpMatch("\\$\\w+|\\$[{(].+[)}]|%.*%")
|
||||
or
|
||||
key.toLowerCase() != "readme" and
|
||||
// look for `password=...`, but exclude `password=;` and `password="$(...)"`
|
||||
val.regexpMatch("(?is).*password\\s*=(?!\\s*;)(?!\"?[$`]).*")
|
||||
// look for `password=...`, but exclude `password=;`, `password="$(...)"`,
|
||||
// `password=%s` and `password==`
|
||||
val.regexpMatch("(?is).*password\\s*=(?!\\s*;)(?!\"?[$`])(?!%s)(?!=).*")
|
||||
) and
|
||||
not exclude(valElement.getFile())
|
||||
select valElement, "Avoid plaintext passwords in configuration files."
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
| mysql-config.json:4:16:4:23 | "secret" | Avoid plaintext passwords in configuration files. |
|
||||
| tst4.json:2:10:2:38 | "script ... ecret'" | Avoid plaintext passwords in configuration files. |
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"password": "Passwort"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"password": "Passwort"
|
||||
}
|
||||
1
javascript/ql/test/query-tests/Security/CWE-313/tst.raml
Normal file
1
javascript/ql/test/query-tests/Security/CWE-313/tst.raml
Normal file
@@ -0,0 +1 @@
|
||||
password: string
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"password": "$pwd"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"password": "%pwd%"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"password": "${pwd:foo}"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cmd": "script.sh password='secret'"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cmd": "script.sh password=%s"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"foo": "password==bar"
|
||||
}
|
||||
Reference in New Issue
Block a user