Conversation
85f5e83 to
4c3c10a
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3224 +/- ##
==========================================
+ Coverage 70.33% 70.35% +0.01%
==========================================
Files 214 216 +2
Lines 6839 6857 +18
==========================================
+ Hits 4810 4824 +14
- Misses 2029 2033 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
3238780 to
9988915
Compare
9988915 to
cb82a61
Compare
cb82a61 to
b7bfbd7
Compare
62fa41c to
014d4d7
Compare
| def soft_delete! | ||
| update(name: 'Deleted User', email: nil) |
There was a problem hiding this comment.
I think it is better to blow up if the update did not work. soft_delete does not need a !. The ! indicates a volatile version of a method. Since we do not implement two versions of this method, we should not use !.
| def soft_delete! | |
| update(name: 'Deleted User', email: nil) | |
| def soft_delete | |
| update!(name: 'Deleted User', email: nil) |
There was a problem hiding this comment.
Maybe we can add a new column deleted_at and add a timestamp when the user was deleted. This is good for debugging.
There was a problem hiding this comment.
Is the updated_at not serving the pretty much same purpose? Once a ExternalUser is updated with (name: 'Deleted User', email: nil) it won't be updated again, right?
There was a problem hiding this comment.
It might be. The username Deleted User could be used by a user. No email could be a side effect from some bug. The deleted_at just makes it clearer and is a common practice for soft deletions.
There was a problem hiding this comment.
I added the deleted_at column and update it now in the soft_delete method.
014d4d7 to
667a61b
Compare
667a61b to
37a665c
Compare
1b514dc to
71bbf3d
Compare
71bbf3d to
142fae9
Compare
142fae9 to
79b8847
Compare
4f7469b to
4379562
Compare
This is a possible way to GDPR delete users via a API. The background is that if we delete a user on openhpi we also want to delete the user on codeocean. Part of SODEV-2997
4379562 to
29ef0d1
Compare
| unless ActiveSupport::SecurityUtils.secure_compare( | ||
| token.to_s, | ||
| ENV.fetch('OPENHPI_API_TOKEN', nil) | ||
| ) |
There was a problem hiding this comment.
Bug: ActiveSupport::SecurityUtils.secure_compare will raise a NoMethodError if the OPENHPI_API_TOKEN environment variable is not set, as ENV.fetch will return nil.
Severity: HIGH
Suggested Fix
Ensure the value passed to secure_compare is a string. Either convert the result of ENV.fetch to a string using .to_s, like ENV.fetch('OPENHPI_API_TOKEN', nil).to_s, or provide an empty string as the default value to fetch, like ENV.fetch('OPENHPI_API_TOKEN', '').
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: app/controllers/api/api_controller.rb#L10-L13
Potential issue: The `authenticate` method uses
`ActiveSupport::SecurityUtils.secure_compare` to validate an API token. The second
argument to this function is `ENV.fetch('OPENHPI_API_TOKEN', nil)`. If the
`OPENHPI_API_TOKEN` environment variable is not set, for example due to a deployment
misconfiguration, `ENV.fetch` will return `nil`. The `secure_compare` function then
attempts to call `.bytesize` on this `nil` value, which raises a `NoMethodError`. This
causes the request to fail with a 500 Internal Server Error instead of gracefully
returning a 401 Unauthorized status as intended.
This PR introduces a possible way to GDPR delete users via a API.
If we delete a user on openHPI we also have to delete the user on codeocean. Previously this was handled via a rake task that has to be triggered manually.
Part of SODEV-2997