1
0
Fork 0
mirror of https://github.com/imjasonh/npm-snoop synced 2026-07-07 00:32:54 +00:00
Commit graph

14 commits

Author SHA1 Message Date
dab2c306d4 Update cost.md with collection-only cost analysis (~$78/month)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 10:57:37 -04:00
5d080b7394 Remove ast-diff service and Terraform
Keep the CLI tool and internal packages (npm, symbols, diff) for
local use. The Cloud Run event-driven approach isn't cost-effective
for this workload; see cost.md for analysis.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 10:51:46 -04:00
67702a9007 Harden ast-diff service and disable in production
- Add tracing spans, httpmetrics, and clog context propagation
- Tarball size limit (20MB), per-file limit (1MB), file count limit (2000)
- Concurrent old/new version processing via errgroup
- Request deadline from env var, aligned with Cloud Run timeout
- Skip events recorded to BQ with skipped_reason for coverage tracking
- Accept *http.Client in npm package for metrics transport
- Disable ast-diff service in production (commented out in ast-diff.tf)
  pending cost optimization; see cost.md for analysis

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 10:50:11 -04:00
946a1869ec Move poller to cmd/npm-cron/
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 21:39:02 -04:00
c0db95e261 Stream tarballs file-by-file instead of extracting to disk
Add ExtractFromTarGz to stream tar entries and parse only JS/TS
files one at a time, avoiding writing the full tarball to Cloud
Run's memory-backed filesystem. The service now pipes the HTTP
response body directly into the streaming extractor.

Also bump instance to 4 vCPU / 16Gi with scale-to-zero and
concurrency=20, and use clog/gcp/init for structured logging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 21:31:35 -04:00
6d6f548f62 Distinguish permanent vs transient errors in ast-diff service
Add PermanentError type to the npm package for 404/403 responses
that will never succeed on retry. The service now ACKs permanent
failures (private packages, deleted tarballs) so PubSub doesn't
waste retry budget, while returning errors for transient failures
(timeouts, 5xx) so PubSub retries with backoff.

Also adds ast-diff service dashboard, cron dashboard fix, and
min_instances=1 with concurrency=10 for better burst handling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 20:09:16 -04:00
9cbb73d2dd Fix ast-diff egress: use PRIVATE_RANGES_ONLY for npm registry access
The service was using ALL_TRAFFIC egress through VPC, which routed
npm registry requests through VPC where they couldn't reach the
internet. PRIVATE_RANGES_ONLY routes only broker traffic through
VPC while npm traffic goes direct, matching the poller's config.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:22:43 -04:00
f16afd293e Switch to pure-Go tree-sitter (gotreesitter) to enable ko builds
The CGO-based tree-sitter bindings can't cross-compile with ko for
Linux containers. gotreesitter is a pure-Go reimplementation with
embedded grammars, so it builds cleanly with ko for Cloud Run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 17:10:13 -04:00
0f53f23342 Add ast-diff Cloud Run service and Terraform wiring
Cloud Run service subscribes to dev.npm.package.released.v1 events,
downloads old+new tarballs, diffs symbols with tree-sitter, and emits
dev.npm.package.diff.v1 events back to the broker for BQ recording.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 16:59:45 -04:00
76af9702ce Add ast-diff CLI for diffing symbols between npm package versions
Uses tree-sitter to parse JS/TS files and extract top-level symbols
(functions, classes, variables, methods), then diffs them by content
hash to identify added/removed/modified symbols between two versions.
Intended to help correlate CVE fixes with specific changed functions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 16:52:19 -04:00
a5eda95590 Fix queries.md: use REGEXP_EXTRACT for dist-tags, add WHERE body IS NOT NULL
BigQuery's JSONPath doesn't support hyphenated keys like "dist-tags".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 16:23:54 -04:00
50185584e0 Record per-version releases, metadata modifications, and raw JSON bodies
- Emit one release event per version published (not per package), using
  the metadata time map to find versions published since last poll
- Add modification events for metadata-only changes (dist-tag moves,
  maintainer updates, etc.) with full raw JSON body for diffing
- Include raw package metadata (versions key stripped) in release and
  modification events for later analysis
- Store poll state as JSON (seq + timestamp) instead of plain seq
- Switch recorder to method=gcs (Pub/Sub writes directly to GCS,
  eliminating the recorder Cloud Run service)
- Add queries.md with example BQ queries including a window-function
  diff query for tracking metadata changes over time

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 16:21:58 -04:00
c47f7dc39b Add cron job monitoring dashboard
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 14:20:38 -04:00
a22a473782 Poll npm registry changes feed and record releases to BigQuery
Go cron job that tails the npm CouchDB _changes feed, fetches package
metadata, and emits CloudEvents for releases and deletions. Events flow
through a Chainguard cloudevent-broker to a cloudevent-recorder that
streams them into BigQuery.

Infrastructure is managed with Terraform using chainguard-dev/terraform-
infra-common modules for networking, broker, recorder, and cron.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 13:03:29 -04:00