feat(ruby): ground-truth sample for the ruby_ast scanner #2

Merged
amiryahaya merged 33 commits from ruby-sample into main 2026-10-28 03:42:06 +01:00
Owner

Summary

Adds ruby/, the ground-truth sample for Triton's ruby_ast scanner (scanner PR: amiryahaya/triton#1376): a hardened stdlib Ruby web app that runs 277 server implementations, plus scanned-only fixture trees (constructs/, rails/, projects/), generators and checks, and expected-findings.json that a real scanner run is compared against. Layout, commands and what a PASS proves are in ruby/README.md; what the scanner cannot reach is in ruby/UNCOVERED.md. The design, survey and scanner plan are copied under docs/superpowers/.

Verification

  • make check (no container, no Go needed): 135 script tests pass; catalogue, family files, fixtures, pins, expected findings and UNCOVERED.md all consistent.
  • Real CLI: make compare-scan TRITON_SRC=<triton at e32c54f0> PASS: 718 expected tuples, 717 matched (the other is the CLI-excluded vendor file), 0 missing/extra/decoy/status/reachability/attribution/derived/evidence failures, 0 SKIPPED. make check-fresh and make check-scan-all pass too.
  • Server tests inside the image: 38 runs, 0 failures. make selftest: 714/714 implementations match their known-answer vectors.
  • Non-Go change: no Go code changed, so there is no Go coverage figure.
  • Dual-pass review (Ponytail + independent correctness): the Important finding (the compose hardening check passed with the hardening removed) and six minors were fixed in the last commit: two 500s now 404/400, an accept-loop ThreadError, Makefile quoting, gems.rb syntax check.

What a PASS means (and does not)

Matching is per file on (algorithm, status, reachability): about 590 detections share tuples and are proven only by the lookup golden file. Say "718 tuples", not "N registry implementations verified". Versions 5.1.7 and 8.1.5 in fixtures are never installed.

Needs attention after merge

  • The snapshots record scanner commit e32c54f0. If #1376 is amended or squash-merged that commit is no longer an ancestor and make check-fresh fails until make snapshot golden-from-go expected is re-run against the merged scanner. Merge this after #1376 and refresh once. make check-fresh TRITON_SRC=... is mandatory whenever the scanner changes.
  • scanner-bug and gap rows record known ruby_ast defects found by this sample (member-call parser keeps only 2 positional args, lambda { || }, const_get, a project-defined BCrypt, per-key withholding wording, first-party lib/vendor/, a withheld KeyGenerator default, and others); they are listed in #1376.

Known and accepted (not fixed here)

Unpinned build-essential in the build stage; check-http-clean scope; loose coverage floors; no version-direction check for rails/; the vendored jwt stand-in uses raw HMAC; an unused rexml pin; make check does not check a header's algorithm name (only compare-scan does); the ThreadError accept-loop fix has no test.

🤖 Generated with Claude Code

