semgrep VS ast-grep

Compare semgrep vs ast-grep and see what are their differences.

semgrep

Lightweight static analysis for many languages. Find bug variants with patterns that look like source code. (by semgrep)
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
semgrep ast-grep
75 35
9,742 5,950
1.4% 4.2%
9.9 9.9
5 days ago about 19 hours ago
OCaml Rust
GNU Lesser General Public License v3.0 only MIT License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

semgrep

Posts with mentions or reviews of semgrep. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-04-16.
  • Semgrep: Semantic Grep for Code
    1 project | news.ycombinator.com | 30 Apr 2024
    1 project | news.ycombinator.com | 4 Aug 2023
  • A Deep Dive Into Terraform Static Code Analysis Tools: Features and Comparisons
    6 projects | dev.to | 16 Apr 2024
    Semgrep OSS Owner/Maintainer: Semgrep Age: First release on GitHub on February 6th, 2020 License: GNU Lesser General Public License v2.1
  • Semgrep – Find bugs and enforce code standards
    1 project | news.ycombinator.com | 9 Apr 2024
  • Application Security - Bridging Frontend and Cybersecurity: What is Application Security?
    1 project | dev.to | 2 Apr 2024
    Semgrep - https://semgrep.dev
  • Creating a DevSecOps pipeline with Jenkins — Part 1
    3 projects | dev.to | 17 Mar 2024
    For the SAST stage, I used SonarQube tool. SonarQube is an open-source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs and code smells on more than 30 programming languages. I preferred SonarQube instead of other SAST tools because it has a detailed documentation and plugins about integration with Jenkins and SonarQube works with Java projects pretty well. Of course you can similar multi-language-supported tools such as Semgrep or language-specific tools such as Bandit.
  • Tree-Sitter
    4 projects | news.ycombinator.com | 17 Feb 2024
    > Not sure I understand your point.

    The problem is using Treesitter (for syntax highlighting and "semantic movements") and an LSP at the same time. So if your language has a LSP, using Treesitter additionally is redundant at best and introduces inconcistency at worst.

    I'm not talking about using Treesitter as the parser for the LSP.

    > Most popular languages have language-specific tools

    I'd say even less popular langauges like Coq^H^H^HRocq, Lean 4, Koka, Idris, Unison, ... have their "own" tools, I do not know of a language that uses a Treesitter parser in its LSP, but I do know about tools like https://semgrep.dev/ (written in OCaml) and Github's code search which use Treesitter.

  • AST-grep(sg) is a CLI tool for code structural search, lint, and rewriting
    15 projects | news.ycombinator.com | 10 Dec 2023
    Well, when I seach for "semgrep", I get a very nice corporate landing page with a "Book Demo" button. Which is a level of hassle that just isn't worth it for smaller teams, because "Book Demo" usually means "We're going to try to do a dance to see how much money we can extract from you." Which smaller teams may only want to do for a handful of key tools.

    (4 years ago, I was more willing to put up with enterprise licensing. But in the last two years, I've seen way too many enterprise vendors try to squeeze every penny they can get from existing clients. An enterprise sales process now often means "Expect 30% annual price hikes once you're in too deep to back out.")

    There's also an open source "semgrep" project here: https://github.com/semgrep/semgrep. But this seems to be basically a vulernability scanner, going by the README.

    Whereas AST-grep seems to focus heavily on things like:

    1. One-off searching: "Search my tree for this pattern."

    2. Refactoring: "Replace this pattern with this other pattern."

    AST-grep also includes a vulnerability scanning mode like semgrep.

    It's possible that semgrep also has nice support for (1) and (2), but it isn't clearly visible on their corporate landing page or the first open source README I found.

  • Top 10 Snyk Alternatives for Code Security
    3 projects | dev.to | 31 Aug 2023
    7. Semgrep
  • semgrep VS bearer - a user suggested alternative
    2 projects | 10 Jul 2023

ast-grep

Posts with mentions or reviews of ast-grep. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-04-28.
  • An infinite canvas for code exploration
    1 project | news.ycombinator.com | 6 May 2024
    It's unclear what the superpowers would be? Video doesn't show anything I can't do with an IDE or decent code editor, and there I also have refactoring tools, metadata like indicators for usages that can be used for navigating and so on.

    Reminds me of UML-like diagrams over relational databases, except that it's generated one piece at a time. In practice I generate diagrams showing cyclomatic complexity much more often, and for code exploration outside the IDE I'd use ast-grep.

    https://ast-grep.github.io/

  • Migrate to React 19 with ast-grep
    2 projects | dev.to | 28 Apr 2024
    This article illustrates the usage of ast-grep, a tool designed to locate and substitute patterns in your codebase, towards easing your migration to React 19.
  • AST-grep(sg) AST grep based on Treesitter
    1 project | news.ycombinator.com | 1 Apr 2024
  • Show HN: GritQL, a Rust CLI for rewriting source code
    8 projects | news.ycombinator.com | 20 Mar 2024
    This looks great, thanks for building and sharing it.

    Interested folks may also want to check out ast-grep:

    https://github.com/ast-grep/ast-grep

  • How I build a chatbot for my OSS project, for free, without code!
    2 projects | dev.to | 31 Dec 2023
    ast-grep is a command-line tool that lets you search and transform code written in many programming languages using abstract syntax trees (ASTs). ASTs are data structures that capture the syntactic and semantic structure of source code. With ast-grep, you can write patterns as if you are writing ordinary code, and it will match all code that has the same syntactical structure. And if you need more power, you can use YAML, a rule system that allows you to write more sophisticated linting rules or code modifications.
  • FLaNK Stack Weekly 11 Dec 2023
    31 projects | dev.to | 11 Dec 2023
  • AST-grep(sg) is a CLI tool for code structural search, lint, and rewriting
    1 project | /r/patient_hackernews | 10 Dec 2023
    1 project | /r/hackernews | 10 Dec 2023
    1 project | /r/hypeurls | 10 Dec 2023
    15 projects | news.ycombinator.com | 10 Dec 2023
    I really like this - it means the tool is available to people with familiarity of any of those four distribution mechanisms.

    You can also download pre-built binaries from their releases page: https://github.com/ast-grep/ast-grep/releases/tag/0.14.2

    On top of that, they offer API bindings for it in three different languages:

    - Rust (not yet stable): https://docs.rs/ast-grep-core/latest/ast_grep_core/

    - JavaScript/TypeScript: https://ast-grep.github.io/guide/api-usage/js-api.html

    - Python: https://ast-grep.github.io/guide/api-usage/py-api.html

    It's rare to see a tool/library offer this depth of language support out of the box.

What are some alternatives?

When comparing semgrep and ast-grep you can also consider the following projects:

SonarQube - Continuous Inspection

ssr.nvim - Treesitter based structural search and replace plugin for Neovim.

snyk - Snyk CLI scans and monitors your projects for security vulnerabilities. [Moved to: https://github.com/snyk/cli]

helix - A post-modern modal text editor.

codeql - CodeQL: the libraries and queries that power security researchers around the world, as well as code scanning in GitHub Advanced Security

weggli - weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.

Spotbugs - SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.

git-repo-sync - Auto synchronization of remote Git repositories. Auto conflict solving. Network fail resilience. Linux & Windows support. And more.

pre-commit - A framework for managing and maintaining multi-language pre-commit hooks.

telescope.nvim - Find, Filter, Preview, Pick. All lua, all the time.

detect-secrets - An enterprise friendly way of detecting and preventing secrets in code.

telescope-sg - Ast-grep picker for telescop.nvim