mythx_cli package

Submodules

mythx_cli.cli module

The main runtime of the MythX CLI.

class mythx_cli.cli.APIErrorCatcherGroup(name=None, commands=None, **attrs)[source]

Bases: click.core.Group

A custom click group to catch API-related errors.

This custom Group implementation catches MythXAPIError exceptions, which get raised when the API returns a non-200 status code. It is used to notify the user about the error that happened instead of triggering an uncaught exception traceback.

It is given to the main CLI entrypoint and propagated to all subcommands.

mythx_cli.util module

mythx_cli.util.index_by_filename(issues_list: List[Tuple[mythx_models.response.detected_issues.DetectedIssuesResponse, Optional[mythx_models.response.analysis_input.AnalysisInputResponse]]])[source]

Index the given report/input responses by filename.

This will return a simplified, unified representation of the report/input payloads returned by the MythX API. It is a mapping from filename to an iterable of issue objects, which contain the report UUID, SWC ID, SWC title, short and long description, severity, as well as the issue’s line location in the source code.

This representation is meant to be passed on to the respective formatter, which them visualizes the data.

Parameters:issues_list – A list of two-tuples containing report and input responses
Returns:A simplified mapping indexing issues by their file path
mythx_cli.util.update_context(context: dict, context_key: str, config: dict, config_key: str, default: Any = None)[source]

Update the click context based on a configuration dict.

If the specified key is set in the configuration dict, it will be added/overwrite the respective other key in the click context.

Parameters:
  • context – The click context dict to set/overwrite
  • context_key – The key in the click context to overwrite
  • config – The config to read additional data from
  • config_key – The config key to overwrite with
  • default – The default value to use if all lookups fail
mythx_cli.util.write_or_print(ctx, data: str, mode='a+') → None[source]

Depending on the context, write the given content to stdout or a given file.

Parameters:
  • ctx – Click context holding group-level parameters
  • data – The data to print or write to a file
  • mode – The mode to open the file in (if file output enabled)
Returns:

Module contents

Top-level package for MythX CLI.