Is there a Findbugs and / or PMD equivalent for C/C++? [closed]

末鹿安然 提交于 2019-12-02 17:38:16
Thomas Owens

The two that come to mind are Splint for C and Cppcheck for C++.

If you want to look for more options, this function of these tools is "static code analysis". That might help you find more tools for C and/or C++. Also, you might be interested in the answer to the question "What open source C++ static analysis tools are available?"

C++ is a complicated enough language that the tooling for it (such as refactoring or static analysis tools) just isn't as good as Java or C#.

Gimpel Software's PC-lint is the closest thing to a standard bug-checking tool for C++ that I know of. It's commercial with a reasonable pricing model. I don't know how well it integrates with other tools.

The Clang open source project should eventually be able to do much of what you want (and looks really cool), but it's still in development.

PC-Lint is the way to go. Unlike most of the other tools, it has full inter-function and inter-module value tracking and supports all the hairy edges of template compilation/parsing as well. I bought a personal copy for myself about 9 years ago, just because it's so cheap. I ended up using it a lot in open source projects. PC-Lint doesn't license based on LOC, it doesn't phone home, and there's no license server. It's very much on the honor system and very no-nonsense. Over the 9 years, I have found some issues in it (and those have been few and far between), but they have almost always been fixed in a few weeks.

Open-source wise, there is SMatch, based on Coverity's meta-compilation analysis techniques, which the wine project uses quite heavily to great effect. PMD's cpd (copy paste detector) sub-tool works on C++, and is really fast. For cyclomatic complexity, there's pmccabe which is easily installable via apt-get (on Linux; on Windows, I compile the source under cygwin).

PC-Lint does require some configuration to get it working well, a day or two at the most. The other tools don't work as deeply, so you can just hit the ground running with a command like "find . -name .c | xargs pmccabe | sort -n | tail -n 20"

I've used Klocwork and Rational Software Analyzer in the past, and they both work well, though both are commercial/non-free.

I use flawfinder.py which scans for 160 dangerous functions in C/C++. http://www.dwheeler.com/flawfinder/

If you want a ruby port based on flawfinder then you can use vulnxpose.rb. https://github.com/nanotechz9l/Source-code-analyzer

Both of these tools scans C/C++ source code files for known vulnerabilities including buffer overflows, race conditions, weak crypto, chroot jail configs ... & more).

Rick

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!