feat(cpp): C/C++ ground-truth sample for cpp_ast #1
Loading…
Reference in a new issue
No description provided.
Delete branch "cpp-sample"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
C/C++ ground-truth sample for the
cpp_astscannerAdds
cpp/: a ground-truth sample for Triton'scpp_astcrypto scanner (Triton PR #1347), in the same shape as the Kotlin, Swift and Dart samples. It has per-library fixtures (OpenSSL, libsodium, Botan, Crypto++, Mbed TLS, wolfSSL and others), construct fixtures and decoys, Windows CNG and Apple CommonCrypto platform fixtures, project/build-system fixtures with real version pins, a catalogue of expected findings, and acompare-scanthat checks a real Triton CLI scan against the expected findings. A hardened Docker/Compose build and test setup is included.Verified
make check: rc 0, 262 node tests.make test: ctest 6/6 under docker (also podman) with Compose hardening (test service adds only SETUID/SETGID).compare-scan, standard and comprehensive profiles: 4252 expected = 4252 reported, exact (203 files), 0 missing / extra / skipped. Two findings the scan reports outside the sample are ignored by design.Known gaps and open items
--pathadds to default targets, default excludes cannot be cleared), #1355 (substring excludes) and #1352 (status policy)..superpowersledger is git-ignored and not part of this PR.Merge note
Please squash-merge. Intermediate commits are not all green:
make testis red from 71f9b27 to 6952756, andfad3da0and90a7cf5failnode --test. The final tree is green.🤖 Generated with Claude Code
The engine (src/engine: JSON, the build-time embedded catalogue and vectors, the implementation shapes, registration checks, run/verify and the self-test summary), the algorithm routes (GET /algorithms[/{id}], POST run and verify as bounded calls, GET /selftest fanning out one bounded call per entry through a new BoundedRunner hook of the HTTP server), and scripts/gen-families.mjs: one function per runnable implementation with the catalogue call verbatim on its own line, glue and registration after it, scan-only files, the family index. check-families.mjs scans the shipped tree with the real cpp_ast module. The catalogue probe now scans the shipped function shape; catalogue: the four stitched EVP_aes_*_cbc_hmac_* ciphers scan-only by rule, Crypto++ class headers and kdf.h/hmac.h/cmac.h includes, argon2i's own limits in its crypto_pwhash call. C++20 for the family files, the pinned library packages, static linking (runtime stays FROM scratch). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>The adapters (scripts/families/{hashing,mac,kdf,rng,pki}.mjs) and the generated family and scan-only files: all 570 runnable implementations of these families across OpenSSL (EVP, fetch, by-name, legacy low-level), libsodium, Crypto++, Botan 3, Mbed TLS (legacy and PSA) and PicoSHA2, each verified against an independent known-answer vector (src/vectors/vectors.json from scripts/vectors/gen-vectors.py: hashlib, pycryptodome, argon2-cffi, bcrypt, gostcrypto, pyskein, the openssl CLI, pure-Python references self-checked against published vectors, a pure-Python GOST R 34.11-94 checked against RFC 5831) or a round trip; 9 are NOT-RUNNABLE because the image's library build lacks the algorithm their call configures (listed with reasons). The family tests exercise every runnable implementation; the self-test does the same through the HTTP API. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>At --cpus 0.25 the SLH-DSA "s" sets and pqc-xmss hit the 20 s per-call deadline and /selftest ended RESULT: FAILED with 426 entries unverified (Task 3b review I1); asym-dh-1024#0's safe-prime search took 0.4 s to 13.4 s there. - An implementation can be marked slow with its reason (engine::slow; adapter spec `slow`, generated as slow(<shape>, "<reason>"); shown as "slow" by GET /algorithms/{id}). Its run, verify and self-test calls get the server's slow call deadline (SLOW_CALL_TIMEOUT_MS, default 60000) instead of CALL_TIMEOUT_MS (20000), which every other call keeps. The HTTP layer only knows a call class: a Bounded route may carry a slow predicate, and the self-test passes the entry's class to each bounded call. - Marked slow: every pqc-xmss implementation and every SLH-DSA "s"-set implementation except OBJ_nid2sn. - SELFTEST_BUDGET_MS defaults to 300000 (still bounded, still one self-test at a time). - Less work: a key an SLH-DSA "s"-set call generates is checked by OpenSSL's pairwise check, not by signing (the fixed key's deterministic signature stays the known answer); Botan's self-generated keys are made once per process. - asym-dh-1024#0 makes its safe-prime search in the call itself: scan-only, with its reason. The catalogue test now forbids any runnable search of 1024 bits or more (it failed on the old catalogue). Measured on the image's server (wall time of POST verify, Docker --cpus): - 0.25 CPU: pqc-xmss 25.1 s (42% of 60 s); SLH-DSA "s" sets 2.5 s to 9.1 s; nothing on the standard deadline above 6.7 s (asym-dsa, 33% of 20 s). - 0.15 CPU: pqc-xmss 31.6 s (53%); SLH-DSA "s" sets 4.1 s to 15.2 s. - GET /selftest: RESULT: OK at 0.25 CPU in 92.2 s, 94.9 s and 96.0 s (3 runs), and at 0.15 CPU in 154.3 s. Tests, each failing on the old code: http_integration (a route's slow call completes a 2.5 s call that the 1.5 s standard deadline stops); routes_integration (an implementation marked slow passes run, verify and the self-test on a 1 s standard deadline, while its unmarked twin is 504 and FAIL); engine_test (slow flags and describe); gen-families.test (the slow wrapper). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>C1: the catalogue's 481 Windows/Apple implementations (windows-cng 296, windows-capi 38, commoncrypto 147; 476 registry, 5 gap) now have their 23 sourceFiles. gen-families' generatePlatform writes them (no adapter): the GENERATED and PLATFORM marks, cstddef, the platform's crypto-free prerequisite (windows.h), the catalogue's includes and preludes, and per implementation its marker, `void platform_<n>(<params>) {`, the call verbatim, `(void)<name>;` after a declaration (so -Werror holds), `}`. The catalogue probe scans each in exactly that shape. check-generated families and removeStale cover windows/ and apple/ beside the hand-written fixtures. check-platform-fixtures tells the two kinds apart by the catalogue's sourceFiles plus the marks: a generated file must equal the generator's output and report exactly the catalogue's findings in ONE scan of the whole tree (check-families expectedFor + the extracted compareExpected); a hand-written file keeps its header checks and fails if it carries the marks. make check (no Go needed) requires every catalogue platform sourceFiles path to exist and accounts for every file under windows/ and apple/. Platform findings: 517 = 480 generated + 37 fixture headers. The mingw shim grows to 135 SDK 10.0.28000 identifiers (56 wide strings, 9 NCRYPT aliases, 70 CNG pseudo-handles); make check verifies names and wide values against the snapshot, and the WINDOWS_SDK_NUPKG check reads bcrypt.h and ncrypt.h and reports unparsable lines. typecheck-windows 31/31 and typecheck-apple 15/15, all -Werror. I1: the Containerfile is parsed as Docker reads it (continuations joined, the escape directive, comments inside a continuation, non-instructions fail closed); negation lines in the ignore files fail; RUN --mount bind sources must be allowed; compose contexts must be `.` and name no platform directory. Each review evasion and the combined attack failed-first as tests. Minor: headers and windows .c files are typechecked (M3); the cng-mode-cast-string control compiles via windows/cng_wide_property.h and every control is typechecked as edited (M6); an installed but broken container engine fails typecheck-windows instead of skipping (M8); the shim rule enforces what its comment says (M2); the pinned nupkg URL is recorded (M1). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>- Namespace closure measured with the real module and exercised: src/constructs/namespace_header_using.cpp (a header's using-directive opens Crypto++ for its includers) and namespace_block_gap.cpp (gap namespace-block-closure: an enclosing `namespace CryptoPP {` block does not open a family reached through a header), with a gap control; new UNCOVERED topic. - README blocks generated and checked: the implementation partition (classes add up to the catalogue total), the pre-standard PQC rated like FIPS (every SAFE non-FIPS PQC scheme with finding counts and the borderline cases), the CLI's default exclude patterns and the compile flags. - check-docs: a committed manifest of required figures (scripts/doc-manifest.mjs), untagged counts fail (allowlist with reasons, measured spans), commit ids of 7-40 hex characters in either case over the docs and the docs/superpowers copies, relative links and anchors, projects/README.md checked; figures for the server constants, the TLS level-0 records, the functional-only Botan schemes, the scanner caps and more; upper-case figure names are compared (they were not). - check-uncovered: the plan's minimum row list is parsed and mapped to units (PLAN_ROWS); checkExclusion requires *.md in both ignore files; gen-expected.test counts the catalogue instead of a hand-typed total. - Review fixes: where to clone, tiny-AES-c licence, Go/Node/vectors requirements, slow implementations, three UNCOVERED rows, "Adding an algorithm" (context.mjs/apiNames, append at the end, --write). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>