Skip to content

Commit 6d693ed

Browse files
authored
fix: Convert sensitive patterns from module constant to function for OTP/28 (#552)
compatibility
1 parent 0720514 commit 6d693ed

File tree

1 file changed

+58
-55
lines changed

1 file changed

+58
-55
lines changed

lib/resource_generator/sensitive_data.ex

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,75 @@ defmodule AshPostgres.ResourceGenerator.SensitiveData do
22
@moduledoc false
33
# I got this from ChatGPT, but this is a best effort transformation
44
# 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,
125

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,
1814

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,
2620

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,
3328

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,
3835

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,
4440

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,
5046

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,
5552

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,
6157

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
6871

6972
def sensitive?(column_name) do
70-
Enum.any?(@sensitive_patterns, fn pattern ->
73+
Enum.any?(sensitive_patterns(), fn pattern ->
7174
Regex.match?(pattern, column_name)
7275
end)
7376
end

0 commit comments

Comments
 (0)