Skip to content

Commit 40f5f0e

Browse files
committed
Try to fix bug in vulnerability dependency
Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent 01f294c commit 40f5f0e

6 files changed

Lines changed: 31 additions & 26 deletions

File tree

scanpipe/pipelines/analyze_symbols_reachability.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ def steps(cls):
7272
def get_vulnerabilities_patches(self):
7373
"""Get unique patch for all vulnerabilities."""
7474
patches = {}
75-
for vulnerability in self.project.package_vulnerabilities:
75+
for vulnerability in (
76+
self.project.package_vulnerabilities
77+
+ self.project.dependency_vulnerabilities
78+
):
7679
advisory_uid = vulnerability.get("advisory_uid")
7780
for patch in vulnerability.get("fixed_in_patches", []):
7881
vcs_url = patch.get("vcs_url")

scanpipe/pipes/reachability.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -479,13 +479,6 @@ def match(self, patch_symbols_metadata):
479479
for metadata in patch_symbols_metadata.values():
480480
qualified_name = metadata["qualified_name"]
481481
fingerprint = metadata["fingerprint"]
482-
483-
short_name = (
484-
qualified_name.rsplit(self.separator, 1)[-1]
485-
if self.separator in qualified_name
486-
else qualified_name
487-
)
488-
489482
defined = qualified_name in self.definitions
490483
fingerprint_hit = bool(fingerprint and fingerprint in self.fingerprints)
491484

@@ -494,9 +487,7 @@ def match(self, patch_symbols_metadata):
494487
or qualified_name in self.imports.values()
495488
)
496489

497-
callers = set()
498-
callers.update(self.callers_of.get(short_name, set()))
499-
callers.update(self.callers_of.get(qualified_name, set()))
490+
callers = set(self.callers_of.get(qualified_name, set()))
500491
called = bool(callers)
501492

502493
if not (defined or fingerprint_hit or called or imported):

scanpipe/tests/data/reachability/python/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def build_file_path(filename):
3232
return "Error: File not found"
3333

3434

35+
def handle_request(req):
36+
return serve_report(req)
37+
38+
3539
def unrelated_top_level_function():
3640
"""Test AST node boundaries."""
3741
return "I am just here to add AST complexity."

scanpipe/tests/data/reachability/python/fixed-app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def build_file_path(filename):
3838
return "Error: File not found"
3939

4040

41+
def handle_request(req):
42+
return serve_report(req)
43+
44+
4145
def unrelated_top_level_function():
4246
"""Test AST node boundaries."""
4347
return "I am just here to add AST complexity."

scanpipe/tests/data/reachability/python/vuln-app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def build_file_path(filename):
3232
return "Error: File not found"
3333

3434

35+
def handle_request(req):
36+
return serve_report(req)
37+
38+
3539
def unrelated_top_level_function():
3640
"""Test AST node boundaries."""
3741
return "I am just here to add AST complexity."

scanpipe/tests/pipes/test_symbols_reachability.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -407,22 +407,22 @@ def test_python_get_symbol_reachability_results(
407407
"reachable_from": [],
408408
},
409409
{
410-
"called": True,
410+
"called": False,
411411
"defined": True,
412412
"imported": False,
413413
"fingerprint": "762e4f7d03b1bf4359c3ca364"
414414
"e558140239913bfabcc5aa77156460c2eb0a355",
415415
"symbol_name": "serve_report.build_file_path",
416-
"reachable_from": ["serve_report"],
416+
"reachable_from": [],
417417
},
418418
{
419-
"called": False,
419+
"called": True,
420420
"defined": True,
421421
"imported": False,
422422
"fingerprint": "d7675efb263896da2a3c0067951183"
423423
"3553907e7e6ea619115a6dfc8625c3457e",
424424
"symbol_name": "serve_report",
425-
"reachable_from": [],
425+
"reachable_from": ["handle_request"],
426426
},
427427
],
428428
"fixed_symbols": [
@@ -474,40 +474,39 @@ def test_java_get_symbol_reachability_results(
474474
"advisory_uids": [],
475475
"evidence": [
476476
{
477+
"symbol_name": "App",
477478
"called": False,
478479
"defined": True,
479480
"imported": False,
480481
"fingerprint": None,
481-
"symbol_name": "App",
482482
"reachable_from": [],
483483
},
484484
{
485+
"symbol_name": "App.serveReport",
485486
"called": False,
486487
"defined": True,
487488
"imported": False,
488-
"fingerprint": "b161e24e9575b655e84c7f249709e5d4d0"
489-
"a1e6f19e2c4baa421a6cc996fda154",
490-
"symbol_name": "App.serveReport",
491-
"reachable_from": [],
489+
"fingerprint": "b161e24e9575b655e84c7f249709e5d4d0a1e6f19e2c4baa421a6cc996fda154",
490+
"reachable_from": []
492491
},
493492
{
494-
"called": True,
493+
"symbol_name": "App.buildFilePath",
494+
"called": False,
495495
"defined": True,
496496
"imported": False,
497497
"fingerprint": None,
498-
"symbol_name": "App.buildFilePath",
499-
"reachable_from": ["App.serveReport"],
500-
},
498+
"reachable_from": []
499+
}
501500
],
502501
"fixed_symbols": [
503502
"App",
504503
"App.buildFilePath",
505-
"App.serveReport",
504+
"App.serveReport"
506505
],
507506
"vulnerable_symbols": [
508507
"App",
509508
"App.buildFilePath",
510-
"App.serveReport",
509+
"App.serveReport"
511510
],
512511
"reachability_status": ReachabilityStatus.REACHABLE.value,
513512
}

0 commit comments

Comments
 (0)