@@ -2,72 +2,75 @@ defmodule AshPostgres.ResourceGenerator.SensitiveData do
2
2
@ moduledoc false
3
3
# I got this from ChatGPT, but this is a best effort transformation
4
4
# anyway.
5
- @ sensitive_patterns [
6
- # Password-related
7
- ~r/ password/ i ,
8
- ~r/ passwd/ i ,
9
- ~r/ pass/ i ,
10
- ~r/ pwd/ i ,
11
- ~r/ hash(ed)?(_password)?/ i ,
12
5
13
- # Authentication-related
14
- ~r/ auth(_key)?/ i ,
15
- ~r/ token/ i ,
16
- ~r/ secret(_key)?/ i ,
17
- ~r/ api_key/ i ,
6
+ def sensitive_patterns do
7
+ [
8
+ # Password-related
9
+ ~r/ password/ i ,
10
+ ~r/ passwd/ i ,
11
+ ~r/ pass/ i ,
12
+ ~r/ pwd/ i ,
13
+ ~r/ hash(ed)?(_password)?/ i ,
18
14
19
- # Personal Information
20
- ~r/ ssn/ i ,
21
- ~r/ social(_security)?(_number)?/ i ,
22
- ~r/ (credit_?card|cc)(_number)?/ i ,
23
- ~r/ passport(_number)?/ i ,
24
- ~r/ driver_?licen(s|c)e(_number)?/ i ,
25
- ~r/ national_id/ i ,
15
+ # Authentication-related
16
+ ~r/ auth(_key)?/ i ,
17
+ ~r/ token/ i ,
18
+ ~r/ secret(_key)?/ i ,
19
+ ~r/ api_key/ i ,
26
20
27
- # Financial Information
28
- ~r/ account(_number)?/ i ,
29
- ~r/ routing(_number)?/ i ,
30
- ~r/ iban/ i ,
31
- ~r/ swift(_code)?/ i ,
32
- ~r/ tax_id/ i ,
21
+ # Personal Information
22
+ ~r/ ssn/ i ,
23
+ ~r/ social(_security)?(_number)?/ i ,
24
+ ~r/ (credit_?card|cc)(_number)?/ i ,
25
+ ~r/ passport(_number)?/ i ,
26
+ ~r/ driver_?licen(s|c)e(_number)?/ i ,
27
+ ~r/ national_id/ i ,
33
28
34
- # Contact Information
35
- ~r/ phone(_number)?/ i ,
36
- ~r/ email(_address)?/ i ,
37
- ~r/ address/ i ,
29
+ # Financial Information
30
+ ~r/ account(_number)?/ i ,
31
+ ~r/ routing(_number)?/ i ,
32
+ ~r/ iban/ i ,
33
+ ~r/ swift(_code)?/ i ,
34
+ ~r/ tax_id/ i ,
38
35
39
- # Health Information
40
- ~r/ medical(_record)?/ i ,
41
- ~r/ health(_data)?/ i ,
42
- ~r/ diagnosis/ i ,
43
- ~r/ treatment/ i ,
36
+ # Contact Information
37
+ ~r/ phone(_number)?/ i ,
38
+ ~r/ email(_address)?/ i ,
39
+ ~r/ address/ i ,
44
40
45
- # Biometric Data
46
- ~r/ fingerprint / i ,
47
- ~r/ retina_scan / i ,
48
- ~r/ face_id / i ,
49
- ~r/ dna / i ,
41
+ # Health Information
42
+ ~r/ medical(_record)? / i ,
43
+ ~r/ health(_data)? / i ,
44
+ ~r/ diagnosis / i ,
45
+ ~r/ treatment / i ,
50
46
51
- # Encrypted or Encoded Data
52
- ~r/ encrypt(ed)?/ i ,
53
- ~r/ encoded/ i ,
54
- ~r/ cipher/ i ,
47
+ # Biometric Data
48
+ ~r/ fingerprint/ i ,
49
+ ~r/ retina_scan/ i ,
50
+ ~r/ face_id/ i ,
51
+ ~r/ dna/ i ,
55
52
56
- # Other Potentially Sensitive Data
57
- ~r/ private(_key)?/ i ,
58
- ~r/ confidential/ i ,
59
- ~r/ restricted/ i ,
60
- ~r/ sensitive/ i ,
53
+ # Encrypted or Encoded Data
54
+ ~r/ encrypt(ed)?/ i ,
55
+ ~r/ encoded/ i ,
56
+ ~r/ cipher/ i ,
61
57
62
- # General patterns
63
- ~r/ .*_salt/ i ,
64
- ~r/ .*_secret/ i ,
65
- ~r/ .*_key/ i ,
66
- ~r/ .*_token/ i
67
- ]
58
+ # Other Potentially Sensitive Data
59
+ ~r/ private(_key)?/ i ,
60
+ ~r/ confidential/ i ,
61
+ ~r/ restricted/ i ,
62
+ ~r/ sensitive/ i ,
63
+
64
+ # General patterns
65
+ ~r/ .*_salt/ i ,
66
+ ~r/ .*_secret/ i ,
67
+ ~r/ .*_key/ i ,
68
+ ~r/ .*_token/ i
69
+ ]
70
+ end
68
71
69
72
def sensitive? ( column_name ) do
70
- Enum . any? ( @ sensitive_patterns , fn pattern ->
73
+ Enum . any? ( sensitive_patterns ( ) , fn pattern ->
71
74
Regex . match? ( pattern , column_name )
72
75
end )
73
76
end
0 commit comments