microsoft / infersharp

Infer# is an interprocedural and scalable static code analyzer for C#. Via the capabilities of Facebook's Infer, this tool detects null dereferences, resource leaks, and thread-safety violations. It also performs taint flow tracking to detect critical security vulnerabilities like SQL injections.
MIT License
735 stars 29 forks source link

run_infersharp.sh parameter must be an absolute path, relative paths do not work #108

Open peter-villadsen opened 2 years ago

peter-villadsen commented 2 years ago

If I run the run_infersharp.sh script from the infersharp1.2 directory I need to pass a parameter defining the root of the tree where the DLLs are found. The problem is that this tree can only be designated by an absolute path, not a relative one. In other words:

$ pwd /root $ infersharp1.2/run_infersharp.sh applicationplatform/bin

will print this: Processing {applicationplatform/bin} Copying binaries to a staging folder...\n cp: cannot stat 'applicationplatform/bin': No such file or directory Code translation started... Translation stage 1/3: Loading binaries. Translation stage 2/3: Computing type environment. Translation stage 3/3: Computing control-flow graph.

Coverage Statistics:

Method successfully translated: 0 (-2147483648%) Method partially translated: 0 (-2147483648%) Instructions translated: 0 (-2147483648%) Instructions skipped: 0 (-2147483648%)

Where as

$ infersharp1.2/run_infersharp.sh /root/applicationplatform/bin

will actually do the analysis as expected.

Also, if there is a real problem where the path really does not exist, you should probably stop with a decent error message and not print out junk information with -2147483648%

xinshiMSFT commented 2 years ago

Relative path should work. I tried a simple case and it works for me. I need to take a closer look.

root@cc7b3a8d04fa:~# pwd
/root
root@cc7b3a8d04fa:~# ./infersharp/run_infersharp.sh Examples/
Processing {Examples/}
Copying binaries to a staging folder...

Code translation started...

Regarding the second suggestion, we have made a fix to properly stop further execution if the script fails. Thank you!