Unscoped Find should exclude only if all belongs_to associations are optional
Is your feature request related to a problem? Please describe. UnscopedFind doesn't detect models in our codebase that I believe it should. Our models have tenant_id and belongs_to :tenant on them. However, if there are any belongs_to associations that are marked as optional in a model the entire check is ignored.
Describe the solution you'd like I want to change UnscopedFind to only ignore if all belongs_to association are optional. The check is optional, and if you are opting in, presumably false positive with ignore is better than missing potential unscoped finds.
Describe alternatives you've considered
- Creating custom brakeman check
Additional context I know this PR https://github.com/presidentbeef/brakeman/pull/1153 changed the check, and the issue that it resolves was https://github.com/presidentbeef/brakeman/issues/1139. I'd consider that it's better to have a false positive there that you ignore than miss actual issues and if the model is representative of all belongs_to association then checking if all associations are optional would solve false positive there as well. I'm happy to create PR, but wanted to check if this would be a change that would even be considered before doing so.
Source: presidentbeef/brakeman