Skip to content

Make every opt-out fail closed (0.4.0) - #36

Merged
dmccoystephenson merged 1 commit into
mainfrom
fix/opt-out-fails-closed
Nov 19, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
fix/opt-out-fails-closed

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Usage reporting must actually stay off when it is turned off. This brings the C++ client to the same fail-closed semantics as the Java client 0.8.0 (Stephenson-Software/trace-client-java#51).

Fail-open paths fixed

  • TRACE_USAGE_REPORTING was a deny-list (off/false/0/no): any other non-blank value, e.g. disabled or a typo, left reporting on. It now disables for anything but blank or true/on/yes/1 (case-insensitive, trimmed).
  • DO_NOT_TRACK was an allow-list of opt-outs (1/true/yes): on, y and so on left reporting on. It now disables for anything but blank or 0/false/off/no.
  • An environment that cannot be read now counts as opting out (environmentOptsOut() catches and returns true); it never throws.
  • The program's own setting had no fail-closed reader. New trace_client::allowsReporting(value): true, or a std::string/const char * reading true/on/yes/1, allows reporting; false, a quoted "false", a typo, a null pointer, a number or any other type turns it off. The README and header examples now use it.

The client reads no config file of its own with a switch (the install-ID file holds only an ID), so no file-parsing changes were needed.

Version

0.3.0 → 0.4.0 in the header comment, TRACE_CLIENT_VERSION, CMakeLists.txt and the README User-Agent example.

Tests

make test: 81 tests, 0 failed checks (env tests now cover typos and the new accepted "on"/"no" values; allowsReporting tests cover bool, std::string, const char *, char *, null, nullptr, numbers). Also compiles warning-free under -std=c++17.

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

A switch that does not clearly mean "on" now turns reporting off, so an
opt-out can never be read as consent:

- Environment: TRACE_USAGE_REPORTING set to anything but blank or a clear
  "on" (true/on/yes/1) disables; DO_NOT_TRACK set to anything but blank or
  a clear "no" (0/false/off/no) disables. Before, only a fixed list of
  values disabled, so TRACE_USAGE_REPORTING=disabled or DO_NOT_TRACK=on
  left reporting on. An environment that cannot be read now disables.
- New trace_client::allowsReporting(value) for a program's own setting:
  only true, or a string true/on/yes/1, allows reporting; anything else,
  including a null pointer, a number or a quoted "false", turns it off.
  The README and header examples now pass the setting through it.

Counterpart of Stephenson-Software/trace-client-java#51.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant