diff options
author | Klaudio Sinani <klaudio.sinani@sonarsource.com> | 2022-09-07 20:04:45 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-09-19 20:03:08 +0000 |
commit | 9b2ed40b6a3bbb79c8cf01e491703d683d9f9769 (patch) | |
tree | 1bed372edb55539b6feb5b8141f093b96128c395 /server/sonar-alm-client | |
parent | 9d1fe387d11c2f27c8463b7bd05497ee1418c31d (diff) | |
download | sonarqube-9b2ed40b6a3bbb79c8cf01e491703d683d9f9769.tar.gz sonarqube-9b2ed40b6a3bbb79c8cf01e491703d683d9f9769.zip |
SONAR-17271 Introduce Github code scanning alert webhook payload parser
* 292a9c66137 SONAR-17271 Rename `GsonGithubWebhookPayload` class to `GsonGithubCodeScanningAlertWebhookPayload`.
* 0fcf756bc35 SONAR-17271 Rename `GithubWebhookPayload` indentifiers to `GithubScanningAlertWebhookPayload`.
* 9882b4f6705 SONAR-17271 Remove `GithubWebhookPayload#message` & `GithubWebhookPayload#toolName` properties.
* ba6834fef16 SONAR-17271 Validate builder parameters in `GithubWebhookPayload` constructor scope.
* 7250cb15b92 SONAR-17271 Allow `dismissedReason` property to be nullable.
* 870efb823e3 SONAR-17271 Introduce builder pattern to `GithubWebhookPayload` class.
* aa49dead5f0 SONAR-17271 Remove `GithubWebhookAction` enum.
* dda46050d40 SONAR-17271 Refactor `GithubWebhookPayloadTest` test class.
* 3a599896295 SONAR-17271 Rename `AlmWebhookPayload#getSonarIssueKey` supplier method to `AlmWebhookPayload#getSonarQubeIssueKey`.
* de04692e92d SONAR-17271 Drop `AlmWebhookPayload#isAllowedAction` predicate method.
* 597570d36b0 SONAR-17271 Refactor `GithubBinding` class structure.
* 3054bcedbac SONAR-17271 Fix typo on UT identifier.
* c89660c466b SONAR-17271 Introduce Github webhook payload parser.
Diffstat (limited to 'server/sonar-alm-client')
-rw-r--r-- | server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubBinding.java | 83 |
1 files changed, 73 insertions, 10 deletions
diff --git a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubBinding.java b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubBinding.java index d136e221917..b0cab0e10bb 100644 --- a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubBinding.java +++ b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubBinding.java @@ -164,8 +164,10 @@ public class GithubBinding { String dismissedReason; @SerializedName("dismissed_comment") String dismissedComment; + @SerializedName("tool") + GsonGithubCodeScanningAlertTool tool; @SerializedName("most_recent_instance") - GithubCodeScanningAlertInstance mostRecentInstance; + GsonGithubCodeScanningAlertInstance mostRecentInstance; public GsonGithubCodeScanningAlert() { // even if empty constructor is not required for Gson, it is strongly @@ -189,28 +191,59 @@ public class GithubBinding { return dismissedComment; } - public GithubCodeScanningAlertInstance getInstance() { + public GsonGithubCodeScanningAlertTool getTool() { + return tool; + } + + public GsonGithubCodeScanningAlertInstance getMostRecentInstance() { return mostRecentInstance; } public String getMessageText() { - return getInstance().getMessageText(); + return getMostRecentInstance().getMessageText(); + } + } + + public static class GsonGithubCodeScanningAlertWebhookPayload { + @SerializedName("action") + String action; + @SerializedName("alert") + GsonGithubCodeScanningAlert alert; + @SerializedName("sender") + GsonGithubCodeScanningAlertWebhookPayloadSender sender; + + public GsonGithubCodeScanningAlertWebhookPayload() { + // even if empty constructor is not required for Gson, it is strongly + // recommended: + // http://stackoverflow.com/a/18645370/229031 + } + + public String getAction() { + return action; + } + + public GsonGithubCodeScanningAlert getAlert() { + return alert; + } + + public GsonGithubCodeScanningAlertWebhookPayloadSender getSender() { + return sender; } } - public static class GithubCodeScanningAlertInstance { + public static class GsonGithubCodeScanningAlertInstance { @SerializedName("state") GithubCodeScanningAlertState state; @SerializedName("message") - Message message; + GsonGithubCodeScanningAlertMessage message; - public GithubCodeScanningAlertInstance() { + public GsonGithubCodeScanningAlertInstance() { // even if empty constructor is not required for Gson, it is strongly // recommended: // http://stackoverflow.com/a/18645370/229031 } - public Message getMessage() { + public GsonGithubCodeScanningAlertMessage getMessage() { return message; } @@ -225,14 +258,14 @@ public class GithubBinding { @SerializedName("fixed") FIXED, @SerializedName("dismissed") - DISMISSED; + DISMISSED } - public static class Message { + public static class GsonGithubCodeScanningAlertMessage { @SerializedName("text") String text; - public Message() { + public GsonGithubCodeScanningAlertMessage() { // even if empty constructor is not required for Gson, it is strongly // recommended: // http://stackoverflow.com/a/18645370/229031 @@ -242,4 +275,34 @@ public class GithubBinding { return text; } } + + public static class GsonGithubCodeScanningAlertWebhookPayloadSender { + @SerializedName("login") + String login; + + public GsonGithubCodeScanningAlertWebhookPayloadSender() { + // even if empty constructor is not required for Gson, it is strongly + // recommended: + // http://stackoverflow.com/a/18645370/229031 + } + + public String getLogin() { + return login; + } + } + + public static class GsonGithubCodeScanningAlertTool { + @SerializedName("name") + String name; + + public GsonGithubCodeScanningAlertTool() { + // even if empty constructor is not required for Gson, it is strongly + // recommended: + // http://stackoverflow.com/a/18645370/229031 + } + + public String getName() { + return name; + } + } } |