示例#1
0
def cli(**kwargs):
    req_body = kwargs

    # Transformations
    req_body['tcp_ports'] = to_port_map(req_body.pop('tcp_port'))
    req_body['excluded_tcp_ports'] = {
        "tcp":
        {str(x[0]): {
            "name": ""
        }
         for x in req_body['excluded_port'] or ()}
    }
    req_body['default_port_map'] = True

    # POST collected data to the appropriate endpoint in leapp-daemon
    resp = post(CMD, req_body)

    # Pretty-print response
    resp_body = resp.json()
    json_pprint = json.dumps(resp_body,
                             sort_keys=True,
                             indent=4,
                             separators=(',', ': '))
    click.secho('Response:\n{0}\n'.format(json_pprint),
                bold=True,
                fg='green' if resp.status_code == 200 else 'red')
示例#2
0
def cli(**kwargs):
    # Simple POST
    resp = post(CMD, kwargs)
    data = resp.json()
    click.echo('Response: {0}\n'.format(data['json']['target_host']))

    # Simple GET
    resp1 = get(CMD, kwargs)
    data = resp1.json()
    click.echo('Response: {0}\n'.format(data))
示例#3
0
def cli(**kwargs):
    req_body = kwargs

    # POST collected data to the appropriate endpoint in leapp-daemon
    resp = post(CMD, req_body)

    # Pretty-print response
    resp_body = resp.json()
    json_pprint = json.dumps(resp_body, sort_keys=True, indent=4, separators=(',', ': '))
    click.secho(
        'Response:\n{0}\n'.format(json_pprint),
        bold=True,
        fg='green' if resp.status_code == 200 else 'red'
    )
示例#4
0
def cli(**kwargs):
    req_body = kwargs

    display_html = req_body.pop('html')
    output_file = req_body.pop('out')

    # POST collected data to the appropriate endpoint in leapp-daemon
    resp = post(CMD, req_body)
    resp_body = resp.json()

    if display_html:
        resp_html = post(HTML_OUT_CMD, resp_body['data'])
        resp_html_body = resp_html.json()
        try:
            content = resp_html_body['data']['html_output'][0]['value']
        except LookupError:
            content = ""
    else:
        content = json.dumps(resp_body)

    if output_file:
        output_file.write(content)
    else:
        print(content)