I just saw this, haven't had a chance to try yet, but it looks very nice.
The idea is a "grep" style tool that understands language scoping and semantics well enough to be useful as a semantic search tool and a simple linter, currently implemented for C / Java / JavaScript / Python / Go . It also has a ruleset database of code errors/smells that should help find security issues and other errors although from what I can tell, it's mostly Python rules so far with only a few for other languages.
It supposedly allows, for example, a grep for os.system(...) in Python to find direct uses after import os, or unqualified uses after from os import system and even stuff like from os import system as execute; execute(args) and import os as x; x.system(args). Also allows matching on parameter values, backreferences and other stuff.
I think it could be useful for Nim (as another backend, perhaps some ideas integrated directly into the compiler or nimgrep). Still thinking about what rules I would write and what searches I would use, and I think it's much LESS useful for Nim than it is for e.g. Python or JS because the Nim compiler & tooling do so much more than Python or JS - but still, I think it's a neat idea and wanted to share.
Project: https://github.com/returntocorp/semgrep
Slides: https://r2c.dev/HellaSecureSemgrep.pdf
I like the idea. I'll have to play with it sometime.
I'm glad you linked the slides. I started by looking at the examples in semgrep repo, and they all showed semgrep through a docker; which makes sense for PHP/Python etc. But would be odd for a compiled language. I would think putting the source code into a docker instance would be a security hazard.
I'll probably play with this the next time I need to do deep code search on legacy code.
allows showing where a symbol is defined (works with all symbols) eg:
inspect resolveSymbol(`$`)
/Users/timothee/git_clone/nim/Nim_prs/tests/magics/tresolve_overloads.nim:134:35: $ = closedSymChoice:
/Users/timothee/git_clone/nim/Nim_prs/lib/system/dollars.nim:10:1 proc `$`(x: float): string {.magic: "FloatToStr", noSideEffect.}
/Users/timothee/git_clone/nim/Nim_prs/lib/system/dollars.nim:128:1 proc `$`[T](x: seq[T]): string
also works if you want to find where a particular overload is defined:
inspect resolveSymbol(newLit(true))
/Users/timothee/git_clone/nim/Nim_prs/tests/magics/tresolve_overloads.nim:151:27: newLit = /Users/timothee/git_clone/nim/Nim_prs/lib/core/macros.nim:702:1 proc newLit(b: bool): NimNode {.compileTime.}