rapid7 / nexpose-client-python

DEPRECATED : Rapid7 Nexpose API client library written in Python
https://www.rapid7.com/
BSD 3-Clause "New" or "Revised" License
25 stars 20 forks source link

Add support for ESO API #45

Open fruechel opened 6 years ago

fruechel commented 6 years ago

This mirrors the changes in https://github.com/rapid7/nexpose-client/pull/309 but limited to discovery connections.

Description

Implement support for ESO API for discovery connections. Based on @hwilson-r7's changes in https://github.com/rapid7/nexpose-client/pull/309

Looking for feedback on whether this is the way you'd like this implemented or if changes are needed.

Motivation and Context

This API is new and there is no support for it yet. We're looking at using it.

How Has This Been Tested?

I created a test script that runs through most functionality. The following things are known issues:

The following things have been tested and work:

A recent update does also seem to cause 401s unless X-Requested-With: XMLHttpRequest HTTP headers are sent. This seems like a weird bug introduced in 6.4.66 so I didn't include it in the PR, assuming it'll go away once fixed there.

No unit tests have been written.

This is the function used to test things:

    print(client.GetEsoServices())
    print(client.GetEsoConfigurationType('amazon-web-services'))
    configs = client.GetEsoServiceConfigurations('amazon-web-services')
    for config in configs:
        print(config.name, config.id)
    configs = {c.name.lower(): c for c in configs}
    config = client.GetEsoServiceConfigurationByName('amazon-web-services', config.name)
    print(config.name, config.id)
    config = client.GetEsoServiceConfiguration(config.id)
    print(config.name, config.id)
    print(client.TestEsoServiceConfiguration(config))
    print(client.PreviewEsoServiceConfiguration(config))
    config.add_region('Asia Pacific (Sydney)')
    config_id = client.SaveEsoServiceConfiguration(config)
    assert config_id == config.id
    assert config.id
    print(config.name, config.id)
    """
    client.DeleteEsoServiceConfiguration(config)
    print('Deleted config {}'.format(config.id))
    """

Types of changes

Checklist:

fruechel commented 6 years ago

I did just realise that the update to 6.4.66 actually pushed out some changes regarding the API. I'm looking at the /integration-options endpoint now, trying to implement it in a user-friendly way. That is, like the UI does, you shouldn't have to manually handle all of these details.