Skip to content

refactor: store api keys in a SecretString#40

Merged
PTFOPlayer merged 1 commit into
PTFOPlayer:masterfrom
brhutchins:refactor/secret-string-for-api-keys
Jun 29, 2026
Merged

refactor: store api keys in a SecretString#40
PTFOPlayer merged 1 commit into
PTFOPlayer:masterfrom
brhutchins:refactor/secret-string-for-api-keys

Conversation

@brhutchins

@brhutchins brhutchins commented Jun 28, 2026

Copy link
Copy Markdown
Contributor
  • Add local SecretString type, which
    • redacts the secret in Debug implementation
    • centralises masking implementation
    • forces exposing of secrets to be explicit
  • Use SecretString for existing secrets

NOTE: Since TinyHarness aims to avoid pulling in external dependencies where feasible, this recreates minimal functionality from the secrecy crate. The local implementation isn't as flexible or secure as the external crate's, but should be sufficient for the use case.

Why?: Previously, API keys were stored as plain strings, making leaks in e.g. logs likely, and making inadvertent leaks to models relatively easy. Revealing a SecretString can only be done explicitly, constraining the potential leak surface.

- Add local `SecretString` type, which
    - redacts the secret in `Debug` implementation
    - centralises masking implementation
- Use `SecretString` for existing secrets

**NOTE**: Since TinyHarness aims to avoid pulling in external
dependencies where feasible, this recreates minimal functionality from
the `secrecy` crate. The local implementation isn't as flexible or
secure as the external crate's, but should be sufficient for the use
case.

**Why?**: Previously, API keys were stored as plain strings, making
leaks in e.g. logs likely, and making inadvertent leaks to models
relatively easy. Revealing a `SecretString` can only be done explicitly,
constraining the potential leak surface.
@PTFOPlayer PTFOPlayer self-requested a review June 29, 2026 06:15
@PTFOPlayer PTFOPlayer merged commit 1df4672 into PTFOPlayer:master Jun 29, 2026
10 checks passed
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.

2 participants