Skip to content
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

Continuous Fuzzing Integration with Fuzzit #7509

Merged
merged 4 commits into from
Sep 23, 2019

Conversation

yevgenypats
Copy link
Contributor

Please do not merge yet. This is work in progress.
The contribution was discuss in the mailing-list with @htuch , @mattklein123 .

Description:
This will introduce another platform (apart from oss) fuzz that
will run the long-running fuzzers as well as will introduce
"sanity fuzzers" that will run the accumlated corpus and crashes
on every Pull-Request to detect bugs early-on in the development
cycle.

Risk Level:
Low - as this will introduce only another step in CircleCI where the fuzzers will be uploaded to Fuzzit and the heavy lifting will be there.

Testing:
No code is added just a CI code in Circle

Docs Changes:
Will be updated later.

Release Notes: None
[Optional Fixes #Issue] None
[Optional Deprecated:] None

@yevgenypats yevgenypats force-pushed the fuzzit_integration branch 4 times, most recently from 13d63ca to 206ec5f Compare July 9, 2019 18:35
ci/run_fuzzit.sh Outdated
export ENVOY_SRC_PATH=`pwd`
cd oss-fuzz
python infra/helper.py build_image --pull envoy
python infra/helper.py build_fuzzers --sanitizer=address envoy ${ENVOY_SRC_PATH}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One key issue here is build performance; if this takes a significant amount of time (which anecdotally it does from local runs), e.g. > 1 hour, it will become a CI bottleneck. Many of our CI jobs now benefit from Bazel caching and (in the future) RBE enablement, this one is going to be inherently stuck without this, since the oss-fuzz image doesn't have any plumbing for this. CC @lizan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@htuch This is exactly what I'm trying to do just wanted to see if it works with the current oss-fuzz images. Anyway I was able to compile the targets with bazel for example

using bazel build //test/server:server_fuzz_test the build completes successfully but it seems that it doesn't link against libFuzzer. what would be the right command to link it against libfuzzer (i.e -fsanitize=fuzzer) as I don't wont to use the oss docker both to use the caching and also not to use the nested docker in Circle.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm afraid you're going to have to do some gnarly Bazel hacking to get it to link against libfuzzer under Bazel. We would be super appreciative of this work, but it will involve diving into https://github.com/envoyproxy/envoy/blob/master/bazel/envoy_test.bzl#L66 and figuring out how to cleanly offer both the corpus run (using the existing test driver) and a way to on the Bazel CLI configure a link against libfuzzer (and somehow getting libfuzzer included in the Envoy build).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll find the way to do that. I just wanted to make sure that I'm not doing double work and it's not implemented yet.

ci/run_fuzzit.sh Outdated
git clone https://github.com/google/oss-fuzz.git
export ENVOY_SRC_PATH=`pwd`
cd oss-fuzz
python infra/helper.py build_image --pull envoy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we doing nested Docker here? I.e. running oss-fuzz Docker build inside a CircleCI Docker env?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm exactly working on this to make it work not inside the oss-fuzz docker.

@yevgenypats
Copy link
Contributor Author

@htuch looks like I get some no-credits error at CircleCI? any particular reason for this to happen? I can test my changes.

@htuch
Copy link
Member

htuch commented Jul 16, 2019

@yevgenypats this is a general Envoy CI issue, we are working to resolve.

@htuch
Copy link
Member

htuch commented Jul 16, 2019

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: Build Error (failed build)

🐱

Caused by: a #7509 (comment) was created by @htuch.

see: more, trace.

@yevgenypats
Copy link
Contributor Author

@htuch thx. just an update. look like it works now. I'll update when the PR will be ready for review. should be soon. cheers.

@yevgenypats yevgenypats force-pushed the fuzzit_integration branch 3 times, most recently from 59876ab to e1b1881 Compare July 17, 2019 07:56
ci/do_ci.sh Outdated
FUZZ_TEST_TARGETS="$(bazel query "attr('tags','fuzzer',${TEST_TARGETS})")"
echo "bazel ASAN libFuzzer build with fuzz tests ${FUZZ_TEST_TARGETS}"
echo "Building envoy fuzzers and executing 100 fuzz iterations..."
bazel_with_collection build ${BAZEL_BUILD_OPTIONS} --config=asan-fuzzer ${FUZZ_TEST_TARGETS} --test_arg="-runs=10"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need --test_arg

ci/do_ci.sh Outdated
FUZZ_TEST_TARGETS="$(bazel query "attr('tags','fuzzer',${TEST_TARGETS})")"
echo "bazel ASAN libFuzzer build with fuzz tests ${FUZZ_TEST_TARGETS}"
echo "Building envoy fuzzers and executing 100 fuzz iterations..."
bazel_with_collection build ${BAZEL_BUILD_OPTIONS} --config=asan-fuzzer ${FUZZ_TEST_TARGETS} --test_arg="-runs=10"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -12,6 +12,8 @@ jobs:
CI_TARGET: 'bazel.compile_time_options'
fuzz:
CI_TARGET: 'bazel.fuzz'
fuzzit:
CI_TARGET: 'bazel.fuzzit_regression'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you intended to do this in every PR? This doesn't provide anything in addition to bazel.fuzz above, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. I think it is and this was one of the main reasons integrating fuzzit in addition to OSS Fuzz. this downloads the current corpus+fixed_crashes from Fuzzit Servers and runs the fuzzers through those test-cases which is stronger then just a run for 10 seconds with empty corpus (which is fine but that just checks if the fuzzers compiled successfully)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we merge those two jobs into one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

sudo service docker restart
displayName: "Enable IPv6"

- script: ci/run_envoy_docker.sh 'ci/do_ci.sh bazel.fuzzit_fuzzing'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add FUZZIT_API_KEY env (it can be in FUZZIT_API_KEY=$(FuzzitApiKey) before ci/do_ci.sh, or env below and add propagate it in ci/run_envoy_docker.sh.

ci/do_ci.sh Outdated
setup_clang_toolchain
FUZZ_TEST_TARGETS="$(bazel query "attr('tags','fuzzer',${TEST_TARGETS})")"
echo "bazel ASAN libFuzzer build with fuzz tests ${FUZZ_TEST_TARGETS}"
echo "Building envoy fuzzers and executing 100 fuzz iterations..."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -12,6 +12,8 @@ jobs:
CI_TARGET: 'bazel.compile_time_options'
fuzz:
CI_TARGET: 'bazel.fuzz'
fuzzit:
CI_TARGET: 'bazel.fuzzit_regression'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we merge those two jobs into one?

@yevgenypats
Copy link
Contributor Author

@lizan fixed the review:)

lizan
lizan previously approved these changes Sep 20, 2019
@lizan
Copy link
Member

lizan commented Sep 20, 2019

@htuch?

@lizan lizan requested a review from htuch September 20, 2019 21:05
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/wait

@@ -53,3 +53,36 @@ jobs:
pathtoPublish: "$(Build.StagingDirectory)/envoy"
artifactName: $(CI_TARGET)
condition: always()

- job: fuzzit_fuzzing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some comments here explaining when this runs? Does this happen on every PR, does it block PRs, is this contributing to the PR critical path on CI? I think this PR generally looks awesome, but this needs some clarification, preferably in source comments. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, as explained in the comments there are two workflows:

  • Fuzzing - This will run on every push/merge to master, will build the fuzzers and will upload them to Fuzzit where they will run asynchronous. This will ensure the latest version of the code is always being fuzzed and new bugs are found as new code is added.
  • Regression - This will run on every commit/PR and will run the fuzzers inline in the CI together with the corpus generated on Fuzzit as well as previous fixed crashes. This will ensure bugs are found BEFORE merge.

Signed-off-by: Yevgeny Pats <[email protected]>
@yevgenypats
Copy link
Contributor Author

@yevgenypats
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: docs (failed build)

🐱

Caused by: a #7509 (comment) was created by @yevgenypats.

see: more, trace.

@yevgenypats
Copy link
Contributor Author

@htuch passing!:)

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yevgenypats. Appreciate your patience and work on iterating to find the best fit with Envoy CI and fuzzing. Also thanks @lizan for all the help with the CI aspects.

