Skip to content

[Logging] Add fuzz-related logs context to corpus pruning task #4774

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

Merged
merged 6 commits into from
Apr 29, 2025

Conversation

ViniciustCosta
Copy link
Collaborator

@ViniciustCosta ViniciustCosta commented Apr 24, 2025

Description

Differently from the tasks instrumented with logs context so far, corpus pruning (and fuzz task) is not based on a testcase. These two in particular operate on top of fuzzers, jobs and fuzz targets. This PR:

  • Creates a new fuzzing-related logs context based on a given fuzzer, job type and fuzz target. Since these metadata are the same as in the testcase-based context (just retrieved from different source), I changed the testcase context to contain only the testcase ID.
  • Added this context manager to corpus pruning task.

Tests

Since corpus pruning runs on batch, a onebox deployment with candidate was not viable. Thus, the test was done by running the task's preprocess locally with the debugger and sending the logs to GCP. Evidence from the logs:
image

@ViniciustCosta ViniciustCosta marked this pull request as ready for review April 24, 2025 17:58
if self == LogContextType.FUZZ:
try:
return FuzzLogStruct(
fuzzer=log_contexts.meta.get('fuzzer_name', 'null'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

WHy not return None instead of "null"?

Copy link
Collaborator Author

@ViniciustCosta ViniciustCosta Apr 25, 2025

Choose a reason for hiding this comment

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

I'm not entirely sure how the gcp logging treats fields that are set to None, my guess is that it omits that field. IMO it's better to have this default value meaning that the information is missing/not applicable than omitting it, which could mean that something went wrong during logging.
( I also used this piece of code as reference: https://github.com/google/clusterfuzz/blob/master/src/clusterfuzz/_internal/metrics/logs.py#L420 )

},
})

def test_fuzz_logs_context(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This tests the log being emited within the log context. We do not have integration tests that go through pre/main/postprocess though, so we are not testing the actual task execution flow here.

Can we get some evidence of this running on a candidate release of some sort, to make sure nothing weird happens and we actually get the logs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, we have this gap of integration tests that hinders our testing capabilities for these kind of changes.
I will do a onebox deployment with candidate and paste the logs here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I executed the task preprocess stage locally and pasted the logs in the PR description (tyvm for the help on how to do this @vitorguidi 🤝)

Copy link
Collaborator

@vitorguidi vitorguidi left a comment

Choose a reason for hiding this comment

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

Thanks for the thorough testing! lgtm

Copy link
Contributor

@javanlacerda javanlacerda left a comment

Choose a reason for hiding this comment

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

Receive it!

@ViniciustCosta ViniciustCosta merged commit 5a0d023 into master Apr 29, 2025
7 checks passed
@ViniciustCosta ViniciustCosta deleted the feat/structured_logs_corpus_pruning branch April 29, 2025 17:49
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