Commit Graph

2178 Commits

Author SHA1 Message Date
jonathanmetzman 0c3d2e3d33
Improve stdout/stderr handling and make sure errors are debuggable (#10993)
Whenever we fail, ensure there's a proper stderr written to stderr.
Also, only write stderr to stderr never to stdout
2023-09-21 21:21:39 -04:00
Mihai Maruseac c05ec5dedc
Fix bazel invocations with jcc (#10973)
We only need to make sure that if the wrapped compiler (clang) prints
something to stderr, we report that to stderr in the wrapper, __even
if__ the compiler exits with 0. This is because when starting up, Bazel
invokes the compiler with various flags to detect what features are
available and what flags to pass during regular compilation. The
detection is based on the stderr of the compiler invocation, so we need
to make sure we are properly printing out stderr. Finally, Bazel uses
stderr to determine if the compiler is clang / gcc or a third option. If
we don't report stderr, then Bazel considers we are using a generic
compiler and then gets confused about what to generate in the toolchain.

Currently, this is the diff from the toolchain autoconfig when Bazel
starts up:

```diff
--- w-clang/bazel-w-clang/external/bazel_tools~cc_configure_extension~local_config_cc/BUILD     2023-09-15 16:54:56.131676995 +0000
+++ w-jcc/bazel-w-jcc/external/bazel_tools~cc_configure_extension~local_config_cc/BUILD 2023-09-15 18:17:24.486499047 +0000
@@ -85,16 +85,13 @@
     "/usr/include/x86_64-linux-gnu",
     "/usr/include",
     "/usr/local/lib/clang/15.0.0/share",
-    "/usr/include/c++/9",
-    "/usr/include/x86_64-linux-gnu/c++/9",
-    "/usr/include/c++/9/backward",
     "/usr/local/include/c++/v1"],
     tool_paths = {"ar": "/usr/bin/ar",
         "ld": "/usr/bin/ld",
         "llvm-cov": "/usr/local/bin/llvm-cov",
         "llvm-profdata": "/usr/local/bin/llvm-profdata",
         "cpp": "/usr/bin/cpp",
-        "gcc": "/usr/local/bin/clang-15",
+        "gcc": "/usr/local/bin/clang-jcc",
         "dwp": "/usr/bin/dwp",
         "gcov": "/usr/bin/gcov",
         "nm": "/usr/bin/nm",
```

The 3 missing header files could be because of
7a4eefa869/tools/cpp/unix_cc_configure.bzl (L316-L321)
but I could not find a way to force this. So far, it didn't look like it
was causing problems though.

---------

Signed-off-by: Mihai Maruseac <mihaimaruseac@google.com>
2023-09-15 15:27:18 -04:00
van Hauser 318f612d30
Update AFL++ commit ID (#10932)
Adds a few features that are very beneficial for CI fuzzing. e.g.
AFL_IGNORE_SEED_PROBLEMS
This also fixes several minor bugfixes.

---------

Co-authored-by: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>
2023-09-14 16:32:17 -04:00
Dongge Liu 4b21830e20
Change to `WORKDIR` before running commands in cloud project experiments. (#10918)
Mitigates the known issue where we don't automatically change to the
`WORKDIR` defined in `Dockerfile` when running cloud experiments.

Question:
Would it be preferred if I introduce a flag for this?
(e.g., `--use_workdir` or `--workdir=/src/<project>`)
While this gives more flexibility, I feel `cd` to `WORKDIR` should
always be preferred if we want the cloud experiments to behave the same
as local ones.
2023-09-14 07:05:18 -04:00
Holly Gong d81e44f16c
fix PR helper when commits have no author. (#10959)
PR helper fails when author information is null. Adding a check before
get login name.

![image](https://github.com/google/oss-fuzz/assets/39108850/f4f3aaa8-3edb-4745-93e1-c6da047d0b7b)
https://github.com/google/oss-fuzz/issues/10955
2023-09-14 12:59:14 +10:00
Catena cyber f71f162a91
infra: update swift to 5.8.1 (#10922)
As done last year by @thomasvl cf
https://github.com/google/oss-fuzz/pull/8501

Hopefully fixes
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61809

Co-authored-by: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>
2023-09-13 14:05:34 -04:00
AdamKorcz 7f893b209d
Fix broken Go coverage reports (#10948)
Fixes https://github.com/google/oss-fuzz/issues/10916

Signed-off-by: AdamKorcz <adam@adalogics.com>
2023-09-13 14:04:44 -04:00
Catena cyber 6efce3bcf4
Update Go to 1.21 (#10920)
cc @DavidKorczynski 

Should replace https://github.com/google/oss-fuzz/pull/9950

Should fix ngolo-fuzzing build cf
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60807
2023-09-13 12:17:27 -04:00
Norbert Schneider 59b8860883
Update Node.js setup for JavaScript projects (#10941)
Migrate the Node.js setup to the currently recommended way and version.
The previously used installation scripts are no longer maintained.

Fixes #10936
2023-09-12 18:09:41 -04:00
Ari Rubinstein 59d03686a2
fix: add tags to go test as well (#10903)
Add the tagspec to the coverage build as well to include the correct
files.

ref: https://github.com/google/oss-fuzz/pull/10884
2023-09-05 17:31:53 -04:00
Dongge Liu fb4afe569a
Take stdin (#10905)
Applying Jonathan's patch to allow jcc take value from `stdin`.
2023-09-01 15:08:31 +10:00
Arthur Chan dd63d146a0
infra: Add fuzzer classes to JVM coverage report (#10906)
In #9658, all jar files of the project has been extracted and dumped in
a directory. Then certain class duplication are removed. But the
removing logic contains a bug. Those class files for fuzzers in the base
of the dump directory are accidentally removed and because they don't
have duplication from the jar files, they are missing from the resulting
coverage report. This PR fixes the bug by ignoring the base directory of
the class dump location when removing classes duplication to ensure the
fuzzer classes existed in the final coverage report.

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2023-09-01 10:51:42 +10:00
Dongge Liu 4a9c344a78
Generate AST of the target file while building project. (#10886)
Tested on `ada-url`.
Does not work on `bzl` projects (e.g. `abseil-cpp` for now.
2023-08-29 06:39:52 +00:00
Ari Rubinstein ce908a4a06
fix: add gofuzz tags to build (#10884)
It appears that `gofuzz` was removed from the default tagspec in the
main branch of go-118-fuzz-build [^1] to `gofuzz_libfuzzer` and
`libfuzzer`. To keep compatibility with the go build scripts, this
change adds the gofuzz tag to the go-118-fuzz-build invocation.

[^1]:
https://github.com/AdamKorcz/go-118-fuzz-build/pull/9/files#diff-2873f79a86c0d8b3335cd7731b0ecf7dd4301eb19a82ef7a1cba7589b5252261L35
2023-08-29 13:11:42 +10:00
jonathanmetzman de3466d56b
Add JavaScript as language (#10895) 2023-08-28 18:51:21 -04:00
DavidKorczynski d6712d688b
infra: bump introspector (#10888)
This has a set of performance improvements in Fuzz Introspector, the two
changes with most impact are:
- removal of some expensive and unnecessary loops in the code
- switching parsing of large yaml files from pure python code to using a
C backend.

Locally it makes OpenSSL builds take approximately 70 minutes whereas in
the cloud build it seems to take 20+ hours. Similar impact happens
across several large java projects.

Signed-off-by: David Korczynski <david@adalogics.com>
2023-08-29 07:26:35 +10:00
jonathanmetzman 3a03d05357
Fix jcc path (#10878) 2023-08-23 16:31:02 -04:00
jonathanmetzman cac76d7045
Update target_experiment.py (#10877) 2023-08-23 16:15:18 -04:00
jonathanmetzman 7e4fde5042
Fix typo (#10876) 2023-08-23 15:56:33 -04:00
DavidKorczynski c37df76180
infra: bump introspector (#10871)
Contains two improvements for speeding projects with a lot of fuzzers.

Specifically:
- https://github.com/ossf/fuzz-introspector/pull/1204
- https://github.com/ossf/fuzz-introspector/pull/1203

Signed-off-by: David Korczynski <david@adalogics.com>
2023-08-23 07:48:26 -04:00
DavidKorczynski 8c049f1e53
infra: bump introspector (#10822)
- adds a deeper recursion logic to introspector's python module, which
fixes some of the broken builds
- fixes https://github.com/ossf/fuzz-introspector/issues/1192
2023-08-21 15:01:23 -04:00
jonathanmetzman 45d49c8f84
Improve jcc (#10783)
1. Put it in a better location on disk.
2. Move it to its own directory.
3. Add tests.
4. Make jcc able to find missing headers.
2023-08-15 12:23:09 -04:00
Elior Schneider d310b02fe0
corrected a typo (#10818)
corrected a typo found when reading a function documentation

I read the contributing.md, the code of conduct and signed the Google
Individual Contributor License Agreement.
2023-08-11 13:07:18 -04:00
Dongge Liu 40c2a8a4a3
Fix `project_experiment.py`: Support copying directories (#10812) 2023-08-09 05:10:26 +00:00
DavidKorczynski b9ce49f8a4
infra: bump fuzz introspector (#10802)
This contains a minor fix in accummulated code complexity for the
annotated CFG feature, used by
https://introspector.oss-fuzz.com/api/annotated-cfg -- in some cases the
value would be 0 incorrectly.

Also includes:
- a refined definition of top-level API fra annotated-cfg extraction: 
  - PR: https://github.com/ossf/fuzz-introspector/pull/1191
- fixes:
https://github.com/ossf/fuzz-introspector/pull/1180#issuecomment-1667163532
- Extended type recognition for C/C++ projects:
  - PR: https://github.com/ossf/fuzz-introspector/pull/1190
  - fixes: https://github.com/ossf/fuzz-introspector/issues/1188
- Converts arg types to array of strings rather a string representation
entirely:
  - PR: https://github.com/ossf/fuzz-introspector/pull/1189 
  - fixes: https://github.com/ossf/fuzz-introspector/issues/1187)
2023-08-09 08:44:54 +10:00
DavidKorczynski e7ecd2f9b8
infra: bump fuzz-introspector (#10791)
Two updates since last:
- Argument name extraction has improved for all functions, and it's
added to `summary.json` files.
- All function names as they are in the binaries are saved. This has
effect only for C++ where the underlying function name is a mangled
function name. Having the raw makes it possible to e.g. demangle it and
get a better-looking name than what currently exists in the reports.

Signed-off-by: David Korczynski <david@adalogics.com>
2023-08-04 10:42:25 +10:00
DavidKorczynski eb81ecd516
infra: bump fuzz introspector (#10772)
This primarily adds additional output and in particular an annotated
list of nodes in the graph which corresponds to first layer of nodes
called by a given fuzzer.

Signed-off-by: David Korczynski <david@adalogics.com>
2023-08-02 19:42:10 +10:00
Holly Gong 75e42585f6
PR helper removes maintainers from known contributors. (#10773)
Details:
https://github.com/google/oss-fuzz/pull/10758#issuecomment-1658574212
2023-08-02 18:10:24 +10:00
Oliver Chang 777176bba5
target_experiment: Upload raw coverage data. (#10774)
This makes them easier to manipulate.
2023-08-02 16:07:24 +10:00
Dongge Liu 94bb76ecd1
Bumping PyYAML to 6.0 (#10770) 2023-08-01 10:16:33 -04:00
Arthur Chan 9d74012656
Extend java coverage reports to include non-covered files (#9658)
Jacoco is used for code coverage report generation of JVM projects. It
will make use of the dumped class file to generate the report. But only
java classes covered by at least one fuzzer will be included in the
report, other files in the project will be ignored. This PR aims to
point the Jacoco class file discovery folder to the original compiled
project jar file in order to force Jacoco to generate coverage report
with source for all java class of the project.
This came as a need from Fuzz Introspector where we noticed some
discrepancies between the static analysis and the code coverage reports.

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>

---------

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
Signed-off-by: David Korczynski <david@adalogics.com>
Co-authored-by: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>
Co-authored-by: David Korczynski <david@adalogics.com>
2023-08-01 07:39:03 +10:00
Oliver Chang e213ae15d3
target_experiment: Print build logs. (#10763)
To make it more convenient to browse results on GCB.
2023-07-31 16:46:25 +10:00
jonathanmetzman 3ed4d727e4
Link "fixed" C to C++ targets with libc++. (#10760)
Otherwise results in a linking error.
2023-07-31 09:12:51 +10:00
Oliver Chang bbe690548b
jcc: Minor logic simplification. (#10756) 2023-07-28 15:09:44 +10:00
Oliver Chang 08a8efb87d
jcc fixes. (#10755)
- Print error properly when compiling for C++ to begin with. Previously
we were masking errors when compiling for C++ at first.
- Use the return code from clang.
- Prefer printing the C++ error over the C error.
- Use Go naming conventions.
2023-07-28 15:05:39 +10:00
Dongge Liu 9046b096a7
Minor fix `project_experiment.py` (#10754)
Copy the content in `/workspace/out/` only.
No need to copy the parent `out` directory level.
2023-07-28 01:02:44 +00:00
Oliver Chang a670bdf642
Add project_experiment.py (#10739)
This allows us to run arbitrary scripts inside project containers on
GCB.

All files in `/workspace/out` are upload to a specified GCS path at the
end.

Usage:
```bash
$ python project_experiment.py --project libxml2 --command 'python3 /workspace/hello.py' \
  --experiment_name test-ochang \
  --upload_output gs://BUCKET/to/upload/NAME
```

(Where /workspace is the OSS-Fuzz repository).
2023-07-24 15:45:47 +10:00
Oliver Chang bf04c203db
Support jcc for cloud experiments. (#10738) 2023-07-24 12:35:02 +10:00
Oliver Chang 2d207721df
chmod jcc in base image. (#10737) 2023-07-24 10:52:17 +10:00
jonathanmetzman 36c3ced2ef
Add jcc (#10734) 2023-07-21 15:06:35 -04:00
jonathanmetzman f90bfa77f6
Fix experiment tagging (#10725) 2023-07-19 13:11:08 -04:00
jonathanmetzman 189073d2bf
Support named experiments (#10723)
Named experiments will be tagged: `branch-$EXPERIMENT_NAME`
2023-07-19 11:04:48 -04:00
Oliver Chang fa9f387bac
target_experiment: fixes. (#10697)
- Fix coverage report generation. The wrong corpus was being used.
- Delete the corpus.zip after we upload it.
2023-07-13 16:24:01 +10:00
DavidKorczynski ff9bb81fa3
infra: fix presubmit when project.yaml fails (#10681)
Currently a `project.yaml` with wrong key names will result in the
following error:

```
...
    return all([check(changed_files) for check in checks])
  File "infra/presubmit.py", line 229, in check_project_yaml
    return all([_check_one_project_yaml(path) for path in paths])
  File "infra/presubmit.py", line 229, in <listcomp>
    return all([_check_one_project_yaml(path) for path in paths])
  File "infra/presubmit.py", line 223, in _check_one_project_yaml
    return checker.do_checks()
  File "infra/presubmit.py", line 131, in do_checks
    check_function()
  File "infra/presubmit.py", line 179, in check_valid_section_names
    self.error(f'{name} is not a valid section name ({valid_names})')
NameError: name 'valid_names' is not defined
```

This fixes it.

Signed-off-by: David Korczynski <david@adalogics.com>
2023-07-13 13:47:05 +10:00
Oliver Chang 609f553894
Bump machine type for fuzz introspector webapp builder (#10692) 2023-07-12 11:58:43 +10:00
jonathanmetzman a790ab47e1
Update sarif_utils.py (#10685) 2023-07-11 13:21:59 -04:00
Holly Gong c4e1361220
Add past contributors for pr helper (#10664) 2023-07-10 10:30:47 -04:00
jonathanmetzman 3162163463
[cifuzz][sarif] Make directory before writing file (#10673) 2023-07-10 10:26:09 -04:00
Oliver Chang 479cd263f3
Use a separate buildpool for experiments. (#10676)
To avoid contention when production builds are running.
2023-07-10 03:12:10 +00:00
Oliver Chang 20112bf1fe
target_experiment: upload build log properly when the build failed. (#10652)
Previously the cloud build exited before we upload the logs. Now we
write a file to record build success and report the failure later after
uploading the log if there was one.
2023-07-07 09:42:43 +10:00