Commit graph

355 commits

Author SHA1 Message Date
Andrew Kaster 32d076ef54 Lagom: Add proper install rules
Create the proper export files to allow Lagom to be a well-behaved
ExternalProject, based on the example project from the cmake-init
project generator here:

https://github.com/friendlyanon/cmake-init-shared-static
2021-07-29 21:46:25 +01:00
Linus Groh 7392a73066 Lagom: Exclude GMLAutocompleteProvider.cpp from GML library sources 2021-07-29 21:46:25 +01:00
Andrew Kaster b6e5117f65 Lagom: Change to shared library build for all Lagom code
Split the Lagom build into shared libraries to match the Serenity build.

This reduces the cognitive load when trying to edit the Lagom CMakeLists
significantly. It also reduces the amount of source files that must be
compiled to run each test or host program significantly.

Also re-organize all the build rules into sections. And reorganize the
CMakeLists file in general.
2021-07-29 21:46:25 +01:00
Andrew Kaster af9be6e093 LibTTF/LibGfx: Remove circular dependency by merging LibTTF into LibGfx
LibTTF has a concrete dependency on LibGfx for things like Gfx::Bitmap,
and LibGfx has a concrete dependency in the TTF::Font class in
Gfx::FontDatabase. This circular dependency works fine for Serenity and
Lagom Linux builds of the two libraries. It also works fine for static
library builds on Lagom macOS builds.

However, future changes will make Lagom use shared libraries, and
circular library dependencies are not tolerated in macOS.
2021-07-29 21:46:25 +01:00
Timothy Flynn 98d8274040 Meta: Add LibUnicode (and its tests) to Lagom
This is primarily to allow using LibUnicode within LibJS and its REPL.

Note: this seems to be the first time that a Lagom dependency requires
generated source files. For this to work, some of Lagom's CMakeLists.txt
commands needed to be re-organized to include the CMake files that fetch
and parse UnicodeData.txt. The paths required to invoke the generator
also differ depending on what is currently building (SerenityOS vs.
Lagom as part of the Serenity build vs. a standalone Lagom build).
2021-07-26 17:03:55 +01:00
Luke 7e7c65abb6 Lagom/Fuzzers: Add fuzzer for the quoted printable decoder 2021-07-24 20:11:28 +04:30
Luke 448e8c6f45 Lagom/Fuzzers: Add fuzzer for FLAC loader 2021-07-13 01:15:46 +02:00
Luke 93340685ed Lagom/Fuzzers: Add fuzzer for POSIX basic regex parser 2021-07-13 01:34:22 +04:30
Jan de Visser 99dc3469e8 Lagom: Exclude LibSQL/SQLClient.cpp and the sql utility from Lagom
Lagom doesn't seem to like IPC services, and sql needs SQLClient.
2021-07-08 17:55:59 +04:30
Idan Horowitz 53f70e5208 LibJS: Remove the default length & attributes from define_native_*
These are usually incorrect, and people sometimes forget to add the
correct values as a result of them being optional, so they should just
be specified explicitly.
2021-07-06 14:20:30 +01:00
Idan Horowitz a6b8291a9b LibJS: Add define_direct_property and remove the define_property helper
This removes all usages of the non-standard define_property helper
method and replaces all it's usages with the specification required
alternative or with define_direct_property where appropriate.
2021-07-06 14:20:30 +01:00
Gunnar Beutner 5c3f781031 Meta: Fix building Lagom on Linux 2021-07-06 02:10:37 +02:00
Gunnar Beutner 01db5205ab LibThreading: Fix building the library on macOS 2021-07-06 00:06:32 +02:00
Andreas Kling 49d0b9e808 LibTTF: Memory map TTF fonts instead of reading them into heap memory
All GUI applications currently load all TTF fonts on startup
(to populate the Gfx::FontDatabase. This could probably be smarter.)

Before this patch, everyone would open the files and read them into
heap-allocated storage. Now we simply mmap() them instead. :^)
2021-07-04 21:34:26 +02:00
Andreas Kling 560109bd42 LibTTF: Make TTF::Font loading API return error strings 2021-07-04 21:34:26 +02:00
Jan de Visser 4198f7e1af LibSQL: Move Lexer and Parser machinery to AST directory
The SQL engine is expected to be a fairly sizeable piece of software.
Therefore we're starting to restructure the codebase for growth.
2021-06-24 00:36:53 +02:00
coderdreams 9ffb3e7e30 LibCore: Add unit test for File::read_line 2021-06-22 18:54:40 +04:30
Peter Bocan 4d5ffd364a LibCrypto+LibTLS: Split and move test suite into Tests directory
This change splits test-crypto.cpp from Userland into separate test
suites located in Tests/ directory.
2021-06-19 19:05:36 +04:30
Luke f29036dc98 Lagom/Fuzzers: Add fuzzers for all current hashing functions
Namely MD5, SHA1, SHA256, SHA384 and SHA512.
2021-06-18 21:44:56 +01:00
sin-ack e2215cc0e1 Lagom: Add an install target
This is used by libjs-test262-runner to be able to copy the libraries
within its own build directory in order to link with them.
2021-06-17 21:20:24 +01:00
Ali Mohammad Pur 1414c7b049 LibJS: Add a basic pass manager and add some basic passes
This commit adds a bunch of passes, the most interesting of which is a
pass that merges blocks together, and a pass that places blocks that
flow into each other next to each other, and a very simply pass that
removes duplicate basic blocks.
Note that this does not remove the jump at the end of each block in that
pass to avoid scope creep in the passes.
2021-06-15 22:06:33 +04:30
x-yl ac712b07f9 Meta: Fuzz the LibIMAP Parser 2021-06-11 23:58:28 +04:30
Ali Mohammad Pur 51c2c69357 AK+Everywhere: Disallow constructing Functions from incompatible types
Previously, AK::Function would accept _any_ callable type, and try to
call it when called, first with the given set of arguments, then with
zero arguments, and if all of those failed, it would simply not call the
function and **return a value-constructed Out type**.
This lead to many, many, many hard to debug situations when someone
forgot a `const` in their lambda argument types, and many cases of
people taking zero arguments in their lambdas to ignore them.
This commit reworks the Function interface to not include any such
surprising behaviour, if your function instance is not callable with
the declared argument set of the Function, it can simply not be
assigned to that Function instance, end of story.
2021-06-06 00:27:30 +04:30
Luke 3bc2527ce7 Lagom/Fuzzers: Add SQL parser fuzzer 2021-05-31 17:07:52 +04:30
Gunnar Beutner 5f18cf75c5 AK: Replace ByteBuffer::grow with resize()/ensure_capacity()
Previously ByteBuffer::grow() behaved like Vector<T>::resize().
However the function name was somewhat ambiguous - and so this patch
updates ByteBuffer to behave more like Vector<T> by replacing grow()
with resize() and adding an ensure_capacity() method.

