コード例 #1
0
 def configure_environment(self, data):
     headers = {
         'accept': 'application/json',
         'Content-Type': 'application/json'
     }
     post_data = json_to_str(data)
     return self._request_http_post(path="configuration/configure_env",
                                    headers=headers,
                                    data=post_data)
コード例 #2
0
 def set_gw_sdk_endpoints(self, data):
     headers = {
         'accept': 'application/json',
         'Content-Type': 'application/json'
     }
     post_data = json_to_str(data)
     return self._request_http_post(
         path="configuration/configure_gw_sdk_endpoints",
         headers=headers,
         data=post_data)
コード例 #3
0
ファイル: Event_Rule.py プロジェクト: owasp-sbot/OSBot-AWS
 def send_event(self, event_data):
     if type(event_data) is not str:
         event_data = json_to_str(event_data, pretty=False)
     event = {
         'Time': date_time_now(),
         'Source': self.event_source,
         "DetailType": "myTestType",
         'Detail': event_data
     }
     return self.events.events_put([event])
コード例 #4
0
ファイル: Cloud_Watch.py プロジェクト: owasp-sbot/OSBot-AWS
 def metric_widget_image(self,
                         metric_widget,
                         save_to_disk=True,
                         path_image_file=None):
     if type(metric_widget) is not str:
         metric_widget = json_to_str(metric_widget)
     response = self.client().get_metric_widget_image(
         MetricWidget=metric_widget)
     png_bytes = response.get('MetricWidgetImage')
     if save_to_disk:
         return file_create_from_bytes(bytes=png_bytes,
                                       extension=".png",
                                       path=path_image_file)
     return png_bytes
コード例 #5
0
    def test_get_valid_endpoints(self):

        test_ips = ["52.51.76.83", "34.245.236.153", "34.242.222.23"]

        endpoints = []
        for ip in test_ips:
            endpoints.append({'IP': ip, "Port": "8080"})

        valid_endpoints = {'Endpoints': endpoints}
        endpoint_string = json_to_str(valid_endpoints)
        result = self.configure_env.get_valid_endpoints(endpoint_string)
        responsive_endpoints = json_parse(result).get('Endpoints')
        assert len(responsive_endpoints) > 0
        for enpoint in responsive_endpoints:
            assert enpoint in endpoints
コード例 #6
0
ファイル: SQS.py プロジェクト: owasp-sbot/OSBot-AWS
    def permission_add_for_service(self, queue_url, source_arn, service, resource, action='sqs:SendMessage', effect='Allow'):
        policy_statement_id = f'{action}-rule-{source_arn}'
        statement  = { 'Action'   : action,
                       'Condition': {'ArnEquals': {'aws:SourceArn':source_arn}},
                       'Effect'   : effect,
                       'Principal': {'Service': service},
                       'Resource' : resource,
                       'Sid'      : policy_statement_id }

        policy = self.policy(queue_url=queue_url)
        if policy == {}:
            policy = {'Statement' : []           ,
                      'Version'   : '2008-10-17' }
        policy.get('Statement').append(statement)
        policy_str = json_to_str(policy)
        self.queue_attributes_update(queue_url=queue_url, new_attributes={"Policy": policy_str})
        return self.policy(queue_url=queue_url)
コード例 #7
0
ファイル: IAM.py プロジェクト: owasp-sbot/OSBot-AWS
 def role_assume_policy_update(self, policy_document):
     if type(policy_document) is not str:
         policy_document = json_to_str(policy_document)
     return self.client().update_assume_role_policy(
         RoleName=self.role_name, PolicyDocument=policy_document)