Conversation
jonathanmetzman
left a comment
There was a problem hiding this comment.
This looks much much better! Nice work
| class Bucket: # pylint: disable=too-few-public-methods | ||
| """Class representing the coverage GCS bucket.""" | ||
| """Class representing the GCS bucket.""" | ||
|
|
There was a problem hiding this comment.
I think you should probably define a BUCKET_NAME = None here.
@oliverchang WDYR?
On the one hand not doing None makes incorrect implementations fail louder, on the other hand it seems too-dynamic and icky to do this.
There was a problem hiding this comment.
The other option would be to override init and use super.
There was a problem hiding this comment.
Yes, the BUCKET_NAME = None was needed for lint.
| introspector_enabled = False | ||
| if project.fuzzing_language in LANGUAGES_WITH_INTROSPECTOR_SUPPORT: | ||
| introspector_enabled = True | ||
|
|
There was a problem hiding this comment.
Hmmm... maybe do
else
introspector_enabled = False
| runner_image_name = build_project.get_runner_image_name( | ||
| base_images_project, config.test_image_suffix) | ||
| if introspector_enabled: | ||
| runner_image_name += ':introspector' |
There was a problem hiding this comment.
Sorry, why are we using the tag for this instead of a different image name?
There was a problem hiding this comment.
Got rid of this as well. We can use :latest now.
| upload_fuzzer_stats_url, | ||
| 'html_report_url': | ||
| bucket.html_report_url, | ||
| os.path.join(bucket.html_report_url, 'index.html'), |
There was a problem hiding this comment.
I don't know what's the right thing to do here, but for URLs I generally use posixpath.join instead of os.path.join
since os.path.join would break on Windows for URLs (it would use backslash: "")
| LATEST_REPORT_INFO_CONTENT_TYPE)) | ||
|
|
||
| if introspector_enabled: | ||
| coverage_url = bucket.html_report_url |
There was a problem hiding this comment.
nit: Don't put this in a variable.
| config.test_image_suffix), | ||
| 'args': [ | ||
| 'bash', '-c', | ||
| ('sed -i s/base-builder/base-builder:introspector/g ' |
There was a problem hiding this comment.
So what you can do to avoid this is the following
run the command:
docker tag gcr.io/oss-fuzz-base/base-builder:introspector gcr.io/oss-fuzz-base/base-builder:latest
and then you won't need sed.
Note that your technique and mine breaks if someone were to change the FROM line.
This happens sometimes when someone wants to use an older version of clang.
There was a problem hiding this comment.
+1. Do this instead of sed.
| 'bash', '-c', | ||
| ('sed -i s/base-builder/base-builder:introspector/g ' | ||
| f'oss-fuzz/projects/{project.name}/Dockerfile' | ||
| f' && cat oss-fuzz/projects/{project.name}/Dockerfile') |
There was a problem hiding this comment.
This cat step shouldn't be necessary right?
There was a problem hiding this comment.
OOPS! it was for debugging purpose.
| 'build', | ||
| '-t', | ||
| f'gcr.io/oss-fuzz/{project.name}', | ||
| '.', |
There was a problem hiding this comment.
Maybe instead of using "." and dir, you can use docker's --file argument.
| config.test_image_suffix), | ||
| 'args': [ | ||
| 'bash', '-c', | ||
| ('sed -i s/base-builder/base-builder:introspector/g ' |
There was a problem hiding this comment.
+1. Do this instead of sed.
|
I have to fix test failures. |
infra/build/functions/deploy.sh
Outdated
There was a problem hiding this comment.
Nit: delete these empty lines
infra/build/functions/deploy.sh
Outdated
|
|
||
|
|
||
| deploy_cloud_function request-introspector-build \ | ||
| introspector_build \ |
There was a problem hiding this comment.
Think you forgot to push. I edited this file.
|
|
||
| def introspector_build(event, context): | ||
| """Entry point for cloud function to build introspector reports.""" | ||
| request_introspector_build.request_introspector_build(event, context) |
There was a problem hiding this comment.
You need to add this file too (request_introspector_build.py).
| import request_introspector_build | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
tip: try not to make changes that aren't necessary for your PR, like deleting lines such as this one.
| @@ -0,0 +1,58 @@ | |||
| # Copyright 2022 Google Inc. | |||
| upload_fuzzer_stats_url, | ||
| 'html_report_url': | ||
| bucket.html_report_url, | ||
| os.path.join(bucket.html_report_url, 'index.html'), |
| def get_fuzz_introspector_steps( # pylint: disable=too-many-locals, too-many-arguments, unused-argument | ||
| project_name, project_yaml_contents, dockerfile_lines, image_project, | ||
| base_images_project, config): | ||
| """Return build steps of fuzz introspector for project""" |
There was a problem hiding this comment.
I think the docstring should be in descriptive style acording to the style guide: https://google.github.io/styleguide/pyguide.html#383-functions-and-methods
e.g. "Returns build step" instead of "Return build step"
infra/build/functions/build_lib.py
Outdated
| return steps | ||
|
|
||
|
|
||
| def download_coverage_data_steps(project_name, latest, bucket_name, testing): |
There was a problem hiding this comment.
I'm going to try to think of a way to share code with download_corpora_steps since it looks like this code was copied.
| steps = [] | ||
| fuzz_targets = _get_targets_list(project_name, testing) | ||
| if not fuzz_targets: | ||
| sys.stderr.write('No fuzz targets found for project "%s".\n' % project_name) |
There was a problem hiding this comment.
Can you log instead of writing to stderr please?
There was a problem hiding this comment.
The other functions in build_lib.py are writing to stderr, too. Should we change them all?
There was a problem hiding this comment.
Eh can leave for consistency. We can change them all another time.
oliverchang
left a comment
There was a problem hiding this comment.
Nice! Looking close! Just some more minor comments.
Also, we need tests for the request_introspector_build part. In the interests of time, we can do this in another PR (please add a TODO) if you've manually tested this already.
|
|
||
| coverage_report_latest = build_project.get_datetime_yesterday().strftime( | ||
| '%Y%m%d') | ||
| # TODO: debug |
| return datetime.datetime.now() | ||
|
|
||
|
|
||
| def get_datetime_yesterday(): |
There was a problem hiding this comment.
Rather than this, we could also try to figure out the actual latest uploaded report by looking at the bucket. Can leave this as a TODO.
There was a problem hiding this comment.
yes that is what we have to change later. For now I changed it to use the current date. It means it needs the coverage build have to finish before starting introspector build.
| f'gcr.io/oss-fuzz/{project.name}', | ||
| '.', | ||
| ], | ||
| 'dir': f'oss-fuzz/projects/{project.name}', |
There was a problem hiding this comment.
Use posixpath.join instead
There was a problem hiding this comment.
I thought we use posixpath.join for URLs. Did you mean using os.path.join()?
There was a problem hiding this comment.
Better to use posixpath here, as the Cloud Build environment is posix. The environment this script runs may not be posix.
Adds build steps for fuzz introspector to the coverage build.
Adds build steps for fuzz introspector to the coverage build.
Adds build steps for fuzz introspector to the coverage build.