12
12
13
13
import cpp
14
14
15
- /** A string for `match` that identifies strings that look like they represent private data. */
15
+ /**
16
+ * A string for `regexpMatch` that identifies strings that look like they
17
+ * represent private data.
18
+ */
16
19
private string privateNames ( ) {
17
20
result =
18
- [
21
+ ".*(" +
19
22
// Inspired by the list on https://cwe.mitre.org/data/definitions/359.html
20
23
// Government identifiers, such as Social Security Numbers
21
- "% social% security%" ,
24
+ "social.* security|" +
22
25
// Contact information, such as home addresses and telephone numbers
23
- "% postcode%" , "% zipcode%" , "% telephone%" ,
26
+ "postcode| zipcode| telephone|" +
24
27
// Geographic location - where the user is (or was)
25
- "% latitude%" , "% longitude%" ,
28
+ "latitude| longitude|" +
26
29
// Financial data - such as credit card numbers, salary, bank accounts, and debts
27
- "% credit% card%" , "% salary%" , "% bank% account%" ,
30
+ "credit.* card| salary| bank.* account|" +
28
31
// Communications - e-mail addresses, private e-mail messages, SMS text messages, chat logs, etc.
29
- "% email%" , "% mobile%" , "% employer%" ,
32
+ "email| mobile| employer|" +
30
33
// Health - medical conditions, insurance status, prescription records
31
- "%medical%"
32
- ]
34
+ "medical" +
35
+ // ---
36
+ ").*"
33
37
}
34
38
35
39
/**
36
40
* A variable that might contain sensitive private information.
37
41
*/
38
42
class PrivateDataVariable extends Variable {
39
43
PrivateDataVariable ( ) {
40
- this .getName ( ) .toLowerCase ( ) .matches ( privateNames ( ) ) and
44
+ this .getName ( ) .toLowerCase ( ) .regexpMatch ( privateNames ( ) ) and
41
45
not this .getUnspecifiedType ( ) instanceof IntegralType
42
46
}
43
47
}
@@ -47,7 +51,7 @@ class PrivateDataVariable extends Variable {
47
51
*/
48
52
class PrivateDataFunction extends Function {
49
53
PrivateDataFunction ( ) {
50
- this .getName ( ) .toLowerCase ( ) .matches ( privateNames ( ) ) and
54
+ this .getName ( ) .toLowerCase ( ) .regexpMatch ( privateNames ( ) ) and
51
55
not this .getUnspecifiedType ( ) instanceof IntegralType
52
56
}
53
57
}
0 commit comments