File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 proxy : null # Optional: "http://proxy.example.com:8080"
1212 timeout : 30 # seconds
1313
14+ # Validation settings
15+ validation :
16+ allow_private_suffixes : false # https://github.com/weppos/publicsuffix-ruby/blob/main/data/list.txt
17+
1418# API server configuration
1519api :
1620 port : 4567
Original file line number Diff line number Diff line change @@ -80,6 +80,14 @@ def history_retention_days
8080 load [ :history_retention_days ] || 30
8181 end
8282
83+ def validation
84+ load [ :validation ] || { }
85+ end
86+
87+ def allow_private_suffixes?
88+ validation [ :allow_private_suffixes ] == true
89+ end
90+
8391 def discord
8492 load [ :discord ] || { }
8593 end
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ def self.valid_wildcard_usage?(val)
7070
7171 # 5. Domain part must be a valid registrable domain (not just a public suffix like *.co.uk)
7272 begin
73- parsed = PublicSuffix . parse ( domain_part )
73+ parsed = PublicSuffix . parse ( domain_part , ignore_private : Config . allow_private_suffixes? )
7474 return false if parsed . sld . nil?
7575 rescue PublicSuffix ::DomainInvalid , PublicSuffix ::DomainNotAllowed
7676 return false
Original file line number Diff line number Diff line change 5959 expect ( described_class . valid_web_target? ( '*.test.com.au' , 'web' ) ) . to be true
6060 end
6161
62+ it 'rejects wildcards on private suffixes by default' do
63+ expect ( described_class . valid_web_target? ( '*.digitaloceanspaces.com' , 'web' ) ) . to be false
64+ expect ( described_class . valid_web_target? ( '*.githubusercontent.com' , 'web' ) ) . to be false
65+ end
66+
67+ context 'when allow_private_suffixes is enabled' do
68+ before do
69+ allow ( ScopesExtractor ::Config ) . to receive ( :allow_private_suffixes? ) . and_return ( true )
70+ end
71+
72+ it 'accepts wildcards on private suffixes' do
73+ expect ( described_class . valid_web_target? ( '*.digitaloceanspaces.com' , 'web' ) ) . to be true
74+ expect ( described_class . valid_web_target? ( '*.githubusercontent.com' , 'web' ) ) . to be true
75+ end
76+
77+ it 'still rejects public suffixes' do
78+ expect ( described_class . valid_web_target? ( '*.co.uk' , 'web' ) ) . to be false
79+ expect ( described_class . valid_web_target? ( '*.com.au' , 'web' ) ) . to be false
80+ end
81+ end
82+
6283 it 'rejects descriptions in parentheses' do
6384 expect ( described_class . valid_web_target? ( '*.example.com (description text)' , 'web' ) ) . to be false
6485 end
You can’t perform that action at this time.
0 commit comments