Skip to content

Commit 0f9b433

Browse files
committed
remove some FPs in js/password-in-configuration-file
1 parent 52cd200 commit 0f9b433

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

javascript/ql/src/Security/CWE-313/PasswordInConfigurationFile.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ where
2727
not val.regexpMatch("\\$.*|%.*%") and
2828
not PasswordHeuristics::isDummyPassword(val)
2929
or
30-
key.toLowerCase() != "readme" and
31-
// look for `password=...`, but exclude `password=;`, `password="$(...)"`,
30+
not key.toLowerCase() = ["readme", "run"] and
31+
// look for `password=...`, but exclude `password=;`, `password="$(...)"`, `password=foo()`
3232
// `password=%s` and `password==`
33-
pwd = val.regexpCapture("(?is).*password\\s*=\\s*(?!;|\"?[$`]|%s|=)(\\S+).*", 1)
33+
pwd = val.regexpCapture("(?is).*password\\s*=\\s*(?!;|\"?[$`]|%s|=|\\w+\\(.+\\))(\\S+).*", 1)
3434
)
3535
select valElement.(FirstLineOf), "Hard-coded password '" + pwd + "' in configuration file."

javascript/ql/test/query-tests/Security/CWE-313/tst.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ steps:
55
username: <%= ENV['USERNAME'] %>
66
password: <%= ENV['PASSWORD'] %>
77
password: change_me
8+
query:
9+
- run : |
10+
printf("This is some scripting")
11+
password = os.env['PASSWORD']
12+
password: foo("blab")

0 commit comments

Comments
 (0)