This also lets the user change the buffer's capacity without affecting
the size which was not previously possible.

Additionally this patch makes the capacity() method public (again).
2021-05-31 14:49:00 +04:30
Ben Wiederhake 774107f37c Fuzz+LibGfx: When fuzzing GIFLoader, try to load all frames 2021-05-30 14:42:34 +01:00
Ali Mohammad Pur 0e4431af33 Meta: Run the Wasm spec tests in CI
Since LibWasm is still not capable of passing all of the spec tests,
ignore failing tests, only fail the build if some segfault/abort/etc
occurs.
2021-05-27 17:28:41 +04:30
Ali Mohammad Pur b3c13c3e8a LibWasm+Meta: Add test-wasm and optionally test the conformance tests
This only tests "can it be parsed", but the goal of this commit is to
provide a test framework that can be built upon :)
The conformance tests are downloaded, compiled* and installed only if
the INCLUDE_WASM_SPEC_TESTS cmake option is enabled.
(*) Since we do not yet have a wast parser, the compilation is delegated
to an external tool from binaryen, `wasm-as`, which is required for the
test suite download/install to succeed.
This *does* run the tests in CI, but it currently does not include the
spec conformance tests.
2021-05-21 00:15:23 +01:00
Ali Mohammad Pur ba2fce14d3 Meta: Add a Wasm parser fuzzer 2021-05-21 00:15:23 +01:00
Ali Mohammad Pur f137c1bfaa LibJS+LibTest: Move out the test-js test runner into LibTest 2021-05-18 18:48:15 +01:00
Ali Mohammad Pur dfb2178519 Meta: Build LibWasm and the wasm utility as part of Lagom 2021-05-17 23:25:30 +02:00
Gunnar Beutner f0fa51773a AK+Userland: Fix some compiler warnings and make variables const-ref
This fixes a few compiler warnings and makes some variables const-ref
in preparation for the next commit which changes how ByteBuffer works.
2021-05-16 17:49:42 +02:00
Andrew Kaster d81f52e529 Lagom: Enable sanitizer builds with gcc
Previously the CMake options for -fsanitize=address, thread and
undefined were gated behind clang, which was unecessary. Only
-fsanitize=fuzzer is clang-only.
2021-05-14 08:34:00 +01:00
DexesTTP 5963f6f9ff LibCrypto: Split BigInteger operations into an Algorithms class
Since the operations are already complicated and will become even more
so soon, let's split them into their own files. We can also integrate
the NumberTheory operations that would better fit there into this class
as well.

This commit doesn't change behaviors, but moves the allocation of some
variables into caller classes.
2021-05-13 19:18:07 +01:00
Dylan Katz 984b6e08cf LibSQL: Add a syntax highlighter 2021-05-09 09:39:05 +02:00
Brian Gianforcaro 7e28ecc305 Meta + Lagom: Fix paths after movement of tests to Tests/
Not sure how this didn't cause a build break when I originally
moved them in #6891. Better fix them now.
2021-05-08 00:04:10 +01:00
Brian Gianforcaro 9720ad3901 Tests: Move Userland/Utilities/test-js to Tests/LibJS 2021-05-08 00:04:10 +01:00
Brian Gianforcaro dd633b9dd1 Meta: Fix Fuzzers CMakeLists.txt and ReadMe.md to use CXX_COMPILER_ID
Previously the directions omitted that you have to specify
`-CMAKE_CXX_COMPILER` when building the Fuzzers. This
would cause all kinds of weird problems at compilation and
link time. You can't specify one or the other, they must
both be pointing at clang in order for things to work as
experted. Fix this by updating the documentation to specify
that the user should specify both the C and CXX compiler explicitly
to be safe, as well as forcing the cmake clang argument handling
to modify the CXX compiler variable instead of the C version.
2021-05-07 15:19:48 +01:00
Idan Horowitz 5c385d06e8 Lagom/Fuzzers: Add fuzzers for Windows-1251 and Windows-1255 decoders 2021-05-01 17:59:08 +02:00
Carlos César Neves Enumo 69e2431c64 Lagom/CMake: Add -fconstexpr-steps for AppleClang 2021-05-01 07:38:43 +02:00
Idan Horowitz 33fdd402b5 Meta: Increase fconstexpr-steps for Clang Lagom builds
Clang's default constexpr-steps limit is 1048576, which is not enough
for LibGfx's generation of the unicode bidirectional class lookup table
while GCC doesn't have any limit at all, so this patch increases the
limit to an arbitrarily larger value.
2021-04-29 10:36:23 +02:00
Andrew Kaster 35c0a6c54d AK+Userland: Move AK/TestSuite.h into LibTest and rework Tests' CMake
As many macros as possible are moved to Macros.h, while the
macros to create a test case are moved to TestCase.h. TestCase is now
the only user-facing header for creating a test case. TestSuite and its
helpers have moved into a .cpp file. Instead of requiring a TEST_MAIN
macro to be instantiated into the test file, a TestMain.cpp file is
provided instead that will be linked against each test. This has the
side effect that, if we wanted to have test cases split across multiple
files, it's as simple as adding them all to the same executable.

