Skip to content

Commit

Permalink
revert last commit - deprecated endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiller authored and tmiller committed May 19, 2022
1 parent 7b79d72 commit 4cfc00e
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 79 deletions.
3 changes: 1 addition & 2 deletions cloudpassage/configuration_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class ConfigurationPolicy(HaloEndpoint):

object_name = "policy"
objects_name = "policies"
# default_endpoint_version = 1 # deprecated
default_endpoint_version = 2
default_endpoint_version = 1

def endpoint(self):
"""Return the endpoint for API requests."""
Expand Down
3 changes: 1 addition & 2 deletions cloudpassage/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class Container(HaloEndpoint):

object_name = "container"
objects_name = "containers"
# default_endpoint_version = 1 # deprecated
default_endpoint_version = 2
default_endpoint_version = 1

def endpoint(self):
"""Return endpoint for API requests."""
Expand Down
15 changes: 6 additions & 9 deletions cloudpassage/container_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ class ContainerEvent(HaloEndpoint):
endpoint_version (int): Endpoint version override.
"""

# object_name = "container_event" # deprecated
# objects_name = "container_events" # deprecated
# default_endpoint_version = 1 # deprecated
object_name = "event"
objects_name = "events"
default_endpoint_version = 2

def endpoint(self, container_id):
object_name = "container_event"
objects_name = "container_events"
default_endpoint_version = 1

def endpoint(self):
"""Return endpoint for API requests."""
return "/v{}/containers/{}/{}".format(self.endpoint_version, container_id, self.objects_name)
return "/v{}/{}".format(self.endpoint_version, self.objects_name)

def pagination_key(self):
"""Return the pagination key for parsing paged results."""
Expand Down
10 changes: 3 additions & 7 deletions cloudpassage/container_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ class ContainerImage(HaloEndpoint):
endpoint_version (int): Endpoint version override.
"""

# object_name = "image" # deprecated
# objects_name = "images" # deprecated
# default_endpoint_version = 1 # deprecated

object_name = "container_image"
objects_name = "container_images"
default_endpoint_version = 2
object_name = "image"
objects_name = "images"
default_endpoint_version = 1

def endpoint(self):
"""Return endpoint for API requests."""
Expand Down
15 changes: 6 additions & 9 deletions cloudpassage/container_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ class ContainerPackage(HaloEndpoint):
endpoint_version (int): Endpoint version override.
"""

# object_name = "software_package" # deprecated
# objects_name = "software_packages" # deprecated
# default_endpoint_version = 1 # deprecated
object_name = "package"
objects_name = "packages"
default_endpoint_version = 2

def endpoint(self, image_id):
object_name = "software_package"
objects_name = "software_packages"
default_endpoint_version = 1

def endpoint(self):
"""Return endpoint for API requests."""
return "/v{}/container_images/{}/{}".format(self.endpoint_version, image_id, self.objects_name)
return "/v{}/{}".format(self.endpoint_version, self.objects_name)

def pagination_key(self):
"""Return the pagination key for parsing paged results."""
Expand Down
15 changes: 6 additions & 9 deletions cloudpassage/container_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,18 @@ class ContainerProcess(HaloEndpoint):
endpoint_version (int): Endpoint version override.
"""

# object_name = "process" # deprecated
# objects_name = "container_processes" # deprecated
# list_objects_name = "processes" # deprecated
# default_endpoint_version = 1 # deprecated
object_name = "process"
objects_name = "processes"
default_endpoint_version = 2
objects_name = "container_processes"
list_objects_name = "processes"
default_endpoint_version = 1

def endpoint(self, container_id):
def endpoint(self):
"""Return endpoint for API requests."""
return "/v{}/containers/{}/{}".format(self.endpoint_version, container_id, self.objects_name)
return "/v{}/{}".format(self.endpoint_version, self.objects_name)

def pagination_key(self):
"""Return the pagination key for parsing paged results."""
return self.objects_name
return self.list_objects_name

