Ejemplo n.º 1
0
 def post(self, policy_profile_name):
     body = request.json
     body['profile_name'] = policy_profile_name
     base_query.create_item(models.PolicyProfileRule, **body)
     # get number of rules in the profile
     items = base_query.get_all_items(models.PolicyProfileRule, profile_name=policy_profile_name)
     base_query.update_item(models.PolicyProfile, {'name': policy_profile_name}, rule_count=items['count'])
Ejemplo n.º 2
0
 def post(self, profile_name):
     rule_set_list = request.json['rule_set_list']
     replace = request.json.get('replace', False)
     if replace:
         # delete existing rules on the profile
         base_query.delete_item(models.WafProfileRuleSet, profile_name=profile_name)
     for rule_set_name in rule_set_list:
         data = {'profile_name': profile_name, 'rule_set_name': rule_set_name}
         base_query.create_item(models.WafProfileRuleSet, **data)
     # update waf-profile with the number of rules
     base_query.update_item(models.WafProfile, {'name': profile_name}, rule_count=len(rule_set_list))
     return None
Ejemplo n.º 3
0
 def post(self):
     # get the clusters in the kube_config
     kube_config = request.json['kube_config']
     tmp_fd, tmp_file_name = tempfile.mkstemp(text=True)
     fd = os.fdopen(tmp_fd, "w")
     fd.write(kube_config)
     fd.close()
     kubernetes.config.load_kube_config(tmp_file_name)
     _, cur_context = kubernetes.config.list_kube_config_contexts()
     base_query.create_item(models.KubeProfile,
         cluster=cur_context['name'], exclude_search=["kube_config"],
         **request.json)
Ejemplo n.º 4
0
 def post(self):
     # parse certificate for important information
     cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, request.json['body'])
     issue_date = arrow.get(cert.get_notBefore().decode(), ['YYYYMMDDHHmmSSz']).datetime
     expiry_date = arrow.get(cert.get_notAfter().decode(), ['YYYYMMDDHHmmSSz']).datetime
     dns = []
     for comp in cert.get_subject().get_components():
         key, value = comp
         if key.decode() == "CN":
             dns.append(value.decode())
     for idx in range(cert.get_extension_count()):
         ext = cert.get_extension(idx)
         if ext.get_short_name().decode() == "subjectAltName":
             dns.extend(ext._subjectAltNameString().split(","))
     base_query.create_item(models.Certificate, exclude_search=["body", "private_key"],
         issue_date=issue_date, expiry_date=expiry_date, subjects=dns, **request.json)
Ejemplo n.º 5
0
 def post(self):
     base_query.create_item(models.WafProfile, **request.json)
Ejemplo n.º 6
0
 def post(self):
     for ruleset in request.json:
         base_query.create_item(models.WafRuleSet, **ruleset)
Ejemplo n.º 7
0
 def post(self):
     body = request.json
     return base_query.create_item(models.PolicyProfile, **body)
Ejemplo n.º 8
0
 def post(self):
     base_query.create_item(models.Address, **request.json)