Skip to content

Commit

Permalink
Better error handling (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Prabhu Subramanian authored Jul 8, 2020
1 parent c715214 commit eeb4507
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions scan
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,17 @@ def scan(type_list, src, reports_dir, convert, scan_mode, repo_context):
else:
# Look for any _scan function in this module for execution
try:
dfn = getattr(sys.modules[__name__], "%s_scan" % type_str)
dfn = getattr(
sys.modules[__name__], "%s_scan" % type_str, None
)
if dfn:
pool.apply_async(
dfn, (src, reports_dir, convert, repo_context)
)
else:
x_scan(type_str)
except Exception as e:
LOG.error(e)
LOG.debug(e)
LOG.warning(
"Scan using the {} plugin did not produce valid result".format(
type_str
Expand All @@ -197,6 +201,16 @@ def scan(type_list, src, reports_dir, convert, scan_mode, repo_context):
pool.join()


def x_scan(type_str):
"""Default placeholder scan method for missing scanners
"""
LOG.info(
"Is there any open-source scanner for {}? Kindly send us a PR 👍".format(
type_str
)
)


def python_scan(src, reports_dir, convert, repo_context):
"""
Method to initiate scan of the python codebase
Expand Down

0 comments on commit eeb4507

Please sign in to comment.