diff --git a/apps/api-runtime/src/main/java/com/akto/dependency/DependencyAnalyser.java b/apps/api-runtime/src/main/java/com/akto/dependency/DependencyAnalyser.java index 9e1f57b5c9..71a90833cd 100644 --- a/apps/api-runtime/src/main/java/com/akto/dependency/DependencyAnalyser.java +++ b/apps/api-runtime/src/main/java/com/akto/dependency/DependencyAnalyser.java @@ -238,7 +238,7 @@ public boolean filterValues(Object val) { if (val == null) return false; if (val instanceof Boolean) return false; if (val instanceof String) return val.toString().length() > 4 && val.toString().length() <= 4096; - if (val instanceof Integer) return ((int) val) > 0; + if (val instanceof Integer) return ((int) val) > 50; return true; } diff --git a/apps/dashboard/src/main/java/com/akto/utils/Utils.java b/apps/dashboard/src/main/java/com/akto/utils/Utils.java index 0223ddb394..23ed12f4b8 100644 --- a/apps/dashboard/src/main/java/com/akto/utils/Utils.java +++ b/apps/dashboard/src/main/java/com/akto/utils/Utils.java @@ -470,6 +470,7 @@ public static void pushDataToKafka(int apiCollectionId, String topic, List varMap, String logId, AuthMechanism authMechanism, FilterNode validatorNode, ApiInfo.ApiInfoKey apiInfoKey, TestingRunConfig testingRunConfig, List customAuthTypes, boolean debug, List testLogs, - Memory memory, Map apiNameToApiInfoKey) { + Memory memory) { List result = new ArrayList<>(); ExecutionListBuilder executionListBuilder = new ExecutionListBuilder(); @@ -152,7 +152,7 @@ public YamlTestResult execute(ExecutorNode node, RawApi rawApi, Map()); } workflowTest = buildWorkflowGraph(reqNodes, rawApi, authMechanism, customAuthTypes, apiInfoKey, varMap, validatorNode); - result.add(triggerMultiExecution(workflowTest, reqNodes, rawApi, authMechanism, customAuthTypes, apiInfoKey, varMap, validatorNode, debug, testLogs, memory, apiNameToApiInfoKey)); + result.add(triggerMultiExecution(workflowTest, reqNodes, rawApi, authMechanism, customAuthTypes, apiInfoKey, varMap, validatorNode, debug, testLogs, memory)); yamlTestResult = new YamlTestResult(result, workflowTest); return yamlTestResult; @@ -264,7 +264,7 @@ public WorkflowTest buildWorkflowGraph(ExecutorNode reqNodes, RawApi rawApi, Aut } public MultiExecTestResult triggerMultiExecution(WorkflowTest workflowTest, ExecutorNode reqNodes, RawApi rawApi, AuthMechanism authMechanism, - List customAuthTypes, ApiInfo.ApiInfoKey apiInfoKey, Map varMap, FilterNode validatorNode, boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey) { + List customAuthTypes, ApiInfo.ApiInfoKey apiInfoKey, Map varMap, FilterNode validatorNode, boolean debug, List testLogs, Memory memory) { ApiWorkflowExecutor apiWorkflowExecutor = new ApiWorkflowExecutor(); Graph graph = new Graph(); @@ -273,7 +273,7 @@ public MultiExecTestResult triggerMultiExecution(WorkflowTest workflowTest, Exec List executionOrder = new ArrayList<>(); WorkflowTestResult workflowTestResult = new WorkflowTestResult(id, workflowTest.getId(), new HashMap<>(), null, null); GraphExecutorRequest graphExecutorRequest = new GraphExecutorRequest(graph, graph.getNode("x1"), workflowTest, null, null, varMap, "conditional", workflowTestResult, new HashMap<>(), executionOrder); - GraphExecutorResult graphExecutorResult = apiWorkflowExecutor.init(graphExecutorRequest, debug, testLogs, memory, apiNameToApiInfoKey); + GraphExecutorResult graphExecutorResult = apiWorkflowExecutor.init(graphExecutorRequest, debug, testLogs, memory); return new MultiExecTestResult(graphExecutorResult.getWorkflowTestResult().getNodeResultMap(), graphExecutorResult.getVulnerable(), Confidence.HIGH, graphExecutorRequest.getExecutionOrder()); } diff --git a/apps/testing/src/main/java/com/akto/testing/ApiWorkflowExecutor.java b/apps/testing/src/main/java/com/akto/testing/ApiWorkflowExecutor.java index 194103dba4..caaa6fa05c 100644 --- a/apps/testing/src/main/java/com/akto/testing/ApiWorkflowExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/ApiWorkflowExecutor.java @@ -11,9 +11,9 @@ public class ApiWorkflowExecutor { - public GraphExecutorResult init(GraphExecutorRequest graphExecutorRequest, boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey) { + public GraphExecutorResult init(GraphExecutorRequest graphExecutorRequest, boolean debug, List testLogs, Memory memory) { GraphExecutor graphExecutor = GraphExecutorFactory.fetchExecutor(graphExecutorRequest); - GraphExecutorResult graphExecutorResult = graphExecutor.executeGraph(graphExecutorRequest,debug,testLogs, memory, apiNameToApiInfoKey); + GraphExecutorResult graphExecutorResult = graphExecutor.executeGraph(graphExecutorRequest,debug,testLogs, memory); return graphExecutorResult; } diff --git a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java index b019b03ecd..d81fe068cb 100644 --- a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java @@ -107,7 +107,7 @@ public void workflowInit (TestingRun testingRun, ObjectId summaryId, boolean deb Graph graph = new Graph(); graph.buildGraph(workflowTest); GraphExecutorRequest graphExecutorRequest = new GraphExecutorRequest(graph, workflowTest, testingRun.getId(), summaryId, valuesMap, false, "linear"); - GraphExecutorResult graphExecutorResult = apiWorkflowExecutor.init(graphExecutorRequest, debug, testLogs, null, null); + GraphExecutorResult graphExecutorResult = apiWorkflowExecutor.init(graphExecutorRequest, debug, testLogs, null); WorkflowTestResultsDao.instance.insertOne(graphExecutorResult.getWorkflowTestResult()); } catch (Exception e) { loggerMaker.errorAndAddToDb("Error while executing workflow test " + e, LogDb.TESTING); @@ -651,7 +651,6 @@ public TestingRunResult runTestNew(ApiInfo.ApiInfoKey apiInfoKey, ObjectId testR } FilterNode filterNode = testConfig.getApiSelectionFilters().getNode(); - Map workFlowSelectionFilters = testConfig.getWorkFlowSelectionFilters(); FilterNode validatorNode = null; if (testConfig.getValidation() != null) { validatorNode = testConfig.getValidation().getNode(); @@ -677,7 +676,7 @@ public TestingRunResult runTestNew(ApiInfo.ApiInfoKey apiInfoKey, ObjectId testR // TestingUtil -> authMechanism // TestingConfig -> auth YamlTestTemplate yamlTestTemplate = new YamlTestTemplate(apiInfoKey,filterNode, validatorNode, executorNode, - rawApi, varMap, auth, testingUtil.getAuthMechanism(), testExecutionLogId, testingRunConfig, customAuthTypes, testConfig.getStrategy(), workFlowSelectionFilters); + rawApi, varMap, auth, testingUtil.getAuthMechanism(), testExecutionLogId, testingRunConfig, customAuthTypes, testConfig.getStrategy()); YamlTestResult testResults = yamlTestTemplate.run(debug, testLogs); if (testResults == null || testResults.getTestResults().isEmpty()) { List res = new ArrayList<>(); diff --git a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/ApiNodeExecutor.java b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/ApiNodeExecutor.java index 8b67217871..92645aa6c6 100644 --- a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/ApiNodeExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/ApiNodeExecutor.java @@ -26,7 +26,7 @@ public class ApiNodeExecutor extends NodeExecutor { private static final LoggerMaker loggerMaker = new LoggerMaker(ApiNodeExecutor.class); - public NodeResult processNode(Node node, Map valuesMap, Boolean allowAllStatusCodes, boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey) { + public NodeResult processNode(Node node, Map valuesMap, Boolean allowAllStatusCodes, boolean debug, List testLogs, Memory memory) { loggerMaker.infoAndAddToDb("\n", LogDb.TESTING); loggerMaker.infoAndAddToDb("NODE: " + node.getId(), LogDb.TESTING); List testErrors = new ArrayList<>(); diff --git a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/ConditionalGraphExecutor.java b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/ConditionalGraphExecutor.java index afc598d5a9..80d68cc439 100644 --- a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/ConditionalGraphExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/ConditionalGraphExecutor.java @@ -16,7 +16,7 @@ public class ConditionalGraphExecutor extends GraphExecutor { - public GraphExecutorResult executeGraph(GraphExecutorRequest graphExecutorRequest, boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey) { + public GraphExecutorResult executeGraph(GraphExecutorRequest graphExecutorRequest, boolean debug, List testLogs, Memory memory) { Map visitedMap = graphExecutorRequest.getVisitedMap(); List errors = new ArrayList<>(); @@ -32,7 +32,7 @@ public GraphExecutorResult executeGraph(GraphExecutorRequest graphExecutorReques boolean success = false; WorkflowTestResult.NodeResult nodeResult; - nodeResult = Utils.executeNode(node, graphExecutorRequest.getValuesMap(), debug, testLogs, memory, apiNameToApiInfoKey); + nodeResult = Utils.executeNode(node, graphExecutorRequest.getValuesMap(), debug, testLogs, memory); graphExecutorRequest.getWorkflowTestResult().getNodeResultMap().put(node.getId(), nodeResult); graphExecutorRequest.getExecutionOrder().add(node.getId()); @@ -79,7 +79,7 @@ public GraphExecutorResult executeGraph(GraphExecutorRequest graphExecutorReques boolean vulnerable = success; if (childNode != null) { GraphExecutorRequest childExecReq = new GraphExecutorRequest(graphExecutorRequest, childNode, graphExecutorRequest.getWorkflowTestResult(), visitedMap, graphExecutorRequest.getExecutionOrder()); - GraphExecutorResult childExecResult = executeGraph(childExecReq, debug, testLogs, memory, apiNameToApiInfoKey); + GraphExecutorResult childExecResult = executeGraph(childExecReq, debug, testLogs, memory); vulnerable = childExecResult.getVulnerable(); return new GraphExecutorResult(graphExecutorRequest.getWorkflowTestResult(), vulnerable, errors); } else { diff --git a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/GraphExecutor.java b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/GraphExecutor.java index 5e6ab7f15a..cc876d2a3c 100644 --- a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/GraphExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/GraphExecutor.java @@ -11,6 +11,6 @@ public abstract class GraphExecutor { - public abstract GraphExecutorResult executeGraph(GraphExecutorRequest graphExecutorRequest, boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey); + public abstract GraphExecutorResult executeGraph(GraphExecutorRequest graphExecutorRequest, boolean debug, List testLogs, Memory memory); } diff --git a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/LinearGraphExecutor.java b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/LinearGraphExecutor.java index 95ad59a8aa..5cc7ace500 100644 --- a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/LinearGraphExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/LinearGraphExecutor.java @@ -16,7 +16,7 @@ public class LinearGraphExecutor extends GraphExecutor { - public GraphExecutorResult executeGraph(GraphExecutorRequest graphExecutorRequest, boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey) { + public GraphExecutorResult executeGraph(GraphExecutorRequest graphExecutorRequest, boolean debug, List testLogs, Memory memory) { List nodes = graphExecutorRequest.getGraph().sort(); int id = Context.now(); @@ -24,7 +24,7 @@ public GraphExecutorResult executeGraph(GraphExecutorRequest graphExecutorReques Map testResultMap = workflowTestResult.getNodeResultMap(); for (Node node: nodes) { WorkflowTestResult.NodeResult nodeResult; - nodeResult = Utils.executeNode(node, graphExecutorRequest.getValuesMap(), debug, testLogs, memory, apiNameToApiInfoKey); + nodeResult = Utils.executeNode(node, graphExecutorRequest.getValuesMap(), debug, testLogs, memory); testResultMap.put(node.getId(), nodeResult); if (nodeResult.getErrors().size() > 0) break; if (graphExecutorRequest.getSkipIfNotVulnerable() && !nodeResult.isVulnerable()) { diff --git a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/NodeExecutor.java b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/NodeExecutor.java index 63a1415d5e..68e5b00c00 100644 --- a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/NodeExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/NodeExecutor.java @@ -11,5 +11,5 @@ public abstract class NodeExecutor { - public abstract WorkflowTestResult.NodeResult processNode(Node node, Map valuesMap, Boolean allowAllStatusCodes, boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey); + public abstract WorkflowTestResult.NodeResult processNode(Node node, Map valuesMap, Boolean allowAllStatusCodes, boolean debug, List testLogs, Memory memory); } diff --git a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/Utils.java b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/Utils.java index 8889e0c8bc..216d4afec7 100644 --- a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/Utils.java +++ b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/Utils.java @@ -189,7 +189,7 @@ public static String fetchToken(RecordedLoginFlowInput recordedLoginFlowInput, i return token; } - public static WorkflowTestResult.NodeResult processNode(Node node, Map valuesMap, Boolean allowAllStatusCodes, boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey) { + public static WorkflowTestResult.NodeResult processNode(Node node, Map valuesMap, Boolean allowAllStatusCodes, boolean debug, List testLogs, Memory memory) { if (node.getWorkflowNodeDetails().getType() == WorkflowNodeDetails.Type.RECORDED) { return processRecorderNode(node, valuesMap); } @@ -197,22 +197,22 @@ else if (node.getWorkflowNodeDetails().getType() == WorkflowNodeDetails.Type.OTP return processOtpNode(node, valuesMap); } else { - return processApiNode(node, valuesMap, allowAllStatusCodes, debug, testLogs, memory, apiNameToApiInfoKey); + return processApiNode(node, valuesMap, allowAllStatusCodes, debug, testLogs, memory); } } - public static WorkflowTestResult.NodeResult processApiNode(Node node, Map valuesMap, Boolean allowAllStatusCodes, boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey) { + public static WorkflowTestResult.NodeResult processApiNode(Node node, Map valuesMap, Boolean allowAllStatusCodes, boolean debug, List testLogs, Memory memory) { NodeExecutorFactory nodeExecutorFactory = new NodeExecutorFactory(); NodeExecutor nodeExecutor = nodeExecutorFactory.getExecutor(node); - return nodeExecutor.processNode(node, valuesMap, allowAllStatusCodes, debug, testLogs, memory, apiNameToApiInfoKey); + return nodeExecutor.processNode(node, valuesMap, allowAllStatusCodes, debug, testLogs, memory); } - public static WorkflowTestResult.NodeResult executeNode(Node node, Map valuesMap,boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey) { + public static WorkflowTestResult.NodeResult executeNode(Node node, Map valuesMap,boolean debug, List testLogs, Memory memory) { WorkflowTestResult.NodeResult nodeResult; try { - nodeResult = Utils.processNode(node, valuesMap, true, debug, testLogs, memory, apiNameToApiInfoKey); + nodeResult = Utils.processNode(node, valuesMap, true, debug, testLogs, memory); } catch (Exception e) { ; List testErrors = new ArrayList<>(); @@ -246,7 +246,7 @@ public static LoginFlowResponse runLoginFlow(WorkflowTest workflowTest, AuthMech if (authMechanism.getRequestData() != null && authMechanism.getRequestData().size() > 0 && authMechanism.getRequestData().get(index).getAllowAllStatusCodes()) { allowAllStatusCodes = authMechanism.getRequestData().get(0).getAllowAllStatusCodes(); } - nodeResult = processNode(node, valuesMap, allowAllStatusCodes, false, new ArrayList<>(), null, null); + nodeResult = processNode(node, valuesMap, allowAllStatusCodes, false, new ArrayList<>(), null); } catch (Exception e) { ; List testErrors = new ArrayList<>(); diff --git a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/YamlNodeExecutor.java b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/YamlNodeExecutor.java index 934737a3d5..0f16a8fb53 100644 --- a/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/YamlNodeExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/workflow_node_executor/YamlNodeExecutor.java @@ -50,7 +50,7 @@ public class YamlNodeExecutor extends NodeExecutor { private static final Gson gson = new Gson(); - public NodeResult processNode(Node node, Map varMap, Boolean allowAllStatusCodes, boolean debug, List testLogs, Memory memory, Map apiNameToApiInfoKey) { + public NodeResult processNode(Node node, Map varMap, Boolean allowAllStatusCodes, boolean debug, List testLogs, Memory memory) { List testErrors = new ArrayList<>(); YamlNodeDetails yamlNodeDetails = (YamlNodeDetails) node.getWorkflowNodeDetails(); @@ -69,15 +69,17 @@ public NodeResult processNode(Node node, Map varMap, Boolean all ApiInfo.ApiInfoKey apiInfoKey = ((YamlNodeDetails) node.getWorkflowNodeDetails()).getApiInfoKey(); ExecutorNode firstChildNode = childNodes.get(0); // todo check for length - if (firstChildNode.getOperationType().equalsIgnoreCase("api")) { - String apiType = firstChildNode.getValues().toString(); - if (apiType.equalsIgnoreCase("get_asset_api")) { - rawApi = memory.findAssetGetterRequest(apiInfoKey); + if (memory != null) { + if (firstChildNode.getOperationType().equalsIgnoreCase("api")) { + String apiType = firstChildNode.getValues().toString(); + if (apiType.equalsIgnoreCase("get_asset_api")) { + rawApi = memory.findAssetGetterRequest(apiInfoKey); + } + childNodes.remove(0); + } else { + OriginalHttpRequest request = memory.run(apiInfoKey.getApiCollectionId(), apiInfoKey.getUrl(), apiInfoKey.getMethod().name()); + rawApi.setRequest(request); } - childNodes.remove(0); - } else { - OriginalHttpRequest request = memory.run(apiInfoKey.getApiCollectionId(), apiInfoKey.getUrl(), apiInfoKey.getMethod().name()); - rawApi.setRequest(request); } diff --git a/apps/testing/src/main/java/com/akto/testing/yaml_tests/SecurityTestTemplate.java b/apps/testing/src/main/java/com/akto/testing/yaml_tests/SecurityTestTemplate.java index 47db26f346..9027116dbf 100644 --- a/apps/testing/src/main/java/com/akto/testing/yaml_tests/SecurityTestTemplate.java +++ b/apps/testing/src/main/java/com/akto/testing/yaml_tests/SecurityTestTemplate.java @@ -2,12 +2,18 @@ import com.akto.dto.ApiInfo; import com.akto.dto.RawApi; -import com.akto.dto.test_editor.*; +import com.akto.dto.test_editor.Auth; +import com.akto.dto.test_editor.ExecutorNode; +import com.akto.dto.test_editor.FilterNode; +import com.akto.dto.test_editor.Strategy; import com.akto.dto.testing.*; import com.akto.dto.testing.TestResult.TestError; import com.akto.test_editor.execution.Memory; -import java.util.*; +import java.util.Collections; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import static com.akto.dto.testing.TestResult.TestError.*; @@ -26,13 +32,9 @@ public abstract class SecurityTestTemplate { TestingRunConfig testingRunConfig; Strategy strategy; - Map apiNameToApiInfoKey = new HashMap<>(); - - Map workFlowSelectionFilters; - Memory memory; - public SecurityTestTemplate(ApiInfo.ApiInfoKey apiInfoKey, FilterNode filterNode, FilterNode validatorNode, ExecutorNode executorNode ,RawApi rawApi, Map varMap, Auth auth, AuthMechanism authMechanism, String logId, TestingRunConfig testingRunConfig, Strategy strategy, Map workFlowSelectionFilters) { + public SecurityTestTemplate(ApiInfo.ApiInfoKey apiInfoKey, FilterNode filterNode, FilterNode validatorNode, ExecutorNode executorNode ,RawApi rawApi, Map varMap, Auth auth, AuthMechanism authMechanism, String logId, TestingRunConfig testingRunConfig, Strategy strategy) { this.apiInfoKey = apiInfoKey; this.filterNode = filterNode; this.validatorNode = validatorNode; @@ -44,13 +46,10 @@ public SecurityTestTemplate(ApiInfo.ApiInfoKey apiInfoKey, FilterNode filterNode this.logId = logId; this.testingRunConfig = testingRunConfig; this.strategy = strategy; - this.workFlowSelectionFilters = workFlowSelectionFilters; } public abstract boolean filter(); - public abstract boolean workflowFilter(); - public abstract boolean checkAuthBeforeExecution(boolean debug, List testLogs); public abstract YamlTestResult executor(boolean debug, List testLogs); @@ -71,14 +70,6 @@ public YamlTestResult run(boolean debug, List testLogs testResults.add(new TestResult(null, rawApi.getOriginalMessage(), Collections.singletonList(SKIPPING_EXECUTION_BECAUSE_AUTH.getMessage()), 0, false, TestResult.Confidence.HIGH, null)); return new YamlTestResult(testResults, null); } - - boolean workflowFound = workflowFilter(); - if (!workflowFound) { - List testResults = new ArrayList<>(); - testResults.add(new TestResult(null, rawApi.getOriginalMessage(), Collections.singletonList("Request API failed to satisfy workflow_selection_filters block, skipping execution"), 0, false, TestResult.Confidence.HIGH, null)); - return new YamlTestResult(testResults, null); - } - YamlTestResult attempts = executor(debug, testLogs); if(attempts == null || attempts.getTestResults().isEmpty()){ List res = new ArrayList<>(); @@ -161,19 +152,4 @@ public void setLogId(String logId) { this.logId = logId; } - public Map getApiNameToApiInfoKey() { - return apiNameToApiInfoKey; - } - - public void setApiNameToApiInfoKey(Map apiNameToApiInfoKey) { - this.apiNameToApiInfoKey = apiNameToApiInfoKey; - } - - public Map getWorkFlowSelectionFilters() { - return workFlowSelectionFilters; - } - - public void setWorkFlowSelectionFilters(Map workFlowSelectionFilters) { - this.workFlowSelectionFilters = workFlowSelectionFilters; - } } diff --git a/apps/testing/src/main/java/com/akto/testing/yaml_tests/YamlTestTemplate.java b/apps/testing/src/main/java/com/akto/testing/yaml_tests/YamlTestTemplate.java index fbc6c5c0b4..1674328e6b 100644 --- a/apps/testing/src/main/java/com/akto/testing/yaml_tests/YamlTestTemplate.java +++ b/apps/testing/src/main/java/com/akto/testing/yaml_tests/YamlTestTemplate.java @@ -1,25 +1,17 @@ package com.akto.testing.yaml_tests; -import com.akto.dao.SampleDataDao; import com.akto.dto.ApiInfo; import com.akto.dto.CustomAuthType; import com.akto.dto.OriginalHttpResponse; import com.akto.dto.RawApi; import com.akto.dto.test_editor.*; import com.akto.dto.testing.*; -import com.akto.dto.traffic.SampleData; import com.akto.log.LoggerMaker; import com.akto.rules.TestPlugin; import com.akto.test_editor.auth.AuthValidator; import com.akto.test_editor.execution.Executor; -import com.akto.test_editor.execution.Memory; import com.akto.testing.StatusCodeAnalyser; -import com.mongodb.BasicDBObject; -import com.mongodb.client.model.Projections; -import com.mongodb.client.model.Sorts; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,8 +22,8 @@ public class YamlTestTemplate extends SecurityTestTemplate { public YamlTestTemplate(ApiInfo.ApiInfoKey apiInfoKey, FilterNode filterNode, FilterNode validatorNode, ExecutorNode executorNode, RawApi rawApi, Map varMap, Auth auth, AuthMechanism authMechanism, String logId, TestingRunConfig testingRunConfig, - List customAuthTypes, Strategy strategy, Map workFlowSelectionFilters) { - super(apiInfoKey, filterNode, validatorNode, executorNode ,rawApi, varMap, auth, authMechanism, logId, testingRunConfig, strategy, workFlowSelectionFilters); + List customAuthTypes, Strategy strategy) { + super(apiInfoKey, filterNode, validatorNode, executorNode ,rawApi, varMap, auth, authMechanism, logId, testingRunConfig, strategy); this.customAuthTypes = customAuthTypes; } @@ -56,10 +48,6 @@ public boolean filter() { return isValid; } - @Override - public boolean workflowFilter() { - return true; - } @Override public boolean checkAuthBeforeExecution(boolean debug, List testLogs) { @@ -83,7 +71,7 @@ public YamlTestResult executor(boolean debug, List tes // loggerMaker.infoAndAddToDb("executor started" + logId, LogDb.TESTING); YamlTestResult results = new Executor().execute(this.executorNode, this.rawApi, this.varMap, this.logId, this.authMechanism, this.validatorNode, this.apiInfoKey, this.testingRunConfig, this.customAuthTypes, - debug, testLogs, memory, apiNameToApiInfoKey); + debug, testLogs, memory); // loggerMaker.infoAndAddToDb("execution result size " + results.size() + " " + logId, LogDb.TESTING); return results; } diff --git a/libs/dao/src/main/java/com/akto/dao/test_editor/TestConfigYamlParser.java b/libs/dao/src/main/java/com/akto/dao/test_editor/TestConfigYamlParser.java index 835670f192..2406e56ecb 100644 --- a/libs/dao/src/main/java/com/akto/dao/test_editor/TestConfigYamlParser.java +++ b/libs/dao/src/main/java/com/akto/dao/test_editor/TestConfigYamlParser.java @@ -1,6 +1,5 @@ package com.akto.dao.test_editor; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -57,33 +56,21 @@ public static TestConfig parseConfig(Map config) throws Exceptio Parser authParser = new Parser(); auth = authParser.parse(authMap); if (auth == null) { - return new TestConfig(id, info, null, null, null, null, null, null, null); + return new TestConfig(id, info, null, null, null, null, null, null); } } Object filterMap = config.get("api_selection_filters"); if (filterMap == null) { // todo: should not be null, throw error - return new TestConfig(id, info, auth, null, null, null, null, null, null); - } - - Object workflowSelectionFilterObj = config.get("workflow_selection_filters"); - Map workFlowSelectionFilters = new HashMap<>(); - if (workflowSelectionFilterObj != null) { - Map workflowSelectionFilterMap = (Map) workflowSelectionFilterObj; - for (String apiName: workflowSelectionFilterMap.keySet()) { - Object o = workflowSelectionFilterMap.get(apiName); - ConfigParserResult childFilter = new ConfigParser().parse(o); - workFlowSelectionFilters.put(apiName, childFilter); - } - // todo: should not be null, throw error + return new TestConfig(id, info, auth, null, null, null, null, null); } ConfigParser configParser = new ConfigParser(); ConfigParserResult filters = configParser.parse(filterMap); if (filters == null) { // todo: throw error - new TestConfig(id, info, auth, null, null, null, null, null, workFlowSelectionFilters); + new TestConfig(id, info, auth, null, null, null, null, null); } Map> wordListMap = new HashMap<>(); @@ -92,44 +79,44 @@ public static TestConfig parseConfig(Map config) throws Exceptio wordListMap = (Map) config.get("wordLists"); } } catch (Exception e) { - return new TestConfig(id, info, null, null, null, null, null, null, workFlowSelectionFilters); + return new TestConfig(id, info, null, null, null, null, null, null); } Object executionMap = config.get("execute"); if (executionMap == null) { // todo: should not be null, throw error - return new TestConfig(id, info, auth, filters, wordListMap, null, null, null, workFlowSelectionFilters); + return new TestConfig(id, info, auth, filters, wordListMap, null, null, null); } com.akto.dao.test_editor.executor.ConfigParser executorConfigParser = new com.akto.dao.test_editor.executor.ConfigParser(); ExecutorConfigParserResult executeOperations = executorConfigParser.parseConfigMap(executionMap); if (executeOperations == null) { // todo: throw error - new TestConfig(id, info, auth, filters, wordListMap, null, null, null, workFlowSelectionFilters); + new TestConfig(id, info, auth, filters, wordListMap, null, null, null); } Object validationMap = config.get("validate"); if (validationMap == null) { // todo: should not be null, throw error - return new TestConfig(id, info, auth, filters, wordListMap, executeOperations, null, null, workFlowSelectionFilters); + return new TestConfig(id, info, auth, filters, wordListMap, executeOperations, null, null); } ConfigParserResult validations = configParser.parse(validationMap); if (validations == null) { // todo: throw error - new TestConfig(id, info, auth, filters, wordListMap, executeOperations, null, null, workFlowSelectionFilters); + new TestConfig(id, info, auth, filters, wordListMap, executeOperations, null, null); } Object strategyObject = config.get("strategy"); if (strategyObject == null) { - return new TestConfig(id, info, auth, filters, wordListMap, executeOperations, validations, null, workFlowSelectionFilters); + return new TestConfig(id, info, auth, filters, wordListMap, executeOperations, validations, null); } StrategyParser strategyParser = new StrategyParser(); Strategy strategy = strategyParser.parse(strategyObject); - testConfig = new TestConfig(id, info, auth, filters, wordListMap, executeOperations, validations, strategy, workFlowSelectionFilters); + testConfig = new TestConfig(id, info, auth, filters, wordListMap, executeOperations, validations, strategy); return testConfig; } diff --git a/libs/dao/src/main/java/com/akto/dto/test_editor/TestConfig.java b/libs/dao/src/main/java/com/akto/dto/test_editor/TestConfig.java index 2f4d77fb1b..09bb3c8d13 100644 --- a/libs/dao/src/main/java/com/akto/dto/test_editor/TestConfig.java +++ b/libs/dao/src/main/java/com/akto/dto/test_editor/TestConfig.java @@ -14,7 +14,6 @@ public class TestConfig { private Auth auth; private ConfigParserResult apiSelectionFilters; - private Map workFlowSelectionFilters; private Map> wordlists; @@ -30,7 +29,7 @@ public class TestConfig { private String author; public TestConfig(String id, Info info, Auth auth, ConfigParserResult apiSelectionFilters, Map> wordlists, ExecutorConfigParserResult execute, - ConfigParserResult validation, Strategy strategy, Map workFlowSelectionFilters) { + ConfigParserResult validation, Strategy strategy) { this.id = id; info.setSubCategory(id); @@ -41,7 +40,6 @@ public TestConfig(String id, Info info, Auth auth, ConfigParserResult apiSelecti this.execute = execute; this.validation = validation; this.strategy = strategy; - this.workFlowSelectionFilters = workFlowSelectionFilters; } public TestConfig() { } @@ -150,14 +148,6 @@ public void setAuthor(String author) { this.author = author; } - public Map getWorkFlowSelectionFilters() { - return workFlowSelectionFilters; - } - - public void setWorkFlowSelectionFilters(Map workFlowSelectionFilters) { - this.workFlowSelectionFilters = workFlowSelectionFilters; - } - public boolean isInactive() { return inactive; }