From d49fd01220a1b78f624d1b82dd39d014ebfe6d6a Mon Sep 17 00:00:00 2001 From: notshivansh Date: Sat, 11 Nov 2023 17:57:14 +0530 Subject: [PATCH 01/11] insert testing run results in smaller batches --- .../java/com/akto/testing/TestExecutor.java | 63 ++++++++----------- 1 file changed, 27 insertions(+), 36 deletions(-) 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 f7836b8d38..837ae4c7ca 100644 --- a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java @@ -165,7 +165,7 @@ public void apiWiseInit(TestingRun testingRun, ObjectId summaryId) { CountDownLatch latch = new CountDownLatch(apiInfoKeyList.size()); ExecutorService threadPool = Executors.newFixedThreadPool(maxConcurrentRequests); - List>> futureTestingRunResults = new ArrayList<>(); + List> futureTestingRunResults = new ArrayList<>(); Map hostsToApiCollectionMap = new HashMap<>(); ConcurrentHashMap subCategoryEndpointMap = new ConcurrentHashMap<>(); @@ -200,7 +200,7 @@ public void apiWiseInit(TestingRun testingRun, ObjectId summaryId) { loggerMaker.errorAndAddToDb("Error while finding host: " + e, LogDb.TESTING); } try { - Future> future = threadPool.submit( + Future future = threadPool.submit( () -> startWithLatch(apiInfoKey, testingRun.getTestIdConfig(), testingRun.getId(),testingRun.getTestingRunConfig(), testingUtil, summaryId, @@ -225,20 +225,6 @@ public void apiWiseInit(TestingRun testingRun, ObjectId summaryId) { loggerMaker.infoAndAddToDb("Finished testing", LogDb.TESTING); - int totalResults = 0; - for (Future> future: futureTestingRunResults) { - if (!future.isDone()) continue; - try { - if (!future.get().isEmpty()) { - int resultSize = future.get().size(); - totalResults += resultSize; - } - } catch (InterruptedException | ExecutionException e) { - loggerMaker.errorAndAddToDb("Error while after running test : " + e, LogDb.TESTING); - } - } - - loggerMaker.infoAndAddToDb("Finished adding " + totalResults + " testingRunResults", LogDb.TESTING); } public static void updateTestSummary(ObjectId summaryId){ @@ -463,7 +449,7 @@ public Map generateResponseMap(String payloadStr, Map startWithLatch( + public Void startWithLatch( ApiInfo.ApiInfoKey apiInfoKey, int testIdConfig, ObjectId testRunId, TestingRunConfig testingRunConfig, TestingUtil testingUtil, ObjectId testRunResultSummaryId, int accountId, CountDownLatch latch, int startTime, int timeToKill, Map testConfigMap, TestingRun testingRun, @@ -472,27 +458,12 @@ public List startWithLatch( loggerMaker.infoAndAddToDb("Starting test for " + apiInfoKey, LogDb.TESTING); Context.accountId.set(accountId); - List testingRunResults = new ArrayList<>(); int now = Context.now(); if ( timeToKill <= 0 || now - startTime <= timeToKill) { try { // todo: commented out older one // testingRunResults = start(apiInfoKey, testIdConfig, testRunId, testingRunConfig, testingUtil, testRunResultSummaryId, testConfigMap); - testingRunResults = startTestNew(apiInfoKey, testRunId, testingRunConfig, testingUtil, testRunResultSummaryId, testConfigMap, subCategoryEndpointMap, apiInfoKeyToHostMap); - String size = testingRunResults.size()+""; - loggerMaker.infoAndAddToDb("testingRunResults size: " + size, LogDb.TESTING); - if (!testingRunResults.isEmpty()) { - trim(testingRunResults); - TestingRunResultDao.instance.insertMany(testingRunResults); - loggerMaker.infoAndAddToDb("Inserted testing results", LogDb.TESTING); - //Creating issues from testingRunResults - TestingIssuesHandler handler = new TestingIssuesHandler(); - boolean triggeredByTestEditor = false; - if (testingRun.getTriggeredBy() != null) { - triggeredByTestEditor = testingRun.getTriggeredBy().equals("test_editor"); - } - handler.handleIssuesCreationFromTestingRunResults(testingRunResults, triggeredByTestEditor); // pass new field here - } + startTestNew(apiInfoKey, testRunId, testingRunConfig, testingUtil, testRunResultSummaryId, testConfigMap, subCategoryEndpointMap, apiInfoKeyToHostMap); } catch (Exception e) { e.printStackTrace(); loggerMaker.errorAndAddToDb("error while running tests: " + e, LogDb.TESTING); @@ -500,7 +471,7 @@ public List startWithLatch( } latch.countDown(); - return testingRunResults; + return null; } public static void trim(TestingRunResult testingRunResult) { @@ -535,7 +506,19 @@ public void trim(List testingRunResults) { } } - public List startTestNew(ApiInfo.ApiInfoKey apiInfoKey, ObjectId testRunId, + public void insertResultsAndMakeIssues(List testingRunResults) { + String size = testingRunResults.size() + ""; + loggerMaker.infoAndAddToDb("testingRunResults size: " + size, LogDb.TESTING); + trim(testingRunResults); + TestingRunResultDao.instance.insertMany(testingRunResults); + loggerMaker.infoAndAddToDb("Inserted testing results", LogDb.TESTING); + TestingIssuesHandler handler = new TestingIssuesHandler(); + boolean triggeredByTestEditor = false; + handler.handleIssuesCreationFromTestingRunResults(testingRunResults, triggeredByTestEditor); + testingRunResults.clear(); + } + + public void startTestNew(ApiInfo.ApiInfoKey apiInfoKey, ObjectId testRunId, TestingRunConfig testingRunConfig, TestingUtil testingUtil, ObjectId testRunResultSummaryId, Map testConfigMap, ConcurrentHashMap subCategoryEndpointMap, Map apiInfoKeyToHostMap) { @@ -543,6 +526,7 @@ public List startTestNew(ApiInfo.ApiInfoKey apiInfoKey, Object List testSubCategories = testingRunConfig == null ? new ArrayList<>() : testingRunConfig.getTestSubCategoryList(); + int random = (int) ( ( Math.random() * 10 ) + 4); for (String testSubCategory: testSubCategories) { TestConfig testConfig = testConfigMap.get(testSubCategory); if (testConfig == null) continue; @@ -557,9 +541,16 @@ public List startTestNew(ApiInfo.ApiInfoKey apiInfoKey, Object e.printStackTrace(); } if (testingRunResult != null) testingRunResults.add(testingRunResult); + + if (!testingRunResults.isEmpty() && testingRunResults.size() % random == 0) { + insertResultsAndMakeIssues(testingRunResults); + } + } + + if(!testingRunResults.isEmpty()){ + insertResultsAndMakeIssues(testingRunResults); } - return testingRunResults; } public boolean applyRunOnceCheck(ApiInfoKey apiInfoKey, TestConfig testConfig, ConcurrentHashMap subCategoryEndpointMap, Map apiInfoKeyToHostMap, String testSubCategory) { From 3226047ced6eaffda58b504fd2a63ad7b041b2fb Mon Sep 17 00:00:00 2001 From: notshivansh Date: Mon, 13 Nov 2023 13:24:15 +0530 Subject: [PATCH 02/11] insert every result --- .../src/main/java/com/akto/testing/TestExecutor.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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 837ae4c7ca..4cc3103569 100644 --- a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java @@ -522,12 +522,12 @@ public void startTestNew(ApiInfo.ApiInfoKey apiInfoKey, ObjectId testRunId, TestingRunConfig testingRunConfig, TestingUtil testingUtil, ObjectId testRunResultSummaryId, Map testConfigMap, ConcurrentHashMap subCategoryEndpointMap, Map apiInfoKeyToHostMap) { - List testingRunResults = new ArrayList<>(); List testSubCategories = testingRunConfig == null ? new ArrayList<>() : testingRunConfig.getTestSubCategoryList(); - int random = (int) ( ( Math.random() * 10 ) + 4); for (String testSubCategory: testSubCategories) { + List testingRunResults = new ArrayList<>(); + TestConfig testConfig = testConfigMap.get(testSubCategory); if (testConfig == null) continue; TestingRunResult testingRunResult = null; @@ -542,12 +542,6 @@ public void startTestNew(ApiInfo.ApiInfoKey apiInfoKey, ObjectId testRunId, } if (testingRunResult != null) testingRunResults.add(testingRunResult); - if (!testingRunResults.isEmpty() && testingRunResults.size() % random == 0) { - insertResultsAndMakeIssues(testingRunResults); - } - } - - if(!testingRunResults.isEmpty()){ insertResultsAndMakeIssues(testingRunResults); } From 2f8aed92622b2019314b85dc1b7f1952c61eb02e Mon Sep 17 00:00:00 2001 From: notshivansh Date: Tue, 14 Nov 2023 13:37:32 +0530 Subject: [PATCH 03/11] load only 1MB of response in memory --- apps/testing/src/main/java/com/akto/testing/ApiExecutor.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/testing/src/main/java/com/akto/testing/ApiExecutor.java b/apps/testing/src/main/java/com/akto/testing/ApiExecutor.java index 1e6731fb7e..831a073e34 100644 --- a/apps/testing/src/main/java/com/akto/testing/ApiExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/ApiExecutor.java @@ -21,6 +21,9 @@ public class ApiExecutor { private static final LoggerMaker loggerMaker = new LoggerMaker(ApiExecutor.class); + // Load only first 1 MiB of response body into memory. + private static final int MAX_RESPONSE_SIZE = 1024*1024; + private static OriginalHttpResponse common(Request request, boolean followRedirects) throws Exception { Integer accountId = Context.accountId.get(); @@ -51,7 +54,7 @@ private static OriginalHttpResponse common(Request request, boolean followRedire String body; try { response = call.execute(); - ResponseBody responseBody = response.body(); + ResponseBody responseBody = response.peekBody(MAX_RESPONSE_SIZE); if (responseBody == null) { throw new Exception("Couldn't read response body"); } From e4510ac2797629480b9de7c7024a85fe379097af Mon Sep 17 00:00:00 2001 From: notshivansh Date: Tue, 14 Nov 2023 17:13:26 +0530 Subject: [PATCH 04/11] optimize summary update query --- .../java/com/akto/testing/TestExecutor.java | 41 +++++++++++++------ .../akto/dto/testing/GenericTestResult.java | 1 + 2 files changed, 29 insertions(+), 13 deletions(-) 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 4cc3103569..75831d5f20 100644 --- a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java @@ -36,9 +36,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.mongodb.BasicDBObject; +import com.mongodb.client.model.Aggregates; import com.mongodb.client.model.Filters; import com.mongodb.client.model.Projections; +import com.mongodb.client.model.Sorts; import com.mongodb.client.model.Updates; + +import org.bson.conversions.Bson; import org.bson.types.ObjectId; import org.json.JSONObject; import org.mortbay.util.ajax.JSON; @@ -246,25 +250,36 @@ public static void updateTestSummary(ObjectId summaryId){ int skip = 0; int limit = 1000; boolean fetchMore = false; + BasicDBObject computedProjection = new BasicDBObject(GenericTestResult._CONFIDENCE, + new BasicDBObject("$first", "$testResults.confidence")); + String computedFieldName = GenericTestResult._CONFIDENCE; + do { fetchMore = false; - List testingRunResults = TestingRunResultDao.instance - .fetchLatestTestingRunResult( - Filters.and( - Filters.eq(TestingRunResult.TEST_RUN_RESULT_SUMMARY_ID, summaryId), - Filters.eq(TestingRunResult.VULNERABLE, true)), - limit, - skip, - Projections.include( - TestingRunResult.TEST_RESULTS)); + List pipeline = new ArrayList<>(); + pipeline.add(Aggregates.match( + Filters.and( + Filters.eq(TestingRunResult.TEST_RUN_RESULT_SUMMARY_ID, summaryId), + Filters.eq(TestingRunResult.VULNERABLE, true)))); + pipeline.add(Aggregates.project( + Projections.computed(computedFieldName,computedProjection))); + pipeline.add(Aggregates.sort(Sorts.descending(Constants.ID))); + pipeline.add(Aggregates.skip(skip)); + pipeline.add(Aggregates.limit(limit)); + List testingRunResults = TestingRunResultDao.instance.getMCollection().aggregate(pipeline, BasicDBObject.class).into(new ArrayList<>()); loggerMaker.infoAndAddToDb("Reading " + testingRunResults.size() + " vulnerable testingRunResults", LogDb.TESTING); - for (TestingRunResult testingRunResult : testingRunResults) { - String severity = getSeverityFromTestingRunResult(testingRunResult).toString(); - int initialCount = totalCountIssues.get(severity); - totalCountIssues.put(severity, initialCount + 1); + for (BasicDBObject testingRunResult : testingRunResults) { + Severity severity = Severity.HIGH; + try { + Confidence confidence = Confidence.valueOf(testingRunResult.getString(computedFieldName)); + severity = Severity.valueOf(confidence.toString()); + } catch (Exception e) { + } + int initialCount = totalCountIssues.get(severity.toString()); + totalCountIssues.put(severity.toString(), initialCount + 1); } if (testingRunResults.size() == limit) { diff --git a/libs/dao/src/main/java/com/akto/dto/testing/GenericTestResult.java b/libs/dao/src/main/java/com/akto/dto/testing/GenericTestResult.java index 7791ef5bfa..42c041427a 100644 --- a/libs/dao/src/main/java/com/akto/dto/testing/GenericTestResult.java +++ b/libs/dao/src/main/java/com/akto/dto/testing/GenericTestResult.java @@ -5,6 +5,7 @@ public class GenericTestResult { private boolean vulnerable; + public static final String _CONFIDENCE = "confidence"; private Confidence confidence = Confidence.HIGH; public GenericTestResult() { From 9bcaec88e07290273ed7740fdb885a117281492c Mon Sep 17 00:00:00 2001 From: notshivansh Date: Fri, 17 Nov 2023 22:15:23 +0530 Subject: [PATCH 05/11] save more relevant error messages instead of generic messages --- .../java/com/akto/test_editor/execution/Executor.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/testing/src/main/java/com/akto/test_editor/execution/Executor.java b/apps/testing/src/main/java/com/akto/test_editor/execution/Executor.java index 361ddb2aa6..14c8543d94 100644 --- a/apps/testing/src/main/java/com/akto/test_editor/execution/Executor.java +++ b/apps/testing/src/main/java/com/akto/test_editor/execution/Executor.java @@ -50,6 +50,8 @@ public List execute(ExecutorNode node, RawApi rawApi, Map error_messages = new ArrayList<>(); + for (ExecutorNode reqNode: reqNodes.getChildNodes()) { // make copy of varMap as well List sampleRawApis = new ArrayList<>(); @@ -59,6 +61,7 @@ public List execute(ExecutorNode node, RawApi rawApi, Map testRawApis = new ArrayList<>(); testRawApis = singleReq.getRawApis(); if (testRawApis == null) { + error_messages.add(singleReq.getErrMsg()); continue; } boolean vulnerable = false; @@ -77,6 +80,7 @@ public List execute(ExecutorNode node, RawApi rawApi, Map execute(ExecutorNode node, RawApi rawApi, Map Date: Mon, 20 Nov 2023 18:57:29 +0530 Subject: [PATCH 06/11] fix summary result count bug --- apps/testing/src/main/java/com/akto/testing/TestExecutor.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 75831d5f20..5e6bcdc5e7 100644 --- a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java @@ -261,8 +261,7 @@ public static void updateTestSummary(ObjectId summaryId){ Filters.and( Filters.eq(TestingRunResult.TEST_RUN_RESULT_SUMMARY_ID, summaryId), Filters.eq(TestingRunResult.VULNERABLE, true)))); - pipeline.add(Aggregates.project( - Projections.computed(computedFieldName,computedProjection))); + pipeline.add(Aggregates.project(computedProjection)); pipeline.add(Aggregates.sort(Sorts.descending(Constants.ID))); pipeline.add(Aggregates.skip(skip)); pipeline.add(Aggregates.limit(limit)); From 8446a8287de357d99b0b804df5b70e1e1311a9e9 Mon Sep 17 00:00:00 2001 From: notshivansh Date: Tue, 21 Nov 2023 12:20:42 +0530 Subject: [PATCH 07/11] remove unsupported operation --- .../java/com/akto/testing/TestExecutor.java | 35 +++++++------------ .../akto/dao/testing/TestingRunResultDao.java | 3 ++ 2 files changed, 15 insertions(+), 23 deletions(-) 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 5e6bcdc5e7..183eca1df4 100644 --- a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java @@ -250,35 +250,24 @@ public static void updateTestSummary(ObjectId summaryId){ int skip = 0; int limit = 1000; boolean fetchMore = false; - BasicDBObject computedProjection = new BasicDBObject(GenericTestResult._CONFIDENCE, - new BasicDBObject("$first", "$testResults.confidence")); - String computedFieldName = GenericTestResult._CONFIDENCE; - do { fetchMore = false; - List pipeline = new ArrayList<>(); - pipeline.add(Aggregates.match( - Filters.and( - Filters.eq(TestingRunResult.TEST_RUN_RESULT_SUMMARY_ID, summaryId), - Filters.eq(TestingRunResult.VULNERABLE, true)))); - pipeline.add(Aggregates.project(computedProjection)); - pipeline.add(Aggregates.sort(Sorts.descending(Constants.ID))); - pipeline.add(Aggregates.skip(skip)); - pipeline.add(Aggregates.limit(limit)); - List testingRunResults = TestingRunResultDao.instance.getMCollection().aggregate(pipeline, BasicDBObject.class).into(new ArrayList<>()); + List testingRunResults = TestingRunResultDao.instance + .fetchLatestTestingRunResult( + Filters.and( + Filters.eq(TestingRunResult.TEST_RUN_RESULT_SUMMARY_ID, summaryId), + Filters.eq(TestingRunResult.VULNERABLE, true)), + limit, + skip, + Projections.include("testResults.confidence")); loggerMaker.infoAndAddToDb("Reading " + testingRunResults.size() + " vulnerable testingRunResults", LogDb.TESTING); - for (BasicDBObject testingRunResult : testingRunResults) { - Severity severity = Severity.HIGH; - try { - Confidence confidence = Confidence.valueOf(testingRunResult.getString(computedFieldName)); - severity = Severity.valueOf(confidence.toString()); - } catch (Exception e) { - } - int initialCount = totalCountIssues.get(severity.toString()); - totalCountIssues.put(severity.toString(), initialCount + 1); + for (TestingRunResult testingRunResult : testingRunResults) { + String severity = getSeverityFromTestingRunResult(testingRunResult).toString(); + int initialCount = totalCountIssues.get(severity); + totalCountIssues.put(severity, initialCount + 1); } if (testingRunResults.size() == limit) { diff --git a/libs/dao/src/main/java/com/akto/dao/testing/TestingRunResultDao.java b/libs/dao/src/main/java/com/akto/dao/testing/TestingRunResultDao.java index 65990ecf12..51efd161f1 100644 --- a/libs/dao/src/main/java/com/akto/dao/testing/TestingRunResultDao.java +++ b/libs/dao/src/main/java/com/akto/dao/testing/TestingRunResultDao.java @@ -1,6 +1,7 @@ package com.akto.dao.testing; import com.akto.dao.AccountsContextDao; +import com.akto.dao.MCollection; import com.akto.dao.context.Context; import com.akto.dto.ApiInfo; import com.akto.dto.testing.TestingRunResult; @@ -87,6 +88,8 @@ public void createIndicesIfAbsent() { Bson summaryIndex = Indexes.descending(Arrays.asList(TestingRunResult.TEST_RUN_RESULT_SUMMARY_ID, Constants.ID)); createIndexIfAbsent(dbName, getCollName(), summaryIndex, new IndexOptions().name("testRunResultSummaryId_-1__id_-1")); + MCollection.createIndexIfAbsent(getDBName(), getCollName(), + new String[] { TestingRunResult.TEST_RUN_RESULT_SUMMARY_ID, TestingRunResult.VULNERABLE, Constants.ID }, false); } } From ea1dfac30fd667797cef435316566419ede076e4 Mon Sep 17 00:00:00 2001 From: notshivansh Date: Tue, 21 Nov 2023 12:43:07 +0530 Subject: [PATCH 08/11] set default max concurrent requests to 10 instead of 100 --- apps/testing/src/main/java/com/akto/testing/TestExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 183eca1df4..26ee553df2 100644 --- a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java @@ -114,7 +114,7 @@ public void workflowInit (TestingRun testingRun, ObjectId summaryId) { public void apiWiseInit(TestingRun testingRun, ObjectId summaryId) { int accountId = Context.accountId.get(); int now = Context.now(); - int maxConcurrentRequests = testingRun.getMaxConcurrentRequests() > 0 ? testingRun.getMaxConcurrentRequests() : 100; + int maxConcurrentRequests = testingRun.getMaxConcurrentRequests() > 0 ? Math.min( testingRun.getMaxConcurrentRequests(), 100) : 10; TestingEndpoints testingEndpoints = testingRun.getTestingEndpoints(); SampleMessageStore sampleMessageStore = SampleMessageStore.create(); From a47455bee455ef6b8e5f3d6a55922d620c3a36cb Mon Sep 17 00:00:00 2001 From: aktoboy Date: Tue, 28 Nov 2023 08:39:41 +0530 Subject: [PATCH 09/11] Added changes to blacklist some events --- apps/dashboard/web/polaris_web/web/src/util/request.js | 3 ++- apps/dashboard/web/src/util/request.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/dashboard/web/polaris_web/web/src/util/request.js b/apps/dashboard/web/polaris_web/web/src/util/request.js index c2cc48dfb7..e935508b48 100644 --- a/apps/dashboard/web/polaris_web/web/src/util/request.js +++ b/apps/dashboard/web/polaris_web/web/src/util/request.js @@ -99,8 +99,9 @@ service.interceptors.response.use((response) => { return response.data }, err) +const black_list_apis = ['dashboard/accesstoken', 'api/fetchBurpPluginInfo', 'api/fetchActiveLoaders', 'api/fetchAllSubCategories'] async function raiseMixpanelEvent(api) { - if (api && api.indexOf("/api/fetchActiveLoaders") == -1) { + if (api && !black_list_apis.some(black_list_api => api.includes(black_list_api))) { window.mixpanel.track(api) } } diff --git a/apps/dashboard/web/src/util/request.js b/apps/dashboard/web/src/util/request.js index 0ab1cf3329..696e93d95e 100644 --- a/apps/dashboard/web/src/util/request.js +++ b/apps/dashboard/web/src/util/request.js @@ -135,9 +135,10 @@ service.interceptors.response.use((response) => { return response.data }, err) +const black_list_apis = ['dashboard/accesstoken', 'api/fetchBurpPluginInfo', 'api/fetchActiveLoaders', 'api/fetchAllSubCategories'] async function raiseMixpanelEvent(api){ - if (api && api.indexOf("/api/fetchActiveLoaders")==-1) { - window.mixpanel.track(api) + if (api && !black_list_apis.some(black_list_api => api.includes(black_list_api))) { + window.mixpanel.track(api); } } From fec9877ac498e815ebb52fd2a4c7ea1e4bcfa219 Mon Sep 17 00:00:00 2001 From: Shivansh Agrawal <112413532+notshivansh@users.noreply.github.com> Date: Tue, 28 Nov 2023 14:18:46 +0530 Subject: [PATCH 10/11] Update Executor.java spell check --- .../main/java/com/akto/test_editor/execution/Executor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/testing/src/main/java/com/akto/test_editor/execution/Executor.java b/apps/testing/src/main/java/com/akto/test_editor/execution/Executor.java index 14c8543d94..585d628d6a 100644 --- a/apps/testing/src/main/java/com/akto/test_editor/execution/Executor.java +++ b/apps/testing/src/main/java/com/akto/test_editor/execution/Executor.java @@ -80,8 +80,8 @@ public List execute(ExecutorNode node, RawApi rawApi, Map Date: Tue, 28 Nov 2023 14:33:42 +0530 Subject: [PATCH 11/11] add count check --- .../java/com/akto/testing/TestExecutor.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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 26ee553df2..a4af4dcc69 100644 --- a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java @@ -510,15 +510,17 @@ public void trim(List testingRunResults) { } public void insertResultsAndMakeIssues(List testingRunResults) { - String size = testingRunResults.size() + ""; - loggerMaker.infoAndAddToDb("testingRunResults size: " + size, LogDb.TESTING); - trim(testingRunResults); - TestingRunResultDao.instance.insertMany(testingRunResults); - loggerMaker.infoAndAddToDb("Inserted testing results", LogDb.TESTING); - TestingIssuesHandler handler = new TestingIssuesHandler(); - boolean triggeredByTestEditor = false; - handler.handleIssuesCreationFromTestingRunResults(testingRunResults, triggeredByTestEditor); - testingRunResults.clear(); + int resultSize = testingRunResults.size(); + if (resultSize > 0) { + loggerMaker.infoAndAddToDb("testingRunResults size: " + resultSize, LogDb.TESTING); + trim(testingRunResults); + TestingRunResultDao.instance.insertMany(testingRunResults); + loggerMaker.infoAndAddToDb("Inserted testing results", LogDb.TESTING); + TestingIssuesHandler handler = new TestingIssuesHandler(); + boolean triggeredByTestEditor = false; + handler.handleIssuesCreationFromTestingRunResults(testingRunResults, triggeredByTestEditor); + testingRunResults.clear(); + } } public void startTestNew(ApiInfo.ApiInfoKey apiInfoKey, ObjectId testRunId,