-
-
Notifications
You must be signed in to change notification settings - Fork 194
Create pipeline for symbol reachability #2151
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
Open
ziadhany
wants to merge
16
commits into
aboutcode-org:main
Choose a base branch
from
ziadhany:add-symbol-reachability
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,402
−1,673
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7006d76
feat: create pipeline for symbol reachability and add a test
ziadhany ccb4740
Add more test for reachability and remove redundant code
ziadhany bd24cf5
Fix the format bugs and refactor the code
ziadhany d7a2a02
Fix a bug in the import-catching logic and add a test.
ziadhany da28c3d
Add an unidiff dependency to pyproject.toml file
ziadhany 2015531
Add unidiff to package dependencies to parse diff text
ziadhany adf6db3
Simplify the pipeline logic for imports and direct calls
ziadhany 5c5cfbe
Add support for vulnerablecode reachability option
ziadhany 9db5fd7
Fix the tests and improve patch extraction performance
ziadhany cfd4626
Fix formatting and linting errors.
ziadhany 1f5dd81
Refactor and simplify reachability pipeline
ziadhany dfbb4db
Add support for getting constant symbols
ziadhany 55bdbc7
Remove dead code and fix the test
ziadhany 2b14b3f
Add unidiff to uv.lock
ziadhany e06e19b
Add support constant to resource analyzer
ziadhany 6768aa8
Fix formating error in CI
ziadhany 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,7 @@ dependencies = [ | |
| "urllib3==2.7.0", | ||
| "idna==3.16", | ||
| "GitPython==3.1.50", | ||
| "unidiff==0.7.5", | ||
| "lxml==6.1.1", | ||
| "certifi==2026.5.20", | ||
| # Profiling | ||
|
|
@@ -142,6 +143,7 @@ run = "scancodeio:combined_run" | |
| analyze_docker_image = "scanpipe.pipelines.analyze_docker:Docker" | ||
| analyze_root_filesystem_or_vm_image = "scanpipe.pipelines.analyze_root_filesystem:RootFS" | ||
| analyze_windows_docker_image = "scanpipe.pipelines.analyze_docker_windows:DockerWindows" | ||
| analyze_symbols_reachability = "scanpipe.pipelines.collect_symbols_reachability:SymbolReachability" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. analyze_symbols_reachability / collect_symbols_reachability |
||
| benchmark_purls = "scanpipe.pipelines.benchmark_purls:BenchmarkPurls" | ||
| collect_strings_gettext = "scanpipe.pipelines.collect_strings_gettext:CollectStringsGettext" | ||
| collect_symbols_ctags = "scanpipe.pipelines.collect_symbols_ctags:CollectSymbolsCtags" | ||
|
|
||
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,33 @@ | ||
| # | ||
| # Copyright (c) nexB Inc. and others. All rights reserved. | ||
| # VulnerableCode is a trademark of nexB Inc. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # See http://www.apache.org/licenses/LICENSE-2.0 for the license text. | ||
| # See https://github.com/aboutcode-org/vulnerablecode for support or download. | ||
| # See https://aboutcode.org for more information about nexB OSS projects. | ||
| # | ||
|
|
||
| from scanpipe.pipelines import Pipeline | ||
| from scanpipe.pipes import reachability | ||
|
|
||
|
|
||
| class SymbolReachability(Pipeline): | ||
| """Patch reachability analysis for given vulnerability patches.""" | ||
|
|
||
| download_inputs = False | ||
| is_addon = True | ||
| results_url = "/project/{slug}/resources/?extra_data=symbol_reachability" | ||
|
|
||
| @classmethod | ||
| def steps(cls): | ||
| return (cls.analyze_and_store_symbol_reachability,) | ||
|
|
||
| def analyze_and_store_symbol_reachability(self): | ||
| """ | ||
| Perform symbol-level reachability analysis for each patch. This step compares | ||
| the AST of patched/vulnerable files against the codebase resources. | ||
| Results are stored directly in the 'extra_data' of each CodebaseResource. | ||
| """ | ||
| reachability.collect_and_store_symbol_reachability_results( | ||
| project=self.project, logger=self.log | ||
| ) |
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.
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.
Is this absolutely needed? No built-in solutions available?
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.
The unidiff library doesn't have any dependencies, and we only need a single file from it:
patch.py.I'll include it in this PR files and add
.ABOUTand.LICENSEfiles for it.