示例#1
0
 def setobject_action(self, dbid, action):
     api_dict = commen.get_api("/DDL.json")
     api_dict = api_dict["oracle"]["objectpermission"]
     print(api_dict["url"])
     try:
         api_request(api_dict['url'] % (dbid, action), api_dict['header'],
                     api_dict['method'])
     except Exception as e:
         assert e
示例#2
0
 def clear(self):
     payload = {}
     res = api_request(api_dict["clear"]["url"],
                       api_dict["clear"]["header"],
                       api_dict["clear"]["method"],
                       payload=payload)
     return res
示例#3
0
 def diy_rule_add(self,
                  dbType=None,
                  name=None,
                  risk_level=None,
                  status=None,
                  ruleType=None):
     param = self.param_dict['add_diy_rule']
     if dbType != None:
         if dbType == "dm":
             param['body']['dbType'] = "dameng"
         else:
             param['body']['dbType'] = dbType
     if name != None:
         param['body']['chsName'] = name
     if risk_level != None:
         param['body']['riskLevel'] = risk_level
     if ruleType != None:
         param['body']['ruleType'] = ruleType
     if status != None:
         param['body']['vpStatus'] = status
     try:
         response = api_request(api_url=param['url'],
                                headers=param['header'],
                                method=param['method'],
                                payload=param['body'])
         return response
     except Exception as e:
         LOG.info(e)
示例#4
0
 def nopage(self):
     try:
         response = api_request(api_url=self.param_dict['nopage']['uri'],
                                method=self.param_dict['nopage']['method'])
         return response
     except Exception as e:
         LOG.info(e)
示例#5
0
 def update_access(self,
                   id=None,
                   action=None,
                   cyc=None,
                   rate=None,
                   riskLevel=None,
                   audit=None):
     self.param_dict['update']['body']['dbIds'][0] = int(id)
     self.param_dict['update']['body']['access']['status'] = 1
     if action != None:
         self.param_dict['update']['body']['access']['action'] = action
     if cyc != None:
         self.param_dict['update']['body']['access']['cyc'] = cyc
     if rate != None:
         self.param_dict['update']['body']['access']['rate'] = rate
     if riskLevel != None:
         self.param_dict['update']['body']['access'][
             'riskLevel'] = riskLevel
     if audit != None:
         self.param_dict['update']['body']['access']['audit'] = audit
     response = api_request(api_url=self.param_dict['update']['url'],
                            headers=self.param_dict['update']['header'],
                            method=self.param_dict['update']['method'],
                            payload=self.param_dict['update']['body'])
     return response
示例#6
0
 def update(self,
            dispose=None,
            featuresStatus=None,
            virStatus=None,
            id=None,
            dataMaskStatusOM=None):
     try:
         if dispose != None:
             self.param_dict['update']['body']['rule']['dispose'] = dispose
         if featuresStatus != None:
             self.param_dict['update']['body'][
                 'featuresStatus'] = featuresStatus
         if dataMaskStatusOM != None:
             self.param_dict['update']['body'][
                 'dataMaskStatusOM'] = dataMaskStatusOM
         if virStatus != None:
             self.param_dict['update']['body']['virStatus'] = virStatus
         self.param_dict['update']['body']['dbIds'][0] = int(id)
         response = api_request(api_url=self.param_dict['update']['url'],
                                headers=self.param_dict['update']['header'],
                                method=self.param_dict['update']['method'],
                                payload=self.param_dict['update']['body'])
         return response
     except Exception as e:
         LOG.info(e)
示例#7
0
 def state_change(self, state, IDlist):
     payload = {"cmdType": state, "ids": IDlist}
     res = api_request(api_dict["status"]["url"],
                       api_dict["status"]["header"],
                       api_dict["status"]["method"],
                       payload=payload)
     res = json.loads(res.content.decode("utf-8"))
     return res
示例#8
0
 def select_rule(self, byparam, param):
     try:
         Param = self.param_dict['select_diy_rule']
         response = api_request(api_url=Param['urlParam'][byparam] % param,
                                headers=Param['header'],
                                method=Param['method'])
         return response
     except Exception as e:
         LOG.info(e)
示例#9
0
 def view_rule(self, id):
     try:
         param = self.param_dict['view_diy_rule']
         response = api_request(api_url=param['url'] + str(id),
                                headers=param['header'],
                                method=param['method'])
         return response
     except Exception as e:
         LOG.info(e)
示例#10
0
 def setrisk(self, dbid=1, auditLevel=3, status=0, dangerownerId=1):
     payload = {
         "dbid": dbid,
         "assetOwner": "",
         "ownerType": "database account",
         "additionRule": "",
         "auditLevel": auditLevel,
         "status": status,
         "dangerownerId": dangerownerId,
         "part": "danger"
     }
     api_dict = commen.get_api("/DDL.json")
     api_dict = api_dict["riskconfig"]
     try:
         api_request(
             api_dict['url'] %
             (payload["dbid"], payload["ownerType"], payload["auditLevel"],
              payload["status"], payload["dangerownerId"], payload["part"]),
             api_dict['header'], api_dict['method'])
     except Exception as e:
         assert e
示例#11
0
 def operate_rule(self, operate, id):
     try:
         self.param_dict['mutiOperate_diy_rule']['body'][operate][
             'ids'].append(id)
         param = self.param_dict['mutiOperate_diy_rule']
         response = api_request(api_url=param['url'],
                                headers=param['header'],
                                method=param['method'],
                                payload=param['body'][operate])
         return response
     except Exception as e:
         LOG.info(e)
     pass
示例#12
0
    def select(self, dbname=None, featuresStatus=None, virStatus=None):
        response = None
        try:
            if dbname != None and featuresStatus == None and virStatus == None:
                response = api_request(
                    api_url=self.param_dict['select']['uri']['dbname'] +
                    dbname,
                    method=self.param_dict['select']['method'])
            if featuresStatus != None and dbname == None and virStatus == None:
                response = api_request(
                    api_url=self.param_dict['select']['uri']['featuresStatus']
                    + str(featuresStatus),
                    method=self.param_dict['select']['method'])
            if virStatus != None and featuresStatus == None and dbname == None:
                response = api_request(
                    api_url=self.param_dict['select']['uri']['virStatus'] +
                    str(virStatus),
                    method=self.param_dict['select']['method'])

            return response
        except Exception as e:
            LOG.info(e)
示例#13
0
 def getlist(self):
     res = api_request(api_dict["whitelist"]["url"],
                       api_dict["whitelist"]["header"],
                       api_dict["whitelist"]["method"])
     res = json.loads(res.content)
     return res
示例#14
0
 def addruler(self, payload):
     res = api_request(api_dict["increase"]["url"],
                       api_dict["increase"]["header"],
                       api_dict["increase"]["method"], payload)
     res = json.loads(res.content)
     assert res['message'] == "success", "%s,新增白名单失败" % res['message']