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

Add toggle to control if Brakeman scans changed files, or all files #23

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

dgholz
Copy link

@dgholz dgholz commented Jun 1, 2020

Thanks for writing Pronto! We've integrated it into our CI pipeline, but have noticed that some checks fail to pick up some Brakeman issues, since Brakeman is passed a list of files to scan but checks like UnscopedFinds need scan data from models to detect problems. So if a change introduces an unscoped find in a controller, pronto-brakeman doesn't pick it up.

We'd rather have pronto-brakeman take a bit longer to scan all the files when running in the CI pipeline, so I've added a check for an environmental variable PRONTO_BRAKEMAN_ONLY_FILES that we can set to 0 in CI to force Brakeman to scan all files.

dgholz added 5 commits May 28, 2020 16:10
Issues like unscoped finds are only detected if Brakeman scans the models,
which means if a patch only changes a controller & introduces an unscoped find
it won't be detected.
@dgholz dgholz requested a review from a team as a code owner June 1, 2020 15:27
@dgholz
Copy link
Author

dgholz commented Jun 1, 2020

Not sure how to address the complexity issue raise by Code Climate, open to ideas!

Also if there's a way to set this option from the config file, I'd much prefer to enable/disable the behaviour with that instead of a bare env var.

@ashkulz
Copy link
Member

ashkulz commented Nov 4, 2020

Have you seen this comment? Until presidentbeef/brakeman#1368 is implemented, I think it would be better to always do this. While this would definitely slow up things for people running it as a git hook or where speed matters, we should have a flag for disabling it and it should clearly indicate what is happening e.g. PRONTO_BRAKEMAN_SPEED_OVER_ACCURACY = 1 🙂

@dgholz
Copy link
Author

dgholz commented Dec 7, 2020

Yes, that comment is why I made this change, since I saw it was impossible to do from Brakeman. I have opinions about changing the behaviour for existing users to make it slower, that's the kind of think I'd do if I could let them know about in advance. Also given the length of time that this behaviour has been the normal & how I'm the first person to suggest this, indicates there aren't many people affected by only scanning changed files.

@ashkulz
Copy link
Member

ashkulz commented Dec 8, 2020

I've been bitten by this in the past, and hence we do a full brakeman run as part of CI checks (I've also seen this mentioned in various other places) -- it's just that people accept it as-is. On making it slower -- do you think if it'll be better if we bump up version to 0.11.0 and prominently state this cause?

I'd rather we generated proper messages (a bit slower), especially since the upstream tool is so opinionated about the option we're using. Missing something invisibly is worse in my opinion than slowing up interactive/time-critical usage (which will be noted and investigated almost immediately).

@maksim-rubashko-freshly
Copy link

maksim-rubashko-freshly commented Feb 17, 2021

Any updates here?

We have same problem but with CheckRedirect check.
This check depends on data from models and it doesn't detect problem on CI, but it detects problem when you manually run brakeman.
Looks like we should remove only_files argument from Brakeman.run and always scan all files:

image

@ashkulz
Copy link
Member

ashkulz commented Feb 18, 2021

I think we need to make a call on whether this behavior is enabled by default or not. I'm in favor of doing it so, but the PR author (@dgholz) didn't reply to my comment. In the interim, 0.11.0 was released so I'm not sure what we should do 🤷‍♂️

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.

3 participants