Resolve source and mobile review findings; record smoke evidence
Production container deploy / production (push) Canceled after 2m42s
Production container deploy / production (push) Canceled after 2m42s
This commit is contained in:
1 parent
53e4f06486
commit
d2bf3bbcb1
13 files changed
+301
-6
No files matched your search
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check rendered pages and every internal link/asset, without running a browser."""
|
||||
import argparse,json,subprocess
|
||||
from html.parser import HTMLParser
|
||||
from urllib.parse import urlsplit,urldefrag
|
||||
parser=argparse.ArgumentParser();parser.add_argument('--base',required=True);parser.add_argument('--origin');parser.add_argument('--output');args=parser.parse_args()
|
||||
class Links(HTMLParser):
|
||||
def __init__(self):super().__init__();self.urls=set();self.ids=set()
|
||||
def handle_starttag(self,tag,attrs):
|
||||
a=dict(attrs)
|
||||
if 'id' in a:self.ids.add(a['id'])
|
||||
for key in ('href','src'):
|
||||
u=a.get(key,'')
|
||||
if u.startswith('/') and not u.startswith('//'):self.urls.add(u)
|
||||
paths=['/','/about','/catalog','/guides/choose','/guides/memory-card','/guides/installation','/guides/save-video','/tools/recording-time','/health/ready','/health/live']
|
||||
results=[];discovered=set();fragments=[];documents={}
|
||||
def request(path):
|
||||
cmd=['curl','-sS','--max-time','20','-w','\n%{http_code}']
|
||||
if args.origin:cmd+=['-k','--resolve',urlsplit(args.base).hostname+':443:'+args.origin]
|
||||
cmd+=[args.base+path]
|
||||
r=subprocess.run(cmd,capture_output=True);body,code=r.stdout.rsplit(b'\n',1);return int(code),body
|
||||
for path in paths:
|
||||
code,body=request(path);assert code==200,(path,code)
|
||||
results.append(dict(path=path,status=code,bytes=len(body)))
|
||||
if path.startswith('/health/'):
|
||||
assert json.loads(body)['status']=='ok';continue
|
||||
parsed=Links();parsed.feed(body.decode());documents[path]=parsed.ids;discovered.update(parsed.urls)
|
||||
assert b'mc.yandex.ru' not in body and b'web.archive.org/web/' not in body,path
|
||||
for url in sorted(discovered):
|
||||
path,frag=urldefrag(url)
|
||||
if path not in paths and path != '/auto.shtml':
|
||||
code,body=request(path);assert code==200,(path,code);results.append(dict(path=path,status=code,bytes=len(body)))
|
||||
if frag:
|
||||
assert frag in documents[path],(url,'missing fragment')
|
||||
for path in ['/api/videos','/_dev/showcase','/does-not-exist']:
|
||||
code,_=request(path);assert code==404,(path,code);results.append(dict(path=path,status=code))
|
||||
code,_=request('/auto.shtml');assert code==308,code;results.append(dict(path='/auto.shtml',status=code))
|
||||
report=dict(base=args.base,origin=args.origin,tlsVerified=not bool(args.origin),checks=results,internalLinksAndAssets='passed',date='2026-10-26')
|
||||
if args.output:open(args.output,'w').write(json.dumps(report,ensure_ascii=False,indent=2)+'\n')
|
||||
print(json.dumps(dict(requests=len(results),status='passed',origin=args.origin)))
|
||||
Reference in new issue
Block a user