Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide sensitive info when inspecting client #517

Merged
merged 2 commits into from
Sep 13, 2024

Conversation

samwaree
Copy link
Contributor

@samwaree samwaree commented Sep 13, 2024

Updates the .inspect method for OpenAI::Client to obfuscate sensitive values by replace them with [REDACTED]. This should prevent accidental logging of API keys, etc.

Resolves #513

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@@ -107,5 +107,17 @@ def beta(apis)
client.add_headers("OpenAI-Beta": apis.map { |k, v| "#{k}=#{v}" }.join(";"))
end
end

def inspect
sensitive_attributes = %i[@access_token @organization_id @extra_headers]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included extra_headers, since my thinking was this may contain other API keys and it is better to hide too much than potentially show something sensitive. Let me know if others disagree

@alexrudall
Copy link
Owner

Thanks @samwaree - would you say this is a breaking change? I tend towards not, surely nobody is relying on inspect

@samwaree
Copy link
Contributor Author

Thanks @samwaree - would you say this is a breaking change? I tend towards not, surely nobody is relying on inspect

@alexrudall That's my thought as well, more of a bug fix/minor update since it's just hiding certain values that shouldn't be shown anyway

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
@alexrudall alexrudall merged commit 3c9411f into alexrudall:main Sep 13, 2024
7 checks passed
@alexrudall
Copy link
Owner

Thanks @samwaree !

@samwaree samwaree deleted the hide-sensitive-info-inspect branch November 19, 2024 20:05
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.

OpenAI::Client#inspect does not filter out access_token or organization_id
2 participants