Skip to content

Commit 33b4e0e

Browse files
author
saiganakato
committed
fix: bash script parity bugs in gitignore, evidence, delta-audit (v1.1.10)
- check-gitignore-consistency.sh: correct severity field order; blocked exits 1 on bash - collect-audit-evidence.sh: full transcript under set -e; only quickstart fails exit - run-delta-audit.sh: awk instead of python; fix empty diff output - run-audit-quickstart.ps1: isolated workdir copies dotfiles - regression tests for tracked-but-ignored fixture
1 parent 19866f1 commit 33b4e0e

9 files changed

Lines changed: 96 additions & 14 deletions

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this regulation shelf are documented here.
44

55
The detailed shelf changelog lives in `regulation/shelf/SHELF_CHANGELOG.md`.
66

7+
## [1.1.10] - 2026-06-17
8+
9+
### Fixed
10+
11+
- `check-gitignore-consistency.sh` stores finding fields as `severity|category|path|reason` (blocked findings now exit 1 on bash)
12+
- `collect-audit-evidence.sh` collects full transcript under `set -e` (screening/gitignore/gitleaks/pytest/gh no longer abort early)
13+
- `run-delta-audit.sh` uses `awk` instead of `python`; empty changed-path list no longer prints spurious `M` line
14+
- `run-audit-quickstart.ps1` isolated workdir copies dotfiles (`.gitignore`, `.github/`, etc.)
15+
16+
### Added
17+
18+
- regulation tests for tracked-but-ignored fixture and evidence transcript continuity
19+
720
## [1.1.9] - 2026-06-17
821

922
### Fixed

regulation/shelf/SHELF_CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to the generic regulation shelf.
44

5+
## 1.1.10 — 2026-06-17
6+
7+
### Fixed
8+
9+
- bash gitignore consistency severity field order; blocked exit parity with PowerShell
10+
- bash evidence collector no longer aborts on screening/gitignore non-zero
11+
- delta-audit bash: no python dependency; empty diff list output
12+
- quickstart isolated copy includes dotfiles on Windows
13+
514
## 1.1.9 — 2026-06-17
615

716
### Fixed

regulation/shelf/SHELF_VERSION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Status: Active
55
## Current
66

77
```text
8-
1.1.9
8+
1.1.10
99
```
1010

1111
## Meaning

scripts/check-gitignore-consistency.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ REPO_PATH="$(pwd)"
88
declare -a findings=()
99

1010
add_finding() {
11-
findings+=("$2|$3|$1|$4")
11+
local path="$1" category="$2" severity="$3" reason="$4"
12+
findings+=("$severity|$category|$path|$reason")
1213
}
1314

