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
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ for pattern in "${PATTERNS[@]}"; do
fi
FAILED=1
echo "ERROR: Possible secret matching '$pattern':"
echo " $content"
echo " (matching line hidden, ${#content} chars; find it with: git diff --cached)"
fi
done <<< "$MATCHES"
fi
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,30 @@ jobs:
node-version: 22
- run: npm ci
- run: npm test

secret-scan:
runs-on: ubuntu-latest
permissions:
contents: read
env:
GITLEAKS_VERSION: 8.30.1
# sha256 of gitleaks_8.30.1_linux_x64.tar.gz, from the release's checksums.txt
GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install gitleaks (pinned, checksum verified)
run: |
set -euo pipefail
tarball="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
curl -sSfL -o "$RUNNER_TEMP/$tarball" \
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${tarball}"
echo "${GITLEAKS_SHA256} $RUNNER_TEMP/$tarball" | sha256sum --check --strict
mkdir -p "$RUNNER_TEMP/gitleaks"
tar -xzf "$RUNNER_TEMP/$tarball" -C "$RUNNER_TEMP/gitleaks" gitleaks
"$RUNNER_TEMP/gitleaks/gitleaks" version
- name: Scan full git history
# --redact keeps secret values out of the log. Verified false positives
# are listed by fingerprint in .gitleaksignore.
run: '"$RUNNER_TEMP/gitleaks/gitleaks" git --redact --no-banner --verbose --log-opts=HEAD .'
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ dist/
.env
.env.*
!.env.example
*.pem
*.key
*.p12
*.pfx
*.keystore
id_rsa*
id_ecdsa*
id_ed25519*
*.token
credentials.json
service-account*.json
.aws/
# npm auth tokens: the root .npmrc is tracked on purpose (no token, only
# min-release-age). Use ${NPM_TOKEN} in CI, never a literal token.
.npmrc
!/.npmrc

# OS
.DS_Store
Expand Down
10 changes: 10 additions & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Verified false positives only: fake Slack tokens used as fixtures in test/setup-slack.test.ts
# (placeholder digits like A0123456789-1234567890). Fingerprint = commit:file:rule:line.
141d0949f621d27b4f55319ba74b5992e6e29c7b:test/setup-slack.test.ts:slack-app-token:19
141d0949f621d27b4f55319ba74b5992e6e29c7b:test/setup-slack.test.ts:slack-app-token:37
141d0949f621d27b4f55319ba74b5992e6e29c7b:test/setup-slack.test.ts:slack-app-token:86
141d0949f621d27b4f55319ba74b5992e6e29c7b:test/setup-slack.test.ts:slack-legacy-workspace-token:36
16ed51f1b97aa99586ffb85af9f563236546d9cd:test/setup-slack.test.ts:slack-app-token:19
16ed51f1b97aa99586ffb85af9f563236546d9cd:test/setup-slack.test.ts:slack-app-token:37
16ed51f1b97aa99586ffb85af9f563236546d9cd:test/setup-slack.test.ts:slack-app-token:94
16ed51f1b97aa99586ffb85af9f563236546d9cd:test/setup-slack.test.ts:slack-legacy-workspace-token:36
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Block commits that contain secrets (see CONTRIBUTING.md).
scripts/scan-staged-secrets.sh
.githooks/pre-commit
2 changes: 2 additions & 0 deletions .secretlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
package-lock.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scan the lockfile for staged secrets

When package-lock.json contains a credential-bearing private dependency URL or another secret, this ignore rule skips it in the staged secretlint scan; the fallback .githooks/pre-commit checks only a few token assignments and key prefixes, so such credentials can pass the pre-commit hook. Scan the lockfile too, or replace this blanket exclusion with targeted suppressions.

Useful? React with 👍 / 👎.

22 changes: 22 additions & 0 deletions .secretlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"rules": [
{
"id": "@secretlint/secretlint-rule-preset-recommend",
"rules": [
{
"id": "@secretlint/secretlint-rule-slack",
"options": {
"allows": [
"/^(xox[a-z]|xapp)-[a-z-]+$/",
"/^xapp-1-A0123456789-1234567890-/",
"/^xapp-1-A1-1-[a-z]+$/",
"/^xapp-N-AXXXX-/",
"/^xoxb-12345678-90ABCDEF-rest1234$/",
"/^xoxb-99999-99999-/"
]
}
}
]
}
]
}
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Tests write under `$HOME` (`~/.roundhouse`, `~/.pi/agent`, `~/.mcporter`). On a

There is no lint script. TypeScript is executed directly via `tsx`; `tsc` only typechecks and is never invoked at build/runtime. The only "build" happens implicitly when `roundhouse run` prefers a compiled `src/dist/index.js` if present; otherwise it imports `src/index.ts` into its own process (tsx is registered by `bin/roundhouse.mjs`).

The repo uses a custom git hooks path: `git config core.hooksPath .githooks` (already set locally). `.githooks/pre-commit` scans staged diffs for secret patterns (Telegram/Anthropic/OpenAI/AWS/NPM) and blocks commits. Don't bypass with `--no-verify` unless the user asks.
Git hooks are installed by husky (`prepare: husky || true`, so `core.hooksPath` is `.husky/_`). `.husky/pre-commit` runs `scripts/scan-staged-secrets.sh` (secretlint over the staged blobs, config `.secretlintrc.json`) and then `.githooks/pre-commit` (pattern scan of added lines: Telegram/Anthropic/OpenAI/AWS/NPM). CI's `secret-scan` job runs a pinned, checksum-verified gitleaks over the full history; verified false positives go in `.gitleaksignore` by fingerprint. Don't bypass with `--no-verify` unless the user asks.

## Architecture

Expand Down
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributing

## Setup

```bash
npm ci # also installs the git hooks (husky, via the "prepare" script)
npm run typecheck
HOME=$(mktemp -d) npm test
```

## Secret scanning

Secrets must never reach the repository. Two layers enforce it:

- **Pre-commit hook** (`.husky/pre-commit`, installed by `npm ci`). It scans the
*staged* version of every added or changed file with
[secretlint](https://github.com/secretlint/secretlint) (`.secretlintrc.json`,
recommended preset), then runs the pattern check in `.githooks/pre-commit`
(Telegram, Anthropic, OpenAI, AWS, npm). A hit blocks the commit and prints
the file and line with the value masked. Nothing needs to be installed
besides the npm dev dependencies.
- **CI** (`secret-scan` job in `.github/workflows/test.yml`). It runs a pinned,
checksum-verified [gitleaks](https://github.com/gitleaks/gitleaks) over the
full git history on every push to `main` and every pull request.

If the hook blocks you, remove the secret, rotate it if it was real, and commit
again. Do not bypass with `git commit --no-verify`: CI scans every commit, so a
secret that slips past the hook still fails the build, and it is already in
history by then.

False positives (fake tokens in tests): prefer an obviously fake value. If a
test needs a realistic shape, allow that exact shape in `.secretlintrc.json`
(the Slack rule's `allows` list) and, for a commit gitleaks flags, add its
fingerprint (`commit:file:rule:line`) to `.gitleaksignore` after checking it.

To run the history scan locally, download gitleaks from its releases page and run
`gitleaks git --redact --log-opts=HEAD .`.

Set `HUSKY=0` to skip installing hooks (e.g. in a packaging environment).
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,8 @@ npm test # run once
npm run test:watch # watch mode
```

`npm ci` installs a pre-commit hook that blocks commits containing secrets, and CI scans the full git history with gitleaks. See [CONTRIBUTING.md](CONTRIBUTING.md).

## License

MIT
Loading
Loading