From f44c9b5e39700e3805aa4d88937e036c67a5bac2 Mon Sep 17 00:00:00 2001 From: Martin Lowe <martin.lowe@eclipse-foundation.org> Date: Tue, 7 Mar 2023 11:19:28 -0500 Subject: [PATCH 1/3] Add strict mode flag for GH webhook (re)processing Currently, if a request comes in from the webhook, we should be strict for all requests to get actual results rather than results with warnings. --- docker-compose.yaml | 1 + .../git/eca/resource/GithubWebhooksResource.java | 1 + 2 files changed, 2 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index b2ccfea7..afef8ecd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,6 +9,7 @@ services: - CONFIG_SECRET_PATH=/var/run/secrets/secret.properties volumes: - ./config/application/secret.properties:/var/run/secrets/secret.properties + - ./config/application/pubkey.pem:/var/run/secrets/pubkey.pem depends_on: - "mariadb" deploy: diff --git a/src/main/java/org/eclipsefoundation/git/eca/resource/GithubWebhooksResource.java b/src/main/java/org/eclipsefoundation/git/eca/resource/GithubWebhooksResource.java index 96cebffb..aae67d2d 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/resource/GithubWebhooksResource.java +++ b/src/main/java/org/eclipsefoundation/git/eca/resource/GithubWebhooksResource.java @@ -303,6 +303,7 @@ public class GithubWebhooksResource { .builder() .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create(repositoryUrl)) + .setStrictMode(true) .setCommits(commits .stream() .map(c -> Commit -- GitLab From f6c36fdcb77bd7131f6512bd602a5965a8e335ef Mon Sep 17 00:00:00 2001 From: Martin Lowe <martin.lowe@eclipse-foundation.org> Date: Tue, 7 Mar 2023 11:47:29 -0500 Subject: [PATCH 2/3] Update redirect for revalidation to use 302 instead of 307 --- .../git/eca/resource/GithubWebhooksResource.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/eclipsefoundation/git/eca/resource/GithubWebhooksResource.java b/src/main/java/org/eclipsefoundation/git/eca/resource/GithubWebhooksResource.java index aae67d2d..fd87bdf7 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/resource/GithubWebhooksResource.java +++ b/src/main/java/org/eclipsefoundation/git/eca/resource/GithubWebhooksResource.java @@ -26,6 +26,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.rest.client.inject.RestClient; @@ -170,7 +171,7 @@ public class GithubWebhooksResource { sb.append("/pull/"); sb.append(tracking.getPullRequestNumber()); // redirect to the pull request page on successful trigger of the webhook - return Response.temporaryRedirect(URI.create(sb.toString())).build(); + return Response.status(Status.FOUND).location(URI.create(sb.toString())).build(); } /** -- GitLab From 6f236f3c2bdd76a0a0301be67eb75e0f3c07243b Mon Sep 17 00:00:00 2001 From: Martin Lowe <martin.lowe@eclipse-foundation.org> Date: Tue, 7 Mar 2023 13:37:40 -0500 Subject: [PATCH 3/3] Change validation response to use warn for non-project when not strict There are errors where errors aren't properly getting tracked when strict mode is off for non-projects. By enabling this, when strict mode is enabled for request all errors will be treated as errors on server side as well, where before it was mainly for client side flagging. --- .../org/eclipsefoundation/git/eca/model/ValidationResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/eclipsefoundation/git/eca/model/ValidationResponse.java b/src/main/java/org/eclipsefoundation/git/eca/model/ValidationResponse.java index fbd297a1..54a9f821 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/model/ValidationResponse.java +++ b/src/main/java/org/eclipsefoundation/git/eca/model/ValidationResponse.java @@ -85,7 +85,7 @@ public abstract class ValidationResponse { /** @param error message to add to the API response */ public void addError(String hash, String error, APIStatusCode code) { - if (getTrackedProject()) { + if (this.getTrackedProject() || this.getStrictMode()) { getCommits().computeIfAbsent(getHashKey(hash), k -> CommitStatus.builder().build()).addError(error, code); } else { addWarning(hash, error, code); -- GitLab