Skip to content

Commit 5e18e89

Browse files
saby1101claude
andcommitted
docs: correct and cut the markdown
README named the package @stackbox/fp-plugins in all six install and import examples; it is @stackbox-dev/fp-plugins, so following the README could not work. It also documented 168 lines of the event-bus plugin deleted in c001efc, claimed Node 18+ against engines >=22, described the local default as the system temp dir rather than a stackboxwms subdirectory, and gave no registry config for a package published only to GitHub Packages. Rewritten for consumers: 378 -> 154 lines, with env vars checked line by line against file-store.ts, and the automatic FastifyInstance.FileStore typing and lazy SDK loading documented for the first time. CLAUDE.md claimed its list was every script (prepare and prepublishOnly are also defined) and omitted utils.spec.ts. gen-test skill said cloud SDKs are never containerised and there are no Docker-based tests, contradicting the MinIO integration spec. security-reviewer agent reviewed the deleted event-bus — broker connections, the publish endpoint, NATS and RabbitMQ clients. Rescoped to the file store. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent afb18d8 commit 5e18e89

5 files changed

Lines changed: 101 additions & 312 deletions

File tree

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
---
22
name: security-reviewer
3-
description: Reviews event-bus and file-store code for credential handling, injection risks, and insecure defaults
3+
description: Reviews file-store code for credential handling, path traversal, and insecure defaults
44
tools: ["Read", "Grep", "Glob"]
55
---
66

7-
You are a security reviewer for a Fastify plugin library that handles cloud credentials and message broker connections.
7+
You are a security reviewer for `@stackbox-dev/fp-plugins`, a Fastify plugin library
8+
that wraps cloud storage (AWS S3, GCS, Azure Blob, MinIO, local filesystem) behind one
9+
`FileStore` interface (`src/file-store.ts`).
810

911
Review the changed or specified files for:
1012

11-
1. **Credential exposure**: Hardcoded secrets, credentials logged to stdout, tokens in error messages
12-
2. **Unsafe deserialization**: `JSON.parse` without try/catch or validation, especially on message payloads from external brokers
13-
3. **Injection risks**: Unsanitized input in the `/event-bus/publish/:event` endpoint, template literal injection in queue/topic names
14-
4. **Insecure defaults**: Missing TLS, overly permissive CORS, unauthenticated endpoints exposed by default
15-
5. **Resource leaks**: Unclosed connections, missing cleanup in error paths, containers not stopped in tests
16-
6. **Dependency concerns**: Known vulnerable patterns in AWS SDK, Azure SDK, GCP SDK, NATS, or RabbitMQ client usage
13+
1. **Credential exposure**: hardcoded secrets, credentials or endpoints logged, tokens
14+
leaking into error messages
15+
2. **Path traversal**: `filepath` arguments are joined onto a base directory in
16+
`LocalFileStore` and used as object keys in the cloud providers — check whether new
17+
code lets `..` escape `LOCAL_STORAGE_DIR` or weakens key handling
18+
3. **Insecure defaults**: env-var fallbacks that silently point at the wrong
19+
region/endpoint, TLS disabled, anonymous credentials
20+
4. **Resource leaks**: unclosed streams or clients, missing cleanup in error paths
21+
5. **SDK misuse**: unsafe patterns in AWS/GCP/Azure SDK usage, e.g. disabling
22+
certificate validation
1723

18-
Report findings with severity (critical/high/medium/low), file location, and a suggested fix.
24+
Report findings with severity (critical/high/medium/low), file location, and a
25+
suggested fix.

‎.claude/skills/gen-test/SKILL.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ Generate a Jest test file for a given source module in this project.
2020
- Test files live alongside source: `src/foo.ts` → `src/foo.spec.ts`.
2121
Provider-specific specs are suffixed: `file-store.<provider>.spec.ts`
2222
- `ts-jest` preset, `testEnvironment: "node"`
23-
- Cloud SDKs are **mocked**, never containerised — `jest.mock("@google-cloud/storage")`
24-
and friends. This package has no Docker-based tests and no `testcontainers`
25-
dependency; do not add one
23+
- Cloud SDKs are **mocked** in unit specs — `jest.mock("@google-cloud/storage")` and
24+
friends. The one exception is `src/file-store.minio.integration.spec.ts`, which talks
25+
to a real MinIO over the S3 wire protocol; it self-skips unless `MINIO_TEST_ENDPOINT`
26+
is set and runs via `pnpm run test:integration`. No `testcontainers` dependency; do
27+
not add one
28+
- Behavioural changes to S3/MinIO paths need cases in the integration spec too —
29+
mocked tests cannot catch SDK behaviour changes (see CLAUDE.md, Testing)
2630
- `LocalFileStore` is the exception: test it against the real filesystem using
2731
`fs.promises.mkdtemp` under `os.tmpdir()`, and clean up in `afterEach`
2832
- Save and restore `process.env` around tests that set provider env vars

‎CLAUDE.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
1313
- **Clean**: `pnpm run clean` — removes `dist`
1414
- **Transpile**: `pnpm run transpile` — TypeScript compilation only
1515

16-
These are the only scripts defined in `package.json`. CI (`.github/workflows/`) runs
16+
The only other scripts in `package.json` are `prepare` (husky) and `prepublishOnly`
17+
(build before publish). CI (`.github/workflows/`) runs
1718
`pnpm install --frozen-lockfile`, then lint, build and test on Node 24; the package declares
1819
`engines: node >=22`.
1920

@@ -57,8 +58,8 @@ Registered via `fastify-plugin` (v6) and decorates the Fastify instance with
5758
## Testing
5859

5960
Jest + ts-jest. Tests live beside their source in `src/` as `*.spec.ts`, split by
60-
provider: `file-store.local.spec.ts`, `.gcs.`, `.s3.`, `.azure.`, plus the original
61-
`file-store.spec.ts` and `integration.spec.ts`. Coverage is 100% on statements,
61+
provider: `file-store.local.spec.ts`, `.gcs.`, `.s3.`, `.azure.`, plus
62+
`file-store.spec.ts`, `integration.spec.ts` and `utils.spec.ts`. Coverage is 100% on statements,
6263
branches, functions and lines — keep it there.
6364

6465
Cloud SDKs are mocked with `jest.mock(...)`; `LocalFileStore` runs against the real

‎CONTRIBUTING.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
## Setup
44

5-
This repository uses **pnpm** (pinned via `packageManager` in `package.json`). Do not
6-
use npm or yarn — `pnpm-lock.yaml` is the committed lockfile and the only one CI reads.
5+
Node.js >= 22 (CI runs 24). This repository uses **pnpm** (pinned via `packageManager`
6+
in `package.json`). Do not use npm or yarn — `pnpm-lock.yaml` is the committed lockfile
7+
and the only one CI reads.
78

89
```bash
910
pnpm install

0 commit comments

Comments
 (0)