From b3c3ce7049d50398785f7a75dd05caf45c4635eb Mon Sep 17 00:00:00 2001 From: Ajimaru Date: Wed, 2 Dec 2026 14:21:00 +0100 Subject: [PATCH] chore: enhance pre-commit hooks and add gitleaks configuration for secret scanning --- .github/workflows/ci.yml | 4 ++++ .gitleaks.toml | 10 ++++++++++ .pre-commit-config.yaml | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 .gitleaks.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da8550c..075c028 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,10 @@ jobs: - name: Run pre-commit if: env.LINT == 'pre-commit' + # Local-only hooks: the branch guard, and the secret scan of staged changes + # (GitHub push protection covers pushes). + env: + SKIP: no-commit-to-branch,gitleaks run: | python -m pip install pre-commit pre-commit run --all-files --show-diff-on-failure diff --git a/.gitleaks.toml b/.gitleaks.toml new file mode 100644 index 0000000..6a250fc --- /dev/null +++ b/.gitleaks.toml @@ -0,0 +1,10 @@ +# Secret scan settings shared by all plugin repos (gitleaks pre-commit hook). +[extend] +useDefault = true +# The generic rule flags settings key names and test IDs, not secrets, in these repos. +disabledRules = ["generic-api-key"] + +[[allowlists]] +description = "Third-party bundles and documentation placeholders" +paths = ['''(^|/)(3rdPartySoftware|vendor)/''', '''\.min\.js$'''] +regexes = ['''YOUR_[A-Z_]+'''] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4a4cbd3..42e79ea 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,6 +14,17 @@ repos: args: [--unsafe] - id: check-toml - id: check-merge-conflict + - id: check-added-large-files + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: detect-private-key + # Changes go through feature branches and pull requests. + - id: no-commit-to-branch + args: [--branch, main, --branch, dev, --branch, master, --branch, testing] + - repo: https://github.com/gitleaks/gitleaks + rev: v8.30.1 + hooks: + - id: gitleaks - repo: https://github.com/PyCQA/isort rev: 9.0.2 hooks: @@ -46,3 +57,16 @@ repos: rev: v0.11.0.1-1 hooks: - id: shellcheck + - repo: https://github.com/rhysd/actionlint + rev: v1.7.12 + hooks: + - id: actionlint + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.39.0 + hooks: + - id: check-github-workflows + - id: check-dependabot + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.27 + hooks: + - id: validate-pyproject