Bouncer Gates

io.github.ajeermahmood由 GitHub 帳號 ajeermahmood 發布v0.5.0更新於 Oct 24, 2026

Stops secrets, cross-tenant queries and unsafe migrations before they merge.

概覽

AI 產生的概覽

對程式碼倉庫執行五項靜態檢查,找出硬編碼密鑰、未限定租戶的查詢、浮點金額運算、不安全遷移與失效文件連結。

可以做什麼
Bouncer Gates 透過 MCP 提供五項檢查,讓智慧編輯器在撰寫程式碼時呼叫。檢查項目包括:密鑰、作用域(租戶資料表查詢缺少租戶過濾)、金額(以浮點數處理貨幣)、遷移安全(會破壞運行中應用程式的 SQL 遷移),以及文件連結(指向不存在檔案的 Markdown 連結)。每筆結果會指出檔案、行號、問題與建議修正方式,也能用附理由的註解豁免,或寫入基準檔案,讓只有新問題才阻擋。它同時能以命令列工具、編輯後鉤子與 GitHub Action 執行。
適用情境
當助手在倉庫中撰寫或修改程式碼,而你希望在編輯器與 CI 中套用同一道低成本防線時使用。適合有多租戶資料模型、涉及金額處理或 SQL 遷移的團隊,在合併前攔下明顯錯誤。
執行需求
需要 Node.js 與 npx,以 stdio 方式在本機執行這個 npm 套件。變更檔案檢查與遷移檢查需要 git 倉庫。初始化命令會產生選用的設定檔;未宣告任何帳號、API 金鑰或環境變數。
安裝前請注意
它會讀取倉庫檔案並輸出檢查結果,選用的鉤子會掃描助手寫入的每個檔案。除非將 BOUNCER_TELEMETRY 設為 0,否則每天會傳送匿名遙測。它比對文字形態而非理解程式碼,因此可能誤報,也會漏掉跨行或沒有可辨識前綴的密鑰。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Bouncer Gates,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

bouncer-gates

Five checks that stop the expensive mistakes before they merge, whether a person or an agent wrote the code.

Hardcoded secrets. Database queries that leak one customer's data to another. Float maths on money. Migrations that break the running app. Docs that link to files which no longer exist.

Agents write most new code now, and they make exactly these mistakes: a key pasted in to make a test pass, a query with no tenant filter because the prompt never mentioned tenants. bouncer-gates runs inside Claude Code and Cursor, so the agent hears about it in the same turn it wrote it, and again in CI so nothing gets through.

Try it on any repository in ten seconds:

bash
npx bouncer-gates

Or paste some code into the playground and watch the same checks run on it.


Quick start

bash
npx bouncer-gates --init          # writes bouncer-gates.config.json, reads your Prisma schema if you have onenpx bouncer-gates --init-agents   # wires the same checks into Claude Code and Cursor for this reponpx bouncer-gates                 # runs every check and prints what it found

Add it to GitHub Actions:

yaml
steps:  - uses: actions/checkout@v4    with:      fetch-depth: 0             # needed so the migration check can see what is new  - uses: ajeermahmood/bouncer-gates@v0    with:      version: "0.5.0"

That is the whole setup. Everything below is detail.

In the editor, with the agent

--init-agents commits two things into the repository: an MCP server the agent can call, and a hook that scans every file the agent writes. When a file has a blocking finding, the agent sees the file, the line, what is wrong and what to do instead, in the same turn:

x src/orders.ts:12  scope/unscoped-query  "order" is tenant-owned, but nothing in this query mentions "tenantId", so it returns rows from every tenant.  fix: Add tenantId to the where clause, or go through a tenant-scoped client.

Any other MCP client can run npx -y bouncer-gates --mcp, and any post-edit hook can pipe its event to npx -y bouncer-gates --hook. How it works, and what it will not do.

[Bouncer Gates MCP server]

What it checks

CheckCatchesExample of what it stops
secretsPasswords, API keys and private keys committed to the repo, plus a few risky shapes like curl ... | shconst apiKey = "sk_live_...", a committed .env with a real password
scopeQueries on multi-tenant tables that are not limited to one tenantprisma.order.findMany({ where: { status: "paid" } }) with no tenantId
moneyCurrency handled as floats, or * 100 assuming every currency has two decimalsMath.round(parseFloat(price) * 100)
migration-safetySQL migrations that break the version of the app still running during a deployALTER TABLE orders DROP COLUMN total while old code still reads it
doc-linksMarkdown links to files that do not exist[setup](docs/setup.md) after the file moved

Each check exists because of a real, expensive bug. None is a style opinion. The gate reference explains every rule with a bad example and a fixed one.

