aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / scripts / test-project-links.py
| 1 | #!/usr/bin/env python3 |
| 2 | """Public navigation oracle. Examples and archived source provenance stay text.""" |
| 3 | from html.parser import HTMLParser |
| 4 | from pathlib import Path |
| 5 | from urllib.parse import urlsplit |
| 6 | import sys,re |
| 7 | class Links(HTMLParser): |
| 8 | def handle_starttag(self,tag,attrs): |
| 9 | for key,value in attrs: |
| 10 | if key=='href' and value: |
| 11 | host=(urlsplit(value).hostname or '').lower() |
| 12 | assert host not in ('github.com','www.github.com'),f'GitHub navigation remains: {value}' |
| 13 | assert not (host=='interplane.io' and re.search(r'/issues/[0-9]+(?:[?#].*)?$',value)),f'Unmapped GitHub issue number: {value}' |
| 14 | assert not re.search(r'&(#[0-9]+|#x[0-9a-fA-F]+|[A-Za-z]+);',value),f'href escaped twice (an entity survives decoding): {value}' |
| 15 | def check(source):Links().feed(source) |
| 16 | root=Path(sys.argv[1]);pages=list(root.rglob('*.html')) |
| 17 | # The English site writes 92 HTML files (main a0bb31a7); the old floor of 100 counted the retired /zh-CN/ copies. |
| 18 | assert len(pages)>=92,'missing or incomplete site output' |
| 19 | for page in pages:check(page.read_text()) |
| 20 | try:check('<a href="https://github.com/aien-dev/omega">source</a>') |
| 21 | except AssertionError:pass |
| 22 | else:raise AssertionError('negative control accepted forbidden navigation') |
| 23 | try:check('<a href="https://interplane.io/drakestapleton/omega-mv/blob/main/docs/OMEGA.md&#35;1-the-parts">source</a>') |
| 24 | except AssertionError:pass |
| 25 | else:raise AssertionError('negative control accepted a twice-escaped href') |
| 26 | print(f'PROJECT-LINKS PASS: {len(pages)} HTML pages, zero GitHub hrefs, no twice-escaped href, planted-link negative controls refused') |
| 27 | |
| 28 | spark=(root/"spark/index.html").read_text() |
| 29 | kept = ["NVIDIA/open-gpu-kernel-modules", "src/common/sdk/nvidia/inc/nvos.h", "lines 1114 to 1118", |
| 30 | "src/common/sdk/nvidia/inc/class/clc96f.h", "line 72", "580.173.02"] |
| 31 | for needle in kept: |
| 32 | assert needle in spark, "external citation provenance retained as text: " + needle |
| 33 | assert "https://github.com/NVIDIA" not in spark, "link policy: NVIDIA citation stays text, not a GitHub URL" |
| 34 | try:check('<a href="https://interplane.io/drakestapleton/omega-mv/issues/515">source</a>') |
| 35 | except AssertionError:pass |
| 36 | else:raise AssertionError("negative control accepted unmapped issue number") |