1415
recommended=(

scripts/collect-audit-evidence.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ echo "Tracked files: $(git ls-files | wc -l | tr -d ' ')"
2424

2525
SCREEN_SCRIPT="$(cd "$(dirname "$0")" && pwd)/check-tracked-files.sh"
2626
if [[ -f "$SCREEN_SCRIPT" ]]; then
27+
set +e
2728
bash "$SCREEN_SCRIPT" "$REPO_PATH"
29+
set -e
2830
fi
2931

3032
GITIGNORE_SCRIPT="$(cd "$(dirname "$0")" && pwd)/check-gitignore-consistency.sh"
3133
if [[ -f "$GITIGNORE_SCRIPT" ]]; then
34+
set +e
3235
bash "$GITIGNORE_SCRIPT" "$REPO_PATH"
36+
set -e
3337
fi
3438

3539
section "Large Tracked Files (>512KB)"
@@ -65,23 +69,35 @@ done
6569

6670
section "Gitleaks"
6771
if command -v gitleaks >/dev/null 2>&1; then
72+
set +e
6873
gitleaks detect --source . --no-banner 2>&1 | tail -n 3
74+
set -e
6975
else
7076
echo "gitleaks: not installed"
7177
fi
7278

7379
if [[ -f pytest.ini || -d tests ]]; then
7480
section "Pytest"
75-
python -m pytest -q 2>&1 | tail -n 5
81+
set +e
82+
if command -v python3 >/dev/null 2>&1; then
83+
python3 -m pytest -q 2>&1 | tail -n 5
84+
elif command -v python >/dev/null 2>&1; then
85+
python -m pytest -q 2>&1 | tail -n 5
86+
else
87+
echo "python: not installed"
88+
fi
89+
set -e
7690
fi
7791

7892
if [[ -n "$HOSTED_REPO" ]] && command -v gh >/dev/null 2>&1; then
7993
section "Hosted Metadata"
94+
set +e
8095
gh api "repos/$HOSTED_REPO" --jq '{description, topics: .topics, homepage, visibility}'
8196
gh api "repos/$HOSTED_REPO/community/profile" --jq '{health_percentage}'
8297
gh api "repos/$HOSTED_REPO" --jq '.security_and_analysis'
8398
section "Latest CI"
8499
gh run list -R "$HOSTED_REPO" --limit 3
100+
set -e
85101
fi
86102

87103
MANIFEST_PATH="$REPO_PATH/audit.manifest.yml"

scripts/run-audit-quickstart.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ $tempRoot = $null
3838
if ($workdir -eq "isolated") {
3939
$tempRoot = Join-Path ([System.IO.Path]::GetTempPath()) ("audit-quickstart-" + [guid]::NewGuid().ToString("n"))
4040
New-Item -ItemType Directory -Path $tempRoot | Out-Null
41-
Copy-Item -Path (Join-Path $RepoPath "*") -Destination $tempRoot -Recurse -Force
41+
Get-ChildItem -LiteralPath $RepoPath -Force |
42+
Where-Object { $_.Name -notin '.', '..' } |
43+
ForEach-Object {
44+
Copy-Item -LiteralPath $_.FullName -Destination (Join-Path $tempRoot $_.Name) -Recurse -Force
45+
}
4246
$runRoot = $tempRoot
4347
Write-Output "Isolated workdir: $runRoot"
4448
} else {

scripts/run-delta-audit.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,20 @@ PRESENT_HEAD="$(git rev-parse HEAD)"
6868
PRIOR_FULL="$(git rev-parse "$PRIOR_HEAD")"
6969
PRIOR_COUNT="$(git ls-tree -r --name-only "$PRIOR_FULL" | wc -l | tr -d ' ')"
7070
PRESENT_COUNT="$(git ls-files | wc -l | tr -d ' ')"
71-
DELTA_PERCENT="$(python - <<PY
72-
prior=$PRIOR_COUNT
73-
present=$PRESENT_COUNT
74-
print(round(abs(present-prior)*100.0/prior, 1) if prior else 100.0)
75-
PY
76-
)"
71+
DELTA_PERCENT="$(awk -v prior="$PRIOR_COUNT" -v present="$PRESENT_COUNT" \
72+
'BEGIN{d=present-prior; if (d<0) d=-d; printf "%.1f", (prior ? 100*d/prior : 100)}')"
7773

7874
mapfile -t CHANGED < <(git diff --name-only "$PRIOR_FULL" "$PRESENT_HEAD")
7975
mapfile -t UNTRACKED < <(git ls-files --others --exclude-standard)
8076

8177
invalidations=()
82-
OVER20="$(python -c "print(1 if float('$DELTA_PERCENT') > 20.0 else 0)")"
78+
OVER20="$(awk -v d="$DELTA_PERCENT" 'BEGIN{print (d>20)?1:0}')"
8379
if [[ "$OVER20" == "1" && "$ALLOW_LARGE_DELTA" != "1" ]]; then
8480
invalidations+=("inventory delta ${DELTA_PERCENT}% exceeds 20%")
8581
fi
8682

