def run(self, params={}): request = ResourceHelper(self.connection.session, self.logger) url = ScanConfig.scan_config(self.connection.url) request_params = dict() for item in params: if params[item]: request_params[item] = params[item] response = request.resource_request(url, 'get', params=request_params) try: result = json.loads(response['resource']) result = result['data'] except json.decoder.JSONDecodeError: self.logger.error(f'InsightAppSec response: {response}') raise Exception( 'The response from InsightAppSec was not in JSON format. Contact support for help.' ' See log for more details') output = list() for item in result: temp = { 'id': item['id'], 'config_name': item['name'], 'config_description': item.get('description', ''), 'app_id': item['app']['id'], 'attack_template_id': item['attack_template']['id'], 'errors': item.get('errors', list()), 'links': item['links'] } output.append(temp) return {Output.SCAN_CONFIGS: output}
def run(self, params={}): request = ResourceHelper(self.connection.session, self.logger) url = ScanConfig.scan_config(self.connection.url) request_params = dict() for item in params: if params[item]: request_params[item] = params[item] response = request.resource_request(url, "get", params=request_params) try: result = json.loads(response["resource"]) result = result["data"] except json.decoder.JSONDecodeError: self.logger.error(f"InsightAppSec response: {response}") raise Exception( "The response from InsightAppSec was not in JSON format. Contact support for help." " See log for more details") output = list() for item in result: temp = { "id": item["id"], "config_name": item["name"], "config_description": item.get("description", ""), "app_id": item["app"]["id"], "attack_template_id": item["attack_template"]["id"], "errors": item.get("errors", list()), "links": item["links"], } output.append(temp) return {Output.SCAN_CONFIGS: output}
def run(self, params={}): scan_config_id = params.get(Input.SCAN_CONFIG_ID) request = ResourceHelper(self.connection.session, self.logger) url = ScanConfig.scan_config(self.connection.url) url = f'{url}{scan_config_id}' response = request.resource_request(url, 'delete') return {Output.STATUS: response['status']}
def run(self, params={}): config_name = params.get(Input.CONFIG_NAME) config_description = params.get(Input.CONFIG_DESCRIPTION) app_id = params.get(Input.APP_ID) attack_template_id = params.get(Input.ATTACK_TEMPLATE_ID) request = ResourceHelper(self.connection.session, self.logger) url = ScanConfig.scan_config(self.connection.url) payload = {'name': config_name, 'description': config_description, 'app': {'id': app_id}, 'attack_template': {'id': attack_template_id}} response = request.resource_request(url, 'post', payload=payload) return {Output.STATUS: response['status']}
def run(self, params={}): scan_config_id = params.get(Input.SCAN_CONFIG_ID) config_name = params.get(Input.CONFIG_NAME) config_description = params.get(Input.CONFIG_DESCRIPTION) app_id = params.get(Input.APP_ID) attack_template_id = params.get(Input.ATTACK_TEMPLATE_ID) request = ResourceHelper(self.connection.session, self.logger) url = ScanConfig.scan_config(self.connection.url) url = f"{url}{scan_config_id}" payload = { "name": config_name, "description": config_description, "app": {"id": app_id}, "attack_template": {"id": attack_template_id}, } response = request.resource_request(url, "put", payload=payload) return {Output.STATUS: response["status"]}
def run(self, params={}): scan_config_id = params.get(Input.SCAN_CONFIG_ID) request = ResourceHelper(self.connection.session, self.logger) url = ScanConfig.scan_config(self.connection.url) url = f'{url}{scan_config_id}' response = request.resource_request(url, 'get') try: result = json.loads(response['resource']) except json.decoder.JSONDecodeError: self.logger.error(f'InsightAppSec response: {response}') raise Exception('The response from InsightAppSec was not in JSON format. Contact support for help.' ' See log for more details') try: return {Output.ID: result['id'], Output.CONFIG_NAME: result['name'], Output.CONFIG_DESCRIPTION: result.get('description', ''), Output.APP_ID: result['app']['id'], Output.ATTACK_TEMPLATE_ID: result['attack_template']['id'], Output.ERRORS: result.get('errors', list()), Output.LINKS: result['links']} except KeyError: self.logger.error(result) raise Exception('The response from InsightAppSec was not in the correct format. Contact support for help.' ' See log for more details')