Skip to content

Commit 8541f68

Browse files
harden: add .gitattributes (eol=lf) + UTF-8 Encoding Guard workflow (#6)
Prevents two recurring issues found in the 2026-05-24 hardening wave: - .gitattributes `* text=auto eol=lf`: stops the CRLF churn that appeared on Windows clones (dozens of phantom-modified files). - Encoding Guard: a CI check that fails if any .github/ file is not valid UTF-8, catching the CP-1252 0x97 em-dash byte that silently broke zizmor's audit on HexGol (the audit aborted before reporting any findings). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9124989 commit 8541f68

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Normalize line endings to LF in the repo. Prevents the CRLF churn that shows
2+
# up on Windows clones and stops CP-1252 control bytes (e.g. 0x97 em-dash) from
3+
# silently breaking UTF-8 tools like zizmor.
4+
* text=auto eol=lf
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Encoding Guard
2+
3+
on:
4+
push:
5+
paths: [".github/**"]
6+
pull_request:
7+
paths: [".github/**"]
8+
9+
# Least privilege; the job only needs to read the checked-out tree.
10+
permissions: {}
11+
12+
jobs:
13+
utf8:
14+
name: Reject invalid UTF-8 in .github
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
steps:
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
with:
21+
persist-credentials: false
22+
- name: Validate UTF-8 (catches CP-1252 0x97 that silently breaks zizmor)
23+
run: |
24+
python3 - <<'PY'
25+
import pathlib, sys
26+
bad = []
27+
for p in pathlib.Path(".github").rglob("*"):
28+
if p.is_file():
29+
try:
30+
p.read_bytes().decode("utf-8")
31+
except UnicodeDecodeError as e:
32+
bad.append(f"{p}: {e}")
33+
if bad:
34+
print("::error::Invalid UTF-8 (e.g. CP-1252 0x97) found in .github/:")
35+
for b in bad:
36+
print(" " + b)
37+
sys.exit(1)
38+
print("OK: all .github files are valid UTF-8.")
39+
PY

0 commit comments

Comments
 (0)