The test main should be portable to kernel mode as well, so if
there's a set of tests that should be run in self-test mode in kernel
space, we can accomodate that.

A new serenity_test CMake function streamlines adding a new test with
arguments for the test source file, subdirectory under /usr/Tests to
install the test application and an optional list of libraries to link
against the test application. To accomodate future test where the
provided TestMain.cpp is not suitable (e.g. test-js), a CUSTOM_MAIN
parameter can be passed to the function to not link against the
boilerplate main function.
2021-04-25 09:36:49 +02:00
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Marco Biscaro 8124719c3d Tests: Reorganize LibCompress unit tests
Move LibCompress unit tests to LibCompress/Tests directory and register
them with CMake's add_test. This allows us to run these tests with
ninja test instead of running a separate executable.

Also split the existing tests in 3 test files that better follow the
source code structure (inspired by AK tests).
2021-04-21 08:00:32 +02:00
Timothy Flynn 110cd98c0a Lagom: Add sql utility and LibSQL unit tests 2021-04-20 18:28:34 +02:00
Andreas Kling 251018676f Everywhere: Update references from ReadMe.md => README.md 2021-04-11 10:52:25 +02:00
Luke 1ff6f2b4b2 Lagom/Fuzzers: Add fuzzer for zip file parser 2021-03-27 16:28:34 +01:00
Andreas Kling d792200a55 LibJS: Rename GlobalObject::initialize() => initialize_global_object()
This function was shadowing Object::initialize() which cannot be called
on global objects and has a different set of parameters.
2021-03-17 16:53:35 +01:00
Luke c983e42e8c Lagom/Fuzzers: Add fuzzers for the new Gzip and Deflate compressors 2021-03-14 11:28:12 +01:00
Luke d27e6f0961 Lagom/Fuzzers: Add fuzzers for Latin 1, Latin 2 and UTF16-BE
No fuzzer for UTF-8 as it (currently) just returns the input.
2021-03-14 11:27:52 +01:00
Andreas Kling 9769542bc2 FuzzilliJs: Add missing <errno.h> include 2021-03-12 17:43:48 +01:00
Luke 28a705d3c7 Lagom/Fuzzers: Add fuzzers for LibCompess
Adds fuzzers for Deflate, Gzip and Zlib.
2021-03-04 09:19:29 +01:00
Andrew Kaster 1aa605bc03 Meta: Run test-js and test-compress as CTest executables
Reduces the number of steps in the Actions workflow this way :^)
2021-03-02 09:00:21 +01:00
Andrew Kaster 669b6c43aa AK/Lagom: Modify TestSuite to return how many tests failed from main
This allows us to remove the FAIL_REGEX logic from the CTest invocation
of AK and LibRegex tests, as they will return a non-zero exit code on
failure :^).

Also means that running a failing TestSuite-enabled test with the
run-test-and-shutdown script will actually print that the test failed.
2021-03-01 11:12:36 +01:00
Luke a66f96ff62 Lagom/Fuzzers: Add WAV fuzzer 2021-03-01 11:09:09 +01:00
Andrew Kaster e787738c24 Meta: Build AK and LibRegex tests in Lagom and for Serenity
These tests were never built for the serenity target. Move their Lagom
build steps to the Lagom CMakeLists.txt, and add serenity build steps
for them. Also, fix the build errors when building them with the
serenity cross-compiler :^)
2021-02-28 18:19:37 +01:00
Linus Groh 24120d9dca Lagom: Build with -Wno-literal-suffix when using GCC
This is already set in the root CMakeLists.txt as well as here for Clang
(-Wno-user-defined-literals), but was forgotten for GCC which made an
Lagom-only build (cmake ../Meta/Lagom [...]) fail.
2021-02-27 16:38:21 +01:00
Linus Groh 590ae7a36d Lagom: CMakeLists.txt housekeeping
- Remove unused LIBM_SOURCES
- Some cosmetic and whitespace changes
2021-02-27 16:38:21 +01:00
Linus Groh e265054c12 Everywhere: Remove a bunch of redundant 'AK::' namespace prefixes
This is basically just for consistency, it's quite strange to see
multiple AK container types next to each other, some with and some
without the namespace prefix - we're 'using AK::Foo;' a lot and should
leverage that. :^)
2021-02-26 16:59:56 +01:00
Brian Gianforcaro 31e1b08e15 AK: Add support for AK::StringView literals with operator""sv
A new operator, operator""sv was added as of C++17 to support
string_view literals. This allows string_views to be constructed
from string literals and with no runtime cost to find the string
length.

