Keep credentials out of app-server logs (#39993)

## Why

App-server logs can be persisted or included in submitted diagnostics, so credentials used by model providers, authentication refreshes, and attestation requests must not appear in diagnostic output.

## What changed

- Add `RedactedString`, which preserves serialization and string access while replacing debug output with `<redacted>`.
- Use it for model-provider bearer tokens, header and query values, authentication command arguments, and attestation tokens.
- Avoid logging JSON-RPC error payloads and parser or authentication errors that may echo credentials; retain safe context such as error codes and categories.

## Testing

- Add an app-server regression test that exercises provider credentials, refreshed authentication tokens, and attestation tokens, then verifies none appear in persisted SQLite or submitted diagnostic logs.

GitOrigin-RevId: 8c50408adf94d93847658b1320682cf3b637d2cc
This commit is contained in:
andrewgu-oai
2026-08-21 19:04:32 +00:00
committed by copyberry
parent 45a3edc02a
commit 79b7606803
36 changed files with 446 additions and 108 deletions
@@ -0,0 +1,6 @@
load("//:defs.bzl", "codex_rust_crate")
codex_rust_crate(
name = "redacted-string",
crate_name = "codex_utils_redacted_string",
)
+16
View File
@@ -0,0 +1,16 @@
[package]
name = "codex-utils-redacted-string"
version.workspace = true
edition.workspace = true
license.workspace = true
[lints]
workspace = true
[dependencies]
schemars = { workspace = true }
serde = { workspace = true, features = ["derive"] }
[lib]
test = false
doctest = false
+49
View File
@@ -0,0 +1,49 @@
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
use std::fmt;
use std::ops::Deref;
use std::ops::DerefMut;
/// A string whose `Debug` output is redacted.
#[derive(Clone, Default, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
#[serde(transparent)]
pub struct RedactedString(String);
impl RedactedString {
pub fn into_inner(self) -> String {
self.0
}
}
impl Deref for RedactedString {
type Target = String;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for RedactedString {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl From<String> for RedactedString {
fn from(value: String) -> Self {
Self(value)
}
}
impl From<&str> for RedactedString {
fn from(value: &str) -> Self {
Self(value.to_owned())
}
}
impl fmt::Debug for RedactedString {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("<redacted>")
}
}