Skip to content

Commit

Permalink
Merge pull request #6 from fossid-ab/id_assist
Browse files Browse the repository at this point in the history
Add optional params no_advanced_match_scoring and match_filtering_threshold
  • Loading branch information
cristianp-fossid authored Jul 10, 2024
2 parents 5ca3184 + f8935f6 commit 42e27a8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ disable=consider-using-f-string,
broad-exception-caught,
unspecified-encoding,
logging-fstring-interpolation,
logging-format-interpolation
logging-format-interpolation,
too-many-arguments

# Specify a configuration file.
#rcfile=
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ usage: workbench-agent.py [-h] --api_url API_URL --api_user API_USER
[--delta_only] [--reuse_identifications]
[--identification_reuse_type {any,only_me,specific_project,specific_scan}]
[--specific_code SPECIFIC_CODE]
[--no_advanced_match_scoring]
[--match_filtering_threshold MATCH_FILTERING_THRESHOLD]
[--chunked_upload]
[--scan_number_of_tries SCAN_NUMBER_OF_TRIES]
[--scan_wait_time SCAN_WAIT_TIME] --path PATH
Expand Down Expand Up @@ -178,6 +180,11 @@ optional arguments:
--specific_code SPECIFIC_CODE
The scan code used when creating the scan in Workbench. It can be based on some env var,
for example: ${BUILD_NUMBER}
--no_advanced_match_scoring
Disable advanced match scoring which by default is enabled.
--match_filtering_threshold MATCH_FILTERING_THRESHOLD
Minimum length, in characters, of the snippet to be considered valid after applying intelligent match
Set to 0 to disable intelligent match filtering for current scan.
--target_path TARGET_PATH
The path on the Workbench server where the code to be scanned is stored.
No upload is done in this scenario.
Expand Down
25 changes: 23 additions & 2 deletions workbench-agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ def run_scan(
reuse_identification: bool,
identification_reuse_type: str = None,
specific_code: str = None,
advanced_match_scoring: bool = True,
match_filtering_threshold: int = -1
):
"""
Expand All @@ -810,7 +812,9 @@ def run_scan(
reuse_identification (bool): Reuse previous identifications
identification_reuse_type (str): Possible values: any,only_me,specific_project,specific_scan
specific_code (str): Fill only when reuse type: specific_project or specific_scan
advanced_match_scoring (bool): If true, scan will run with advanced match scoring.
match_filtering_threshold (int): Minimum length (in characters) of snippet to be considered
valid after applying intelligent match filtering.
Returns:
"""
Expand Down Expand Up @@ -843,8 +847,11 @@ def run_scan(
auto_identification_resolve_pending_ids
),
"delta_only": int(delta_only),
"advanced_match_scoring": int(advanced_match_scoring),
},
}
if match_filtering_threshold > -1:
payload["data"]['match_filtering_threshold'] = match_filtering_threshold
if reuse_identification:
data = payload["data"]
data["reuse_identification"] = "1"
Expand Down Expand Up @@ -1151,7 +1158,19 @@ def non_empty_string(s):
type=str,
required=False,
)

optional.add_argument(
'--no_advanced_match_scoring',
help='Disable advanced match scoring which by default is enabled.',
dest='advanced_match_scoring',
action='store_false',
)
optional.add_argument(
"--match_filtering_threshold",
help="Minimum length, in characters, of the snippet to be considered valid after applying match filtering.\n"
"Set to 0 to disable intelligent match filtering for current scan.",
type=int,
default=-1,
)
optional.add_argument(
"--target_path",
help="The path on the Workbench server where the code to be scanned is stored.\n"
Expand Down Expand Up @@ -1420,6 +1439,8 @@ def main():
params.reuse_identifications,
params.identification_reuse_type,
params.specific_code,
params.advanced_match_scoring,
params.match_filtering_threshold
)
# Check if finished based on: scan_number_of_tries X scan_wait_time until throwing an error
workbench.wait_for_scan_to_finish(
Expand Down

0 comments on commit 42e27a8

Please sign in to comment.