See: https://en.cppreference.com/w/cpp/string/basic_string_view/operator%22%22sv

This change implements that functionality in AK::StringView.
We do have to suppress some warnings about implementing reserved
operators as we are essentially implementing STL functions in AK
as we have no STL :).
2021-02-24 14:38:31 +01:00
Andreas Kling 5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling 5625a1d608 Lagom: Build LibTextCodec into Lagom 2021-02-16 19:00:02 +01:00
Luke 5b891b0c36 Lagom/Fuzzers: Add RSA key parser fuzzer
First issue: #5317
2021-02-13 11:03:06 +01:00
Ben Wiederhake c6a42ab5c3 Everywhere: Remove unnecessary headers 4/4
Arbitrarily split up to make git bisect easier.

These unnecessary #include's were found by combining an automated tool (which
determined likely candidates) and some brain power (which decided whether
the #include is also semantically superfluous).
2021-02-08 18:03:57 +01:00
Ben Wiederhake 6e9fa350bc Fuzz: Remove unused FuzziliJS header 2021-02-08 18:03:57 +01:00
Ben Wiederhake 648f153951 Lagom/Fuzzers: Recommend enabling UBSan, extend instructions 2021-01-30 09:23:18 +01:00
Ben Wiederhake 1cbc01e288 Lagom: Don't include Shell/main.cpp
This caused some confusion: Apparently, clang has no trouble overriding Shell's
main, and this issue only surfaced when I tried to build the fuzzers with
wrong configuration (i.e., without the clang-injected 'main').

The diff is suggested by, and work of, @alimpfard.
2021-01-30 09:23:18 +01:00
Andreas Kling 7ec8f83a7f Lagom+AK: Remove remains of clang -Wconsumed usage
We stopped using that warning ages ago since it confused the compiler.
2021-01-28 09:14:49 +01:00
asynts 7cf0c7cc0d Meta: Split debug defines into multiple headers.
The following script was used to make these changes:

    #!/bin/bash
    set -e

    tmp=$(mktemp -d)

    echo "tmp=$tmp"

    find Kernel \( -name '*.cpp' -o -name '*.h' \) | sort > $tmp/Kernel.files
    find . \( -path ./Toolchain -prune -o -path ./Build -prune -o -path ./Kernel -prune \) -o \( -name '*.cpp' -o -name '*.h' \) -print | sort > $tmp/EverythingExceptKernel.files

    cat $tmp/Kernel.files | xargs grep -Eho '[A-Z0-9_]+_DEBUG' | sort | uniq > $tmp/Kernel.macros
    cat $tmp/EverythingExceptKernel.files | xargs grep -Eho '[A-Z0-9_]+_DEBUG' | sort | uniq > $tmp/EverythingExceptKernel.macros

    comm -23 $tmp/Kernel.macros $tmp/EverythingExceptKernel.macros > $tmp/Kernel.unique
    comm -1 $tmp/Kernel.macros $tmp/EverythingExceptKernel.macros > $tmp/EverythingExceptKernel.unique

    cat $tmp/Kernel.unique | awk '{ print "#cmakedefine01 "$1 }' > $tmp/Kernel.header
    cat $tmp/EverythingExceptKernel.unique | awk '{ print "#cmakedefine01 "$1 }' > $tmp/EverythingExceptKernel.header

    for macro in $(cat $tmp/Kernel.unique)
    do
        cat $tmp/Kernel.files | xargs grep -l $macro >> $tmp/Kernel.new-includes ||:
    done
    cat $tmp/Kernel.new-includes | sort > $tmp/Kernel.new-includes.sorted

    for macro in $(cat $tmp/EverythingExceptKernel.unique)
    do
        cat $tmp/Kernel.files | xargs grep -l $macro >> $tmp/Kernel.old-includes ||:
    done
    cat $tmp/Kernel.old-includes | sort > $tmp/Kernel.old-includes.sorted

    comm -23 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.new
    comm -13 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.old
    comm -12 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.mixed

    for file in $(cat $tmp/Kernel.includes.new)
    do
        sed -i -E 's/#include <AK\/Debug\.h>/#include <Kernel\/Debug\.h>/' $file
    done

    for file in $(cat $tmp/Kernel.includes.mixed)
    do
        echo "mixed include in $file, requires manual editing."
    done
2021-01-26 21:20:00 +01:00
asynts 1a3a0836c0 Everywhere: Use CMake to generate AK/Debug.h.
This was done with the help of several scripts, I dump them here to
easily find them later:

    awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in

    for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in)
    do
        find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \;
    done

    # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list.
    awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in
