Skip to content

Commit 0f3cf47

Browse files
committed
Ruby/JS/Py: Add "random" to the notSensitiveRegexp() heuristic
1 parent 532fc08 commit 0f3cf47

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

javascript/ql/lib/semmle/javascript/security/internal/SensitiveDataHeuristics.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module HeuristicNames {
9898
* suggesting nouns within the string do not represent the meaning of the whole string (e.g. a URL or a SQL query).
9999
*/
100100
string notSensitiveRegexp() {
101-
result = "(?is).*([^\\w$.-]|redact|censor|obfuscate|hash|md5|sha|((?<!un)(en))?(crypt|code)).*"
101+
result = "(?is).*([^\\w$.-]|redact|censor|obfuscate|hash|md5|sha|random|((?<!un)(en))?(crypt|code)).*"
102102
}
103103

104104
/**

python/ql/lib/semmle/python/security/internal/SensitiveDataHeuristics.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module HeuristicNames {
9898
* suggesting nouns within the string do not represent the meaning of the whole string (e.g. a URL or a SQL query).
9999
*/
100100
string notSensitiveRegexp() {
101-
result = "(?is).*([^\\w$.-]|redact|censor|obfuscate|hash|md5|sha|((?<!un)(en))?(crypt|code)).*"
101+
result = "(?is).*([^\\w$.-]|redact|censor|obfuscate|hash|md5|sha|random|((?<!un)(en))?(crypt|code)).*"
102102
}
103103

104104
/**

ruby/ql/lib/codeql/ruby/security/internal/SensitiveDataHeuristics.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module HeuristicNames {
9898
* suggesting nouns within the string do not represent the meaning of the whole string (e.g. a URL or a SQL query).
9999
*/
100100
string notSensitiveRegexp() {
101-
result = "(?is).*([^\\w$.-]|redact|censor|obfuscate|hash|md5|sha|((?<!un)(en))?(crypt|code)).*"
101+
result = "(?is).*([^\\w$.-]|redact|censor|obfuscate|hash|md5|sha|random|((?<!un)(en))?(crypt|code)).*"
102102
}
103103

104104
/**

ruby/ql/test/query-tests/security/cwe-312/app/controllers/users_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,12 @@ def fileWrites
6363
# BAD: plaintext password stored to disk
6464
File.new("bar.txt", "a").puts("password: #{new_password}")
6565
end
66+
67+
def randomPasswordAssign
68+
user = User.find(1)
69+
random_password = SecureRandom.hex(20)
70+
# GOOD: the `random_password` value here looks like the hash of an unknown password
71+
user.password = random_password
72+
user.save
73+
end
6674
end

0 commit comments

Comments
 (0)