When it finds something

Every finding names the file, the line, what is wrong and what to do instead:

  FAIL  scope
    x src/orders.ts:2  scope/unscoped-query      "order" is tenant-owned, but nothing in this query mentions "tenantId", so it returns rows from every tenant.      fix: Add tenantId to the where clause, or go through a tenant-scoped client.

You have three options, in this order:

  1. Fix it. Usually the right answer.
  2. Explain why it is fine. Put a comment on the line, or the line above it, with a reason. The reason is required; a bare marker does nothing.
    js
    // bouncer-gates-ok(scope): nightly revenue report spans every tenant by designconst all = await prisma.order.findMany();
  3. Record existing problems so only new ones block. On a codebase that already has findings, run this once and commit the file it writes:
    bash
    npx bouncer-gates --baseline-write
    Old findings stop blocking. Anything new still does. The file is readable, and the count in it should only ever go down.

Configuration

bouncer-gates --init writes this for you. Edit it by hand any time.

json
{  "exclude": ["fixtures/**"],  "scope": {    "models": ["order", "customer"],    "tables": ["orders", "customers"],    "column": "tenantId",    "clients": ["prisma"],    "rawAccessor": "raw"  },  "doc-links": { "repoUrl": "https://github.com/you/your-repo" }}
  • exclude: files not to scan at all. The run prints how many files each pattern removed, every time, so the list cannot grow quietly.
  • scope.models / tables: the models and tables that belong to a tenant. --init fills these from any model in your Prisma schema that has a tenantId field.
  • scope.clients: plain client names, like prisma, whose queries should be checked for the tenant column. Use this when you do not have a scoped wrapper.
  • scope.rawAccessor: if you do have a scoped wrapper, this is the name of the raw client it hides, like db.raw. Reaching for it gets flagged.
  • doc-links.repoUrl: lets absolute links back to your own repository be checked as file paths too.

Without a scope section, the scope check reports skipped, not passed.

All the commands

bash
npx bouncer-gates                        # every check, whole repositorynpx bouncer-gates --init                 # write a starter confignpx bouncer-gates --init-agents          # wire the gates into Claude Code and Cursornpx bouncer-gates --mcp                  # serve the gates over MCP, for any agentic editornpx bouncer-gates --hook                 # scan the file named by a hook event on stdinnpx bouncer-gates --changed              # only files this branch touchednpx bouncer-gates --only scope,money     # just some checksnpx bouncer-gates --explain scope        # what a check does and how to excuse a casenpx bouncer-gates --baseline-write       # record existing findingsnpx bouncer-gates --json                 # machine-readable outputnpx bouncer-gates --sarif                # for the GitHub Security tab

Exit code 0 means clean, 1 means something blocked, 2 means the tool itself could not run (bad flag, broken config, not a git repository). CI treats 1 and 2 differently on purpose: a broken tool should not look like a codebase full of problems.

What it does not do

Honest limits, so nobody trusts it further than it deserves:

  • It matches shapes in text. It does not understand your code. A tenant filter built in a helper the check cannot see will be reported, and the comment above is the fix.
  • The money and scope checks only read JavaScript and TypeScript.
  • The migration check only reads .sql files. Migrations written in JavaScript or TypeScript are not checked.
  • Secrets split across lines, or with no recognisable prefix, are not found. For deep history scanning use gitleaks or trufflehog; this is the cheap guard on the door, not the audit.
  • A query inside prisma.$transaction(async (tx) => ...) uses a client the check cannot follow.

Every rule's blind spots are listed in the gate reference.

Words used here

  • Gate or check: one of the five things it looks for.
  • Finding: one problem it reports, with a file and line.
  • Blocking: a finding that makes the run exit 1. Warnings do not.
  • Baseline: the file that records findings you have chosen to live with for now, so only new ones block.
  • Acknowledge or excuse: the bouncer-gates-ok comment that says a specific line is fine, and why.

Telemetry

One anonymous ping a day: a random id, the version, the runtime, the OS and the Node major. Nothing about your code, ever. BOUNCER_TELEMETRY=0 turns it off. Everything it sends.

More

Development

bash
npm installnpm test                        # unit testsnpm run check                   # bouncer-gates on itselfnpm run bench -- ../some-repo   # measure against a real codebasenpm run dev                     # the playground site

Licence

MIT. Take any of it.

Built by Ajeer Mohammed. The rules come from the checks that gate a multi-tenant platform where most of the code is written by a coding agent, and where missing one meant a merchant seeing another merchant's orders. How that workflow fits together.

來源:README.md,提交 a12b315

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.5.0最新Sep 20, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分