2021-01-25 09:47:36 +01:00
Luke 1c18d1380f Lagom/Fuzzers: Fix FuzzilliJs build and update patch for new Fuzzilli version
-fsanitize=fuzzer was being added to LINKER_FLAGS from Lagom/CMakeLists,
which we don't want with FuzzilliJs as we want to define the functions
it provides ourselves.
2021-01-24 00:40:49 +01:00
Nico Weber 7e5c49b755 Meta: Add some more documentation on oss-fuzz 2021-01-20 21:00:58 +01:00
AnotherTest 86f50aa74e Shell: Make tests use PASS/FAIL instead of exit codes
There's no guarantee that the last executed command will have a zero
exit code, and so the shell exit code may or may not be zero, even if
all the tests pass.
Also changes the `test || echo fail && exit` to
`if not test { echo fail && exit }`, since that's nicer-looking.
2021-01-19 08:19:43 +01:00
Andreas Kling affcdafc8d Lagom: Add Userland/ to include paths
This should make FuzzShell build.
2021-01-12 13:28:00 +01:00
Andreas Kling 13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Andreas Kling ececac65c2 Userland: Move command-line utilities to Userland/Utilities/ 2021-01-12 12:04:09 +01:00
Andreas Kling c4e2fd8123 Shell: Move to Userland/Shell/ 2021-01-12 12:04:07 +01:00
asynts 938e5c7719 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:

The modifications in this commit were automatically made using the
following command:

    find . -name '*.cpp' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-09 21:11:09 +01:00
Linus Groh b36f57e570 Lagom: Build gml-format 2021-01-03 22:12:08 +01:00
William Marlow 3e815ad5b1 Loader.so+LibELF: Move most of Loader.so's logic into ELF::DynamicLinker
Loader.so now just performs the initial self relocations and static
LibC initialisation before handing over to ELF::DynamicLinker::linker_main
to handle the rest of the process.

As a trade-off, ELF::DynamicLinker needs to be explicitly excluded from
Lagom unless we really want to try writing a cross platform dynamic loader
2021-01-03 17:15:55 +01:00
Luke c49899b0b6 FuzzJs: If the program successfully parsed, try running it
This should help us get a lot more coverage in LibJS.
2021-01-03 17:12:43 +01:00
Luke 5dfcecd244 Lagom/Fuzzers: Add TTF fuzzer 2021-01-02 01:39:34 +01:00
Andreas Kling 3eca77bd86 Lagom: Build test-compress 2021-01-01 22:42:13 +01:00
Brian Gianforcaro 6d67c4cafc CMake: Consolidate all options to the root of the project 2021-01-01 14:37:04 +01:00
Andreas Kling 1e4c010643 LibELF: Remove ELF::Loader and move everyone to ELF::Image
This commit gets rid of ELF::Loader entirely since its very ambiguous
purpose was actually to load executables for the kernel, and that is
now handled by the kernel itself.

This patch includes some drive-by cleanup in LibDebug and CrashDaemon
enabled by the fact that we no longer need to keep the ref-counted
ELF::Loader around.
2020-12-25 02:14:56 +01:00
Lenny Maiorani 765936ebae
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem:
- `(void)` simply casts the expression to void. This is understood to
  indicate that it is ignored, but this is really a compiler trick to
  get the compiler to not generate a warning.

Solution:
- Use the `[[maybe_unused]]` attribute to indicate the value is unused.

Note:
- Functions taking a `(void)` argument list have also been changed to
  `()` because this is not needed and shows up in the same grep
  command.
2020-12-21 00:09:48 +01:00
Andreas Kling 48d74c5356 LibHTTP: Make HTTPRequest::from_raw_request() take a ReadonlyBytes
This allows us to get rid of some ByteBuffer::wrap() usage.
2020-12-19 18:29:13 +01:00
AnotherTest eb7a943641 Meta: Set a 10 second timeout on Shell tests
Shell-backgrounding seems to be deadlocking at times, until that's
fixed, let's not take 5 hours to fail the build.
2020-12-15 20:58:32 +01:00
Itamar b1e01066fe Lagom/Fuzzers: Fix creation of ELF::Loader 2020-12-14 23:05:53 +01:00
Ben Wiederhake 4b4f23165f Meta+LibHTTP: Fuzz HTTP request parsing 2020-12-02 10:46:40 +01:00
Ben Wiederhake a0f6db246e Meta: Document fuzz dump 2020-12-01 11:06:23 +01:00
Luke 030dac8c4d Lagom/Fuzzers: Add URL fuzzer 2020-11-30 11:35:16 +01:00
Luke 5c911ad4b1 Meta: Add GitHub Actions workflow for Lagom with Fuzzers
There are cases where Lagom will build with GCC but not Clang.
This often goes unnoticed for a while as we don't often build with
Clang.

However, this is now important to test in CI because of the
OSS-Fuzz integration.

