harden(ci): enhanced SEV-2499 drift guard catches all truncation patterns (#2499) #2536
Reference in New Issue
Block a user
Delete Branch "fix/sev-2499-enhanced-drift-guard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Enhances the existing KI-013 drift-prevention guard so it catches ANY workspace-ID truncation pattern, not just the historical
:0:12.Checks added
\${VAR:0:N}(any N < 20)cuttruncation:cut -c1-N/cut -c 1-Nawk substr:substr(...,1,N)ws-/docker/container/volume, avoiding false positives on unrelated truncation (git SHAs, timestamps).Scope expanded
tests/e2e/*.shonlytests/e2e/and.gitea/scripts/(provisioning shells)Local verification
bash .gitea/scripts/lint-e2e-ki013-container-names.sh→ PASSgolangci-lint run ./...→ 0 issuesgo build ./...&go vet ./...→ greenRefs #2499
8a027e5de3tobcf889784aExpands the existing lint-e2e-ki013-container-names.sh from a single :0:12 check to a comprehensive guard that catches ANY workspace-ID truncation in container/volume naming context: - Bash substring: ${VAR:0:N} (any N < 20) - cut truncation: cut -c1-N / cut -c 1-N - awk substr: substr(...,1,N) - Context-aware: only flags lines that also reference ws- / docker / container / volume, avoiding false positives on unrelated truncation (git SHAs, timestamps). - Expanded scan scope: tests/e2e/ AND .gitea/scripts/ (provisioning shells). Refs #2499 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>bcf889784atoca0c049444APPROVE — 1st-genuine, correctness lane.
Solid drift-guard hardening: extends the KI-013 lint from the single
:0:12literal to all truncation shapes (bash${VAR:0:N},cut -c1-N/cut -c 1-N,awk substr(...,1,N)), and gates on a container/volume/ws-context keyword so legitimate non-naming truncation (short SHAs, timestamps) isn't falsely flagged. Now also scans.gitea/scripts/. ERR propagation is correct —check_filesets the globalERRand the driver loop uses process substitution (< <(find ...)), not a pipe, so the flag isn't lost to a subshell. Fails closed (exit 1) on any hit — right direction for a guard.MINOR (non-blocking): the N-range regex
[1-9][0-9]?matches N=1–99, not the "N = 1–19 / allow N ≥ 20" the header comment claims — so:0:20…:0:99(and:0:36) would be flagged despite the stated allowance. Harmless because it errs STRICTER (any workspace-ID truncation is what KI-013 forbids), but the comment and regex disagree — either tighten the pattern to([1-9]|1[0-9])or fix the comment to match the actual behaviour. Not blocking; approving.APPROVED on head
ca0c049444.5-axis: the SEV-2499/KI-013 drift guard is scoped to shell linting, expands detection beyond the old literal :0:12 case, and scans both tests/e2e and .gitea/scripts. The context filter keeps it focused on container/volume/workspace naming; the noted N=1-99 vs comment is stricter than the comment and safe. No secret/auth/destructive-op or performance concern found. Required CI is green, trusted SOP is green, PR is mergeable, and agent-researcher approval 10653 is current-head.