-
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
base: master
Are you sure you want to change the base?
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
| @@ -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
The patch enables using luzer for fuzzing Lua projects in OSS-Fuzz. sudo docker build infra/base-images/base-runner sudo docker tag 12a7301c37b0 gcr.io/oss-fuzz-base/base-runner:latest 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 . Usage: sudo python infra/helper.py build_fuzzers lua-example sudo python infra/helper.py check_build lua-example fuzz_basic sudo python infra/helper.py run_fuzzer lua-example fuzz_basic TODO - Fix compile_lua_fuzzer-related text in documentation - Move projects/lua-example/compile_lua_fuzzer to infra? - Describe using luzer for testing builtin Lua C modules Closes google#13782
57847c8 to
32f9e6e
Compare
The patch enables using luzer for fuzzing Lua projects in OSS-Fuzz.
Usage:
Closes #13782
Depends on ligurio/luzer#74