Note that this only tests the build, it does not run any tests.
Note that it also only builds LagomCore, Lagom and the fuzzers.
It does not build the other programs that use Lagom.
2020-11-29 20:22:56 +01:00
Nico Weber 29e4dc7634 Lagom: Mention OSS-Fuzz in ReadMe
We added OSS-Fuzz integration in #4154, but documentation about it
is spread across several pull requests, IRC, and issues. Let's collect
the important bits in the ReadMe.
2020-11-29 20:22:09 +01:00
AnotherTest 1ecea2f105 Lagom: Add a Shell parser fuzzer 2020-11-29 16:22:44 +01:00
Linus Groh 6a37285d93 Lagom: Add Regex fuzzers 2020-11-29 09:29:26 +01:00
DavidKorczynski ff8ac60184
Lagom: Various fixes to make Lagom run on OSS-Fuzz (#4176) 2020-11-27 23:57:02 +01:00
Emanuel Sprung 55450055d8 LibRegex: Add a regular expression library
This commit is a mix of several commits, squashed into one because the
commits before 'Move regex to own Library and fix all the broken stuff'
were not fixable in any elegant way.
The commits are listed below for "historical" purposes:

- AK: Add options/flags and Errors for regular expressions

Flags can be provided for any possible flavour by adding a new scoped enum.
Handling of flags is done by templated Options class and the overloaded
'|' and '&' operators.

- AK: Add Lexer for regular expressions

The lexer parses the input and extracts tokens needed to parse a regular
expression.

- AK: Add regex Parser and PosixExtendedParser

This patchset adds a abstract parser class that can be derived to implement
different parsers. A parser produces bytecode to be executed within the
regex matcher.

- AK: Add regex matcher

This patchset adds an regex matcher based on the principles of the T-REX VM.
The bytecode pruduced by the respective Parser is put into the matcher and
the VM will recursively execute the bytecode according to the available OpCodes.
Possible improvement: the recursion could be replaced by multi threading capabilities.

To match a Regular expression, e.g. for the Posix standard regular expression matcher
use the following API:

```
Pattern<PosixExtendedParser> pattern("^.*$");
auto result = pattern.match("Well, hello friends!\nHello World!"); // Match whole needle

EXPECT(result.count == 1);
EXPECT(result.matches.at(0).view.starts_with("Well"));
EXPECT(result.matches.at(0).view.end() == "!");

result = pattern.match("Well, hello friends!\nHello World!", PosixFlags::Multiline); // Match line by line

EXPECT(result.count == 2);
EXPECT(result.matches.at(0).view == "Well, hello friends!");
EXPECT(result.matches.at(1).view == "Hello World!");

EXPECT(pattern.has_match("Well,....")); // Just check if match without a result, which saves some resources.
```

- AK: Rework regex to work with opcodes objects

This patchsets reworks the matcher to work on a more structured base.
For that an abstract OpCode class and derived classes for the specific
OpCodes have been added. The respective opcode logic is contained in
each respective execute() method.

- AK: Add benchmark for regex

- AK: Some optimization in regex for runtime and memory

- LibRegex: Move regex to own Library and fix all the broken stuff

Now regex works again and grep utility is also in place for testing.
This commit also fixes the use of regex.h in C by making `regex_t`
an opaque (-ish) type, which makes its behaviour consistent between
C and C++ compilers.
Previously, <regex.h> would've blown C compilers up, and even if it
didn't, would've caused a leak in C code, and not in C++ code (due to
the existence of `OwnPtr` inside the struct).

To make this whole ordeal easier to deal with (for now), this pulls the
definitions of `reg*()` into LibRegex.

pros:
- The circular dependency between LibC and LibRegex is broken
- Eaiser to test (without accidentally pulling in the host's libc!)

cons:
- Using any of the regex.h functions will require the user to link -lregex
- The symbols will be missing from libc, which will be a big surprise
  down the line (especially with shared libs).

Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2020-11-27 21:32:41 +01:00
Nico Weber f160df123b Lagom: Rename FuzzBMP to FuzzBMPLoader 2020-11-26 09:59:46 +01:00
Nico Weber ec4c2f971b Lagom: Make BMP fuzzer look like the other image loader fuzzers 2020-11-26 09:59:46 +01:00
Nico Weber 4f12efe191 Lagom: Add fuzzers for remaining image loaders: ICO, PNG, PBM, PGM 2020-11-26 09:59:46 +01:00
Linus Groh 4e68f179d6 Lagom: Fix FuzzJs build
This was broken with the JS::Parser::Error position changes, but I don't
actually see a reason to do anything with the parser errors here, so
let's remove it and consider simply not crashing a success. :^)
2020-11-25 20:00:23 +01:00
Nico Weber f13a38aa4d Lagom: Add a gif loader fuzzer 2020-11-20 21:17:58 +01:00
Nico Weber 812892ef86 Lagom: Add a jpg fuzzer 2020-11-19 21:21:45 +01:00
Nico Weber 3f3a7d128b Lagom: Make fuzzer cmake less repetitive 2020-11-19 21:21:45 +01:00
Nico Weber f5967c4745 Lagom: Add a PPM fuzzer
It finds the problem fixed in 69518bd178 but nothing else.
2020-11-19 14:04:35 +01:00
Nico Weber 39ce7251f7 Lagom: Use -fsanitize=fuzzer, not -fsanitize=fuzzer-no-link
Fuzzers don't link for me without this change.
2020-11-14 10:09:03 +01:00
Nico Weber d775dea13c Lagom: Add a gemini fuzzer
Didn't find anything interesting, but might as well check it in.
2020-11-14 10:09:03 +01:00
Nico Weber 8ed83f9a1d Lagom: Augment fuzzing readme a bit
Recommend using asan, don't set the c compiler (c++ compiler is
sufficient), mention how to run on several cores, and how to get less
output.
2020-11-14 10:09:03 +01:00
Nico Weber 5c2e8b6189 Lagom: Add ntpquery to lagom build 2020-11-12 21:21:33 +01:00
Nico Weber 5fcd34b810 Userland: Add an "adjtime" utility
It's a thin userland wrapper around adjtime(2). It can be used
to view current pending time adjustments, and root can use it to
smoothly adjust the system time.

As far as I can tell, other systems don't have a userland utility
for this, but it seems useful. Useful enough that I'm adding it to
the lagom build so I can use it on my linux box too :)
2020-11-10 19:03:08 +01:00
Linus Groh 46cd9157cd Lagom/Fuzzers: Add a Dockerfile for FuzzilliJs
Based on Fedora. This allows building and running FuzzilliJs and Fuzzilli
itself in a Docker/Podman container.
2020-11-08 11:01:07 +01:00
Linus Groh 2c9e6585f8 Documentation: Update required GCC version to >= 10
I initially thought as long as Lagom is not built >= 9 would be fine,
but LagomCore is always built for the code generators.
2020-11-07 18:22:18 +01:00
Luke 8928607455 Lagom/Fuzzers: Add Fuzzilli version of FuzzJs
Fuzzilli is a JavaScript engine fuzzer made by googleprojectzero.

