feat(http): env-gated debug logging with hashed access tokens#180
Merged
Conversation
PANW_AI_SEC_DEBUG=1 logs every request/response to stderr across all domains; Authorization/x-pan-token values shown as sha256:<prefix> so raw tokens never leak. Zero output/overhead when unset. Closes #179.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #179.
What
Opt-in debug logging of every SDK API call, gated by the
PANW_AI_SEC_DEBUGenv var. Access tokens are hashed so logs are safe to share.src/http/debug.ts:isDebugEnabled,hashToken(sha256:<12 hex>),sanitizeHeaders,logRequest/logResponse.request()chokepoint → covers scan, management, model security, and red teaming uniformly.res.clone()so the real body isn't consumed. formData bodies log as[multipart/form-data].Security
Authorizationandx-pan-tokenvalues are replaced with a non-reversiblesha256:<prefix>hash —logRequestsanitizes internally so a caller can't leak a raw token. Verified live: real OAuth bearer logged asAuthorization":"sha256:6ba877dddebe". Zero output / zero overhead when the var is unset.Sample
Tests
test/http/debug.spec.ts— hashToken format/determinism, sanitizeHeaders redaction + case-insensitivity + no-mutation, isDebugEnabled truthy parsing.test/http/request.spec.ts— integration: enabled logs sanitized req/resp (raw token absent, hash present, status logged); disabled = silent; one log pair per retry attempt.Docs
docs/getting-started/environment-variables.md— new Debugging section with sample output + prompt-content warning.Changeset
minor— additive feature.