Commit Graph

2310 Commits

Author SHA1 Message Date
Tim Allison d6f73fbd2a
Build in stages to shed 9gb from the jvm base builder image (#12649)
This PR reduces the final `base-builder-jvm` image by 9GB.

Careful review and full integration testing across oss-fuzz projects are
required before merging, obviously.

This worked on two projects I was interested in. One that used
`@FuzzTest` and one that used `fuzzerTestOneInput`
2024-11-15 08:42:44 -08:00
Oliver Chang ff5360419e
cached build: Re-build for every sanitizer. (#12695) 2024-11-07 15:19:31 +11:00
DavidKorczynski e3ccf897f8
ofg: prepare use of cached images (#12693)
Ref: https://github.com/google/oss-fuzz-gen/pull/696

---------

Signed-off-by: David Korczynski <david@adalogics.com>
Co-authored-by: Oliver Chang <ochang@google.com>
2024-11-07 12:40:57 +11:00
Oliver Chang 6fabfa4baf
target_experiment: Properly propagate real name. (#12692)
Follow up to #12691
2024-11-06 16:03:59 +11:00
Oliver Chang 2c733ba65b
Make target_experiment with with OSS-Fuzz-Gen. (#12691)
OSS-Fuzz-Gen creates fake project names, but for cached images to work
we need the real name.
2024-11-06 15:00:49 +11:00
DavidKorczynski 51e01dcebc
infra: add script to capture replayable commands (#12608)
Giving
https://github.com/google/oss-fuzz/pull/12592#issuecomment-2415803665 a
go using `bashlex`

Will place a script in `/out/replay-build-script.sh` with the script
that can be used for replaying.

This is still poc and will need some adjustments, e.g. we need some more
handling on the bash script's ast to reason about loops.

---------

Signed-off-by: David Korczynski <david@adalogics.com>
Co-authored-by: Oliver Chang <ochang@google.com>
2024-11-06 13:00:19 +11:00
Oliver Chang 9f56cf477e
Make ccache work with jcc. (#12689)
Create ccache wrappers for clang[++]-jcc, and remove the explicit path
from the CC/CXX variables in target_experiment.py.

Note: this is not fully tested end to end yet.

Part of https://github.com/google/oss-fuzz-gen/issues/682.
2024-11-05 10:48:52 +00:00
DavidKorczynski a85eebb40b
infra: enable building projects using cached images (#12597)
Signed-off-by: David Korczynski <david@adalogics.com>
Co-authored-by: Oliver Chang <ochang@google.com>
2024-11-01 20:50:27 +00:00
Oliver Chang 36f31300f0
Fix entrypoint for chronos images. (#12677) 2024-11-01 14:42:45 +11:00
Oliver Chang dd978a43f8
Add ccache to base-builder. (#12675)
This installs clang wrappers at /ccache/bin, and sets up a build cache
at /ccache/cache. To use this, inside the project container we just need
to do:

```
export PATH=/ccache/bin:$PATH
```

In another PR, we can store the /ccache/cache somewhere we can pull down
at runtime.

Some results:

Fresh compile:

real	0m49.249s
user	10m41.818s
sys	1m2.097s

With ccache cache:

real	0m9.877s
user	0m6.278s
sys	0m19.966s

Fresh compile:

real	1m17.214s
user	0m49.454s
sys	0m27.963s

With ccache:

real	0m34.962s
user	0m18.092s
sys	0m17.083s
2024-11-01 13:42:39 +11:00
Oliver Chang c68e8e0125
Update sanitizer strings for chronos builds. (#12676)
Make these match the formatting conventions oss-fuzz already uses (i.e.
"address" instead of "asan").
2024-11-01 13:18:52 +11:00
Yuta Saito 65939bedc7
[CFL] Interpret `PARALLEL_FUZZING` as a boolean value (#12655)
The `PARALLEL_FUZZING` environment variable is used to enable parallel
fuzzing in CFLite. The variable is always defined by GH Action, but it
was not interpreted as a boolean value, so it was always enabled even if
the option is set to `false`.

Co-authored-by: Vitor Guidi <vitorguidi@gmail.com>
2024-10-31 13:07:15 -04:00
DavidKorczynski 9439d2c705
infra: bump introspector (#12658)
This fixes an issue introduced
https://github.com/google/oss-fuzz/pull/12643
2024-10-27 19:58:40 +00:00
DavidKorczynski bf3ff619b1
infra: bump introspector (#12643)
Contains updates for FI light
2024-10-24 17:34:39 +01:00
Oliver Chang 0f1a82a96f
Add ability to manually request introspector builds. (#12641) 2024-10-23 20:30:09 +01:00
Oliver Chang 28ba247ccf
Fix introspector scheduling exception. (#12640)
This was caused by a very old refactor, but we never deployed the
introspector scheduler since then so we didn't run into this until now.
2024-10-23 09:19:42 +11:00
Oliver Chang d288d1bc52
Fix typo (#12624) 2024-10-21 15:25:28 +11:00
Oliver Chang 4b20cd8564
Fix base builder exception. (#12623) 2024-10-21 15:00:54 +11:00
DavidKorczynski 9e9ed9bb7e
infra: build: introspector: upload artifacts in all cases (#12609)
Upload introspector report even when build fails. This is to ensure
artifacts from FI light is uploaded for each build.

---------

Signed-off-by: David Korczynski <david@adalogics.com>
2024-10-17 20:34:19 +01:00
DavidKorczynski fb88de8bd2
infra: enable introspector light (#12580)
This enables a light version of introspector, which performs analysis
prior to compilation, i.e. without use of LTO. At the current stage
light FI has implemented features to support test-to-harness migration
on OFG including harness source/executable pairing. Once this has been
rolled out in full the light analysis will continue to support more
interesting logic related to program analysis, all purely static.

Signed-off-by: David Korczynski <david@adalogics.com>
2024-10-16 10:21:28 +01:00
Dongge Liu bc81d57248
Customize cloud build region (#12601)
Avoids hardcoding cloud build region to `us-central1`, so that users
(e.g., `target_experiment.py`) can define their own region.
2024-10-16 10:33:57 +11:00
jonathanmetzman 74ef15bf2c
Use a seperate pool for Chronos (#12578)
It seems to be causing congestion that is breaking oss-fuzz builds.
Fixes: https://github.com/google/oss-fuzz/issues/12573
2024-10-09 12:55:34 -04:00
correctmost 0fe8dae146
infra: print log data when Python fuzz_target fails (#12502)
## Description

This will make it easier to debug coverage failures that are not
reproducible locally.

The failure that I am trying to debug:
- https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62231
-
https://oss-fuzz-build-logs.storage.googleapis.com/log-c420cf0c-f073-4c42-b75c-422971ef272e.txt

```
Step #5: Already have image (with digest): gcr.io/oss-fuzz-base/base-runner
Step #5: Entering python fuzzing
Step #5: Error happened getting coverage of fuzz_parse
Step #5: This is likely because Atheris did not exit gracefully
```

Similar log data is displayed in other blocks:

f716590249/infra/base-images/base-runner/coverage (L101-L105)


f716590249/infra/base-images/base-runner/coverage (L149-L153)


f716590249/infra/base-images/base-runner/coverage (L206-L210)


f716590249/infra/base-images/base-runner/coverage (L255-L260)

---

This PR is a continuation of
https://github.com/google/oss-fuzz/pull/12405 with a renamed branch to
avoid trial-build errors:

```
ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: invalid build: invalid build tag "testing-cm/display-coverage-log": must match format "^[\\w][\\w.-]{0,127}$"
```

Co-authored-by: Vitor Guidi <vitorguidi@gmail.com>
2024-10-07 15:06:36 -03:00
Oliver Chang 38d4a5abcb
Fix service account for chronos build. (#12551)
Also set the worker pool.
2024-10-02 14:24:42 +10:00
Oliver Chang 788631defd
Add cloudbuild for building chronos images for all C++. (#12549)
Once this is merged, we just need to set up an automated trigger to run
this daily.
2024-10-02 11:07:39 +10:00
Catena cyber 1778ebe700
Update Clang toolchain from 18.0.0 to 18.1.8 (#12365)
Follow-up on #12077 by @alexcrichton cc @maflcko 

Main difference is to update
infra/base-images/base-runner/profraw_update.py so that oss-fuzz
converts profraw version 8 to 9 (and llvm-cov seems more tolerant in
older version reading cf
llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp

This way, it should be more transparent for projects, that can be
updated individually or not

---------

Co-authored-by: Alex Crichton <alex@alexcrichton.com>
2024-10-01 11:03:06 -03:00
DavidKorczynski d28f6e6f3e
infra: build: functions: add default empty list for tags (#12522)
This caused a regression for experiments in OFG.

```sh
2024-09-20 22:39:56.906 INFO models - do_generate: vertex_ai_gemini-1-5 generating response with config: {'temperature': 0.6, 'max_output_tokens': 8192}
2024-09-20 22:39:57.088 ERROR builder_runner - _run_with_retry_control: Failed to evaluate /experiment/results/output-htslib-hfile_list_plugins/fixed_targets/02.c on cloud, attempt 1:

Traceback (most recent call last):	  File "/tmp/tmp5dlnpp7z/infra/build/functions/target_experiment.py", line 339, in <module>	    main()	  File "/tmp/tmp5dlnpp7z/infra/build/functions/target_experiment.py", line 332, in main	    run_experiment(args.project, args.target, args.args, args.upload_output_log,	  File "/tmp/tmp5dlnpp7z/infra/build/functions/target_experiment.py", line 288, in run_experiment	    extra_tags=[experiment_name, project_name] + tags)	               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~	TypeError: can only concatenate list (not "NoneType") to list	
2024-09-20 22:39:57.088 INFO evaluator - log: Fixing /experiment/results/output-htslib-hfile_list_plugins/fixed_targets/02.c with vertex_ai_gemini-1-5, attempt 1.
2024-09-20 22:39:57.088 WARNING prompt_builder - _format_fixer_problem: Unexpected empty error message in fix prompt for error_desc: None
2024-09-20 22:39:57.089 INFO models - do_generate: vertex_ai_gemini-1-5 generating response with config: {'temperature': 0.46, 'max_output_tokens': 8192}
```

From https://github.com/google/oss-fuzz-gen/pull/636

Ref: https://github.com/google/oss-fuzz/pull/12520
2024-09-20 15:01:20 +01:00
Dongge Liu bf53d7f396
Add tags to cloud build from target_experiment.py (#12520)
This helps us to identify and debug cloud build from OFG.
2024-09-20 13:57:12 +10:00
DavidKorczynski 2325a301c9
infra: bump fuzz introspector (#12492)
contains updates for Python
2024-09-16 10:15:33 +01:00
DavidKorczynski 8c6a087478
infra: bump introspector (#12468)
Contains logic for supporting java test-to-harness migration
2024-09-11 09:54:22 +01:00
Dongge Liu 85bb64c0ae
Let recompile become compile if Chronos did not intercept any command (#12458)
This can happen when the project [uses `make` or
`cmake`](https://github.com/google/oss-fuzz/issues/12411#issuecomment-2332982907)
to build fuzz targets.
2024-09-06 16:44:58 +10:00
Oliver Chang 3d4969670d
Add a cloudbuild setup to build chronos-images. (#12456) 2024-09-06 16:36:28 +10:00
DavidKorczynski 2ea9ae843d
infra: blog: add java OFG blog post (#12455)
Signed-off-by: David Korczynski <david@adalogics.com>
2024-09-06 14:18:02 +10:00
DavidKorczynski e19716fd89
infra: bump introspector (#12453)
Makes it possible to extract all files from a given project. This is
particularly useful for bazel projects where we need a path prior to
bazel build in order to identify harness source.

Ref: https://github.com/google/oss-fuzz-gen/pull/577
2024-09-05 21:46:19 +01:00
DavidKorczynski ea603093cf
infra: bazel_build_fuzz_tests: avoid change of OUT ownership (#12414)
The current bazel builds change the owner of the $OUT directory due to
`tar`. This can cause some issues depending on how Docker is run, but,
this is ultimately annoying since e.g. OSS-Fuzz-gen and end-to-end
OSS-Fuzz runs relies on reading the files in the OUT directory, which is
not possible when the owner changes. Furthermore, it's inconsistent with
the existing `compile_*` scripts to change the owner of $OUT/

This fixes it by not changing the owner.
2024-08-28 16:02:21 +01:00
DavidKorczynski ca7434078d
infra: bump introspector (#12412)
Contains updates regarding test-to-harness conversion
https://github.com/google/oss-fuzz-gen/issues/494
2024-08-27 20:21:36 +01:00
Khaled Yakdan 6b9ff87ad4
Jazzer Pro (#12375) 2024-08-27 10:57:51 +10:00
Dongge Liu 3c7957312c
Add the commands to build for coverage measurement (#12370)
By passing `SANITIZER` env to the container when compiling the fuzz
target.
2024-08-19 10:08:50 +10:00
Dongge Liu dee1595fdf
chronos: Pause `compile` just before compiling the fuzz target so that we can reuse it later. (#11937)
@jonathanmetzman proposed a great idea about saving the machine state
just before compiling the fuzz target so that we can compile different
fuzz targets from that state later without having to go through the
earlier commands.
This is particularly beneficial for `OSS-Fuzz-Gen`.

This PR is an (incomplete) PoC at that.
Ideally, we: 
1. [ ] Replace the fuzz target compilation command and all commands
after it with no-ops,
2. [x] Save them into a script (e.g., `$SRC/re-run.sh`), and 
3. [x] Push the resulting image for later reuse.

In this way, we can reuse the image later by swapping the fuzz target
source code and executing `$SRC/re-run.sh`.

The script in the PR can do 2, but not 1.
This might be OK already because steps in 1 are normally at the end, and
there is unlikely any check to prevent them, but ideally, we should do
1, too.

To test this locally:
```bash
python infra/helper.py build_image libiec61850
docker run -ti --entrypoint=/bin/bash gcr.io/oss-fuzz/libiec61850
(in container) compile
cat /src/re-run.sh
```
2024-08-16 08:04:27 +10:00
DavidKorczynski 3beb664440
infra: make it possible to cache docker containers build (#12284)
Signed-off-by: David Korczynski <david@adalogics.com>
2024-08-02 09:10:35 +01:00
DavidKorczynski 5c99ed9f0e
helper: fix coverage extra args reading (#12255)
There's a bit more to reading the coverage extra args in
https://github.com/google/oss-fuzz/pull/12229. We need to essentially
pass the whole yaml value. This fixes it.

Fixes: https://github.com/google/oss-fuzz/issues/12251
Fixes: https://github.com/google/oss-fuzz/issues/12252

---------

Signed-off-by: David Korczynski <david@adalogics.com>
2024-07-20 17:55:06 +01:00
DavidKorczynski 224040c2ca
infra: update fuzz introspector (#12247)
Contains updates for:

- java coverage analysis improvements
- test-to-harness conversion
(https://github.com/google/oss-fuzz-gen/issues/494)
2024-07-20 12:23:38 +01:00
DavidKorczynski 7010f45b3b
infra: apply coverage ignores when running locally (#12229)
`coverage_extra_args` are currently only used in cloud builds e.g.
7db2eae0b1/infra/build/functions/build_and_run_coverage.py (L128)
and not locally. Besides being confusing, this can cause some issues
with e.g. OSS-Fuzz-gen which relies on the `coverage` command to extract
coverage reports, as it may end up comparing apples to oranges.

This commit fixes it by applying the coverage extra args when coverage
is run by way of `infra/helper.py coverage`.

---------

Signed-off-by: David Korczynski <david@adalogics.com>
2024-07-18 09:00:37 +01:00
Alex Crichton 150b4239c5
Add `--locked` to installation of `cargo fuzz` (#12178)
Helps pin dependencies at the time of when `cargo-fuzz` itself was
published to avoid dependency updates breaking builds. This fixes a
current issue where all Rust projects using `cargo fuzz` are broken due
to the installation of `cargo-fuzz` failing due to failing to build a
newer dependency with an older nightly.

Closes #12168
2024-07-11 12:43:46 +10:00
jonathanmetzman 791e7d2f05
[trial_build] Fix handling of languages. (#12196)
Consider "ruby" a language before a project.
2024-07-10 12:02:48 -04:00
jonathanmetzman 94ef0c2e24
Build base ruby image. (#12181) 2024-07-09 12:41:19 -04:00
jonathanmetzman 23a76bdb3b
Format and lint (#12189) 2024-07-09 12:39:50 -04:00
jonathanmetzman 9df12dae76
Break up long line (#12184) 2024-07-09 12:25:52 -04:00
jonathanmetzman 30c0bd918e
Remove unused import (#12188) 2024-07-09 12:23:21 -04:00
jonathanmetzman acc7129e33
Disable uneeded warning (#12187) 2024-07-09 12:22:55 -04:00