From 2fc8eedd6e17451646611de957adcb3ac0725dac Mon Sep 17 00:00:00 2001 From: Jonathan Miller <230051081+jmiller-moko@users.noreply.github.com> Date: Tue, 23 Dec 2025 17:15:21 -0600 Subject: [PATCH] Update version_branch.yml --- .github/workflows/version_branch.yml | 56 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/.github/workflows/version_branch.yml b/.github/workflows/version_branch.yml index f2dabc3..61266d9 100644 --- a/.github/workflows/version_branch.yml +++ b/.github/workflows/version_branch.yml @@ -182,38 +182,40 @@ jobs: moko_init "Sanity check workflow file" python3 - <<'PY' - from pathlib import Path +from pathlib import Path - target = Path('.github/workflows/version_branch.yml') - if not target.exists(): - raise SystemExit('[FATAL] Missing workflow file: .github/workflows/version_branch.yml') +target = Path('.github/workflows/version_branch.yml') +if not target.exists(): + 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). - # Report line numbers without printing the raw characters. - def byte_to_line(blob: bytes, idx: int) -> int: - return blob[:idx].count(b'\n') + 1 +# Disallow literal tab (0x09) and other ASCII control characters except LF (0x0A) and CR (0x0D). +# Report line numbers without printing the raw characters. - bad = [] - for i, b in enumerate(data): - if b == 0x09: - bad.append(('TAB', i, b)) - elif b < 0x20 and b not in (0x0A, 0x0D): - bad.append(('CTRL', i, b)) +def byte_to_line(blob: bytes, idx: int) -> int: + return blob[:idx].count(b' +') + 1 - if bad: - print('[ERROR] Disallowed characters detected in workflow file:') - for kind, off, val in bad[:200]: - line_no = byte_to_line(data, off) - if kind == 'TAB': - print(f' line {line_no}: TAB_PRESENT') - else: - print(f' line {line_no}: CTRL_0x{val:02X}_PRESENT') - raise SystemExit(2) +bad = [] +for i, b in enumerate(data): + if b == 0x09: + bad.append(('TAB', i, b)) + elif b < 0x20 and b not in (0x0A, 0x0D): + bad.append(('CTRL', i, b)) - print('[INFO] Sanity check passed') - PY +if bad: + print('[ERROR] Disallowed characters detected in workflow file:') + for kind, off, val in bad[:200]: + line_no = byte_to_line(data, off) + if kind == 'TAB': + print(f' line {line_no}: TAB_PRESENT') + else: + print(f' line {line_no}: CTRL_0x{val:02X}_PRESENT') + raise SystemExit(2) + +print('[INFO] Sanity check passed') +PY - name: Enterprise policy gate run: | @@ -343,7 +345,7 @@ root = Path(".").resolve() # 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})") -manifest_marker_re = re.compile(r"(?is))([^<]*?)()") xml_date_res = [ re.compile(r"(?is)()([^<]*?)()"),