File tree Expand file tree Collapse file tree 4 files changed +11
-3
lines changed
javascript/ql/lib/semmle/javascript/security/internal
python/ql/lib/semmle/python/security/internal
lib/codeql/ruby/security/internal
test/query-tests/security/cwe-312/app/controllers Expand file tree Collapse file tree 4 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ module HeuristicNames {
98
98
* suggesting nouns within the string do not represent the meaning of the whole string (e.g. a URL or a SQL query).
99
99
*/
100
100
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)).*"
102
102
}
103
103
104
104
/**
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ module HeuristicNames {
98
98
* suggesting nouns within the string do not represent the meaning of the whole string (e.g. a URL or a SQL query).
99
99
*/
100
100
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)).*"
102
102
}
103
103
104
104
/**
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ module HeuristicNames {
98
98
* suggesting nouns within the string do not represent the meaning of the whole string (e.g. a URL or a SQL query).
99
99
*/
100
100
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)).*"
102
102
}
103
103
104
104
/**
Original file line number Diff line number Diff line change @@ -63,4 +63,12 @@ def fileWrites
63
63
# BAD: plaintext password stored to disk
64
64
File . new ( "bar.txt" , "a" ) . puts ( "password: #{ new_password } " )
65
65
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
66
74
end
You can’t perform that action at this time.
0 commit comments