clawdforge/clients
Kayos 19fe299b3d clients/cpp: apply audit findings — protocol-error guard + libcurl redirect clamp (bae34a7 → next)
HIGH:
- H1: nlohmann::json::exception wrapped as ProtocolError at 5 sites in
  client.cpp via with_protocol_guard helper. Preserves the documented
  clawdforge::Error catch-all base contract; nlohmann types never leak
  into the message (e.what() only).
- H2: libcurl MAXREDIRS=5, REDIR_PROTOCOLS_STR="http,https"
  (CURLOPT_REDIR_PROTOCOLS bitmask fallback for libcurl < 7.85.0),
  UNRESTRICTED_AUTH=0L. Defense-in-depth on top of libcurl's automatic
  bearer strip on cross-host redirects (>=7.64.0).

MEDIUM:
- M1: upload_file resolves the path via std::filesystem::canonical up
  front. Closes broken-symlink, symlink-loop, and TOCTOU-on-target
  classes without a doc burden on callers.
- M2: README "Linking" section documents the public-ABI nlohmann_json
  implication. v0.2 wrapper deferred.
- M3: README "Threat model" section documents the parse-depth concern
  on the result field of /run replies. Runtime guard skipped for v0.1
  per audit recommendation (low yield, complexity).

LOW:
- L1: cxx_std_20 → cxx_std_17 in CMakeLists.txt (no C++20-only
  features in the library source; broader downstream reach). Examples
  and tests still build via designated initializers (g++ accepts these
  in C++17 mode).
- L2: RunResult struct doc clarifies that missing ok/duration_ms
  decode to defaults — opt-out forward-compat.
- L3: Client class doc clarifies that moved-from instances must not
  have any non-special-member methods invoked (UB), with explicit
  callout on base_url() returning an internal reference.

Test-only:
- cpp-httplib 0.15.3 → 0.20.1. Optional backends (OpenSSL / zlib /
  brotli / zstd) forced off to keep the dep graph minimal. Test-only,
  never on the consumer wire path. README "Test deps" section added
  for transparency.

Tests added (12 → 23 cases, 70 → 106 assertions):
- protocol_error on malformed response for healthz, run, upload_file,
  create_token, list_tokens (H1 regression)
- redirect_clamp_test (H2 regression — TransportError after 5+ hops)
- redirect_protocol_clamp (H2 regression — ftp:// Location rejected)
- upload_file_canonicalize: symlink→file works, broken symlink
  rejected, symlink loop rejected, directory rejected (M1 regression)

Verified:
- cmake --build build clean (-Wall -Wextra -Wpedantic -Wshadow
  -Wconversion -Wsign-conversion -Wold-style-cast -Werror)
- ctest --output-on-failure all green (Release)
- ASan + UBSan: 23/23 cases, 106/106 assertions, zero diagnostics

Audit: memory/clawdforge-audits/cpp-bae34a7.md
2026-04-28 23:41:41 -07:00
..
bash clients/bash: apply audit findings — security hardening + correctness fixes (347fdde → new) 2026-04-28 23:09:06 -07:00
c clients/c: apply audit findings — security + CVE bump (a69e924 → new) 2026-04-28 23:25:22 -07:00
cpp clients/cpp: apply audit findings — protocol-error guard + libcurl redirect clamp (bae34a7 → next) 2026-04-28 23:41:41 -07:00
csharp clients/csharp: apply audit findings — JSON depth caps + stream lifecycle (09aca58 → new) 2026-04-28 23:22:58 -07:00
go clients/go: apply audit findings — fmt + doc + test coverage (3c62613 → new) 2026-04-28 23:08:46 -07:00
java clients/java: apply audit findings — true streaming upload + token redaction (0d3ee26 → next) 2026-04-28 23:20:45 -07:00
kotlin clients/kotlin: apply audit findings — per-call HTTP timeout + token redaction (cc54cfb → next) 2026-04-28 23:33:08 -07:00
mcp clients/mcp: apply audit findings — release-blocker fix on upload (093021c → new) 2026-04-28 23:10:33 -07:00
php clients/php: apply audit findings — token redaction + uploadStream + tests (1cff9b8 → next) 2026-04-28 23:12:34 -07:00
python clients/python: apply audit findings (90e158f → next) 2026-04-28 23:07:38 -07:00
ruby clients/ruby: apply audit findings (b1d6e3f -> new) 2026-04-28 23:07:49 -07:00
rust clients/rust: apply audit findings — UTF-8 panic + Debug redaction + path-traversal (062d405 → next) 2026-04-28 23:26:22 -07:00
swift clients/swift: apply audit findings — multipart fix + token redaction (e4e8192 → HEAD) 2026-04-28 23:12:17 -07:00
typescript clients/typescript: apply audit findings — uploadFile streaming + metadata + validation (15de6e7cc54cfb) 2026-04-28 23:12:27 -07:00