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

False-positives for Flask #232

Open
MartinThoma opened this issue Sep 9, 2020 · 2 comments
Open

False-positives for Flask #232

MartinThoma opened this issue Sep 9, 2020 · 2 comments

Comments

@MartinThoma
Copy link

MartinThoma commented Sep 9, 2020

I've noticed some false-positives with Flask applications:

  • app.url_map.strict_slashes = False (source)
  • Functions under a @app.errorhandler(SomeException)
  • Functions under a @app.route
  • Functions under a @after_this_request
@RJ722
Copy link
Contributor

RJ722 commented May 15, 2021

Regarding ignoring results for functions which are decorated by some specific decorator:

The --ignore-decorators option can be used to ignore functions decorated with the given decorator. This is helpful for example in Flask projects, where you can use --ignore-decorators "@app.route" to ignore all functions with the @app.route decorator.

For your use case, I think you can invoke Vulture like following:

vulture dir/ --ignore-decorators "@after_this_request,@app.errorhandler,@app.route"

To deal with strict_slashes variable, I think the following whitelist should suffice:

from vulture.whitelists.whitelist_utils import Whitelist
flask_whitelist = Whitelist()

flask_whitelist.url_map.strict_slashes

@jendrikseipp
Copy link
Owner

It would actually be useful to put the strict_slashes field into a whitelist that we then bundle with Vulture. Care to draft a pull request for this (see https://github.com/jendrikseipp/vulture/pull/258/files for an example)?

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

No branches or pull requests

3 participants