Live data from Hacker News

Semgrep: Semantic grep for code

semgrep.dev

1–10 of 110 posts

Re: Semgrep: Semantic grep for code

#6
post #3

> You need to enable JavaScript to run this app. Wait, is this a web app? I was expecting a command line tool to navigate my code locally.

The cli is here: https://semgrep.dev/docs/getting-started/

You can write stuff like

    # Check for Python == where the left and right hand sides are the same (often a bug)
    $ semgrep -e '$X == $X' --lang=py path/to/src

Re: Semgrep: Semantic grep for code

#8
post #5
post #3

> You need to enable JavaScript to run this app. Wait, is this a web app? I was expecting a command line tool to navigate my code locally.

There’s a demo on the site, I assume that’s it?

No, it's just the landing page. Apparently it does not allow to see it without running some javascript.

Re: Semgrep: Semantic grep for code

#9
post #2

Isn't "grep for code" called just "grep"?

Semgrep started off as a “syntactic grep” but has increasingly become more semantic. So if you want to find all calls to foo that have 1 as the first argument, you just search for foo(1) and even things like x = 1; foo(x); will match.

Here’s an elaborate example: https://semgrep.dev/s/ievans:c-dataflow

Re: Semgrep: Semantic grep for code

#10
post #9
post #2

Isn't "grep for code" called just "grep"?

Semgrep started off as a “syntactic grep” but has increasingly become more semantic. So if you want to find all calls to foo that have 1 as the first argument, you just search for foo(1) and even things like x = 1; foo(x); will match. Here’s an elaborate example: https://semgrep.dev/s/ievans:c-dataflow

Ok, I've put the word 'semantic' up there so we can not get hung up on title stuff. (Submitted title said "Like Grep but for Code".)
Post reply on HN