Domanda

I'm trying to configure Brakeman for my Rails projects and I want it to ignore certain directories and files. I can't find an option to specify paths to exclude. Does anyone know if this is possible?

È stato utile?

Soluzione 2

You can use the --skip-files option to ignore specific files, but there is not currently support for skipping entire directories. There is also the inverse option --only-files which does accept directories. Additionally, there is the --skip-libs option to skip just the lib directory. (You should check the output of brakeman --help for more options.)

However, if you really want to skip an entire directory, you could do something like

ls app/some/dir/ | paste -s -d , - | xargs brakeman --skip-files

If you are using Brakeman as a library, then you can pass the files in :skip_files:

Brakeman.run(:app_path => "my_app", :skip_files => Dir["my_app/bad/path/*"])

Altri suggerimenti

There is now support for skipping entire directories. See https://www.rubydoc.info/gems/brakeman/4.3.1

brakeman --skip-files file1,/path1/,path2/

After digging more into the source code, I found that Brakeman::Scanner generates an AppTree object, which takes an argument called skip_files.

Source is here: https://github.com/presidentbeef/brakeman/blob/master/lib/brakeman/app_tree.rb#L12

If you look further down in that file, you can also see what directories Brakeman looks at when it scans. It turns out some of my exceptions are already excluded by Brakeman's cleverness!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top