def object_key(self):
"""Return the object key for parsing detailed results."""
Expand Down
18 changes: 6 additions & 12 deletions cloudpassage/cve_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ class CveExceptions(HaloEndpoint):
endpoint_version (int): Endpoint version override.
"""

# object_name = "cve_exception" # deprecated
# objects_name = "cve_exceptions" # deprecated
# default_endpoint_version = 1 # deprecated
object_name = "exception"
objects_name = "exceptions"
default_endpoint_version = 2
object_name = "cve_exception"
objects_name = "cve_exceptions"
default_endpoint_version = 1

def endpoint(self):
"""Return the endpoint for API requests."""
Expand Down Expand Up @@ -114,12 +111,9 @@ class CveException(HaloEndpoint):
"""

# object_name = "cve_exception" # deprecated
# objects_name = "cve_exceptions" # deprecated
# default_endpoint_version = 1 # deprecated
object_name = "exception"
objects_name = "exceptions"
default_endpoint_version = 2
object_name = "cve_exception"
objects_name = "cve_exceptions"
default_endpoint_version = 1

def endpoint(self):
"""Return the endpoint for API requests."""
Expand Down
14 changes: 5 additions & 9 deletions cloudpassage/fim_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ class FimPolicy(HaloEndpoint):
endpoint_version (int): Endpoint version override.
"""

# object_name = "fim_policy" # deprecated
# objects_name = "fim_policies" # deprecated
# default_endpoint_version = 1 # deprecated
object_name = "policy"
objects_name = "policies"
default_endpoint_version = 2
object_name = "fim_policy"
objects_name = "fim_policies"
default_endpoint_version = 1

def endpoint(self):
"""Return endpoint for API requests."""
Expand Down Expand Up @@ -54,12 +51,11 @@ class FimBaseline(HaloEndpoint):
"""
object_name = "baseline"
objects_name = "baselines"
# default_endpoint_version = 1 # deprecated
default_endpoint_version = 2
default_endpoint_version = 1

