Python static analysis comparison: Bandit vs Semgrep
Blog post from Semgrep
GitLab announced a transition from Bandit and ESLint to Semgrep for SAST analyzers, beginning with the GitLab 14.0 release. Semgrep offers a broader range of community-maintained rules across multiple programming languages, while Bandit is focused on Python with fewer but more precise rules. Semgrep allows for rapid customization and extension of rules, which makes it versatile and adaptable to varying security needs. Both tools can be integrated into CI/CD pipelines and support ignoring specific lines of code or paths, but Semgrep’s multilingual capabilities enable it to handle multi-language projects. Despite Semgrep's slower performance on smaller repositories due to setup overhead, it matches Bandit's speed on larger repositories, particularly when multithreading is enabled. Additionally, both tools facilitate rule testing and custom rule creation, with Semgrep offering a more straightforward pattern syntax.