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
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM ubuntu:22.04

# Install gitleaks for local secret scanning
COPY --from=ghcr.io/gitleaks/gitleaks:v8.30.1 /usr/bin/gitleaks /usr/local/bin/gitleaks

# Install prerequisites
RUN set -x \
&& export DEBIAN_FRONTEND=noninteractive \
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Gitleaks

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read

jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Scan Git history for secrets
run: make gitleaks
4 changes: 4 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title = "annowork-api-python-client gitleaks config"

[extend]
useDefault = true
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.30.1
hooks:
- id: gitleaks
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
GITLEAKS_VERSION := v8.30.1
GITLEAKS_DOCKER_CONFIG ?=


ifndef SOURCE_FILES
export SOURCE_FILES:=annoworkapi
Expand All @@ -22,3 +25,22 @@ test:

docs:
cd docs && uv run make html

.PHONY: gitleaks

gitleaks:
@if command -v gitleaks >/dev/null 2>&1; then \
gitleaks git --redact=100 --verbose --log-opts="-m HEAD" .; \
elif command -v docker >/dev/null 2>&1; then \
if [ -n "${GITLEAKS_DOCKER_CONFIG}" ]; then \
mkdir -p "${GITLEAKS_DOCKER_CONFIG}"; \
export DOCKER_CONFIG="${GITLEAKS_DOCKER_CONFIG}"; \
fi; \
docker run --rm \
-v "$$(pwd):$$(pwd):ro" \
-v "$$(git rev-parse --path-format=absolute --git-common-dir):$$(git rev-parse --path-format=absolute --git-common-dir):ro" \
-w "$$(pwd)" ghcr.io/gitleaks/gitleaks:${GITLEAKS_VERSION} git --redact=100 --verbose --log-opts="-m HEAD" .; \
else \
echo "gitleaksまたはdockerをインストールしてください。" >&2; \
exit 127; \
fi
15 changes: 15 additions & 0 deletions README_for_developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,18 @@ ReadTheDocsのビルド結果は https://readthedocs.org/projects/annowork-api-p




## シークレット検査

`make gitleaks` で現在のブランチの Git 履歴(マージ時の変更を含む)を検査します。gitleaks をインストール済みならそのコマンドを使い、未インストールなら Docker で v8.30.1 を実行します。検出値はログでマスクします。CI でも同じ検査を実行します。

DevContainer には gitleaks v8.30.1 を同梱しています。既存のコンテナは再ビルドしてください。

コミット前の差分検査には pre-commit フックを利用できます。

```sh
uv sync --locked
uv run pre-commit install
```

Docker の接続先・認証設定は、通常利用している設定を引き継ぎます。設定ディレクトリを明示的に切り替える場合のみ、`GITLEAKS_DOCKER_CONFIG=/tmp/gitleaks-docker-config make gitleaks` のように指定してください。
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test = [
"more-itertools>=11.2.1",
]
linter = [
"pre-commit>=4.7.0",
"ruff>=0.17.2",
"mypy>=2.4.0",
"types-requests>=2.33.0.20261006",
Expand Down
146 changes: 146 additions & 0 deletions uv.lock

Large diffs are not rendered by default.

Loading