Skip to content

Commit 5dc2bb7

Browse files
committed
Python: ignore common words (certain/concert) as sensitive source
1 parent abdcfd5 commit 5dc2bb7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,14 @@ module HeuristicNames {
9696
* Gets a regular expression that identifies strings that may indicate the presence of data
9797
* that is hashed or encrypted, and hence rendered non-sensitive, or contains special characters
9898
* suggesting nouns within the string do not represent the meaning of the whole string (e.g. a URL or a SQL query).
99+
*
100+
* We also filter out common words like `certain` and `concert`, since otherwise these could
101+
* be matched by the certificate regular expressions. Same for `accountable` (account), or
102+
* `secretarial` (secret).
99103
*/
100104
string notSensitiveRegexp() {
101105
result =
102-
"(?is).*([^\\w$.-]|redact|censor|obfuscate|hash|md5|sha|random|((?<!un)(en))?(crypt|code)).*"
106+
"(?is).*([^\\w$.-]|redact|censor|obfuscate|hash|md5|sha|random|((?<!un)(en))?(crypt|code)|certain|concert|secretar|accountant|accountab).*"
103107
}
104108

105109
/**

python/ql/test/experimental/dataflow/sensitive-data/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def my_func(password): # $ SensitiveDataSource=password
5858

5959
# FP where the `cert` in `uncertainty` makes us treat it like a certificate
6060
# https://github.com/github/codeql/issues/9632
61-
def my_other_func(uncertainty): # $ SPURIOUS: SensitiveDataSource=certificate
62-
print(uncertainty) # $ SPURIOUS: SensitiveUse=certificate
61+
def my_other_func(uncertainty):
62+
print(uncertainty)
6363

6464
password = some_function() # $ SensitiveDataSource=password
6565
print(password) # $ SensitiveUse=password

0 commit comments

Comments
 (0)