-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ipeleg
committed
Nov 1, 2023
1 parent
9f0b650
commit 5fdc982
Showing
3 changed files
with
69 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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,54 @@ | ||
from __future__ import annotations | ||
|
||
from checkov.sast.report import SastData, SastReport | ||
from checkov.sast.consts import SastLanguages | ||
from checkov.sast.prisma_models.report import Function, Repositories, File, Package | ||
|
||
|
||
def _create_sast_reports_for_test_get_sast_reachability_report_with_one_report() -> list[SastReport]: | ||
# we don't care about the init's params, except for the sast-language | ||
report1 = SastReport('', {}, SastLanguages.JAVASCRIPT) | ||
report1.sast_reachability = { | ||
'repo_1': Repositories(files={ | ||
'/index.js': File(packages={ | ||
'axios': Package(alias='ax', functions=[ | ||
Function(name='trim', alias='hopa', line_number=4, code_block='hopa()') | ||
]), | ||
'lodash': Package(alias='', functions=[ | ||
Function(name='template', alias='', line_number=1, code_block='template()'), | ||
Function(name='toNumber', alias='', line_number=4, code_block='hopa()') | ||
]) | ||
}), | ||
'/main.js': File(packages={ | ||
'axios': Package(alias='ax', functions=[ | ||
Function(name='trim', alias='hi', line_number=4, code_block='hi()') | ||
]) | ||
}) | ||
}) | ||
} | ||
return [report1] | ||
|
||
|
||
def test_get_sast_reachability_report_with_one_report(): | ||
scan_reports: list[SastReport] = _create_sast_reports_for_test_get_sast_reachability_report_with_one_report() | ||
sast_reachability_report = SastData.get_sast_reachability_report(scan_reports) | ||
assert sast_reachability_report == { | ||
'reachability': { | ||
SastLanguages.JAVASCRIPT: { | ||
'/index.js': File(packages={ | ||
'axios': Package(alias='ax', functions=[ | ||
Function(name='trim', alias='hopa', line_number=4, code_block='hopa()') | ||
]), | ||
'lodash': Package(alias='', functions=[ | ||
Function(name='template', alias='', line_number=1, code_block='template()'), | ||
Function(name='toNumber', alias='', line_number=4, code_block='hopa()') | ||
]) | ||
}), | ||
'/main.js': File(packages={ | ||
'axios': Package(alias='ax', functions=[ | ||
Function(name='trim', alias='hi', line_number=4, code_block='hi()') | ||
]) | ||
}) | ||
} | ||
} | ||
} |