-
Notifications
You must be signed in to change notification settings - Fork 7
Generate composer.lock files #471
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: main
Are you sure you want to change the base?
Conversation
catching up branch with main
| def install_package_files(include_dev: bool, path: str, root_path: str): | ||
| # Create a composer.lock file if it doesn't already exist | ||
| logger.info( | ||
| f"Generating composer.lock for {path.replace(root_path, '')} (including dev dependencies: {include_dev}" |
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.
(minor) Missing end paren at the end of the log message.
| docker_client = docker.from_env() | ||
|
|
||
|
|
||
| def install_package_files(include_dev: bool, path: str, root_path: str): |
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.
Since this function doesn't report errors up, we should document the fact that this is "best effort", i.e. if the composer.lock couldn't be generated then we will continue anyway.
| {"success": not bool(results), "details": results, "errors": lock_file_errors, "alerts": lock_file_alerts} | ||
| ) | ||
| ) | ||
| print(json.dumps({"success": not bool(results), "details": results, "errors": errors, "alerts": alerts})) |
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.
(minor) Since our JSON results can be quite large, we should switch from using json.dumps (which renders the whole JSON to a string first) to json.dump that renders the output directly to the output, e.g.:
json.dump({ ... }, sys.stdout)|
|
||
| # Run Composer in a container | ||
| COMPOSER_IMG = "composer:latest" | ||
| container_name = "composer_runner" |
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.
Container names must be unique, so we should append a UUID.
catching up with main
Description
Currently, when a directory has a composer.json file and does not have a composer.lock file, we can not use our trivy SCA scanner. Now with this change, a composer.lock file will be auto generated when a directory contains a composer.json file.
Motivation and Context
To extend our SCA language coverage
How Has This Been Tested?
in a development environment
Types of changes
Checklist