Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Lua language #1931

Closed
mwild1 opened this issue Oct 30, 2020 · 9 comments · Fixed by #2312
Closed

Support for Lua language #1931

mwild1 opened this issue Oct 30, 2020 · 9 comments · Fixed by #2312

Comments

@mwild1
Copy link

mwild1 commented Oct 30, 2020

Is your feature request related to a problem? Please describe.

Add support for the Lua language.

Additional context

Lua is used in a wide variety of contexts including many video games, business logic software, and within notable open-source software such as Apache, MediaWiki, Redis, VLC and Wireshark.

There is currently one popular static analysis tool for Lua, luacheck. However it is not as powerful or extensible as semgrep.

As a relatively small language with a relatively simple syntax, hopefully it wouldn't be tremendously difficult to support!

@aryx
Copy link
Collaborator

aryx commented Oct 30, 2020

There is actually already a tree-sitter grammar for LUA: https://github.com/Azganoth/tree-sitter-lua
so integrating LUA should not be too difficult.
We already have a few people adding support for C# and kotlin by also usint a tree-sitter-based parser.

@aryx
Copy link
Collaborator

aryx commented Oct 30, 2020

If you're willing to learn a bit OCaml, you could try to add yourself support for LUA!
See the work of @Sjord for C# support here: #1392

@Ruin0x11
Copy link
Contributor

Ruin0x11 commented Dec 26, 2020

I did a lot of work on this:

https://github.com/Ruin0x11/semgrep/tree/lua
https://github.com/Ruin0x11/pfff/tree/lua
https://github.com/Ruin0x11/semgrep-grammars/tree/lua
https://github.com/Ruin0x11/ocaml-tree-sitter/tree/lua
https://github.com/Ruin0x11/ocaml-tree-sitter-lang/tree/lua
https://github.com/Ruin0x11/tree-sitter-lua/tree/fix-call-expression

At this stage it can parse Lua source code to the generic AST format.

Blocked by #2280 and Azganoth/tree-sitter-lua#7. There are also still some other parse errors caused by tree-sitter-lua.

@aryx
Copy link
Collaborator

aryx commented Jan 4, 2021

@DrewDennison we should add Lua and C# on https://dashboard.semgrep.dev/languages

@DrewDennison
Copy link
Member

@aryx
Copy link
Collaborator

aryx commented Jan 6, 2021

Ok we're getting really close to get Lua support in semgrep!

@aryx
Copy link
Collaborator

aryx commented Jan 6, 2021

Hopefully we can release in the next version of semgrep next week (0.37)

@mwild1
Copy link
Author

mwild1 commented Jan 6, 2021

@Ruin0x11 @aryx and all: I just want to say thanks so much for all this effort! It's more exciting than Christmas! I'm looking forward to beginning experimenting with it :)

Happy new year!

@aryx
Copy link
Collaborator

aryx commented Jan 7, 2021

Good news we are also at 99.9% parsing success rate with tree-sitter-lua: https://dashboard.semgrep.dev/metric/semgrep.core.lua.parse.pct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants