This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 8dc038fe Handle CSP check of site is missing
8dc038fe is described below
commit 8dc038fefc3a40981352fe4d4ab6915c52b21096
Author: Sebb <[email protected]>
AuthorDate: Fri Oct 31 15:58:42 2025 +0000
Handle CSP check of site is missing
---
lib/whimsy/sitestandards.rb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/whimsy/sitestandards.rb b/lib/whimsy/sitestandards.rb
index 8266b904..31169e22 100644
--- a/lib/whimsy/sitestandards.rb
+++ b/lib/whimsy/sitestandards.rb
@@ -144,7 +144,7 @@ module SiteStandards
'csp_check' => { # Custom: CSP must follow standards
CHECK_TEXT => 'Non-default CSP',
CHECK_CAPTURE => nil,
- CHECK_VALIDATE => %r{OK},
+ CHECK_VALIDATE => %r{^OK},
CHECK_TYPE => 'message',
CHECK_POLICY => 'https://infra.apache.org/tools/csp.html',
CHECK_DOC => 'Websites must not replace the default
Content-Security-Policy',
@@ -276,7 +276,7 @@ module SiteStandards
def process_csp(sites)
sites.each do |site, data|
csp = data.fetch('csp', '')
- squashed = csp.gsub(/ +/, ' ')
+ squashed = csp&.gsub(/ +/, ' ') # might be null
m = DEFAULT_CSP_RE.match(squashed)
if m # the syntax of the CSP appears to be OK
extras = m.captures.uniq
@@ -290,6 +290,8 @@ module SiteStandards
else
data['csp_check'] = "Mixed Extras - should not happen: #{extras}"
end
+ elsif csp == nil
+ data['csp_check'] = 'OK - no website yet'
elsif data['nonpmc'] and data['uri'] =~
%r{^https://(www\.)?apache\.org/} and squashed == WWW_CSP
data['csp_check'] = 'OK'
else # did not match