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

experimental: refactor to simplify and compartmentalise #454

Merged
merged 14 commits into from
Jul 9, 2024

Conversation

DavidKorczynski
Copy link
Collaborator

Refactors the from-scratch logic by:

  • Adding a container for build workers
  • Removing unused code
  • Facelifting string formatting since it was added to the CI

Note, in the manager and build_generator we can't remove the use of List and Dict since it relies on the Python from OSS-Fuzz, which hasn't migrated to list and dict yet.

This is working towards #450

This fixes bugs happening when the relative path is used

Signed-off-by: David Korczynski <[email protected]>
Signed-off-by: David Korczynski <[email protected]>
Signed-off-by: David Korczynski <[email protected]>
Signed-off-by: David Korczynski <[email protected]>
Signed-off-by: David Korczynski <[email protected]>
Signed-off-by: David Korczynski <[email protected]>
Signed-off-by: David Korczynski <[email protected]>
Signed-off-by: David Korczynski <[email protected]>
Signed-off-by: David Korczynski <[email protected]>
Signed-off-by: David Korczynski <[email protected]>
@DavidKorczynski
Copy link
Collaborator Author

/gcbrun skip

Signed-off-by: David Korczynski <[email protected]>
@DavidKorczynski
Copy link
Collaborator Author

/gcbrun skip

Signed-off-by: David Korczynski <[email protected]>
self.build_suggestion: AutoBuildContainer = build_suggestion
self.build_script: str = ''
self.build_directory: str = ''
self.executable_files_build: Dict[str, List[str]] = {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: dict[str, list[str]]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can't -- this code runs in the oss-fuzz base images which relies on Python 3.8 and the typing is a Python3.9+ thing (see initial PR comment)

all_build_scripts: List[Tuple[str, str, AutoBuildContainer]],
initial_executable_files: Dict[str, List[str]]) -> Dict[str, Any]:
all_build_scripts: List[Tuple[str, str, AutoBuildContainer]]
) -> Dict[str, BuildWorker]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: list[tuple[str, str, AutoBuildContainer]], dict[str, BuildWorker]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can't -- this code runs in the oss-fuzz base images which relies on Python 3.8 and the typing is a Python3.9+ thing (see initial PR comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh I see. thanks!

experimental/c-cpp/build_generator.py Outdated Show resolved Hide resolved
experimental/c-cpp/build_generator.py Outdated Show resolved Hide resolved
experimental/c-cpp/manager.py Outdated Show resolved Hide resolved
experimental/c-cpp/manager.py Outdated Show resolved Hide resolved

The harness should be in libFuzzer style, with the code wrapped in `int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)`.

Please wrap all code in <code> tags and you should include nothing else but the code in your reply. Do not include any other text.

Make sure the ensure strings passed to the target are null-terminated.

There is one rule that your harness must satisfy: all of the header files in this library is %s. Make sure to not include any header files not in this list.
There is one rule that your harness must satisfy: all of the header files in this library is {str(headers_to_include)}. Make sure to not include any header files not in this list.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same above
Do we need to cast headers_to_include explicitly with str()?

Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW, could this be in a template file in the final version?
Also, could we define repeated lines once and reuse them to avoid repetitions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same above Do we need to cast headers_to_include explicitly with str()?

We don't! thanks, fixed!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

BTW, could this be in a template file in the final version? Also, could we define repeated lines once and reuse them to avoid repetitions?

Yep, I'll look at doing this when merging the two #450 -- for the moment it's nice to have this in a single module as it makes for easy copying in/out of the containers as some development of this module happens within base-builder container environments. I will address this later though.

experimental/c-cpp/manager.py Outdated Show resolved Hide resolved
experimental/c-cpp/manager.py Outdated Show resolved Hide resolved
experimental/c-cpp/manager.py Outdated Show resolved Hide resolved
Signed-off-by: David Korczynski <[email protected]>
@DavidKorczynski
Copy link
Collaborator Author

/gcbrun skip

@DavidKorczynski DavidKorczynski merged commit 1b39ce5 into main Jul 9, 2024
7 checks passed
@DavidKorczynski DavidKorczynski deleted the refactor-experimental-250 branch July 9, 2024 10:04
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.

2 participants