Update version_branch.yml

This commit is contained in:
2025-12-23 17:15:21 -06:00
parent 17c3e67621
commit 2fc8eedd6e

View File

@@ -182,27 +182,29 @@ jobs:
moko_init "Sanity check workflow file" moko_init "Sanity check workflow file"
python3 - <<'PY' python3 - <<'PY'
from pathlib import Path from pathlib import Path
target = Path('.github/workflows/version_branch.yml') target = Path('.github/workflows/version_branch.yml')
if not target.exists(): if not target.exists():
raise SystemExit('[FATAL] Missing workflow file: .github/workflows/version_branch.yml') raise SystemExit('[FATAL] Missing workflow file: .github/workflows/version_branch.yml')
data = target.read_bytes() data = target.read_bytes()
# Disallow literal tab (0x09) and other ASCII control characters except LF (0x0A) and CR (0x0D). # Disallow literal tab (0x09) and other ASCII control characters except LF (0x0A) and CR (0x0D).
# Report line numbers without printing the raw characters. # Report line numbers without printing the raw characters.
def byte_to_line(blob: bytes, idx: int) -> int:
return blob[:idx].count(b'\n') + 1
bad = [] def byte_to_line(blob: bytes, idx: int) -> int:
for i, b in enumerate(data): return blob[:idx].count(b'
') + 1
bad = []
for i, b in enumerate(data):
if b == 0x09: if b == 0x09:
bad.append(('TAB', i, b)) bad.append(('TAB', i, b))
elif b < 0x20 and b not in (0x0A, 0x0D): elif b < 0x20 and b not in (0x0A, 0x0D):
bad.append(('CTRL', i, b)) bad.append(('CTRL', i, b))
if bad: if bad:
print('[ERROR] Disallowed characters detected in workflow file:') print('[ERROR] Disallowed characters detected in workflow file:')
for kind, off, val in bad[:200]: for kind, off, val in bad[:200]:
line_no = byte_to_line(data, off) line_no = byte_to_line(data, off)
@@ -212,8 +214,8 @@ jobs:
print(f' line {line_no}: CTRL_0x{val:02X}_PRESENT') print(f' line {line_no}: CTRL_0x{val:02X}_PRESENT')
raise SystemExit(2) raise SystemExit(2)
print('[INFO] Sanity check passed') print('[INFO] Sanity check passed')
PY PY
- name: Enterprise policy gate - name: Enterprise policy gate
run: | run: |
@@ -343,7 +345,7 @@ root = Path(".").resolve()
# Use escape sequences only. Do not introduce literal tab characters. # Use escape sequences only. Do not introduce literal tab characters.
header_re = re.compile(r"(?im)(VERSION[ \t]*:[ \t]*)([0-9]{2}[.][0-9]{2}[.][0-9]{2})") header_re = re.compile(r"(?im)(VERSION[ \t]*:[ \t]*)([0-9]{2}[.][0-9]{2}[.][0-9]{2})")
manifest_marker_re = re.compile(r"(?is)<extension\b\b") # word boundary guard manifest_marker_re = re.compile(r"(?is)<extension\b")
xml_version_re = re.compile(r"(?is)(<version[ \t]*>)([^<]*?)(</version[ \t]*>)") xml_version_re = re.compile(r"(?is)(<version[ \t]*>)([^<]*?)(</version[ \t]*>)")
xml_date_res = [ xml_date_res = [
re.compile(r"(?is)(<creationDate[ \t]*>)([^<]*?)(</creationDate[ \t]*>)"), re.compile(r"(?is)(<creationDate[ \t]*>)([^<]*?)(</creationDate[ \t]*>)"),