## Summary Adds `ruby/`, the ground-truth sample for Triton's `ruby_ast` scanner (scanner PR: amiryahaya/triton#1376): a hardened stdlib Ruby web app that runs 277 server implementations, plus scanned-only fixture trees (`constructs/`, `rails/`, `projects/`), generators and checks, and `expected-findings.json` that a real scanner run is compared against. Layout, commands and what a PASS proves are in `ruby/README.md`; what the scanner cannot reach is in `ruby/UNCOVERED.md`. The design, survey and scanner plan are copied under `docs/superpowers/`. ## Verification - `make check` (no container, no Go needed): 135 script tests pass; catalogue, family files, fixtures, pins, expected findings and UNCOVERED.md all consistent. - Real CLI: `make compare-scan TRITON_SRC=<triton at e32c54f0>` PASS: 718 expected tuples, 717 matched (the other is the CLI-excluded `vendor` file), 0 missing/extra/decoy/status/reachability/attribution/derived/evidence failures, 0 SKIPPED. `make check-fresh` and `make check-scan-all` pass too. - Server tests inside the image: 38 runs, 0 failures. `make selftest`: 714/714 implementations match their known-answer vectors. - Non-Go change: no Go code changed, so there is no Go coverage figure. - Dual-pass review (Ponytail + independent correctness): the Important finding (the compose hardening check passed with the hardening removed) and six minors were fixed in the last commit: two 500s now 404/400, an accept-loop `ThreadError`, Makefile quoting, `gems.rb` syntax check. ## What a PASS means (and does not) Matching is per file on (algorithm, status, reachability): about 590 detections share tuples and are proven only by the lookup golden file. Say "718 tuples", not "N registry implementations verified". Versions 5.1.7 and 8.1.5 in fixtures are never installed. ## Needs attention after merge - The snapshots record scanner commit `e32c54f0`. If #1376 is amended or squash-merged that commit is no longer an ancestor and `make check-fresh` fails until `make snapshot golden-from-go expected` is re-run against the merged scanner. Merge this after #1376 and refresh once. `make check-fresh TRITON_SRC=...` is mandatory whenever the scanner changes. - `scanner-bug` and gap rows record known `ruby_ast` defects found by this sample (member-call parser keeps only 2 positional args, `lambda { || }`, `const_get`, a project-defined `BCrypt`, per-key withholding wording, first-party `lib/vendor/`, a withheld KeyGenerator default, and others); they are listed in #1376. ## Known and accepted (not fixed here) Unpinned `build-essential` in the build stage; `check-http-clean` scope; loose coverage floors; no version-direction check for `rails/`; the vendored jwt stand-in uses raw HMAC; an unused rexml pin; `make check` does not check a header's algorithm name (only `compare-scan` does); the `ThreadError` accept-loop fix has no test. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Catalogue generators under ruby/scripts/catalogue/*.mjs (adapted from cpp/ and dart/), the generated
lib/catalogue/*.json (11 families, 485 entries, 1204 implementations keyed to the Ruby scanner registry,
44 derived, 32 gaps) and a structural node:test suite. make check runs it without Go.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Family files are generated from the catalogue (every call verbatim); known-answer
vectors come from an independent Python reference checked against RFC/FIPS vectors.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
GET /algorithms, POST /algorithms/{id}/run, make selftest, bcrypt/jwt/rotp locked,
native build tools in the build stage only, killed handler threads are joined.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Engine#run rescued every StandardError into BadInput. LibraryErrors (lib/library_errors.rb, outside lib/engine and lib/server)
now decides what the library rejected: ArgumentError/RangeError, the library error hierarchies, and the by-name
'unsupported ...' RuntimeError. A NoMethodError inside a family propagates and the server answers 500 (test added).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
constructs/ holds the scanned-only fixtures, every .rb with a '# triton-expect:' header (registry, false-positive, marker, gap,
absent): the catalogue's 437 construct calls generated (constructs/catalogue/, make families), and hand-written lexical,
namespace, argument, dynamic, setter and collision-decoy cases. scripts/check-constructs.mjs (+ node:test) checks the grammar,
catalogue coverage and registry keys (make check-constructs, in make check); --scan runs the real ruby_ast module.
The Makefile engine-clean pattern also catches JWT|BCrypt|ROTP|Net::HTTP|Faraday|Cipher in lib/engine and lib/server.
Catalogue: attr_encrypted explicit rows move to the derived-gems project (a bare DSL needs the project lock); class-key and
dynamic-cost rows state the marker evidence and TRANSITIONAL status the scanner gives them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Rows whose registry rule needs a member-call argument past the 2nd (pkcs5_keyivgen digest, OCSP sign digest) are gap/scanner-bug
in the catalogue and scanner-bug headers in constructs/ (never expected findings; --scan expects them absent and flips when the
scanner is fixed). LibraryErrors treats a wrong-typed request value (TypeError no implicit conversion / wrong argument type) as 400.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The seven catalogue rails projects are generated from RAILS and the catalogue like constructs/catalogue: lock pins railties,
activesupport, activerecord, activemodel and bcrypt at one exact version, config/application.rb states a literal load_defaults,
derived headers carry the scanner's [derived: gem [min, max]; load_defaults N.M] token. Corrected against the real module:
configIndependent ranges name no load_defaults, KeyGenerator's digest constant adds no digest finding, withheld defaults add a marker.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
rails/shop (Zeitwerk chain, DSLs, bin/* gap), rails/withheld-<cause> trees, check-rails (+ tests) wired into make check.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
check-projects.mjs: lock grammar, own-project package claims, vendored trees (absent only),
derived-ranges relations against the registry snapshot, lock-remote credential leak check.
check-constructs.mjs gains the `package <gem> <version|none>` header and a packages option for
scanProblems; the scan probe prints Package and takes RUBY_PROBE_PROFILE.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Generated: catalogue project locks and projects/derived-ranges/<gem>-<relation>/ (inside, below,
above, gap, partial, no lock, GIT pin, gem-wide setter) for bcrypt, jwt, rotp, ruby-saml, json-jwt,
lockbox and attr_encrypted. By hand: platform-suffixed, git-entry, private-remote, locks-openssl,
no-openssl-lock, two-projects, gems-rb, vendored, engine-with/without-lock, monorepo,
first-party-vendor-named. The BCrypt::Engine.cost= catalogue row is a registry row (the scanner
reports the Engine mention) in its own project next to a create call.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Gemfile, Gemfile.lock, bin, lib and test move under ruby/app/; the catalogue's server-scope file
paths, the generators, vectors scripts, Containerfile COPY paths, Makefile targets and README follow.
Fixture trees stay at constructs/, rails/, projects/. Server behaviour unchanged (make test, selftest 715/715, up/health/run/down).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
check-scan-all scans ruby/ as one root against every header (constructs, rails,
projects and the server family files, headers synthesised from the catalogue)
and finds 0 problems. Server rows corrected: dynamic-selection markers, class
keys reported as markers, the AES class row reported as AES-256-GCM, const_get
with a literal resolved (construct-scope registry row), and family lambdas
without a '||' pair so the scanner tracks their locals.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
data/triton-ruby-registry.json is dumped by the scanner's own Go code (scripts/go-parity/parity) and joined with the harness's verification
snapshot; data/lookup-golden.json pins the JS lookup port (ResolveRubyCrypto, RubyDerivedFor, load_defaults rows) to Go over 18k keys. The
registry half of check-constructs/rails/projects now reads the committed snapshot (no Go, no scanner checkout), so it is no longer skipped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
expected-findings.json lists the (algorithm, status, reachability) tuples per file with evidence kind, libraries and own-lock Packages, the
gaps and scanner bugs (with reserved UNCOVERED row ids), the decoys and the files the triton CLI never scans. gen-expected --check fails on
any drift, a stale golden file, an untracked data file and, with a scanner checkout, a stale snapshot or a scanner change after its commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
compare-scan scans ruby/ as one root with the real triton CLI and fails on missing, extra, decoy, status, reachability, attribution,
derived-flag/token and evidence differences and on a scanner-bug tuple that is now reported. check-pins ties every Gemfile pin, Package claim,
derived range and catalogue claim to the locks and the registry snapshot. make check runs both without Go.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Only the recorded scanner commit changed; expected findings are identical.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- check: the compose hardening is asserted on exact lines of the app
  service and the last USER line, not by substring anywhere in the file.
- engine: an implementation index past the list is a 404; a string that
  is not valid UTF-8 is a 400 (both were 500s).
- server: a failed Thread.new drops that connection and keeps accepting.
- Makefile: TRITON_SRC, SCAN, ROOT, SAVE and TRITON_BIN are quoted;
  check-syntax covers gems.rb. README states the freshness auto-detect.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/triton-samples!2
No description provided.