-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Support integration with luzer #13929
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 integration with luzer #13929
Conversation
|
ligurio is integrating a new project: |
bc8fb48 to
e62118b
Compare
|
@jonathanmetzman could you please review? |
|
I can take a look at this but to be honest we're concerned about the maintenance burden supporting Lua will impose and somewhat doubtful of the impact. Could you maybe help us with the latter? Is the electrical grid, or something else very important running on Lua? |
Yeah, I remember this concern and took it into account when developing the patch. Hence, I avoid introducing the support for yet another language toolchain. Instead, my patch adds a wrapper generator for Lua tests and modifies the code to run these wrappers. The runtime itself will be compiled by the project. The patch with implementation is about 70 LOC, other changes is an example and documentation. I also want to say that I want to make this contribution on my own behalf, not on behalf of any company, so I'll be here; I won't run away immediately after the merge :)
There are two main scenarios for using Lua:
Physicists at CERN use LuaJIT (the Just-In-Time compiler) for computing physics accelerator beams 34. Network infrastructure (applications and known Lua-related CVE's):
Industrial cases:
Footnotes
|
projects/lua-example/build.sh
Outdated
| @@ -0,0 +1,36 @@ | |||
| #!/bin/bash -eu | |||
| # Copyright 2023-2025 Google LLC | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Just do 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed:
--- a/projects/lua-example/build.sh
+++ b/projects/lua-example/build.sh
@@ -1,5 +1,5 @@
#!/bin/bash -eu
-# Copyright 2023-2025 Google LLC
+# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.| @@ -0,0 +1,23 @@ | |||
| local luzer = require("luzer") | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a license header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed:
--- a/projects/lua-example/example_basic.lua
+++ b/projects/lua-example/example_basic.lua
@@ -1,3 +1,19 @@
+-- Copyright 2023-2025 Google LLC
+
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the
+-- License.
+-- You may obtain a copy of the License at
+
+-- http://www.apache.org/licenses/LICENSE-2.0
+
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+-- either express or implied.
+-- See the License for the specific language governing permissions
+-- and limitations under the License.
+
local luzer = require("luzer")
local function TestOneInput(buf)e62118b to
27cbbac
Compare
| # luarocks install --tree=lua_modules --server=https://luarocks.org/dev luzer | ||
| # XXX: A custom rockspec is used because custom branch is required, | ||
| # see https://github.com/ligurio/luzer/issues/63. | ||
| export OSS_FUZZ=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathanmetzman The OSS Fuzz environment has some differences 1 in comparison to usual Linux environment (for example, a name of sanitizers libraries and libclang_rt.fuzzer_no_main). What is a proper way to detect OSS Fuzz environment? There is no env like OSS_FUZZ among other env variables 2.
Footnotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to add one to base-images/base
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would make sense to define OSS_FUZZ everywhere? Currently it's necessary to do weird things like avahi/avahi@c01a63b to make scripts work in various environments including OSS-Fuzz. With OSS_FUZZ it should be possible to add if properly and take the OSS-Fuzz differences into account.
| @@ -0,0 +1,37 @@ | |||
| #!/bin/bash -eu | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathanmetzman this file will be used in every project for building wrappers for Lua tests. Where should we place it: in infra/base-images/base-builder/ (with other compile_*_fuzzer scripts), or in the project dirs (there will be some code duplication)?
|
I'm going to double check that others internally don't think this is a bad idea before proceeding. |
| @@ -0,0 +1,39 @@ | |||
| -- Copyright 2023-2025 Google LLC | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 2025 for copyright.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed:
--- a/projects/lua-example/example_basic.lua
+++ b/projects/lua-example/example_basic.lua
@@ -1,12 +1,12 @@
--- Copyright 2023-2025 Google LLC
+-- Copyright 2025 Google LLC
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the
-- License.27cbbac to
57847c8
Compare
cd infra/base-images/base-runner/ sudo docker build -f ubuntu-24-04.Dockerfile -t gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04 . sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test /tmp/not-out/tmpl_6fepn3/tarantool: error while loading shared libraries: libncurses.so.6: cannot open shared object file: No such file or directory Depends on google#13929 Depends on ligurio/luzer#74
This adds luarocks to the apt-get install list in: - docker/oss-fuzz/base/Dockerfile - docker/oss-fuzz/base/ubuntu-20-04.Dockerfile - docker/oss-fuzz/base/ubuntu-24-04.Dockerfile Unblocks: google/oss-fuzz#13929
|
/gcbrun trial_build.py lua |
cd infra/base-images/base-runner/ sudo docker build -f ubuntu-24-04.Dockerfile -t gcr.io/oss-fuzz-base/base-runner:ubuntu-24-04 . sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test /tmp/not-out/tmpl_6fepn3/tarantool: error while loading shared libraries: libncurses.so.6: cannot open shared object file: No such file or directory Depends on google#13929 Depends on ligurio/luzer#74
57847c8 to
32f9e6e
Compare
@jonathanmetzman is there any decision to this? |
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Requires ligurio/luzer#73
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Requires ligurio/luzer#73
|
We'll accept it. |
|
/gcbrun trial_build.py lua |
|
The partial support we have here (you may need to hunt down more places in infra/) breaks CI. Do you think we can pretend these are C projects or would you rather do more thorough support (I think the later makes sense). |
I looked at the logs 12 to figure out the cause, but it looks like the problem is the lack of Docker-image: Can you tell me where to look?
Let me explain how I see Lua integration to OSS Fuzz. With luzer, you can test both code written in plain Lua and native Lua extensions (that is, those implemented in C, for example lua-cmsgpack 3 or modules built into Lua runtimes). For native extensions written in C/C++, it's better to use the "C" name, because this is essentially a regular C project, and code coverage support and Fuzz Introspector analysis are already implemented for this language in OSS Fuzz. For extensions written in Lua, it's better to use a separate name, "lua." Without a separate category ("lua"), it will be difficult to implement coverage and Fuzz Introspector support for Lua in the future. What do you think? OSS Fuzz already have two C projects with native Lua extensions: tarantool and lua. For both, there are WIP pull requests: Technically for both cases the requirements to infra are similar:
Other things can be done on the side of the projects: create a wrapper script Footnotes |
|
@jonathanmetzman kind reminder |
|
Can you remove the use of lua as a language so that it piggybacks off of base-builder? I don't want our devs to think they need to maintain this so I'd rather the support remain a bit hacky. |
|
@jonathanmetzman thanks for the help! |
|
I actually want to test everything since we modified the base builders: #14808 |
|
I'm here if something will go bad and help will be required. |
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Requires ligurio/luzer#73
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Requires ligurio/luzer#73
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Requires ligurio/luzer#73
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Requires ligurio/luzer#73
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Requires ligurio/luzer#73
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Requires ligurio/luzer#73
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Requires ligurio/luzer#73
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Requires ligurio/luzer#73
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Depends on ligurio/lunapark#163 Depends on ligurio/luzer#73 Depends on ligurio/luzer#76 Depends on tarantool/tarantool#12097
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Depends on ligurio/lunapark#163 Depends on ligurio/luzer#73 Depends on ligurio/luzer#76 Depends on tarantool/tarantool#12097
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Depends on ligurio/lunapark#163 Depends on ligurio/luzer#73 Depends on ligurio/luzer#76 Depends on tarantool/tarantool#12097
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Depends on ligurio/lunapark#163 Depends on ligurio/luzer#73 Depends on ligurio/luzer#76 Depends on tarantool/tarantool#12097
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Depends on ligurio/lunapark#163 Depends on ligurio/luzer#73 Depends on ligurio/luzer#76 Depends on tarantool/tarantool#12097
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Depends on ligurio/lunapark#163 Depends on ligurio/luzer#73 Depends on ligurio/luzer#76 Depends on tarantool/tarantool#12097
sudo python infra/helper.py build_fuzzers tarantool sudo python infra/helper.py check_build tarantool decimal_new_test sudo python infra/helper.py run_fuzzer tarantool decimal_new_test Depends on google#13929 Depends on ligurio/luzer#73 Depends on ligurio/luzer#74 Depends on ligurio/luzer#76 Depends on ligurio/luzer#78 Depends on ligurio/lunapark#163 Depends on tarantool/tarantool#12097
Depends on google#13929 Depends on ligurio/luzer#73 Depends on ligurio/luzer#74 Depends on ligurio/luzer#76 Depends on ligurio/luzer#78 Depends on ligurio/lunapark#163 Depends on tarantool/tarantool#12097
- [x] ~~Depends on #13929~~ - [x] ~~Depends on ligurio/luzer#74 - [x] ~~Depends on ligurio/luzer#76 - [x] ~~Depends on ligurio/luzer#78 - [x] ~~Depends on ligurio/lunapark#163 - [x] Depends on tarantool/tarantool#12097
- [x] ~~Depends on google#13929~~ - [x] ~~Depends on ligurio/luzer#74 - [x] ~~Depends on ligurio/luzer#76 - [x] ~~Depends on ligurio/luzer#78 - [x] ~~Depends on ligurio/lunapark#163 - [x] Depends on tarantool/tarantool#12097
|
@jonathanmetzman Sorry for bothering. For unknown reasons, Lua tests cannot start (see full log https://github.com/tarantool/tarantool/actions/runs/21443723445/job/61753664347#step:5:451) when execution is triggered by Github Action: Before the start the command I suspect it is because Moreover, the problem cannot be reproduced locally. Any ideas why it could be? Footnotes |
|
Weird. Note that this is not the image that is used in ClusterFuzz. |
|
The fuzzers in cifuzz are run in cifuzz-run-fuzzers but this descends from cifuzz-base which descends from base-runner so things should be working. |
Follows up google#13929
|
Thanks for the answer! I suppose the problem is found - in cifuzz tests are executed not in the same directory where tests are located. I've used relative path instead absolute path to a directory with Lua modules in the |
The patch enables using luzer for fuzzing Lua projects in OSS-Fuzz.
Usage:
Closes #13782
Depends on ligurio/luzer#74