From d1f7aceafd1ee84216a5783d4579c77344b1b793 Mon Sep 17 00:00:00 2001 From: Levi Durfee Date: Sat, 17 Oct 2026 15:04:23 +0000 Subject: [PATCH 1/2] Add repo-setup v1 config for Claude Code Record this repo's working rules so Claude Code follows them: the check command, the commit policy, and that feature branches and pull requests target development rather than main. The new make check target runs vet and test, so the default pre-commit check works here. The threat model in .claude/claude-security-guidance.md feeds the security-guidance reviewers. It names the token, redirect and server-text rules the client already enforces. Co-Authored-By: Claude Opus 5.5 --- .claude/claude-security-guidance.md | 29 +++++++++++++++++++++++++++++ .claude/repo-setup.json | 15 +++++++++++++++ .claude/settings.json | 14 ++++++++++++++ CLAUDE.md | 21 +++++++++++++++++++++ Makefile | 5 ++++- 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 .claude/claude-security-guidance.md create mode 100644 .claude/repo-setup.json create mode 100644 .claude/settings.json create mode 100644 CLAUDE.md diff --git a/.claude/claude-security-guidance.md b/.claude/claude-security-guidance.md new file mode 100644 index 0000000..11d0703 --- /dev/null +++ b/.claude/claude-security-guidance.md @@ -0,0 +1,29 @@ +# Security guidance for this repo + + + +## What this repo is + +- Type: library (Go client for the rypt API, encryption as a service in front of Google Cloud KMS) +- Languages: go +- Exposure: imported by other programs; it makes outbound HTTPS calls to https://api.rypt.dev (or a caller-chosen base URL) and listens on nothing + +## Trust boundaries + +- Untrusted input enters through: API responses (status, headers such as Retry-After, and JSON bodies, including server text copied into errors), and caller arguments to exported functions (ids interpolated into URL paths, base URL, HTTP client, plaintexts and data keys) +- Secrets come from: the caller, who passes an API token or console session token to `NewClient` and plaintexts and data keys as byte slices; the examples and integration tests read `RYPT_TOKEN` and `RYPT_KEY_ID` from the environment; never from the repo + +## Rules + +- Every query that touches tenant data filters by tenant ID. +- Every external input is validated before use in SQL, shell, file paths, or templates. +- Cryptography uses the standard library or a vetted library; no custom primitives. +- Errors returned to clients never include stack traces, SQL, or secrets. +- The token is sent only to the configured base URL over https (plain http only to a loopback host), and redirects are never followed. +- Server-supplied text in an error has control and format characters removed and any copy of the token redacted before it is kept. +- Plaintexts, data keys and request/response bodies that carry them stay byte slices, and the client clears its own copies when a call ends. + +## Known exceptions + +- The tenant-ID rule does not apply here: the library has no data store, and the API enforces tenancy through the token's container. diff --git a/.claude/repo-setup.json b/.claude/repo-setup.json new file mode 100644 index 0000000..fe45651 --- /dev/null +++ b/.claude/repo-setup.json @@ -0,0 +1,15 @@ +{ + "rules_version": 1, + "claude_commits": true, + "config_in_git": true, + "github_config": true, + "repo_type": ["library"], + "languages": ["go"], + "check_command": "make check", + "sbom": true, + "default_branch": "main", + "taskd_project": "rypt", + "required_checks": ["test", "lint", "vulncheck"], + "ruleset_include": ["~DEFAULT_BRANCH", "refs/heads/development"], + "security_scan": { "initial": "pending" } +} diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..3ae2463 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,14 @@ +{ + "permissions": { + "allow": [ + "Bash(git commit *)", + "Bash(git push *)", + "Bash(gh pr create *)", + "Bash(gh pr view *)", + "Bash(gh pr checks *)" + ] + }, + "enabledPlugins": { + "gopls-lsp@claude-plugins-official": true + } +} diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..b1a5711 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,21 @@ + +## Repo facts + +- Repo type: library +- Languages: go +- Check command: `make check` +- Versioning: SemVer tags `vMAJOR.MINOR.PATCH` +- Default branch: `main` +- Claude may commit: yes +- taskd project: rypt + + +## Branching + +This repo does not use plain GitHub Flow. It overrides the global branching +rules as follows; [CONTRIBUTING.md](CONTRIBUTING.md) has the details. + +- Feature branches start from `development`, not `main`. +- Pull requests target `development`: run `gh pr create --base development`. +- A release is a pull request from `development` into `main`, then a `v*` + tag on the merge commit. Hotfixes branch from `main` as `hotfix/...`. diff --git a/Makefile b/Makefile index 28c52dc..8cd0a15 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,12 @@ GO ?= go -.PHONY: all test race vet cover fuzz integration +.PHONY: all check test race vet cover fuzz integration all: vet test +# check is what runs before every commit. +check: vet test + test: $(GO) test ./... From 36bb711ce9a623acd1d0177e3c5be6b1aff57bd3 Mon Sep 17 00:00:00 2001 From: Levi Durfee Date: Sat, 17 Oct 2026 17:12:55 +0000 Subject: [PATCH 2/2] Deny destructive git push and commit forms The allow rules let Claude push and commit without a prompt, but their wildcards also approved forms that run commands (--receive-pack, --exec), rewrite or delete remote refs (--force, --delete, --mirror, --prune, colon refspecs), or skip hooks (--no-verify). Deny rules take precedence over allow rules, so those forms are now refused while ordinary pushes still need no prompt. Co-Authored-By: Claude Opus 5.5 --- .claude/settings.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.claude/settings.json b/.claude/settings.json index 3ae2463..bb2f629 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -6,6 +6,18 @@ "Bash(gh pr create *)", "Bash(gh pr view *)", "Bash(gh pr checks *)" + ], + "deny": [ + "Bash(git push *--receive-pack*)", + "Bash(git push *--exec*)", + "Bash(git push *--force*)", + "Bash(git push *--delete*)", + "Bash(git push -d *)", + "Bash(git push * -d *)", + "Bash(git push *--mirror*)", + "Bash(git push *--prune*)", + "Bash(git push *:*)", + "Bash(git commit *--no-verify*)" ] }, "enabledPlugins": {