facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.83k stars 2k forks source link

Confusion about allow-list-path-regex CLI option #1746

Open peckto opened 1 year ago

peckto commented 1 year ago

I want to filter the results generated by infer. For the purpose I use the command infer report. In the documentation there are allow and block options, to whitelist/blacklist findings based on the source file location:

       --report-allow-list-path-regex +path_regex
           Report issues only on files whose relative path matches the
           specified OCaml regex (and which do not match
           --report-block-list-path-regex)

       --report-block-list-files-containing +string
           Do not report any issues on files containing the specified string

       --report-block-list-path-regex +path_regex
           Do not report any issues on files whose relative path matches the
           specified OCaml regex, even if they match the allow list specified
           by --report-allow-list-path-regex

From the documentation I understand, that first the allow list is processed and then the block list. Meaning, when allowing src/, only findings within src/ directory should be listed. To exclude src/test I could use the block option.

Unfortunately, I could not reproduce this behavior. The following command yields all findings:

$ infer report --report-allow-list-path-regex 'none-existing-path' 

The following command works as expected and excludes all findings from the report:

$ infer report --report-block-list-path-regex '.*'

It turns out, that in the actual implementation, the allow list is processed somehow after the block list. So this works:

$ infer report --report-allow-list-path-regex 'src/main/.*' --report-block-list-path-regex '.*'

Is this the intended functionality of the block/allow option?

Infer version:

$ infer --version
Infer version v1.1.0-600e1c17
Copyright 2009 - present Facebook. All Rights Reserved.

Build system: Linux

Subham122000 commented 1 year ago

that was same work sation