Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
86d4dcc
feat: create pipeline for symbol reachability and add a test
ziadhany Apr 22, 2026
87bde58
Add more test for reachability and remove redundant code
ziadhany Jun 5, 2026
1a32c0f
Fix the format bugs and refactor the code
ziadhany Jun 10, 2026
a6bec7a
Fix a bug in the import-catching logic and add a test.
ziadhany Jun 11, 2026
680e3b6
Add an unidiff dependency to pyproject.toml file
ziadhany Jun 16, 2026
0c96148
Simplify the pipeline logic for imports and direct calls
ziadhany Jun 23, 2026
e7a7056
Add support for vulnerablecode reachability option
ziadhany Jun 24, 2026
605a292
Fix the tests and improve patch extraction performance
ziadhany Jun 24, 2026
0a99680
Fix formatting and linting errors.
ziadhany Jun 25, 2026
c752810
Refactor and simplify reachability pipeline
ziadhany Jun 26, 2026
5ddf24f
Add support for getting constant symbols
ziadhany Jul 1, 2026
decfbf2
Remove dead code and fix the test
ziadhany Jul 1, 2026
4599f13
Add unidiff to uv.lock
ziadhany Jul 1, 2026
1d5cb02
Add support constant to resource analyzer
ziadhany Jul 1, 2026
5b8d57e
Fix formating error in CI
ziadhany Jul 1, 2026
ee31acb
Add a test for constants, extract_imports,collect_imports
ziadhany Jul 2, 2026
60f7963
Remove dependency and copy only the required file
ziadhany Jul 15, 2026
c222fed
Update pipeline/functions name
ziadhany Jul 22, 2026
0fd6f07
Fix CI files format
ziadhany Jul 23, 2026
192deab
Fix a typo in patch.py.ABOUT file
ziadhany Jul 23, 2026
c8b573e
Skip the test for macOS
ziadhany Jul 23, 2026
08c81ec
Allow reachability by default, for vulnerabilities pipeline
ziadhany Jul 29, 2026
43bd799
Update the code to difflib instead of unidiff library
ziadhany Jul 29, 2026
20b5a86
Add missing docs
ziadhany Aug 7, 2026
626baab
Fix a typo in build_symbol_metadata function signature
ziadhany Aug 7, 2026
c380406
Add a test for java
ziadhany Aug 10, 2026
fd011f6
Simplify the pipeline test
ziadhany Aug 11, 2026
8f7958d
Generate advisory reachability report ( last step in the pipeline )
ziadhany Aug 13, 2026
7f5aa02
Fix Formating and typo in test
ziadhany Aug 14, 2026
78e2423
Remove type hints
ziadhany Aug 14, 2026
1558768
Remove type hints for symbols.py
ziadhany Aug 14, 2026
2b774c3
Remove type hints for symbols.py
ziadhany Aug 14, 2026
7f196b9
Fix a typo in docs
ziadhany Aug 14, 2026
e7941d9
Fix a typo in error message
ziadhany Aug 14, 2026
e7f9da5
Update the pipeline to clone repo once and collect_patch_symbols for …
ziadhany Aug 18, 2026
bcde743
Try to fix bug in vulnerability dependency
ziadhany Aug 20, 2026
027ab5e
Update the pipeline to have a test for resource_patch_matcher
ziadhany Aug 24, 2026
60ab0e2
Add more test and make sure it returns not if there is no match
ziadhany Aug 24, 2026
bde0ec5
Move Business logic to be in the pipes reachability file
ziadhany Aug 24, 2026
2dfce28
fix is_reachable to be by default NOT_REACHABLE
ziadhany Aug 25, 2026
35c3dca
Fix a bug related to vulnerability dependency reachability pipeline
ziadhany Aug 27, 2026
2b17307
Update function docs
ziadhany Aug 28, 2026
ca03409
Fix a typo
ziadhany Aug 28, 2026
df56dd2
Fix format error
ziadhany Aug 28, 2026
cb83ff3
Add a LoopProgress to the most time-consuming functions
ziadhany Aug 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,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.analyze_symbols_reachability:SymbolReachability"
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"
Expand Down
103 changes: 103 additions & 0 deletions scanpipe/pipelines/analyze_symbols_reachability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 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 import Pipeline
from scanpipe.pipes import reachability
from scanpipe.pipes.symbols import TS_QUERIES


class SymbolReachability(Pipeline):
Comment thread
ziadhany marked this conversation as resolved.
"""
Determine the reachability of vulnerabilities identified in the project.

Note: You must run `find_vulnerabilities` pipeline before running this pipeline.

For every patch the git repository is cloned and extract the vulnerable and fixed
symbols from the patch commit. These symbols are then matched against
the project's codebase resources to determine if the vulnerable code
is actually present and reachable.

The analysis checks if vulnerable symbols are defined, imported, called,
or exactly match a code within the project files. The results, including
tool_details and a reachability status (yes, unknown, or no), are stored
in the `extra_data` of the matching resources under the `symbols_reachability` key.

Finally, a summary report is generated for each vulnerability
advisory and saved as a JSON output file.
"""

download_inputs = False
is_addon = True
results_url = "/project/{slug}/resources/?extra_data=symbol_reachability"

@classmethod
def steps(cls):
return (
cls.get_vulnerabilities_patches,
cls.collect_resource_index,
cls.collect_patch_symbols,
cls.collect_and_match_resources,
cls.generate_advisory_reachability_report,
)

def get_vulnerabilities_patches(self):
"""Get unique patch for all vulnerabilities."""
self.patches = reachability.get_vulnerabilities_patches(
package_vulnerabilities=self.project.package_vulnerabilities,
dependency_vulnerabilities=self.project.dependency_vulnerabilities,
)

def collect_resource_index(self):
"""Collect resources symbols for each resource"""
self.candidate_resources = self.project.codebaseresources.files().filter(
Comment thread
ziadhany marked this conversation as resolved.
is_binary=False,
is_archive=False,
is_media=False,
programming_language__in=TS_QUERIES.keys(),
)
self.resource_indexes = reachability.collect_resource_index(
candidate_resources=self.candidate_resources, logger=self.log
)

def collect_patch_symbols(self):
"""Collect patch symbols for all related commits."""
self.patch_symbols = reachability.collect_patch_symbols(
patches=self.patches, logger=self.log
)

def collect_and_match_resources(self):
"""Match resource symbols against patch symbols."""
reachability.match_patches_to_resources(
patches=self.patches,
patch_symbols=self.patch_symbols,
resource_indexes=self.resource_indexes,
candidate_resources=self.candidate_resources,
logger=self.log,
)

def generate_advisory_reachability_report(self):
"""Generate a reachability report summarizing status by advisory."""
reachability.generate_advisory_reachability_report(
project=self.project,
patches=self.patches,
candidate_resources=self.candidate_resources,
)
Loading
Loading