-
-
Notifications
You must be signed in to change notification settings - Fork 194
feat: add pipeline specialized in Maven package scan #1953
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
Merged
Merged
Changes from all commits
Commits
Show all changes
113 commits
Select commit
Hold shift + click to select a range
9e93317
Add "scan_maven_package" pipeline (Working-in-progress) #1763
chinyeungli 928f742
Use pom_url as the datafile_path for the dependenies #1763
chinyeungli d63a1e5
Use empty string for datafile_path in dependencies #1763
chinyeungli 9812129
Removed dup code that's already present in ScanSinglePackage #1763
chinyeungli 114eb75
Update the matching regex for parse_maven_filename and added test #1763
chinyeungli 13e8e88
Refactor code and add tests #1763
chinyeungli cb623c1
Implement "update_package_license_from_resource_if_missing" function …
chinyeungli b937cff
Only work with "maven" package type #1763
chinyeungli 0bbe979
Update docstring description #1763
chinyeungli 2b3c9bb
Add test for the "scan_maven_package" pipeline #1763
chinyeungli 9a11dd8
Fix the Incomplete URL substring sanitization #1763
chinyeungli f303430
Add "maven.google.com" as a maven_hosts and accept .aar file #1763
chinyeungli ab71751
Reorganize code structure and code enhancement #1763
chinyeungli 5579db8
Update build-in-pipelines.rst #1763
chinyeungli 9ed4c2d
Merge remote-tracking branch 'origin/main' into 1763_pipeline_for_maven
chinyeungli 12728e4
Added steps to handle D2D in the maven pipeline #1763
chinyeungli 3242b16
Update "exclude_from_diff" list #1763
chinyeungli 97a109b
Ruff reformatted #1763
chinyeungli 9992d15
Update class description #1763
chinyeungli 4f1b4d3
Error handling if pom url not found #1763
chinyeungli 6fffa2c
Prevent duplicate CodebaseRelation entries #1763
chinyeungli ee673f1
Update minecode pipelines with stable release v0.1.1 (#2013)
AyanSinhaMahapatra 257560c
Fix typos in docstrings for pathmap.py (#1985)
pranavkeerti66-hue 3124455
Store the whole vulnerability data from cdx to local models (#2007)
tdruez 9e2b2bc
Add project vulnerability list view (#2018)
tdruez c602e9d
feat: Improve class file mapping #2021
chinyeungli 3bd3112
Update index.rst with new structure
DennisClark 395a906
Fix index page issues
AyanSinhaMahapatra 6b03c2d
Update README.rst to improve structure
DennisClark aeb6f3c
Update to scancode-toolkit v32.5.0 (#2000)
AyanSinhaMahapatra 1602d6a
exclude github folder from deploy resource
Aryan-SINGH-GIT 5406ece
removing unnecessary git stat
Aryan-SINGH-GIT 96535de
reformat file
Aryan-SINGH-GIT d09aa27
adding github in deployed_resource_path_exclusions
Aryan-SINGH-GIT e0d7391
chore: upgrade django to version 6.x (#2052)
tdruez bdc592c
fix: upgrade python in the rtd config file (#2053)
tdruez 7d23536
Match MacOS binary symbols to Go TypeScript symbols (#2056)
AyanSinhaMahapatra 706dbe5
Bump android_inspector to v0.2.0 (#2069)
keshav-space 0adfb1e
chore: automatically closes low-quality and AI slop PRs (#2072)
tdruez c9be588
chore: upgrade RQ, Redis, and more to their latest version (#2073)
tdruez 3387a47
chore: upgrade Django and Redis to their latest version
tdruez ac1331a
fix: failing test by updating the expectation fixture (#2084)
tdruez 621d890
chore: upgrade Django to latest version (#2085)
tdruez 2216bf2
feat: remove the chown service in compose file (#2086)
tdruez e541b86
fix: URL-encode programming language filter values in resource list (…
uttam282005 492b693
fix: rename "Grammar" optional step group to "Antlr" in d2d pipeline …
Monal-Reddy 1f1e74c
feat!: replace plain-text DRF token with PBKDF2-hashed API token (#2087)
tdruez beb1807
chore: set explicit workflow permissions and pin down actions (#2090)
tdruez 13ab091
chore: bump version to v37.0.0 for release (#2091)
tdruez edf44da
fix: add the checkout step to pypi release workflow
tdruez 44371f6
chore: refine gh workflows for security and consistency
tdruez 40e45a5
feat: display scio and toolkit versions in place of django version (#…
tdruez cf25704
fix missing space in scan_max_file_size help text (#2097)
rishabh23rohil e13b78f
feat: add tests for chunked and get_purls utilities (#2100)
rishabh23rohil 85ea093
feat: display layers information (created_by, comment) in tree view (…
tdruez 0cd684f
feat: enhance the global HTML structure (#2103)
tdruez e1a47cd
feat: remove the need for context processor and improve base template…
tdruez 827b545
chore: remove the PR quality workflow
tdruez c8f0707
chore: upgrade the scancode-action to latest version (pinned deps) (#…
tdruez 925cd15
fix: XSS and duplicate file detection in file upload UI (#2129)
tdruez b5298f7
fix: incomplete URL sanitization for Slack webhook detection (#2130)
tdruez 6e04d0e
chore: correct typo in `pipes/clamav` (#2121)
OmAnand857 5110b1f
feat: is_safe_url to mitigate SSRF in URL requests (#2131)
tdruez 9582fb6
feat: add search to resource tree (#2114)
aayushkdev 500fdcf
feat: enhance tree search rendering and implementation (#2133)
tdruez b10d157
feat: use uv and uv.lock for reproducible builds in Docker image (#2134)
tdruez 5ed4a74
fix: add support for sqlite in the apitoken data migration (#2138)
tdruez 56db41d
feat!: convert Dockerfile to multi-stage build (#2139)
tdruez 47a761f
chore: bump version to v37.1.0 for release (#2140)
tdruez 62dc6a1
chore: upgrade scancode-action to docker base v0.1 release (#2141)
tdruez d120a2d
feat: add "base" Docker build stage (#2142)
tdruez 5c63602
fix: fallback to license_declared when loading SPDX SBOM (#2144)
tdruez 21722fb
feat!: Switch development workflow from local venv to Docker Compose …
tdruez 7c6c343
fix: relax validation for non-HTTP URLs (#2147)
tdruez dc151c4
fix: load the .env in the Docker dev compose (#2149)
tdruez eb1a3ab
chore: upgrade Django and cryptography to latest version (#2150)
tdruez fedf5ad
fix: replace the hardcoded /var/www/html by named volume (#2160)
tdruez d3f82a2
chore: bump minecode-pipelines version to 1.0.0 (#2170)
JonoYang 39ac66f
chore: update minecode-pipelines version to 1.0.1 (#2171)
JonoYang d34bda9
Install Java and jadx in Dockerfile #1812 (#2174)
JonoYang c3a0797
chore: upgrade dependencies (#2173)
tdruez 4e7401c
chore: bump version to v37.2.0 for release (#2175)
tdruez 16ffc08
fix: add setup-buildx step to enable GHA cache support (#2176)
tdruez cfde610
fix: add latest-full tag and OCI annotations to Docker publish workflow
tdruez 13d7d2a
Change the text files #1763
chinyeungli 6de4ecf
Merge branch 'main' into 1763_pipeline_for_maven
chinyeungli 2af1275
Removed "def dependency_count(self):" that's removed in current main …
chinyeungli edcdc35
chore: refine dev compose file
tdruez f9c8f68
feat: render the compliance alert value as a colored label (#2186)
tdruez 8f6fcb8
feat: add pipeline availability check with disabled state in UI (#2188)
tdruez 2abcc07
feat: replace django-taggit with a plain Project.labels JSONField (#2…
tdruez 263275e
feat: move scanpipe settings to local settings.py with lazy resolutio…
tdruez 60e9098
fix: ClamAV scan crash on codebase root directory (#2190)
tdruez 5c1f7f4
chore: upgrade vulnerable dependencies (#2191)
tdruez e26b3ae
Refactor code structure for Maven pipeline #1763
chinyeungli c77c169
Add more comments #1763
chinyeungli 52eaf65
Add the missing import settings #1763
chinyeungli 8514b77
Merge branch 'main' into 1763_pipeline_for_maven
chinyeungli 4066b85
Add the missing import settings #1763
chinyeungli a7cadde
Update tests #1763
chinyeungli 9516d88
Skip test_scanpipe_scan_maven_package_single_file on macos #1763
chinyeungli f018823
Better code organization #1763
chinyeungli 8e83344
Remove non-used code #1763
chinyeungli 131f84b
Restore license notice and code enhancement #1763
chinyeungli f3401de
Apply suggestion from @tdruez
chinyeungli 96b9334
Code enhancement based on the PR review comments #1763
chinyeungli 2631c80
Better code structure and added tests #1763
chinyeungli 91120ae
Clean up code and improve formatting #1763
chinyeungli f2a7e3b
Update scanpipe/pipes/maven.py
chinyeungli f479350
Re-order the pipelines order #1763
chinyeungli 90c71dd
Refactor Maven pipeline for error handling and performance #1763
chinyeungli 62a29ac
Fix code/doc formatting #1763
chinyeungli 895b1ce
Use PurePosixPath for file checking #1763
chinyeungli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # http://nexb.com and https://github.com/aboutcode-org/scancode.io | ||
| # The ScanCode.io software is licensed under the Apache License version 2.0. | ||
| # Data generated with ScanCode.io is provided as-is without warranties. | ||
| # ScanCode is a trademark of nexB Inc. | ||
| # | ||
| # You may not use this software except in compliance with the License. | ||
| # You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software distributed | ||
| # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
| # CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations under the License. | ||
| # | ||
| # Data Generated with ScanCode.io is provided on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
| # OR CONDITIONS OF ANY KIND, either express or implied. No content created from | ||
| # ScanCode.io should be considered or used as legal advice. Consult an Attorney | ||
| # for any legal advice. | ||
| # | ||
| # ScanCode.io is a free software code scanning tool from nexB Inc. and others. | ||
| # Visit https://github.com/aboutcode-org/scancode.io for support and download. | ||
|
|
||
| from scanpipe.pipelines.deploy_to_develop import DeployToDevelop | ||
| from scanpipe.pipelines.scan_single_package import ScanSinglePackage | ||
| from scanpipe.pipes import d2d_config | ||
| from scanpipe.pipes.maven import check_input_and_return_purl | ||
| from scanpipe.pipes.maven import fetch_and_scan_remote_pom | ||
| from scanpipe.pipes.maven import fetch_inputs | ||
| from scanpipe.pipes.maven import update_package_license_from_resource_if_missing | ||
|
|
||
|
|
||
| class ScanMavenPackage(ScanSinglePackage, DeployToDevelop): | ||
| """ | ||
| Scan a single Maven package and perform a deployment to development | ||
| relation scan. | ||
|
|
||
| This pipeline takes a Maven PURL as input, fetches the binary and | ||
| source archives (if they exist), and then performs scans for package | ||
| metadata, declared dependencies, licenses, license clarity scores, and | ||
| copyrights. It also performs a deployment to development relation scan | ||
| if both the source and binary archives are available. | ||
|
|
||
| The output is a summary of the scan results in JSON format. | ||
| """ | ||
|
|
||
| download_inputs = False | ||
|
|
||
| @classmethod | ||
| def steps(cls): | ||
| return ( | ||
| cls.check_input_and_return_purl, | ||
| cls.fetch_inputs, | ||
| cls.d2d_check, | ||
| cls.collect_input_info, | ||
| cls.extract_input, | ||
| cls.extract_archives, | ||
| cls.maven_d2d_steps, | ||
| cls.run_scan, | ||
| cls.fetch_and_scan_remote_pom, | ||
| cls.load_inventory_from_toolkit_scan, | ||
| cls.update_package_license_from_resource_if_missing, | ||
| cls.make_summary_from_scan_results, | ||
| ) | ||
|
|
||
| def check_input_and_return_purl(self): | ||
| """Validate the input is a PURL string and return the PURL object.""" | ||
| self.purl = check_input_and_return_purl(self.project) | ||
|
|
||
| def fetch_inputs(self): | ||
| """Fetch the binary and source of the given PURL.""" | ||
| from_file, to_file = fetch_inputs(self.purl) | ||
| # The pipeline will call self.extract_inputs_to_codebase_directory() | ||
| # from deploy_to_develop.py, which expects both self.from_files and | ||
| # self.to_files to be of list type. | ||
| self.from_files = [from_file] if from_file else [] | ||
| self.to_files = [to_file] if to_file else [] | ||
|
|
||
| def d2d_check(self): | ||
| """ | ||
| Enable the deployment to development relation scan if both from | ||
| and to files are present. | ||
| """ | ||
| self.d2d_enabled = False | ||
| if self.from_files and self.to_files: | ||
| self.d2d_enabled = True | ||
|
|
||
| def collect_input_info(self): | ||
| """Collect information about the input.""" | ||
| if not self.d2d_enabled: | ||
| if self.from_files: | ||
| self.input_path = self.from_files[0] | ||
| else: | ||
| self.input_path = self.to_files[0] | ||
| self.collect_input_information() | ||
|
|
||
| def extract_input(self): | ||
| """Extract the input to the codebase directory.""" | ||
| if not self.d2d_enabled: | ||
| self.extract_input_to_codebase_directory() | ||
| else: | ||
| self.extract_inputs_to_codebase_directory() | ||
|
|
||
| def maven_d2d_steps(self): | ||
|
tdruez marked this conversation as resolved.
|
||
| """Run deployment to development relation scan steps for Maven projects.""" | ||
| if self.d2d_enabled: | ||
| self.collect_and_create_codebase_resources() | ||
| self.fingerprint_codebase_directories() | ||
| self.flag_empty_files() | ||
| self.flag_whitespace_files() | ||
| self.flag_ignored_resources() | ||
| self.d2d_ecosystem_config() | ||
| self.map_about_files() | ||
| self.map_checksum() | ||
| self.match_archives_to_purldb() | ||
| self.d2d_java() | ||
| self.d2d_scala() | ||
| self.d2d_kotlin() | ||
| self.d2d_javascript() | ||
| self.d2d_process() | ||
|
|
||
| def d2d_ecosystem_config(self): | ||
| options = ["Java", "Kotlin", "Scala", "JavaScript"] | ||
| d2d_config.load_ecosystem_config(pipeline=self, options=options) | ||
|
|
||
| def d2d_java(self): | ||
| self.find_java_packages() | ||
| self.map_java_to_class() | ||
| self.map_jar_to_java_source() | ||
|
|
||
| def d2d_scala(self): | ||
| self.find_scala_packages() | ||
| self.map_scala_to_class() | ||
| self.map_jar_to_scala_source() | ||
|
|
||
| def d2d_kotlin(self): | ||
| self.find_kotlin_packages() | ||
| self.map_kotlin_to_class() | ||
| self.map_jar_to_kotlin_source() | ||
|
|
||
| def d2d_javascript(self): | ||
| self.map_javascript() | ||
| self.map_javascript_symbols() | ||
| self.map_javascript_strings() | ||
|
|
||
| def d2d_process(self): | ||
| self.get_symbols_from_binaries() | ||
| self.map_elf() | ||
| self.match_directories_to_purldb() | ||
| self.match_resources_to_purldb() | ||
| self.map_javascript_post_purldb_match() | ||
| self.map_javascript_path() | ||
| self.map_javascript_colocation() | ||
| self.map_path() | ||
| self.flag_mapped_resources_archives_and_ignored_directories() | ||
| self.perform_house_keeping_tasks() | ||
| self.match_purldb_resources_post_process() | ||
| self.remove_packages_without_resources() | ||
| self.scan_ignored_to_files() | ||
| self.scan_unmapped_to_files() | ||
| self.scan_mapped_from_for_files() | ||
| self.collect_and_create_license_detections() | ||
| self.flag_deployed_from_resources_with_missing_license() | ||
| self.create_local_files_packages() | ||
|
|
||
| def fetch_and_scan_remote_pom(self): | ||
| """Fetch and scan remote POM files.""" | ||
| scanning_errors = fetch_and_scan_remote_pom( | ||
| self.purl, self.scan_output_location | ||
| ) | ||
| for scanning_error in scanning_errors: | ||
| for resource_reference, errors in scanning_error.items(): | ||
| self.project.add_error( | ||
| description="\n".join(errors), | ||
| model=self.pipeline_name, | ||
| details={ | ||
| "resource_path": resource_reference.removeprefix("codebase/") | ||
| }, | ||
| ) | ||
|
|
||
| def update_package_license_from_resource_if_missing(self): | ||
| """ | ||
| Fill in missing package licenses using licenses detected in | ||
| their resources. | ||
| """ | ||
| update_package_license_from_resource_if_missing(self.project) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.