Pipeline for Maven#1953
Conversation
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
- Update format Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
…1763 - Update package's license if missing while the same package has license detected in RESOURCES Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
tdruez
left a comment
There was a problem hiding this comment.
- Create a new maven pipe module in place of use resolve
- Opening and loading a large file to make edits multiple times in various steps is not great.
- To be discussed: Do we need a dedicated pipeline for just an extra step? Shouldn't the original
scan_single_packagedetect that it's a Maven package and apply the necessary? Any reason to keep this new logic separated?
| with open(self.scan_output_location) as file: | ||
| data = json.load(file) | ||
| # Return and do nothing if data has pom.xml | ||
| for file in data["files"]: | ||
| if "pom.xml" in file["path"]: | ||
| return | ||
| packages = data.get("packages", []) | ||
|
|
||
| pom_url_list = get_pom_url_list(self.project.input_sources[0], packages) | ||
| pom_file_list = download_pom_files(pom_url_list) | ||
| scanned_pom_packages, scanned_dependencies = scan_pom_files(pom_file_list) | ||
|
|
||
| updated_packages = packages + scanned_pom_packages | ||
| # Replace/Update the package and dependencies section | ||
| data["packages"] = updated_packages | ||
| data["dependencies"] = scanned_dependencies | ||
| with open(self.scan_output_location, "w") as file: | ||
| json.dump(data, file, indent=2) |
There was a problem hiding this comment.
Code logic should not be on the pipeline itself but in dedictated and easilly testable pipe functions
| cls.extract_input_to_codebase_directory, | ||
| cls.extract_archives, | ||
| cls.run_scan, | ||
| cls.update_package_license_from_resource_if_missing, |
There was a problem hiding this comment.
This may have quite an impact on the default ScanSinglePackage results. We should probably handle this one separatly of the Maven context.
| if not packages or not resources: | ||
| return | ||
|
|
||
| updated_packages = update_package_license_from_resource_if_missing( |
There was a problem hiding this comment.
We should use database queries instead of manipulating complex dictionaries.
| return pom_file_list | ||
|
|
||
|
|
||
| def scan_pom_files(pom_file_list): |
There was a problem hiding this comment.
This is too complex, it needs to be refactored as smaller functions
| return scanned_pom_packages, scanned_pom_deps | ||
|
|
||
|
|
||
| def update_package_license_from_resource_if_missing(packages, resources): |
There was a problem hiding this comment.
This should be query-based.
Signed-off-by: Chin Yeung Li <tli@nexb.com>
- Create a new maven pipe module - Use database queries for update_package_license_from_resource_if_missing() - Add tests Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
|
@tdruez I’ve updated the code to include support for the "D2D" option.
The "deploy_to_devel" option is equivalent to the "map_deploy_to_develop" pipeline, which runs on Java, JavaScript, Kotlin, and Scala as these are the languages commonly found in Maven projects. |
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Some projects encountered a unique constraint violation when a resource was already mapped: ``` duplicate key value violates unique constraint "scanpipe_codebaserelation_unique_relation" DETAIL: Key (from_resource_id, to_resource_id, map_type)=(1512780, 1512790, jar_to_source) already exists. ``` Signed-off-by: Chin Yeung Li <tli@nexb.com>

Uh oh!
There was an error while loading. Please reload this page.