ouchbill 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +14 -0
- package/README.md +253 -3
- package/action.yml +96 -0
- package/dist/THIRD_PARTY_NOTICES.txt +3 -0
- package/dist/ouchbill-online.mjs +5 -0
- package/dist/ouchbill.mjs +222 -0
- package/package.json +42 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Copyright (c) 2026 Drevan. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software, including its source code, its built bundles (dist/) and its data tables,
|
|
4
|
+
is proprietary to Drevan and is not open source.
|
|
5
|
+
|
|
6
|
+
No licence is granted to copy, modify, merge, publish, distribute, sublicense or sell this
|
|
7
|
+
software, in whole or in part, or to make works derived from it, except as Drevan agrees in
|
|
8
|
+
writing. Running a copy that Drevan provided to you is permitted only on the terms under
|
|
9
|
+
which Drevan provided it.
|
|
10
|
+
|
|
11
|
+
Third-party components that are bundled into dist/ keep their own licences. Their notices
|
|
12
|
+
are in dist/THIRD_PARTY_NOTICES.txt.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
|
package/README.md
CHANGED
|
@@ -1,3 +1,253 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# ouchbill
|
|
2
|
+
|
|
3
|
+
A local check you run before you ship. It tells you what in a project will break, and what could
|
|
4
|
+
cost you money:
|
|
5
|
+
|
|
6
|
+
1. **What will break, and when.** AI model ids in your code that the provider retires, with file,
|
|
7
|
+
line, date, days left, the provider's suggested replacement and its source page. The same check
|
|
8
|
+
covers runtimes, frameworks, databases, serverless runtimes and GitHub Actions versions that reach
|
|
9
|
+
end of life.
|
|
10
|
+
2. **Is a key sitting in the repo or the build output?** The same key patterns as the
|
|
11
|
+
OuchBill site scanner, with masked output.
|
|
12
|
+
3. **Which usage-billed services does this project use, and does each provider offer a hard
|
|
13
|
+
spending cap?** Read from dependency manifests, env var *names* and infrastructure files.
|
|
14
|
+
|
|
15
|
+
Findings are ranked critical, high, medium, low or unknown, and each has fix steps. The default run
|
|
16
|
+
makes no network calls.
|
|
17
|
+
|
|
18
|
+
It exits 1 when it finds a key, or (with `--fail-on-uncapped`) when the project uses a service with
|
|
19
|
+
no cap declared, so it can fail a CI build.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
npx ouchbill check [dir] # services + cap status + key scan
|
|
23
|
+
npx ouchbill scan [path] # key scan only (files or build output)
|
|
24
|
+
npx ouchbill providers # provider ids the catalog knows
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Privacy: no network by default
|
|
28
|
+
|
|
29
|
+
- **No network calls by default.** ouchbill reads files on disk and prints a result. Without
|
|
30
|
+
`--fresh` or `--online` it does not call any provider, any OuchBill server or any analytics
|
|
31
|
+
service. A test replaces every way Node can reach the network (fetch, http, https, http2, net,
|
|
32
|
+
tls, dns, dgram) and every way to start a process, runs every command on every fixture, and fails
|
|
33
|
+
on a single call. Another test checks that `dist/ouchbill.mjs` imports only `node:fs`, `node:path`
|
|
34
|
+
and, behind those two flags, the separate `dist/ouchbill-online.mjs`. A third puts a booby-trapped
|
|
35
|
+
copy of that file next to the bundle and proves default commands never load it.
|
|
36
|
+
- **`--fresh` contacts ouchbill.com only.** It requests the signed date tables and sends no code,
|
|
37
|
+
paths or file names. The host sees your IP address and a `User-Agent` of `ouchbill/<version>`.
|
|
38
|
+
It needs a free data feed key in the `OUCHBILL_TABLE_KEY` environment variable (ouchbill.com, Settings),
|
|
39
|
+
sent only as `Authorization: Bearer` to `https://ouchbill.com/api/table`, never read from repo files and
|
|
40
|
+
never printed. Without a key no request is made and the bundled tables are used, with a line saying how
|
|
41
|
+
to get one; a refused key (401/403) also falls back. Watermark rows in the served table are dropped
|
|
42
|
+
before scanning. Verified tables are cached in your OS user cache folder under `ouchbill`. **Until the production
|
|
43
|
+
signing key and site are live, `--fresh` uses the bundled data** and says so.
|
|
44
|
+
- **`--online` contacts the listed hosts and rdap.org.** It prints every hostname before connecting,
|
|
45
|
+
does a TLS handshake on port 443 with up to 10 production hostnames found in the repo, and looks up
|
|
46
|
+
their domains through rdap.org, which redirects to the domain's registry. Those parties learn that
|
|
47
|
+
this machine asked about those names. IP addresses, localhost, private names and names that resolve
|
|
48
|
+
to a private address are refused.
|
|
49
|
+
- **No telemetry.** None, opt-in or otherwise.
|
|
50
|
+
- **Env var names only.** ouchbill reads the part before `=` in `.env.example` and similar files,
|
|
51
|
+
and names like `process.env.OPENAI_API_KEY` in code. It never opens `.env`, `.env.local`,
|
|
52
|
+
`.envrc` or any other local env file: they hold real values by design. The report lists them so
|
|
53
|
+
you can check they are git-ignored. From your shell it only checks whether `ANTHROPIC_API_KEY` is
|
|
54
|
+
set (see below), never what it is.
|
|
55
|
+
- **Masked keys only.** A found key is printed as its prefix and last four characters
|
|
56
|
+
(`sk-proj-…a1B2`). The full value is never printed, logged or written to JSON. ouchbill never tests a found key against its provider.
|
|
57
|
+
|
|
58
|
+
## What it prints
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
SERVICE DETECTED BY HARD CAP OFFERED (catalog) YOUR CAP WHERE TO SET IT
|
|
62
|
+
OpenAI API env OPENAI_API_KEY, npm openai yes (verified 2026-11-03) not declared https://platform.openai.com/settings/organization/limits
|
|
63
|
+
Microsoft Azure terraform provider "azurerm" no (verified 2026-11-03) not declared https://portal.azure.com/
|
|
64
|
+
Cloudflare npm wrangler unknown: no confirmed cap not declared https://dash.cloudflare.com/
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- **Hard cap offered** comes from the OuchBill provider catalog, with the date the fact was read on
|
|
68
|
+
the provider's own docs. `unknown` means nobody has confirmed the provider's limit stops spending.
|
|
69
|
+
It is shown as "no confirmed cap", never as "fine", and it never counts as capped.
|
|
70
|
+
- **Your cap** is what your project has declared in `.ouchbill.json`. ouchbill cannot see your
|
|
71
|
+
provider consoles, so "offered" never means "on".
|
|
72
|
+
- ouchbill never says your bill is safe. It tells you what is declared on, what has no cap, what
|
|
73
|
+
is unknown and where to fix it.
|
|
74
|
+
|
|
75
|
+
## Declaring your caps: `.ouchbill.json`
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"caps": {
|
|
80
|
+
"openai": { "status": "on", "checkedOn": "2026-11-15", "note": "org limit + project limits" },
|
|
81
|
+
"azure": { "status": "accepted", "reason": "PAYG has no hard cap; budget alerts at 50/80/100%" }
|
|
82
|
+
},
|
|
83
|
+
"exclude": ["test/fixtures"]
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- `"on"` needs `checkedOn`: the date someone looked at the provider's setting.
|
|
88
|
+
- `"accepted"` needs a `reason`: you know there is no hard cap and chose to run without one.
|
|
89
|
+
- `"on"` counts only where the catalog confirms the provider has a stop (`yes` or `partial`).
|
|
90
|
+
Where the catalog says **no** hard cap, or the cap is **unknown**, `"on"` is reported as
|
|
91
|
+
"declared, not counted" and still fails `--fail-on-uncapped`. Budgets that only send alerts are
|
|
92
|
+
not caps. If you accept running without a confirmed cap, say so with `"accepted"` and a reason.
|
|
93
|
+
- Provider ids come from `ouchbill providers`. An unknown id is an error, so a typo can't pass CI.
|
|
94
|
+
- A config file that contains anything key-shaped is refused (exit 2).
|
|
95
|
+
|
|
96
|
+
## Exit codes
|
|
97
|
+
|
|
98
|
+
| Code | Meaning |
|
|
99
|
+
|---|---|
|
|
100
|
+
| 0 | Nothing failing found |
|
|
101
|
+
| 1 | A key-shaped value was found, or `--fail-on-uncapped` is set and a detected service has no confirmed cap declared (unknown never counts) and no accepted reason |
|
|
102
|
+
| 2 | Bad arguments, a missing path, or an invalid `.ouchbill.json` |
|
|
103
|
+
|
|
104
|
+
## Options
|
|
105
|
+
|
|
106
|
+
| Option | |
|
|
107
|
+
|---|---|
|
|
108
|
+
| `--json` | Print the result as JSON (`schemaVersion: 1`). The test suite holds the shape to a strict schema. |
|
|
109
|
+
| `--fail-on-uncapped` | Exit 1 when a detected service has no cap declared on or accepted. |
|
|
110
|
+
| `--fresh` | `check` only. Use the latest signed date tables (contacts ouchbill.com only). Output states the source (live, cache or bundled), data date and any warning. A failed refresh falls back and never changes the exit code by itself. |
|
|
111
|
+
| `--online` | `check` only. Add TLS certificate and domain expiry for up to 10 repo hostnames (contacts those hosts and rdap.org). Uses the same severity dates. A failed check is shown as unknown, never as fine. |
|
|
112
|
+
| `--fail-on-severity=L` | `check` only. Exit 1 when a security pack finding (key, browser-exposed key, agent or MCP config, GitHub Actions, prompt-injection sink) is at severity L or above: `critical`, `high`, or `none` (default: pack findings never fail the run). |
|
|
113
|
+
| `--fail-on-expiry[=N]` | With `--online`, exit 1 when a known certificate or domain date is within N days (default 30) or past. An unknown result does not fail the run. |
|
|
114
|
+
| `--scan <path>` | Also scan this file or folder, e.g. build output outside `dir`. Repeatable. |
|
|
115
|
+
| `--exclude <path>` | Leave a path (relative to `dir`) out of the model, version and service checks. Repeatable. Excluded paths are always listed in the report and are still scanned for key-shaped values. |
|
|
116
|
+
| `--badge` | `check` only. Print a link that makes a README badge: a date and counts (services, caps declared, gaps, keys found), no provider names. The link opens a page that signs it and gives the README line. Still makes no network call. |
|
|
117
|
+
| `--badge-breaks` | `check` only. Print a markdown badge, `breaks in 90 days: N`, linking to ouchbill.com/retirements. It counts dated retirements and end-of-life dates within 90 days (green at 0, orange for some, red `N now` when any is already critical). Counts only: no model ids, paths or provider names. A plain shields.io link; no network call is made. Cannot be combined with `--json` or `--badge`. |
|
|
118
|
+
| `--badge-providers` | With `--badge`, also list the detected service ids on the badge's page. Off by default. |
|
|
119
|
+
| `--report <file.html>` | `check` only. Also write one self-contained HTML report: headline first ("2 critical, 3 high: fix these before you ship"), a severity bar, a fix-first list, then every finding grouped by severity and category with file:line, why, numbered fix steps, source and checked date. Filters by severity and category, light and dark, prints well. Inline CSS, no script at all, and a Content-Security-Policy that blocks every request: it works offline. |
|
|
120
|
+
| `--sarif <file.sarif>` | Also write SARIF 2.1.0 (validated against the OASIS schema in the tests) for GitHub code scanning. One rule per finding id, one result per place, `security-severity` set. |
|
|
121
|
+
|
|
122
|
+
## AI-stack security pack
|
|
123
|
+
|
|
124
|
+
`ouchbill check` also runs these rules, in-process: no network, no external binary, nothing uploaded. Every finding
|
|
125
|
+
uses the same id in text, `--json` (`ranked` and the raw `security` hits), `--report`, `--sarif` and the MCP server.
|
|
126
|
+
Titles, reasons and fix steps are our own words; a repo path appears only in `where`.
|
|
127
|
+
|
|
128
|
+
| Id | Severity | What |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| `secret:<provider>` | critical | A key-shaped value in the repo or build output (now also Perplexity, Fireworks, Hugging Face org tokens, OuchBill data feed keys (`obt_`), and Mistral, Cohere, Together, DeepSeek, ElevenLabs keys written next to their env var name). Masked, never tested. Also read: committed env files (keys only), text with NUL bytes and UTF-16 without a byte-order mark. |
|
|
131
|
+
| `exposed:public-env-llm-key` | critical | An LLM key name with a browser-public prefix: `NEXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`, `REACT_APP_`. |
|
|
132
|
+
| `exposed:llm-sdk-in-client` | critical | An LLM SDK imported in browser code (`"use client"` files, `*.client.*`, Vue/Svelte components, `public/`, browser bundles), or `dangerouslyAllowBrowser: true`. |
|
|
133
|
+
| `exposed:key-in-client-code` | critical | A key-shaped value in browser code or a browser bundle (also reported as `secret:`). |
|
|
134
|
+
| `agent:pipe-to-shell` | critical | A hook, status line or MCP start command that pipes `curl`/`wget` into a shell or interpreter, by program name (`sh`, `/bin/sh`, `env bash`, `sudo bash`, `python`, `node` …), or gives one `$(curl …)`. |
|
|
135
|
+
| `actions:pr-target-checkout` | critical | `pull_request_target` with a checkout of the pull request head. |
|
|
136
|
+
| `agent:mcp-plaintext-secret` | high | A literal secret in an MCP server's `env` or `headers`. |
|
|
137
|
+
| `agent:bypass-permissions` | high | `bypassPermissions`, `--dangerously-skip-permissions` or a `dangerously…: true` key. |
|
|
138
|
+
| `agent:wildcard-allow` | high | An allow rule of `Bash`, `Bash(*)`, `Bash(:*)` or `*`, or one that allows a shell, an interpreter with inline code or a wrapper with any arguments (`Bash(sh:*)`, `Bash(bash -c:*)`, `Bash(node:*)`, `Bash(env:*)`). |
|
|
139
|
+
| `agent:auto-approve-mcp` | high | `enableAllProjectMcpServers: true`: every server in the project's `.mcp.json` starts without a prompt. |
|
|
140
|
+
| `agent:mcp-plain-http` | high | A remote MCP server on `http://` (loopback is fine). |
|
|
141
|
+
| `actions:template-injection` | high | `${{ github.event.* }}` or `github.head_ref` inside `run:` (numbers, SHAs and maintainer-set fields excepted), in block or flow style, quoted keys and multi-line values. |
|
|
142
|
+
| `actions:write-all` | high | `permissions: write-all`. |
|
|
143
|
+
| `agent:mcp-unpinned-package` | medium | An MCP server started with `npx`/`bunx`/`pnpm dlx`/`uvx` and no exact version, or `@latest`. |
|
|
144
|
+
| `actions:unpinned-third-party` | medium | A third-party action (or `docker://` image) not pinned to a full SHA (digest). |
|
|
145
|
+
| `actions:no-permissions` | medium | A workflow with no `permissions:` block (reusable `workflow_call`-only workflows excepted). |
|
|
146
|
+
| `injection:input-in-prompt` | medium, to check | Request input joined into a prompt string in a file that calls an LLM. |
|
|
147
|
+
| `injection:output-to-sink` | medium, to check | Model output on the same line as `eval`, a shell call, raw SQL or raw HTML. |
|
|
148
|
+
| `actions:unpinned-first-party` | low | `actions/*` or `github/*` not pinned to a full SHA. |
|
|
149
|
+
| `actions:persist-credentials` | low | `actions/checkout` without `persist-credentials: false`. |
|
|
150
|
+
|
|
151
|
+
Files read: `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, `.claude/settings.json`, `.claude/settings.local.json`,
|
|
152
|
+
`claude_desktop_config.json` (JSON with comments allowed), `.github/workflows/*.yml` and `action.yml`, and code files.
|
|
153
|
+
Tests, docs and installed packages are skipped by the code rules. Folders of installed packages and caches
|
|
154
|
+
(`node_modules`, a virtualenv with its full layout, a Go `vendor/` with `modules.txt` and `go.mod`, `.cache` …) are not
|
|
155
|
+
entered, but each is listed in the output, and the files in them that git tracks are still scanned for keys and agent
|
|
156
|
+
and Actions configs. An exclude never hides the root workflows, `action.yml` or the root agent configs. "To check" findings are heuristics
|
|
157
|
+
(`confirmed: false`) and are never critical. The pack does not change exit codes: keys still exit 1 as before.
|
|
158
|
+
|
|
159
|
+
Every rule reads text in linear time (1 MB hostile files under 1 s each, in `test/redos.test.ts` and
|
|
160
|
+
`test/security-pack.test.ts`). Sources for each rule are in `src/pack.ts`; the key prefixes and where each was
|
|
161
|
+
confirmed on 2026-12-01 are in `src/llm-keys.ts`.
|
|
162
|
+
|
|
163
|
+
## GitHub Action
|
|
164
|
+
|
|
165
|
+
The Action runs the same bundle on the runner. It fails the build on a key in the repo or the
|
|
166
|
+
built bundle, and on a used service with no declared cap. It does not send spend alerts; other free
|
|
167
|
+
tools already do that hourly. This one checks whether a cap exists at all.
|
|
168
|
+
|
|
169
|
+
```yaml
|
|
170
|
+
# .github/workflows/ouchbill.yml
|
|
171
|
+
name: ouchbill
|
|
172
|
+
on: [pull_request]
|
|
173
|
+
permissions:
|
|
174
|
+
contents: read
|
|
175
|
+
jobs:
|
|
176
|
+
caps-and-keys:
|
|
177
|
+
runs-on: ubuntu-24.04
|
|
178
|
+
steps:
|
|
179
|
+
- uses: actions/checkout@v4
|
|
180
|
+
- uses: actions/setup-node@v4
|
|
181
|
+
with:
|
|
182
|
+
node-version: 22
|
|
183
|
+
- run: npm ci && npm run build # scan what you actually ship
|
|
184
|
+
- uses: OWNER/REPO/packages/cli@COMMIT_SHA # pin a full SHA once the repo is public
|
|
185
|
+
with:
|
|
186
|
+
scan: |
|
|
187
|
+
dist
|
|
188
|
+
exclude: |
|
|
189
|
+
test/fixtures # still scanned for keys; only model, version and service checks skip it
|
|
190
|
+
fail-on-uncapped: "true"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Inputs: `path` (default `.`), `scan` and `exclude` (one per line), `fail-on-uncapped` (default
|
|
194
|
+
`"true"`), `json-file` (also write the JSON result), `fail-if-config-changed` (default `"false"`; on a pull
|
|
195
|
+
request, fail when it changes `.ouchbill.json`; needs `fetch-depth: 0`). Output: `exit-code`. The Action needs no
|
|
196
|
+
secrets and no token. It needs Node 20 or newer on the runner; GitHub-hosted runners have it.
|
|
197
|
+
|
|
198
|
+
A full example is in [`examples/ouchbill.yml`](examples/ouchbill.yml).
|
|
199
|
+
|
|
200
|
+
## How detection works
|
|
201
|
+
|
|
202
|
+
| Signal | Read from |
|
|
203
|
+
|---|---|
|
|
204
|
+
| Dependencies | `package.json` (all dependency sections), `requirements*.txt`, `pyproject.toml` (PEP 621, Poetry), `Pipfile`, `go.mod` |
|
|
205
|
+
| Env var names | `.env.example` / `.env.sample` / `.env.template`, CI and deploy config (workflows, compose files, `fly.toml` …), and `process.env.X`-style references in code |
|
|
206
|
+
| Infrastructure | Terraform `provider` blocks and `required_providers`, `wrangler.toml`, `vercel.json`, `netlify.toml`, `fly.toml`, `render.yaml`, `firebase.json`, `supabase/config.toml`, `cdk.json`, SAM/CloudFormation templates, Bicep files |
|
|
207
|
+
|
|
208
|
+
Only unambiguous signals count: an official SDK, the provider's own config file, an env var name
|
|
209
|
+
the provider documents, or an IaC provider. Generic clients that also reach self-hosted software
|
|
210
|
+
(`pg`, `mongodb`, `redis`) are left out, so a self-hosted database is not reported as a cloud bill.
|
|
211
|
+
If nothing is detected, ouchbill says so and says that is not proof there is nothing.
|
|
212
|
+
|
|
213
|
+
`node_modules`, `.git`, virtualenvs and build caches (`.next/cache`) are skipped. Build output
|
|
214
|
+
(`dist`, `build`, `.next`, `out`) is scanned, because that is what ships to browsers. Files over
|
|
215
|
+
20 MB and binary files are skipped and counted in the report.
|
|
216
|
+
|
|
217
|
+
### Claude Code and `ANTHROPIC_API_KEY`
|
|
218
|
+
|
|
219
|
+
If `ANTHROPIC_API_KEY` is set in the shell that runs `ouchbill check`, it prints a note: on a
|
|
220
|
+
Claude Pro/Max plan, Claude Code can bill that API key per token instead of your plan. Only the
|
|
221
|
+
variable's name is checked.
|
|
222
|
+
|
|
223
|
+
## Where the data comes from
|
|
224
|
+
|
|
225
|
+
The provider catalog (cap status, source link, verified date, where to set the cap) and the key
|
|
226
|
+
patterns are not copied into this package. They are imported from the OuchBill web app's sources
|
|
227
|
+
(`apps/web/src/data/providers.ts`, `apps/web/src/lib/patterns.ts`) and bundled into
|
|
228
|
+
`dist/ouchbill.mjs` at build time, so the CLI, the website and the site scanner never disagree. A
|
|
229
|
+
test fails when the committed bundle no longer matches those sources.
|
|
230
|
+
|
|
231
|
+
## Develop
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
cd packages/cli
|
|
235
|
+
npm ci
|
|
236
|
+
npm test # typecheck + vitest
|
|
237
|
+
npm run build # rebuild dist/ouchbill.mjs after changing src or the shared catalog
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Test fixtures contain no keys. Tests plant obviously fake keys (`…OUCHBILLFAKE…`) in temp folders
|
|
241
|
+
at runtime.
|
|
242
|
+
|
|
243
|
+
## Licence
|
|
244
|
+
|
|
245
|
+
Proprietary. Copyright (c) 2026 Drevan. All rights reserved. See [LICENSE](LICENSE). Bundled third-party
|
|
246
|
+
components keep their own licences: `dist/THIRD_PARTY_NOTICES.txt`.
|
|
247
|
+
|
|
248
|
+
## `usage` and `detect` (local, offline)
|
|
249
|
+
|
|
250
|
+
- `ouchbill usage` reads Claude Code (`~/.claude/projects/**/*.jsonl`, or `CLAUDE_CONFIG_DIR`), Codex CLI (`~/.codex/sessions`, or `CODEX_HOME`) and Gemini CLI (`~/.gemini/tmp/*/chats`) logs on this machine and prints tokens per model for today, this week (from Monday) and this month. Any money shown is an **estimate at list price** from a bundled table with a source URL and checked date (`src/pricing.ts`), in integer micro-dollars. A model not in the table has an unknown cost, never zero. It is not your bill.
|
|
251
|
+
- `ouchbill detect` reports which logins already exist: AWS CLI profile names, whether gcloud has an active account, whether a Vercel login file exists, and the Claude, Codex and Gemini CLIs. It never opens credentials or token files and prints no secret or account value.
|
|
252
|
+
|
|
253
|
+
Neither command makes a network call, and neither accepts `--fresh` or `--online`.
|
package/action.yml
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
name: OuchBill check
|
|
2
|
+
description: >-
|
|
3
|
+
Fails the build when a key-shaped value is in the repo or the built bundle, or when a usage-billed
|
|
4
|
+
service the project uses has no cap declared in .ouchbill.json. Runs on the runner only: no network
|
|
5
|
+
calls, no telemetry, no secrets needed.
|
|
6
|
+
author: OuchBill
|
|
7
|
+
branding:
|
|
8
|
+
icon: shield
|
|
9
|
+
color: orange
|
|
10
|
+
|
|
11
|
+
inputs:
|
|
12
|
+
path:
|
|
13
|
+
description: Folder to check (detect services and scan for keys).
|
|
14
|
+
required: false
|
|
15
|
+
default: "."
|
|
16
|
+
scan:
|
|
17
|
+
description: Extra files or folders to scan for keys, one per line (e.g. build output outside `path`).
|
|
18
|
+
required: false
|
|
19
|
+
default: ""
|
|
20
|
+
exclude:
|
|
21
|
+
description: Paths to leave out of the model, version and service checks, relative to `path`, one per line. They are still scanned for keys, and every excluded path is printed.
|
|
22
|
+
required: false
|
|
23
|
+
default: ""
|
|
24
|
+
fail-on-uncapped:
|
|
25
|
+
description: '"true" fails the build when a detected service has no cap declared in .ouchbill.json.'
|
|
26
|
+
required: false
|
|
27
|
+
default: "true"
|
|
28
|
+
json-file:
|
|
29
|
+
description: If set, also write the JSON result (schemaVersion 1) to this file.
|
|
30
|
+
required: false
|
|
31
|
+
default: ""
|
|
32
|
+
fail-if-config-changed:
|
|
33
|
+
description: >-
|
|
34
|
+
"true" fails the check on a pull request that changes .ouchbill.json in the checked folder, so a pull request
|
|
35
|
+
cannot add its own excludes or cap declarations to pass. Needs the base commit: check out with fetch-depth 0.
|
|
36
|
+
required: false
|
|
37
|
+
default: "false"
|
|
38
|
+
|
|
39
|
+
outputs:
|
|
40
|
+
exit-code:
|
|
41
|
+
description: 0 nothing failing, 1 findings, 2 usage or config error.
|
|
42
|
+
value: ${{ steps.check.outputs.exit-code }}
|
|
43
|
+
|
|
44
|
+
runs:
|
|
45
|
+
using: composite
|
|
46
|
+
steps:
|
|
47
|
+
- id: check
|
|
48
|
+
shell: bash
|
|
49
|
+
# Inputs reach the script through env vars, never through ${{ }} inside the script (no injection).
|
|
50
|
+
env:
|
|
51
|
+
OUCHBILL_PATH: ${{ inputs.path }}
|
|
52
|
+
OUCHBILL_SCAN: ${{ inputs.scan }}
|
|
53
|
+
OUCHBILL_EXCLUDE: ${{ inputs.exclude }}
|
|
54
|
+
OUCHBILL_FAIL_ON_UNCAPPED: ${{ inputs.fail-on-uncapped }}
|
|
55
|
+
OUCHBILL_JSON_FILE: ${{ inputs.json-file }}
|
|
56
|
+
OUCHBILL_FAIL_IF_CONFIG_CHANGED: ${{ inputs.fail-if-config-changed }}
|
|
57
|
+
run: |
|
|
58
|
+
set -uo pipefail
|
|
59
|
+
major="$(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0)"
|
|
60
|
+
if [ "$major" -lt 20 ]; then
|
|
61
|
+
echo "::error::ouchbill needs Node 20 or newer on the runner (found: $(node --version 2>/dev/null || echo none)). Add actions/setup-node before this step."
|
|
62
|
+
exit 2
|
|
63
|
+
fi
|
|
64
|
+
# Options first, then `--`, then the path: a path input such as "--help" stays a path.
|
|
65
|
+
opts=()
|
|
66
|
+
while IFS= read -r p; do [ -n "$p" ] && opts+=(--scan="$p"); done <<< "$OUCHBILL_SCAN"
|
|
67
|
+
while IFS= read -r p; do [ -n "$p" ] && opts+=(--exclude="$p"); done <<< "$OUCHBILL_EXCLUDE"
|
|
68
|
+
[ "$OUCHBILL_FAIL_ON_UNCAPPED" = "true" ] && opts+=(--fail-on-uncapped)
|
|
69
|
+
bin="$GITHUB_ACTION_PATH/dist/ouchbill.mjs"
|
|
70
|
+
# The report quotes text from the repo: workflow commands are off while it prints (one-time token, S-24).
|
|
71
|
+
token="ouchbill-$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n')"
|
|
72
|
+
echo "::stop-commands::$token"
|
|
73
|
+
node "$bin" check "${opts[@]}" -- "$OUCHBILL_PATH"
|
|
74
|
+
code=$?
|
|
75
|
+
echo "::$token::"
|
|
76
|
+
# S-20: a pull request must not edit .ouchbill.json (excludes, cap declarations) to pass its own check.
|
|
77
|
+
if [ "$OUCHBILL_FAIL_IF_CONFIG_CHANGED" = "true" ]; then
|
|
78
|
+
case "${GITHUB_EVENT_NAME:-}" in
|
|
79
|
+
pull_request|pull_request_target)
|
|
80
|
+
base="$(node -e 'const e = require(process.env.GITHUB_EVENT_PATH); process.stdout.write(String((e.pull_request && e.pull_request.base && e.pull_request.base.sha) || ""))')"
|
|
81
|
+
if ! printf '%s' "$base" | grep -Eq '^[0-9a-f]{40}$'; then echo "::error::fail-if-config-changed could not read the pull request's base commit."; exit 2; fi
|
|
82
|
+
git cat-file -e "$base^{commit}" 2>/dev/null || git fetch --no-tags --depth=1 origin "$base" >/dev/null 2>&1 || true
|
|
83
|
+
if ! git cat-file -e "$base^{commit}" 2>/dev/null; then echo "::error::fail-if-config-changed needs the base commit. Use actions/checkout with fetch-depth: 0."; exit 2; fi
|
|
84
|
+
if ! git diff --quiet "$base" HEAD -- "${OUCHBILL_PATH%/}/.ouchbill.json"; then
|
|
85
|
+
echo "::error::This pull request changes .ouchbill.json (fail-if-config-changed is on). A maintainer must review that change; it can hide findings."
|
|
86
|
+
[ "$code" -eq 0 ] && code=1
|
|
87
|
+
fi
|
|
88
|
+
;;
|
|
89
|
+
*) echo "fail-if-config-changed: not a pull request, nothing to compare." ;;
|
|
90
|
+
esac
|
|
91
|
+
fi
|
|
92
|
+
if [ -n "$OUCHBILL_JSON_FILE" ] && [ "$code" -ne 2 ]; then
|
|
93
|
+
node "$bin" check "${opts[@]}" --json -- "$OUCHBILL_PATH" > "$OUCHBILL_JSON_FILE" || true
|
|
94
|
+
fi
|
|
95
|
+
echo "exit-code=$code" >> "$GITHUB_OUTPUT"
|
|
96
|
+
exit "$code"
|