From d5762cfe9872bc0cfb3720cb35e626fb0e7f4bb8 Mon Sep 17 00:00:00 2001 From: Umesh Kumar <166806589+TangoBeeAkto@users.noreply.github.com> Date: Fri, 13 Dec 2024 23:32:10 +0530 Subject: [PATCH 1/3] fix: creating jira ticket with a unique title --- .../com/akto/action/JiraIntegrationAction.java | 16 ++++++---------- .../src/main/java/com/akto/utils/Utils.java | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java b/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java index 24187c1e21..40a1747d83 100644 --- a/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java +++ b/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java @@ -1,17 +1,10 @@ package com.akto.action; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.TimeUnit; +import com.akto.utils.Utils; import org.apache.commons.io.FileUtils; import org.bson.conversions.Bson; @@ -199,8 +192,11 @@ public String createIssue() { BasicDBObject reqPayload = new BasicDBObject(); BasicDBObject fields = new BasicDBObject(); + String endpoint = jiraMetaData.getEndPointStr().replace("Endpoint - ", ""); + String lastPartOfEndpoint = endpoint.length() > 30 ? endpoint.substring(endpoint.length() - 30) : endpoint; + // issue title - fields.put("summary", "Akto Report - " + jiraMetaData.getIssueTitle()); + fields.put("summary", "Akto Report - " + jiraMetaData.getIssueTitle() + " - " + lastPartOfEndpoint + " - " + Utils.generateRandomString(3)); jiraIntegration = JiraIntegrationDao.instance.findOne(new BasicDBObject()); // issue type (TASK) 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 9f74d7cd21..deee985f67 100644 --- a/apps/dashboard/src/main/java/com/akto/utils/Utils.java +++ b/apps/dashboard/src/main/java/com/akto/utils/Utils.java @@ -627,4 +627,18 @@ public static List getUniqueValuesOfList(List input){ return input; } + public static String generateRandomString(int length) { + String characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + Random random = new Random(); + StringBuilder result = new StringBuilder(); + + for (int i = 0; i < length; i++) { + int randomIndex = random.nextInt(characters.length()); + result.append(characters.charAt(randomIndex)); + } + + return result.toString(); + } + } From a5016664d7fef6f382a2d3481564249af7f438b8 Mon Sep 17 00:00:00 2001 From: Umesh Kumar <166806589+TangoBeeAkto@users.noreply.github.com> Date: Sat, 14 Dec 2024 11:28:44 +0530 Subject: [PATCH 2/3] fix: changing the jira ticket title format (adding endpoint) --- .../com/akto/action/JiraIntegrationAction.java | 3 +-- .../src/main/java/com/akto/utils/Utils.java | 15 --------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java b/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java index 40a1747d83..26963c575d 100644 --- a/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java +++ b/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java @@ -4,7 +4,6 @@ import java.util.*; import java.util.concurrent.TimeUnit; -import com.akto.utils.Utils; import org.apache.commons.io.FileUtils; import org.bson.conversions.Bson; @@ -196,7 +195,7 @@ public String createIssue() { String lastPartOfEndpoint = endpoint.length() > 30 ? endpoint.substring(endpoint.length() - 30) : endpoint; // issue title - fields.put("summary", "Akto Report - " + jiraMetaData.getIssueTitle() + " - " + lastPartOfEndpoint + " - " + Utils.generateRandomString(3)); + fields.put("summary", "Akto Report - " + jiraMetaData.getIssueTitle() + " - " + lastPartOfEndpoint); jiraIntegration = JiraIntegrationDao.instance.findOne(new BasicDBObject()); // issue type (TASK) 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 deee985f67..5646ed3700 100644 --- a/apps/dashboard/src/main/java/com/akto/utils/Utils.java +++ b/apps/dashboard/src/main/java/com/akto/utils/Utils.java @@ -626,19 +626,4 @@ public static List getUniqueValuesOfList(List input){ input.addAll(copySet); return input; } - - public static String generateRandomString(int length) { - String characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - Random random = new Random(); - StringBuilder result = new StringBuilder(); - - for (int i = 0; i < length; i++) { - int randomIndex = random.nextInt(characters.length()); - result.append(characters.charAt(randomIndex)); - } - - return result.toString(); - } - } From 81c5d1e2cd26ec253f5a6e8e479ce82e8c4b6bc8 Mon Sep 17 00:00:00 2001 From: Umesh Kumar <166806589+TangoBeeAkto@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:06:42 +0530 Subject: [PATCH 3/3] refactor: change in jira issue title --- .../main/java/com/akto/action/JiraIntegrationAction.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java b/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java index 26963c575d..8c59b635f7 100644 --- a/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java +++ b/apps/dashboard/src/main/java/com/akto/action/JiraIntegrationAction.java @@ -192,10 +192,15 @@ public String createIssue() { BasicDBObject fields = new BasicDBObject(); String endpoint = jiraMetaData.getEndPointStr().replace("Endpoint - ", ""); - String lastPartOfEndpoint = endpoint.length() > 30 ? endpoint.substring(endpoint.length() - 30) : endpoint; + String truncatedEndpoint = endpoint; + if(endpoint.length() > 30) { + truncatedEndpoint = endpoint.substring(0, 15) + "..." + endpoint.substring(endpoint.length() - 15); + } + + String endpointMethod = jiraMetaData.getTestingIssueId().getApiInfoKey().getMethod().name(); // issue title - fields.put("summary", "Akto Report - " + jiraMetaData.getIssueTitle() + " - " + lastPartOfEndpoint); + fields.put("summary", "Akto Report - " + jiraMetaData.getIssueTitle() + " (" + endpointMethod + " - " + truncatedEndpoint + ")"); jiraIntegration = JiraIntegrationDao.instance.findOne(new BasicDBObject()); // issue type (TASK)