-
Notifications
You must be signed in to change notification settings - Fork 623
[NDB PERMISSION_DENIED] Introduce FuzzerRunOutputData and utils #5376
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
|
|
||
| import base64 | ||
| import collections | ||
| import dataclasses | ||
| import datetime | ||
| import os | ||
| import re | ||
|
|
@@ -356,6 +357,65 @@ class Crash( | |
| fields.""" | ||
|
|
||
|
|
||
| @dataclasses.dataclass | ||
| class FuzzerRunOutputData: | ||
| """Output metadata for a single fuzzer run stored in memory or a temp file.""" | ||
| _output: str | bytes | None = None | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would document that you expect |
||
| _file_path: str | None = None | ||
| crash_path: str | None = None | ||
| return_code: int = 0 | ||
| log_time: datetime.datetime | None = None | ||
|
|
||
| @classmethod | ||
| def from_file_path(cls, | ||
| file_path: str, | ||
| crash_path: str | None = None, | ||
| return_code: int = 0, | ||
| log_time: datetime.datetime | None = None): | ||
| return cls( | ||
| _file_path=file_path, | ||
| crash_path=crash_path, | ||
| return_code=return_code, | ||
| log_time=log_time) | ||
|
|
||
| @classmethod | ||
| def from_memory(cls, | ||
| output: str | bytes, | ||
| crash_path: str | None = None, | ||
| return_code: int = 0, | ||
| log_time: datetime.datetime | None = None): | ||
| return cls( | ||
| _output=output, | ||
| crash_path=crash_path, | ||
| return_code=return_code, | ||
| log_time=log_time) | ||
|
|
||
| def get_output(self) -> str | None: | ||
| """Reads or decodes the fuzzer output text.""" | ||
| if self._file_path: | ||
| if not os.path.exists(self._file_path): | ||
| return None | ||
| output = utils.read_data_from_file_and_remove( | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deletes the files because output files are meant to be temp files that allows us to more easily capture the fuzzer's log output
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, this probably answers my previous comment. |
||
| self._file_path, eval_data=False) | ||
| return None if output is None else output.decode( | ||
| 'utf-8', errors='replace') | ||
|
|
||
| if not self._output: | ||
| return None | ||
|
|
||
| if isinstance(self._output, bytes): | ||
| return self._output.decode('utf-8', errors='replace') | ||
|
|
||
| return self._output | ||
|
|
||
|
|
||
| @dataclasses.dataclass | ||
| class TestcaseRunResult: | ||
| """Result of a testcase execution queued for processing.""" | ||
| crash: Crash | None = None | ||
| fuzzer_run_output_data: FuzzerRunOutputData | None = None | ||
|
|
||
|
|
||
| def get_resource_paths(output): | ||
| """Read the urls from the output.""" | ||
| resource_paths = set() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we still call
remove_fileif this throws an error?