File tree Expand file tree Collapse file tree
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 Original file line number Diff line number Diff 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 /**
Original file line number Diff line number Diff 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 /**
Original file line number Diff line number Diff 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 /**
Original file line number Diff line number Diff 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
6674end
You can’t perform that action at this time.
0 commit comments