Compare commits

...

3 Commits

Author SHA1 Message Date
bd7e201df1 Merge pull request 'Add MIT LICENSE' (#3) from chore/add-license into main
All checks were successful
CI / skip-ci-check (push) Successful in 20s
CI / secret-scan (push) Successful in 18s
CI / node-ci (push) Successful in 19s
2026-07-26 14:57:43 -05:00
78e2ef06ac Add MIT LICENSE
All checks were successful
CI / skip-ci-check (pull_request) Successful in 21s
CI / node-ci (pull_request) Successful in 22s
CI / secret-scan (pull_request) Successful in 33s
2026-07-26 14:54:23 -05:00
09e8287b20 ci: add local pre-commit gitleaks hook
All checks were successful
CI / skip-ci-check (push) Successful in 11s
CI / secret-scan (push) Successful in 10s
CI / node-ci (push) Successful in 13s
2026-07-13 14:44:16 -05:00
4 changed files with 103 additions and 0 deletions

View File

@ -1,6 +1,15 @@
# Homelab bootstrap — gitleaks allowlist (tests, examples, placeholders) # Homelab bootstrap — gitleaks allowlist (tests, examples, placeholders)
#
# IMPORTANT: `useDefault = true` is required — without it gitleaks loads ONLY
# this file (title + allowlist) with ZERO detection rules, so it would never
# flag a real secret. Fixed 2026-07 (security-hardening track); if you're
# re-pushing this template to a repo that already had the old version, that
# repo's secret scanning was a no-op until this lands.
title = "homelab gitea bootstrap" title = "homelab gitea bootstrap"
[extend]
useDefault = true
[allowlist] [allowlist]
description = "Test fixtures and example configs are not production secrets" description = "Test fixtures and example configs are not production secrets"
paths = [ paths = [

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ilia Dobkin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
# One-time installer for the local pre-commit gitleaks hook.
# Run once per clone: bash scripts/git-hooks/install.sh
#
# Respects `core.hooksPath` if you've set one (local or global) — some setups
# point git at a hooks dir outside `.git/hooks/` (e.g. a machine-wide
# `~/.git-hooks/`), and installing to `.git/hooks/` in that case would be a
# silent no-op. If an existing hook is already at that path, this chains to
# it so nothing already relying on it breaks.
set -euo pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "$REPO_ROOT"
HOOKS_DIR="$(git config --get core.hooksPath || true)"
if [ -z "$HOOKS_DIR" ]; then
HOOKS_DIR=".git/hooks"
elif [[ "$HOOKS_DIR" != /* ]]; then
HOOKS_DIR="$REPO_ROOT/$HOOKS_DIR"
fi
mkdir -p "$HOOKS_DIR"
TARGET="$HOOKS_DIR/pre-commit"
if [ -f "$TARGET" ] && ! grep -q "gitleaks" "$TARGET" 2>/dev/null; then
echo "⚠️ Existing pre-commit hook found at $TARGET that isn't ours — chaining instead of overwriting."
CHAINED="$HOOKS_DIR/pre-commit.d-gitleaks"
cp scripts/git-hooks/pre-commit "$CHAINED"
chmod +x "$CHAINED"
if ! grep -q "pre-commit.d-gitleaks" "$TARGET" 2>/dev/null; then
printf '\n# Added by levkinops ansible repo (scripts/git-hooks/install.sh)\n"%s"\n' "$CHAINED" >> "$TARGET"
fi
else
cp scripts/git-hooks/pre-commit "$TARGET"
chmod +x "$TARGET"
fi
echo "✓ Installed pre-commit gitleaks hook → $TARGET"
if [ "$HOOKS_DIR" != ".git/hooks" ] && [ "$HOOKS_DIR" != "$REPO_ROOT/.git/hooks" ]; then
echo " (using core.hooksPath=$HOOKS_DIR — applies to every repo that shares this hooksPath)"
fi
if ! command -v gitleaks >/dev/null 2>&1; then
echo " Note: gitleaks isn't installed locally yet. Install it for the hook to actually run:"
echo " macOS: brew install gitleaks"
echo " Linux: see https://github.com/gitleaks/gitleaks#installing"
echo " Until then this hook is a no-op locally (CI still scans every push)."
fi

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Local pre-commit secret scan — mirrors the `secret-scanning` CI job (gitleaks)
# so leaked secrets are caught before they ever leave your machine, not just at
# CI time. Installed via `make install-git-hooks`.
#
# Uses the same .gitleaks.toml allowlist as CI. Only scans staged content.
set -euo pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "$REPO_ROOT"
if ! command -v gitleaks >/dev/null 2>&1; then
echo "⚠️ gitleaks not installed locally — skipping local secret scan."
echo " Install: brew install gitleaks (CI will still catch it either way)"
exit 0
fi
echo "🔐 Running gitleaks on staged changes..."
if ! gitleaks protect --staged --config .gitleaks.toml --no-banner --redact; then
echo ""
echo "❌ gitleaks found a potential secret in your staged changes."
echo " Fix it, or if it's a false positive, add an allowlist entry to .gitleaks.toml."
echo " Bypass (not recommended): git commit --no-verify"
exit 1
fi
echo "✓ gitleaks: no secrets found in staged changes"