https://github.com/googleprojectzero/fuzzilli/
2020-11-07 10:09:55 +01:00
Linus Groh 21912123c4 Travis: Update host GCC to version 10
This allows us to use the latest C++20 features in programs which we
compile and run as part of Lagom.
2020-11-02 13:12:35 +01:00
AnotherTest 37c089fb7b LibTLS: (Almost) verify certificate chain against root CA certificates
Also adds a very primitive systemwide ca_certs.ini file.
2020-10-30 23:42:03 +01:00
asynts 607931268e CMake: Use CONFIGURE_DEPENDS in existing globs. 2020-10-29 11:52:47 +01:00
Ben Wiederhake 25ccd40d5a Meta: Describe how to analyze an LLVM fuzzer crash 2020-09-12 00:13:29 +02:00
Ben Wiederhake 98bfcb4b57 Meta+LibGfx: Fuzz BMP parsing 2020-09-12 00:13:29 +02:00
Ben Wiederhake 5d3c437cce LibJS: Fix start position of multi-line tokens
This broke in case of unterminated regular expressions, causing goofy location
numbers, and 'source_location_hint' to eat up all memory:

Unexpected token UnterminatedRegexLiteral. Expected statement (line: 2, column: 4294967292)
2020-09-12 00:13:29 +02:00
Andreas Kling e002cbb06b Build: Add some -Wno-unknown-warning-option flags to CXXFLAGS
Patch from Anonymous.
2020-09-01 12:00:53 +02:00
AnotherTest 465d46c665 Meta+Userland: Run the TLS test too
While this _does_ add a point of failure, it'll be a pretty bad day when
google goes down.
And this is unlikely to put a (positive) dent in their incoming
requests, so let's just roll with it until we have our own TLS server.
2020-08-24 09:29:39 +02:00
Andreas Kling a37331e236 Lagom: Add LibHTTP to Lagom (it builds fine without changes) 2020-08-15 00:05:45 +02:00
Nico Weber 00f658b984
Lagom+LibELF: Add an ELF fuzzer, and tweak the code to survive a few minutes of fuzzing (#3071)
If a buffer smaller than Elf32_Ehdr was passed to Image, header()
would do an out-of-bounds read.

Make parse() check for that. Make most Image methods assert that the image
is_valid(). For that to work, set m_valid early in Image::parse()
instead of only at its end.

Also reorder a few things so that the fuzzer doesn't hit (valid)
assertions, which were harmless from a security PoV but which still
allowed userspace to crash the kernel with an invalid ELF file.

Make dbgprintf()s configurable at run time so that the fuzzer doesn't
produce lots of logspam.
2020-08-10 15:55:17 +02:00
Nico Weber 700f5cfc90 Lagom: Pass -Wno-deprecated-copy to clang too
Due to Serenity's use of concepts, it now requires clang 10 or newer,
and clang 10 or newer both understands and requires
-Wno-deprecated-copy.
2020-08-09 21:13:06 +02:00
Nico Weber 9c136be08b disasm: For ELF files, disassemble .text section
Since disasm is built in lagom, this requires adding LibELF to lagom.
2020-08-09 21:12:54 +02:00
Nico Weber a619943001 Build: Make things build with clang without needing local changes
Useful for sanitizer fuzzer builds.

clang doesn't have a -fconcepts switch (I'm guessing it just enables
concepts automatically with -std=c++2a, but I haven't checked),
and at least the version on my system doesn't understand
-Wno-deprecated-move, so pass these two flags only to gcc.
In return, disable -Woverloaded-virtual which fires in many places.

The preceding commits fixed the handful of -Wunused-private-field
warnings that clang emitted.
2020-08-04 17:42:08 +02:00
stelar7 98e18d7339 LibCompress: Add LibCompress
For now this only contains DEFLATE, and a very simple Zlib
Eventually GZip, etc. can go here as well.
2020-08-04 11:27:07 +02:00
Nico Weber c7652a2166 Lagom: Clean up glob after puff.c -> puff.cpp rename 2020-07-29 15:11:04 +02:00
Andreas Kling 96dce6893f Lagom: Build with -std=c++2a -Wno-deprecated-copy 2020-07-27 21:54:22 +02:00
Nico Weber 3f45e9ab1e Lagom: Add LibGemini, LibGfx
They are dependencies of LibWeb and might be useful for
running test-web on GitHub actions one day.
2020-07-23 23:02:28 +02:00
Nico Weber c22790adb2 Lagom: Add a markdown fuzzer 2020-07-14 17:45:16 +02:00
Nico Weber 417caeb14a Lagom: Add a note on how to build the fuzzers to readme 2020-07-14 17:45:16 +02:00
Matthew Olsson b9cf7a833f LibJS/test-js: Create test-js program, prepare for test suite refactor
This moves most of the work from run-tests.sh to test-js.cpp. This way,
we have a lot more control over how the test suite runs, as well as how
it outputs. This should result in some cool functionality!

This commit also refactors test-common.js to mimic the jest library.
This should allow tests to be much more expressive :)
2020-07-06 23:40:35 +02:00
AnotherTest 639c1a1737 Shell: Build as part of Lagom as well
Bringing the Serenity Shell to your very own host system :^)
2020-07-05 15:43:14 +02:00
Matthew Olsson e8e728454c AK: JsonParser improvements
- Parsing invalid JSON no longer asserts
    Instead of asserting when coming across malformed JSON,
    JsonParser::parse now returns an Optional<JsonValue>.