@htuch htuch merged commit bbae4a7 into envoyproxy:master Sep 23, 2019
@yevgenypats
Copy link
Contributor Author

@htuch @lizan sure thing, thank you! and feel free to ping me if there are any issues/changes you need.

also @lizan are you sure the FUZZIT_API_KEY is available because I see that the script didn't find it (I couldn't check it before merge as this is environment variable is not available for forked-PRs)

Also looks there are some crashes already https://app.fuzzit.dev/orgs/envoyproxy/dashboard

and of course feel free to RT https://twitter.com/fuzzitdev/status/1176246876821217283

Thanks!

@htuch
Copy link
Member

htuch commented Sep 23, 2019

@yevgenypats are these crashes limited in visibility? We would like to maintain embargo on any zero days and only have https://github.com/google/oss-fuzz/blob/master/projects/envoy/project.yaml#L3 see these.

@yevgenypats
Copy link
Contributor Author

@htuch yes of course, like we discussed. currently only @lizan has access I can add you to the email notifications but you need to sign-up at https://app.fuzzit.dev so I can add you to the envoy account so you will have access to the crashes and other data.

@lizan
Copy link
Member

lizan commented Sep 23, 2019

I set the api key right now, should be fixed in future builds

@yevgenypats
Copy link
Contributor Author

yevgenypats commented Sep 23, 2019 via email

@lizan
Copy link
Member

lizan commented Sep 24, 2019

@yevgenypats now it is failing with

+ ./fuzzit create target --skip-if-exists --public-corpus envoyproxy/access-log-formatter
2019/09/23 23:20:23 Creating target...
2019/09/23 23:20:23 target can only contain lowercase characetrs, numbers and hypens

danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Sep 24, 2019
This will introduce another platform (apart from oss) fuzz that
will run the long-running fuzzers as well as will introduce
"sanity fuzzers" that will run the accumlated corpus and crashes
on every Pull-Request to detect bugs early-on in the development
cycle.

Risk Level: Low - as this will introduce only another step in CircleCI where the fuzzers will be uploaded to Fuzzit and the heavy lifting will be there.

Testing: No code is added just a CI code in Circle

Signed-off-by: Yevgeny Pats <[email protected]>
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Oct 4, 2019
This will introduce another platform (apart from oss) fuzz that
will run the long-running fuzzers as well as will introduce
"sanity fuzzers" that will run the accumlated corpus and crashes
on every Pull-Request to detect bugs early-on in the development
cycle.

Risk Level: Low - as this will introduce only another step in CircleCI where the fuzzers will be uploaded to Fuzzit and the heavy lifting will be there.

Testing: No code is added just a CI code in Circle

Signed-off-by: Yevgeny Pats <[email protected]>
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Oct 4, 2019
This will introduce another platform (apart from oss) fuzz that
will run the long-running fuzzers as well as will introduce
"sanity fuzzers" that will run the accumlated corpus and crashes
on every Pull-Request to detect bugs early-on in the development
cycle.

Risk Level: Low - as this will introduce only another step in CircleCI where the fuzzers will be uploaded to Fuzzit and the heavy lifting will be there.

Testing: No code is added just a CI code in Circle

Signed-off-by: Yevgeny Pats <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants