From 4cfc00e5772ba7605310c132c94f7d75dbc14e9f Mon Sep 17 00:00:00 2001 From: tmiller Date: Wed, 18 May 2022 20:04:58 -0400 Subject: [PATCH] revert last commit - deprecated endpoint --- cloudpassage/configuration_policy.py | 3 +-- cloudpassage/container.py | 3 +-- cloudpassage/container_event.py | 15 ++++++--------- cloudpassage/container_image.py | 10 +++------- cloudpassage/container_package.py | 15 ++++++--------- cloudpassage/container_process.py | 15 ++++++--------- cloudpassage/cve_exception.py | 18 ++++++------------ cloudpassage/fim_policy.py | 14 +++++--------- cloudpassage/halo_endpoint.py | 3 +-- cloudpassage/image_registry.py | 3 +-- cloudpassage/image_repo.py | 3 +-- cloudpassage/issue.py | 3 +-- cloudpassage/lids_policy.py | 9 +++------ cloudpassage/time_series.py | 2 +- .../test_integration_http_helper.py | 4 ++-- .../test_integration_time_series.py | 2 +- .../cis-benchmark-for-centos-7-v1.policy.json | 2 +- .../policies/core-system-centos-v1-1.lids.json | 2 +- 18 files changed, 47 insertions(+), 79 deletions(-) diff --git a/cloudpassage/configuration_policy.py b/cloudpassage/configuration_policy.py index ab83597..070f9d3 100644 --- a/cloudpassage/configuration_policy.py +++ b/cloudpassage/configuration_policy.py @@ -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.""" diff --git a/cloudpassage/container.py b/cloudpassage/container.py index 1abd113..ab8d481 100644 --- a/cloudpassage/container.py +++ b/cloudpassage/container.py @@ -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.""" diff --git a/cloudpassage/container_event.py b/cloudpassage/container_event.py index 27450fd..0aaedac 100644 --- a/cloudpassage/container_event.py +++ b/cloudpassage/container_event.py @@ -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.""" diff --git a/cloudpassage/container_image.py b/cloudpassage/container_image.py index 245a708..321330b 100644 --- a/cloudpassage/container_image.py +++ b/cloudpassage/container_image.py @@ -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.""" diff --git a/cloudpassage/container_package.py b/cloudpassage/container_package.py index 145269e..b449eb9 100644 --- a/cloudpassage/container_package.py +++ b/cloudpassage/container_package.py @@ -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.""" diff --git a/cloudpassage/container_process.py b/cloudpassage/container_process.py index affc232..66ca4db 100644 --- a/cloudpassage/container_process.py +++ b/cloudpassage/container_process.py @@ -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.""" diff --git a/cloudpassage/cve_exception.py b/cloudpassage/cve_exception.py index 547b61c..790a5be 100644 --- a/cloudpassage/cve_exception.py +++ b/cloudpassage/cve_exception.py @@ -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.""" @@ -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.""" diff --git a/cloudpassage/fim_policy.py b/cloudpassage/fim_policy.py index cace54d..8cf70aa 100644 --- a/cloudpassage/fim_policy.py +++ b/cloudpassage/fim_policy.py @@ -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.""" @@ -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): diff --git a/cloudpassage/halo_endpoint.py b/cloudpassage/halo_endpoint.py index b56848f..49813ce 100644 --- a/cloudpassage/halo_endpoint.py +++ b/cloudpassage/halo_endpoint.py @@ -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 diff --git a/cloudpassage/image_registry.py b/cloudpassage/image_registry.py index f5c444d..64e9d1d 100644 --- a/cloudpassage/image_registry.py +++ b/cloudpassage/image_registry.py @@ -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.""" diff --git a/cloudpassage/image_repo.py b/cloudpassage/image_repo.py index d7d06d1..07b6116 100644 --- a/cloudpassage/image_repo.py +++ b/cloudpassage/image_repo.py @@ -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.""" diff --git a/cloudpassage/issue.py b/cloudpassage/issue.py index 527f01c..fd34b7f 100644 --- a/cloudpassage/issue.py +++ b/cloudpassage/issue.py @@ -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.""" diff --git a/cloudpassage/lids_policy.py b/cloudpassage/lids_policy.py index 2151de3..953e3ef 100644 --- a/cloudpassage/lids_policy.py +++ b/cloudpassage/lids_policy.py @@ -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.""" diff --git a/cloudpassage/time_series.py b/cloudpassage/time_series.py index bf55c7f..cf29bdc 100644 --- a/cloudpassage/time_series.py +++ b/cloudpassage/time_series.py @@ -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 diff --git a/tests/integration/test_integration_http_helper.py b/tests/integration/test_integration_http_helper.py index ec30c42..423941e 100644 --- a/tests/integration/test_integration_http_helper.py +++ b/tests/integration/test_integration_http_helper.py @@ -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: diff --git a/tests/integration/test_integration_time_series.py b/tests/integration/test_integration_time_series.py index f9d33bb..26b343d 100644 --- a/tests/integration/test_integration_time_series.py +++ b/tests/integration/test_integration_time_series.py @@ -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) diff --git a/tests/policies/cis-benchmark-for-centos-7-v1.policy.json b/tests/policies/cis-benchmark-for-centos-7-v1.policy.json index 2a91243..0df683b 100644 --- a/tests/policies/cis-benchmark-for-centos-7-v1.policy.json +++ b/tests/policies/cis-benchmark-for-centos-7-v1.policy.json @@ -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": [ diff --git a/tests/policies/core-system-centos-v1-1.lids.json b/tests/policies/core-system-centos-v1-1.lids.json index 3a46ed0..0b0a69e 100644 --- a/tests/policies/core-system-centos-v1-1.lids.json +++ b/tests/policies/core-system-centos-v1-1.lids.json @@ -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",