87-
for p in "${CHANGED[@]:-}"; do
83+
for p in "${CHANGED[@]}"; do
84+
[[ -z "$p" ]] && continue
8885
case "$p" in
8986
LICENSE|SECURITY.md|audit.manifest.yml|.github/workflows/*)
9087
invalidations+=("sensitive path changed: $p")
@@ -113,7 +110,9 @@ echo "Prior tracked count: $PRIOR_COUNT"
113110
echo "Present tracked count: $PRESENT_COUNT"
114111
echo "Inventory delta: ${DELTA_PERCENT}%"
115112
echo "Changed tracked paths: ${#CHANGED[@]}"
116-
for p in "${CHANGED[@]:-}"; do echo " M $p"; done
113+
for p in "${CHANGED[@]}"; do
114+
[[ -n "$p" ]] && echo " M $p"
115+
done
117116
if [[ ${#UNTRACKED[@]} -gt 0 ]]; then
118117
echo "New untracked (non-ignored): ${#UNTRACKED[@]}"
119118
for p in "${UNTRACKED[@]:0:20}"; do echo " ? $p"; done
@@ -137,7 +136,7 @@ if [[ "$DELTA_MODE" == "upgrade-to-full" ]]; then
137136
else
138137
echo "1. Read regulation/execution/RE_AUDIT_POLICY.md delta rules"
139138
echo "2. G-21 full read only changed paths + dependency cone listed above"
140-
echo "3. Rescore gates affected by the change set"
139+
echo "3. Rescore gates affected by the change set; carry forward others only when allowed"
141140
echo "4. Update audits/$SLUG/audit-report.md and fill delta-audit-record.md"
142141
fi
143142
echo "5. Refresh R-02, R-09 when audit mode is release or strict-product"

scripts/tests/run-regulation-tests.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,26 @@ Assert-ExitCode "check-gitignore-consistency on fixture" 0 {
5858
& (Join-Path $Shelf "scripts\check-gitignore-consistency.ps1") -RepoPath $fixture
5959
}
6060

61+
$trackedIgnoredFixture = Join-Path $Shelf "scripts\tests\fixtures\tracked-ignored-repo"
62+
if (-not (Test-Path (Join-Path $trackedIgnoredFixture ".git"))) {
63+
Push-Location $trackedIgnoredFixture
64+
git init | Out-Null
65+
git add README.md LICENSE SECURITY.md .gitignore
66+
git add -f AGENTS.md
67+
git -c user.email="fixture@test" -c user.name="fixture" commit -m "init tracked-ignored fixture" | Out-Null
68+
Pop-Location
69+
}
70+
71+
Assert-ExitCode "check-gitignore-consistency blocked tracked-ignored fixture" 1 {
72+
& (Join-Path $Shelf "scripts\check-gitignore-consistency.ps1") -RepoPath $trackedIgnoredFixture
73+
}
74+
75+
Assert-Pass "collect-audit-evidence completes after blocked gitignore" {
76+
$out = & (Join-Path $Shelf "scripts\collect-audit-evidence.ps1") -RepoPath $trackedIgnoredFixture 2>&1 | Out-String
77+
if ($LASTEXITCODE -ne 0) { throw "expected exit 0, got $LASTEXITCODE" }
78+
if ($out -notmatch "=== Root Files ===") { throw "evidence transcript truncated before Root Files" }
79+
}
80+
6181
$presentHead = (git -C $Shelf rev-parse HEAD)
6282
# v1.1.4 → present always includes audit.manifest.yml change (v1.1.5); stable across future commits
6383
$manifestPriorHead = (git -C $Shelf rev-parse 'v1.1.4^{commit}')

scripts/tests/run-regulation-tests.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ run_exit "check-tracked-files on shelf" 0 bash "$SHELF/scripts/check-tracked-fil
4040
run_exit "check-tracked-files on fixture" 0 bash "$SHELF/scripts/check-tracked-files.sh" "$FIXTURE"
4141
run_exit "check-gitignore-consistency on shelf" 0 bash "$SHELF/scripts/check-gitignore-consistency.sh" "$SHELF"
4242
run_exit "check-gitignore-consistency on fixture" 0 bash "$SHELF/scripts/check-gitignore-consistency.sh" "$FIXTURE"
43+
TRACKED_IGNORED="$SHELF/scripts/tests/fixtures/tracked-ignored-repo"
44+
if [[ ! -d "$TRACKED_IGNORED/.git" ]]; then
45+
git -C "$TRACKED_IGNORED" init
46+
git -C "$TRACKED_IGNORED" add README.md LICENSE SECURITY.md .gitignore
47+
git -C "$TRACKED_IGNORED" add -f AGENTS.md
48+
git -C "$TRACKED_IGNORED" -c user.email=fixture@test -c user.name=fixture commit -m "init tracked-ignored fixture"
49+
fi
50+
run_exit "check-gitignore-consistency blocked tracked-ignored fixture" 1 \
51+
bash "$SHELF/scripts/check-gitignore-consistency.sh" "$TRACKED_IGNORED"
52+
echo "TEST: collect-audit-evidence completes after blocked gitignore"
53+
set +e
54+
evidence_out="$(bash "$SHELF/scripts/collect-audit-evidence.sh" "$TRACKED_IGNORED" 2>&1)"
55+
evidence_code=$?
56+
set -e
57+
if [[ "$evidence_code" -eq 0 ]] && echo "$evidence_out" | grep -q "=== Root Files ==="; then
58+
echo " PASS"
59+
else
60+
echo " FAIL: expected exit 0 and Root Files section, got exit $evidence_code"
61+
failures=$((failures + 1))
62+
fi
4363
PRESENT_HEAD="$(git -C "$SHELF" rev-parse HEAD)"
4464
# v1.1.4 → present always includes audit.manifest.yml change (v1.1.5); stable across future commits
4565
MANIFEST_PRIOR_HEAD="$(git -C "$SHELF" rev-parse "v1.1.4^{commit}")"

0 commit comments

Comments
 (0)