def endpoint(self, policy_id):
"""Return endpoint for API requests."""
return "/v{}/policies/{}/{}".format(self.endpoint_version,
return "/v{}/fim_policies/{}/{}".format(self.endpoint_version,
policy_id, self.objects_name)

def list_all(self, fim_policy_id):
Expand Down
3 changes: 1 addition & 2 deletions cloudpassage/halo_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
class HaloEndpoint(object):
"""Base class inherited by other specific HaloEndpoint classes."""

# default_endpoint_version = 1 # deprecated
default_endpoint_version = 2
default_endpoint_version = 1

def __init__(self, session, **kwargs):
self.session = session
Expand Down
3 changes: 1 addition & 2 deletions cloudpassage/image_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class ImageRegistry(HaloEndpoint):

object_name = "registry"
objects_name = "registries"
# default_endpoint_version = 1 # deprecated
default_endpoint_version = 2
default_endpoint_version = 1

def endpoint(self):
"""Return endpoint for API requests."""
Expand Down
3 changes: 1 addition & 2 deletions cloudpassage/image_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class ImageRepo(HaloEndpoint):

object_name = "repository"
objects_name = "repositories"
# default_endpoint_version = 1 # deprecated
default_endpoint_version = 2
default_endpoint_version = 1

def endpoint(self):
"""Return endpoint for API requests."""
Expand Down
3 changes: 1 addition & 2 deletions cloudpassage/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class Issue(HaloEndpoint):
"""
object_name = "issue"
objects_name = "issues"
# default_endpoint_version = 1 # deprecated
default_endpoint_version = 3
default_endpoint_version = 1

def endpoint(self):
"""Return endpoint for API requests."""
Expand Down
9 changes: 3 additions & 6 deletions cloudpassage/lids_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ class LidsPolicy(HaloEndpoint):
endpoint_version (int): Endpoint version override.
"""

# object_name = "lids_policy" # deprecated
# objects_name = "lids_policies" # deprecated
# default_endpoint_version = 1 # deprecated
object_name = "policy"
objects_name = "policies"
default_endpoint_version = 2
object_name = "lids_policy"
objects_name = "lids_policies"
default_endpoint_version = 1

def endpoint(self):
"""Return endpoint for API requests."""
Expand Down
2 changes: 1 addition & 1 deletion cloudpassage/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TimeSeries(object):
will return, effecting a clean exit.
"""

allowed_urls = ["/v1/events", "/v1/scans", "/v3/issues"]
allowed_urls = ["/v1/events", "/v1/scans", "/v1/issues"]

def __init__(self, session, start_time, start_url, item_key, params={}):
self.url = start_url
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_integration_http_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def test_get_paginated_badkey(self):
def test_get_next_page_path(self):
body = {u'count': 6961,
u'issues': [],
u'pagination': {u'next': u'https://api.cloudpassage.com/v3/issues?critical=true&page=2&per_page=100&sort_by=last_seen_at.desc&state=active%2Cinactive%2Cmissing%2Cretired&status=active%2Cresolved'}} # NOQA
u'pagination': {u'next': u'https://api.cloudpassage.com/v1/issues?critical=true&page=2&per_page=100&sort_by=last_seen_at.desc&state=active%2Cinactive%2Cmissing%2Cretired&status=active%2Cresolved'}} # NOQA
result = cloudpassage.HttpHelper.get_next_page_path(body)
assert result == "/v3/issues?critical=true&page=2&per_page=100&sort_by=last_seen_at.desc&state=active%2Cinactive%2Cmissing%2Cretired&status=active%2Cresolved" # NOQA
assert result == "/v1/issues?critical=true&page=2&per_page=100&sort_by=last_seen_at.desc&state=active%2Cinactive%2Cmissing%2Cretired&status=active%2Cresolved" # NOQA


class TestIntegrationPost:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_integration_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_time_series_iter_issues_many_pages(self):
session = self.get_halo_session()
start_time = utility.datetime_to_8601((datetime.now() -
timedelta(30)))
start_url = "/v3/issues"
start_url = "/v1/issues"
item_key = "issues"
streamer = cloudpassage.TimeSeries(session, start_time,
start_url, item_key)
Expand Down
2 changes: 1 addition & 1 deletion tests/policies/cis-benchmark-for-centos-7-v1.policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "This policy helps you to verify the security of servers that are hardened according to the consensus guidance put forth by the Center for Internet Security (CIS) document \"CIS CentOS Linux 7 Benchmark v1.1.0 04-02-2015\". The policy detects deviations in your servers' configurations from the Benchmark specifications. You may wish to explicitly harden your servers by following the Benchmark suggestions before scanning with this policy. \r\n\r\n Several rules in this policy are by default deactivated, for one of the following reasons: \r\n - A rule includes configuration checks that Halo does not perform at this time. \r\n - A rule includes configuration checks that look for dangerous settings that, if set, would prevent remote access to the server. \r\n\r\n You can activate those rules if and when your server configurations make them appropriate, or when new Halo checks become available.",
"platform": "linux",
"template": true,
"url": "https://portal.cloudpassage.com/v2/policies/f7459be01c5711e5b8dd05741f3c0727",
"url": "https://portal.cloudpassage.com/v1/policies/f7459be01c5711e5b8dd05741f3c0727",
"id": "f7459be01c5711e5b8dd05741f3c0727",
"used_by": [],
"rules": [
Expand Down
2 changes: 1 addition & 1 deletion tests/policies/core-system-centos-v1-1.lids.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"template": true,
"retired": false,
"used_by": [],
"url": "https://portal.cloudpassage.com/v2/policies/cec1b0dc695f11e5941a13ee8436bb31",
"url": "https://portal.cloudpassage.com/v1/lids_policies/cec1b0dc695f11e5941a13ee8436bb31",
"rules": [
{
"name": "User ID (UID) was modified",
Expand Down

0 comments on commit 4cfc00e

Please sign in to comment.