Esempio n. 1
0
def cli():
    parser = argparse.ArgumentParser(
        description="Generate a dataset from proxy traffic")
    parser.add_argument('fout', help="output file to store results")

    # Add global options
    cli_db(parser)
    cli_log_level(parser)

    #
    # Parse cli
    #
    args = parser.parse_args()

    #
    # Build config from CLI args
    #
    running_config = RunningConfig(args.__dict__)

    #
    # Setup log for console
    #
    setup_console_log(logger, log_level=running_config.log_level)

    #
    # Setup db
    #
    setup_db_engine(running_config.db_connection_string)

    #
    # Launch
    #
    run(running_config)
Esempio n. 2
0
def cli():
    parser = argparse.ArgumentParser(
        description="API-Check manage commands"
    )

    # Add global options
    cli_db(parser)
    cli_log_level(parser)

    subparsers = parser.add_subparsers(dest="option",
                                       description="Valid options",
                                       help='Actions')

    #
    # Add subparsers
    #
    cli_apis(subparsers)
    cli_create_plugin(subparsers)
    cli_definitions(subparsers)

    #
    # Parse cli
    #
    args = parser.parse_args()

    #
    # Choice correct config object
    try:
        config, run_function = ACTION_MAP[args.option]
    except KeyError as e:
        print(f"[!] Invalid importer: '{e}'")
        exit(1)

    #
    # Delete 'importer_type' key. Used only for aux keyword in the Cli.
    #
    cli_config = args.__dict__
    del cli_config["option"]

    #
    # Build config
    #
    running_config = config(**cli_config)

    #
    # Setup log for console
    #
    setup_console_log(logger, log_level=args.log_level)

    #
    # Setup db
    #
    if ":" in running_config.db_connection_string:
        setup_db_engine(running_config.db_connection_string)

    #
    # Launch API Check
    #
    run_function(running_config)
Esempio n. 3
0
def cli():
    parser = argparse.ArgumentParser(
        description="Send API definition to proxy")

    # Add global options
    cli_db(parser)
    cli_log_level(parser)

    parser.add_argument('api_id', help="api definition ID to send")
    parser.add_argument('--source',
                        dest="source",
                        default="definition",
                        choices=RunningConfig.OPERATION_MODES,
                        help="origin of data. Default: definition")
    parser.add_argument('--proxy',
                        dest="proxy_destination",
                        required=True,
                        help="proxy destination. IP:PORT")

    c = parser.add_argument_group("API Definitions")
    c.add_argument("--api-url",
                   dest="api_url",
                   help="api base url used for requests")

    #
    # Parse cli
    #
    args = parser.parse_args()

    #
    # Build config from CLI args
    #
    running_config = RunningConfig(args.__dict__)

    #
    # Setup log for console
    #
    setup_console_log(logger, log_level=running_config.log_level)

    #
    # Setup db
    #
    setup_db_engine(running_config.db_connection_string)

    #
    # Launch
    #
    run(running_config)
Esempio n. 4
0
def cli():
    parser = argparse.ArgumentParser(
        description="Launches a local proxy to track API requests")

    # Add global options
    cli_db(parser)
    cli_log_level(parser)

    parser.add_argument('domain',
                        metavar="domain",
                        nargs="*",
                        help="Domain to inspect using proxy")
    parser.add_argument('-l',
                        '--listen',
                        dest="listen_addr",
                        default="127.0.0.1",
                        help="proxy listen address (default: 127.0.0.1)")
    parser.add_argument('-p',
                        '--port',
                        dest="listen_port",
                        help="proxy listen port (default: 8080)")
    parser.add_argument('--store-assets',
                        action="store_true",
                        default=False,
                        dest="store_assets_content",
                        help="store assets content in database")
    parser.add_argument('-a',
                        '--learning_mode',
                        action="store_true",
                        default=False,
                        dest="learning_mode",
                        help="enable learning mode to introspect the "
                        "REST API")
    parser.add_argument('--promiscuous',
                        action="store_true",
                        default=False,
                        dest="promiscuous",
                        help="save all requests that passthroughs "
                        "the proxy")

    #
    # Parse cli
    #
    args = parser.parse_args()

    #
    # Build config from CLI args
    #
    running_config = RunningConfig(**args.__dict__)

    #
    # Setup log for console
    #
    setup_console_log(logger, log_level=running_config.log_level)

    #
    # Setup db
    #
    setup_db_engine(running_config.db_connection_string)

    #
    # Launch
    #
    run(running_config)