Skip to content

Commit 6320567

Browse files
Add public boundary scan
1 parent b0e7d00 commit 6320567

3 files changed

Lines changed: 104 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Public Boundary
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
scan:
12+
name: Scan public boundary
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Scan files and commit metadata
21+
shell: bash
22+
run: |
23+
set -euo pipefail
24+
25+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
26+
range="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
27+
elif [[ "${{ github.event.before }}" =~ ^0+$ ]]; then
28+
range="${{ github.sha }}^..${{ github.sha }}"
29+
else
30+
range="${{ github.event.before }}..${{ github.sha }}"
31+
fi
32+
33+
PUBLIC_BOUNDARY_GIT_RANGE="$range" scripts/check-public-boundary.sh

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ $ GIT_USER=<Your GitHub username> yarn deploy
3939
```
4040

4141
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
42+
43+
## Public Boundary Checks
44+
45+
This is a public repository. Do not add private tracker names, workspace-only absolute paths, or loop/lane metadata to files or new commit metadata. Run `scripts/check-public-boundary.sh` before publishing changes; CI runs the same scan on pushes and pull requests.

scripts/check-public-boundary.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
root="${1:-.}"
5+
cd "$root"
6+
7+
status=0
8+
9+
file_patterns=(
10+
"zor""poration/"
11+
"/home/""vscode"
12+
"/home/lab/""workspace-hq"
13+
)
14+
15+
metadata_patterns=(
16+
"${file_patterns[@]}"
17+
"Loop""-ID:"
18+
".tmp/""loops/"
19+
"loop-""runner"
20+
)
21+
22+
pathspec=(
23+
.
24+
':!.git'
25+
':!vendor'
26+
':!node_modules'
27+
':!build'
28+
':!dist'
29+
':!coverage'
30+
':!storage'
31+
':!bootstrap/cache'
32+
':!public/build'
33+
':!var'
34+
)
35+
36+
for pattern in "${file_patterns[@]}"; do
37+
while IFS=: read -r file line _; do
38+
[[ -n "${file:-}" ]] || continue
39+
printf 'public-boundary: forbidden file content at %s:%s\n' "$file" "$line" >&2
40+
status=1
41+
done < <(git grep -n -I -e "$pattern" -- "${pathspec[@]}" || true)
42+
done
43+
44+
if [[ -n "${PUBLIC_BOUNDARY_GIT_RANGE:-}" ]]; then
45+
read -r -a rev_args <<< "$PUBLIC_BOUNDARY_GIT_RANGE"
46+
else
47+
rev_args=(-1 HEAD)
48+
fi
49+
50+
if mapfile -t commits < <(git rev-list "${rev_args[@]}" 2>/dev/null); then
51+
for commit in "${commits[@]}"; do
52+
metadata="$(git show -s --format='%an <%ae>%n%s%n%b' "$commit")"
53+
54+
for pattern in "${metadata_patterns[@]}"; do
55+
if grep -Fq -- "$pattern" <<< "$metadata"; then
56+
printf 'public-boundary: forbidden commit metadata at %s\n' "${commit:0:12}" >&2
57+
status=1
58+
break
59+
fi
60+
done
61+
done
62+
else
63+
printf 'public-boundary: unable to inspect commit metadata range: %s\n' "${PUBLIC_BOUNDARY_GIT_RANGE:-HEAD}" >&2
64+
status=1
65+
fi
66+
67+
exit "$status"

0 commit comments

Comments
 (0)