Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy support to sysdig client stack #236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sdcclient/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class _SdcCommon(object):
'''
lasterr = None

def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None):
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None, proxies=None):
self.token = os.environ.get("SDC_TOKEN", token)
self.hdrs = self.__get_headers(custom_headers)
self.url = os.environ.get("SDC_URL", sdc_url).rstrip('/')
Expand All @@ -56,6 +56,8 @@ def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=T
self.http = requests.Session()
self.http.mount("https://", adapter)
self.http.mount("http://", adapter)
if proxies:
self.http.proxies = proxies

def __get_headers(self, custom_headers):
headers = {
Expand Down
4 changes: 2 additions & 2 deletions sdcclient/_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

class SdMonitorClient(DashboardsClientV3, EventsClientV2, _SdcCommon):

def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None):
super(SdMonitorClient, self).__init__(token, sdc_url, ssl_verify, custom_headers)
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None, proxies=None):
super(SdMonitorClient, self).__init__(token, sdc_url, ssl_verify, custom_headers, proxies)
self.product = "SDC"

def get_alerts(self) -> Union[Tuple[bool, str], Tuple[bool, Any]]:
Expand Down
4 changes: 2 additions & 2 deletions sdcclient/_monitor_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class SdMonitorClientV1(SdMonitorClient):
Handles dashboards version 1 (ie. up to February 2019). For later Sysdig Monitor versions, please use :class:`~SdMonitorClient` instead.
'''

def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True):
super(SdMonitorClientV1, self).__init__(token, sdc_url, ssl_verify)
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, proxies=None):
super(SdMonitorClientV1, self).__init__(token, sdc_url, ssl_verify, proxies)
self._dashboards_api_version = 'v1'
self._dashboards_api_endpoint = '/ui/dashboards'
self._default_dashboards_api_endpoint = '/api/defaultDashboards'
Expand Down
4 changes: 2 additions & 2 deletions sdcclient/_scanning.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@


class SdScanningClient(ScanningAlertsClientV1, _SdcCommon):
def __init__(self, token="", sdc_url='https://secure.sysdig.com', ssl_verify=True, custom_headers=None):
super(SdScanningClient, self).__init__(token, sdc_url, ssl_verify, custom_headers)
def __init__(self, token="", sdc_url='https://secure.sysdig.com', ssl_verify=True, custom_headers=None, proxies=None):
super(SdScanningClient, self).__init__(token, sdc_url, ssl_verify, custom_headers, proxies)
self.product = "SDS"

def add_image(self, image, force=False, dockerfile=None, annotations={}, autosubscribe=True):
Expand Down
4 changes: 2 additions & 2 deletions sdcclient/_secure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class SdSecureClient(FalcoRulesFilesClientOld,
PolicyEventsClientOld,
PolicyClientV2,
_SdcCommon):
def __init__(self, token="", sdc_url='https://secure.sysdig.com', ssl_verify=True, custom_headers=None):
super(SdSecureClient, self).__init__(token, sdc_url, ssl_verify, custom_headers)
def __init__(self, token="", sdc_url='https://secure.sysdig.com', ssl_verify=True, custom_headers=None, proxies=None):
super(SdSecureClient, self).__init__(token, sdc_url, ssl_verify, custom_headers, proxies)

self.product = "SDS"
self._policy_v2 = None
Expand Down
4 changes: 2 additions & 2 deletions sdcclient/monitor/_dashboards_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


class DashboardsClientV2(_SdcCommon):
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None):
super(DashboardsClientV2, self).__init__(token, sdc_url, ssl_verify, custom_headers)
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None, proxies=None):
super(DashboardsClientV2, self).__init__(token, sdc_url, ssl_verify, custom_headers, proxies)
self.product = "SDC"
self._dashboards_api_version = 'v2'
self._dashboards_api_endpoint = '/api/{}/dashboards'.format(self._dashboards_api_version)
Expand Down
4 changes: 2 additions & 2 deletions sdcclient/monitor/_dashboards_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


class DashboardsClientV3(_SdcCommon):
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None):
super(DashboardsClientV3, self).__init__(token, sdc_url, ssl_verify, custom_headers)
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None, proxies=None):
super(DashboardsClientV3, self).__init__(token, sdc_url, ssl_verify, custom_headers, proxies)
self.product = "SDC"
self._dashboards_api_version = 'v3'
self._dashboards_api_endpoint = '/api/{}/dashboards'.format(self._dashboards_api_version)
Expand Down
4 changes: 2 additions & 2 deletions sdcclient/monitor/_events_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@


class EventsClientV1(_SdcCommon):
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None):
super().__init__(token, sdc_url, ssl_verify, custom_headers)
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None, proxies=None):
super().__init__(token, sdc_url, ssl_verify, custom_headers, proxies)
self.product = "SDC"

def get_events(self, from_s=None, to_s=None, last_s=None):
Expand Down
4 changes: 2 additions & 2 deletions sdcclient/monitor/_events_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


class EventsClientV2(_SdcCommon):
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None):
super().__init__(token, sdc_url, ssl_verify, custom_headers)
def __init__(self, token="", sdc_url='https://app.sysdigcloud.com', ssl_verify=True, custom_headers=None, proxies=None):
super().__init__(token, sdc_url, ssl_verify, custom_headers, proxies)
self.product = "SDC"

def get_events(self, name=None, category=None, direction='before', status=None, limit=100, pivot=None, from_s=None,
Expand Down