- Disallow trailing commas in JSON objects and arrays
- No longer parse 'undefined', as that is a purely JS thing
- No longer allow non-whitespace after anything consumed by the initial
  parse() call. Examples of things that were valid and no longer are:
    - undefineddfz
    - {"foo": 1}abcd
    - [1,2,3]4
- JsonObject.for_each_member now iterates in original insertion order
2020-06-13 12:43:22 +02:00
AnotherTest 40829b849a Meta: Run Crypto tests in CI
We skip the tests that are not self-contained (TLS) to avoid adding
extra variables to the tests.
2020-06-07 19:29:40 +02:00
Sergey Bugaev 80f671e16c Lagom: Fix target name 2020-06-01 17:37:44 +02:00
Andreas Kling 5f9de61bf2 Lagom: Build LibCrypto, LibTLS and test-crypto :^) 2020-05-27 12:28:39 +02:00
Linus Groh 33defef267 LibJS: Let parser keep track of errors
Rather than printing them to stderr directly the parser now keeps a
Vector<Error>, which allows the "owner" of the parser to consume them
individually after parsing.

The Error struct has a message, line number, column number and a
to_string() helper function to format this information into a meaningful
error message.

The Function() constructor will now include an error message when
throwing a SyntaxError.
2020-05-15 09:53:52 +02:00
Sergey Bugaev 450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Linus Groh 82cb751907 Lagom: Add missing copyright header to FuzzJS.cpp 2020-05-09 23:45:16 +02:00
Linus Groh 660fd04063 Meta: Build Lagom js and run LibJS tests on Travis 2020-04-20 22:44:13 +02:00
Andreas Kling 32d83fdee4 LibX86: Add an X86 instruction decoder library + basic disassembler
This will be very useful for developer tools like ProfileView, and also
for future tools like debuggers and such. :^)
2020-04-11 13:16:17 +02:00
Paul Redmond 7291d5c86f
Lagom: Add fuzz testing for LibJS using libFuzzer (#1692)
Note: clang only (see https://llvm.org/docs/LibFuzzer.html)

- add FuzzJs which will run the LibJS parser on random javascript inputs
- added a basic dictionary of javascript tokens

To use fuzzer:
CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -DENABLE_FUZZER_SANITIZER=1 ..
Fuzzers/FuzzJs -dict=../Fuzzers/FuzzJs.dict
2020-04-08 10:40:02 +02:00
Brian Gianforcaro 1e67efc5c1 Lagom: Add clang address/memory/undefined-behavior analyzer support
Adding the ability to turn on Clang analyzer support in the Lagom build.
Right now the following are working warning free on the LibJS test suite:

 -DENABLE_MEMORY_SANITIZER:BOOL=ON

 -DENABLE_ADDRESS_SANITIZER:BOOL=ON

The following analyzer produces errors when running the LibJS test suite:

 -DENABLE_UNDEFINED_SANITIZER:BOOL=ON
2020-04-05 12:49:06 +02:00
Andreas Kling 6529b78d08 Lagom: Build LibLine since "js" depends on it 2020-03-31 18:58:59 +02:00
Andreas Kling e31dac3ba4 Lagom: Build LibJS + "js" test program
You can now get a full Linux build of the "js" test program by simply
building in Meta/Lagom :^)
2020-03-23 13:15:32 +01:00
Andreas Kling 5f4d81ff55 Lagom: Add a tiny JSON test app 2020-02-06 19:32:34 +01:00
Andreas Kling be6a31dde1 Lagom: Remove the bitrotted SimpleIPC test program 2020-02-06 19:23:18 +01:00
Andreas Kling d17e23bd27 LibCore: Remove leading C from filenames 2020-02-06 15:04:03 +01:00
Andreas Kling 2d39da5405 LibCore: Put all classes in the Core namespace and remove the leading C
I've been wanting to do this for a long time. It's time we start being
consistent about how this stuff works.

The new convention is:

- "LibFoo" is a userspace library that provides the "Foo" namespace.

That's it :^) This was pretty tedious to convert and I didn't even
start on LibGUI yet. But it's coming up next.
2020-02-02 15:15:30 +01:00
Andreas Kling 94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Andreas Kling 0ddde627b1 Lagom: Fix build 2019-11-19 11:14:26 +01:00
Andreas Kling dcd10149fe Lagom: Move this into Meta/
This is more of a meta thing, since it's not seeing active development,
but is just a way for me to build some Serenity parts and include them
in other projects. Move it out of the root to keep things tidy.
2019-11-18 09:07:05 +01:00