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

Don't show secrets for SignedGlobalID#inspect #160

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

p8
Copy link
Member

@p8 p8 commented Jun 20, 2023

If anyone calls to_sgid on a model in the console it will show the secret of the encryptor.

By overriding the inspect method to only show the class name we can avoid accidentally outputting sensitive information.

Before:

SignedGlobalID.create(Person.new(5)).inspect
"#<SignedGlobalID:0x0000000104888038 ... @secret=\"muchSECRETsoHIDDEN\ ... >"

After:

SignedGlobalID.create(Person.new(5)).inspect
"#<SignedGlobalID:0x0000000104888038>"

If anyone calls `to_sgid` on a model in the console it will
show the secret of the encryptor.

By overriding the `inspect` method to only show the class name we can
avoid accidentally outputting sensitive information.

Before:

```ruby
SignedGlobalID.create(Person.new(5)).inspect
"#<SignedGlobalID:0x0000000104888038 ... @secret=\"muchSECRETsoHIDDEN\ ... >"
```

After:

```ruby
SignedGlobalID.create(Person.new(5)).inspect
"#<SignedGlobalID:0x0000000104888038>"
```
@rafaelfranca rafaelfranca merged commit 86ddaae into rails:main Jun 30, 2023
17 checks passed
@p8 p8 deleted the security/gid-inspect branch July 1, 2023 06:13
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.

None yet

2 participants