Exemple #1
0
def get_nessus_status():
    try:
        server_status_url = "/server/status"
        response = requests.get(base_url() + server_status_url, verify=False)
        status = json.loads(response.text)
        return status

    except (ConnectionError, requests.exceptions.ConnectionError) as e:
        print("connection error")
        return {"status": "loading", "progress": "0"}
Exemple #2
0
def nessus_ready():
    try:
        server_status_url = "/server/status"
        response = requests.get(base_url() + server_status_url, verify=False)
        status = json.loads(response.text)
        return status["status"] == "ready"

    except (ConnectionError, requests.exceptions.ConnectionError):
        print("connection error")
        return False
Exemple #3
0
def put_keys():
    keys_url = "/session/keys"
    keys_response = requests.put(base_url() + keys_url,
                                 headers=get_token(),
                                 verify=False)
    keys = json.loads(keys_response.text)
    access_key = keys["accessKey"]
    secret_key = keys["secretKey"]
    put_param(access_key, type="access_key")
    put_param(secret_key, type="secret_key")
def nessus_ready():
    try:
        server_status_url = "/server/status"
        response = requests.get(base_url() + server_status_url, verify=False)
        status = json.loads(response.text)
        return status["status"] == "ready"

    except (ConnectionError, requests.exceptions.ConnectionError):
        print("connection error")
        return False
    except json.JSONDecodeError as error:
        print("JSON parse failed: " + str(error))
        print("response: " + response.text)
        return False
Exemple #5
0
def main():
    ec2_timeout = time.time() + 60 * 10
    while True:
        if get_status_checks():
            break
        elif time.time() > ec2_timeout:
            print("Timed out, failed to connect to ec2.")
            break
        else:
            time.sleep(60)

    nessus_timeout = time.time() + 60 * 60
    while True:
        put_param(base_url(), type="public_base_url")
        status = get_nessus_status()
        if status["status"] == "ready":
            put_keys()
            break
        elif time.time() > nessus_timeout:
            print("Timed out, check nessus is installed correctly.")
            break
        elif status["status"] != "ready":
            print(f"Nessus is still loading.\n Progess: {status['progress']}")
            time.sleep(300)
Exemple #6
0
def get_fqdn():
    tf_fqdn = os.environ.get("fqdn")
    if tf_fqdn:
        return f"https://{tf_fqdn}"
    else:
        return base_url()
def test_base_url():
    result = n.base_url()
    assert "https://" in result