Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -21,14 +23,13 @@ jobs:
run: python -m pytest tests/ -v

scan-secrets:
name: Secret Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history so gitleaks can scan all commits
- name: Trivy secret scan
uses: aquasecurity/trivy-action@master
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
scanners: secret
Expand All @@ -41,7 +42,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Trivy CVE scan (warn only)
uses: aquasecurity/trivy-action@master
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
scanners: vuln
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: gitleaks

on:
push:
pull_request:

permissions:
contents: read

jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install gitleaks
run: |
curl -sSfL https://github.com/gitleaks/gitleaks/releases/download/v8.28.0/gitleaks_8.28.0_linux_x64.tar.gz | tar -xz gitleaks
sudo mv gitleaks /usr/local/bin/
- name: Scan full history
run: gitleaks detect --source . --config .gitleaks.toml --no-banner --redact --log-opts=--all
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,19 @@ venv/
# Local knowledge base copy
knowledge_base.txt
sync_manifest.json

# Hive76 template (ops/repo-template/.gitignore)
*.env
.env*
!*.env.example
secrets/
*.key
*.pem
id_*
!id_*.pub
*.sql
*.sql.gz
*.dump
*.csv
.superpowers/
.pytest_cache/
19 changes: 19 additions & 0 deletions git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Block commits that contain secrets. Installed with: git config core.hooksPath git-hooks
set -euo pipefail
# Hooks and runuser get a minimal PATH; the pinned gitleaks lives in /usr/local/bin.
export PATH="$PATH:/usr/local/bin:/opt/homebrew/bin"

if ! command -v gitleaks >/dev/null 2>&1; then
echo "pre-commit: gitleaks is not installed; refusing to commit unscanned changes." >&2
exit 1
fi

root=$(git rev-parse --show-toplevel)
cfg=()
[ -f "$root/.gitleaks.toml" ] && cfg=(--config "$root/.gitleaks.toml")

if ! gitleaks protect --staged "${cfg[@]}" --no-banner --redact; then
echo "pre-commit: possible secret in staged changes. Secrets belong in /etc/hive76/secrets/, never in git." >&2
exit 1
fi
19 changes: 19 additions & 0 deletions git-hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Refuse to force-push or delete main. GitHub's free org plan can't protect branches in
# private repos, so this hook is the guard. Installed with: git config core.hooksPath git-hooks
set -euo pipefail

zero=0000000000000000000000000000000000000000
status=0
while read -r _local_ref local_sha remote_ref remote_sha; do
[ "$remote_ref" = refs/heads/main ] || continue
if [ "${local_sha//0/}" = "" ]; then
echo "pre-push: refusing to delete main." >&2
status=1
elif [ "$remote_sha" != "$zero" ] && ! git merge-base --is-ancestor "$remote_sha" "$local_sha" 2>/dev/null; then
echo "pre-push: refusing to force-push main (it would drop commits already on GitHub)." >&2
echo "pre-push: run 'git pull' and push again; to undo a pushed commit, use 'git revert'." >&2
status=1
fi
done
exit $status
Loading