Merge pull request 'fix(cd): 核验主站首页的 SSO 同源改写' (#29) from fix/cd-serving-proof into main
build / build (push) Successful in 1m46s
build / build (push) Successful in 1m46s
This commit was merged in pull request #29.
This commit is contained in:
@@ -667,7 +667,15 @@ class LiveHost:
|
||||
def read_asset(path):
|
||||
return run(['docker', 'exec', name, 'cat', '/usr/share/nginx/html' + path], 'read running web asset')
|
||||
|
||||
require(origin_index == read_asset('/index.html'), 'served index differs from running web image')
|
||||
image_index = read_asset('/index.html')
|
||||
if origin_index != image_index:
|
||||
# The main site's SSO proxy strips the crossorigin attribute on same-origin assets.
|
||||
config = run(['docker', 'exec', name, 'cat', '/etc/nginx/conf.d/default.conf'],
|
||||
'read active web configuration')
|
||||
expected = re.sub(rb'(<(?:script|link)\b[^<>]*?) crossorigin(?= (?:src|href)="/assets/)',
|
||||
rb'\1 ', image_index)
|
||||
require(b"sub_filter 'crossorigin' '';" in config and origin_index == expected,
|
||||
'served index differs from running web image')
|
||||
for path, served_digest in assets.items():
|
||||
require(hashlib.sha256(read_asset(path)).hexdigest() == served_digest, 'served asset differs from running web image')
|
||||
return assets
|
||||
|
||||
Reference in New Issue
Block a user