garyxuehong / gh4j

MIT License
0 stars 0 forks source link

sweep: put secret_scanning_alert events into queue before processing #4

Open garyxuehong opened 5 months ago

garyxuehong commented 5 months ago

The event processing in webhook-receive-post is not putting events "secret_scanning_alert" into queue, like "push" queue in queue.ts. This will risk lost of events "secret_scanning_alert".

Task:

  1. Put "secret_scanning_alert" events into a new queue. Please refer to "push" as example.
  2. In queue.ts, create new queue for the "secret_scanning_alert" events and copy the handling logic for "secret_scanning_alert" in webhook-receive-post.ts into queue.ts
Checklist - [X] Create `src/sqs/secret-scanning-alert.ts` ✓ https://github.com/garyxuehong/gh4j/commit/b7e8720751f5cc70edd7e5ae9519e295ddd5e1b3 [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/secret-scanning-alert.ts) - [X] Running GitHub Actions for `src/sqs/secret-scanning-alert.ts` ✓ [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/secret-scanning-alert.ts) - [X] Create `src/sqs/secret-scanning-alert.test.ts` ✓ https://github.com/garyxuehong/gh4j/commit/0ecc70d702d07918740b06deae759626c2d9c5ed [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/secret-scanning-alert.test.ts) - [X] Running GitHub Actions for `src/sqs/secret-scanning-alert.test.ts` ✓ [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/secret-scanning-alert.test.ts) - [X] Modify `src/sqs/queues.ts` ✓ https://github.com/garyxuehong/gh4j/commit/0b7cc97d1b90d9fbf84671116c61eec72df4ec3d [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/queues.ts#L41-L77) - [X] Running GitHub Actions for `src/sqs/queues.ts` ✓ [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/queues.ts#L41-L77) - [X] Modify `src/routes/github/webhook/webhook-receiver-post.ts` ✓ https://github.com/garyxuehong/gh4j/commit/10b0f1f7f48153da7e730651024ccf5b7d7c5855 [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/routes/github/webhook/webhook-receiver-post.ts#L27-L150) - [X] Running GitHub Actions for `src/routes/github/webhook/webhook-receiver-post.ts` ✓ [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/routes/github/webhook/webhook-receiver-post.ts#L27-L150)
sweep-ai[bot] commented 5 months ago

🚀 Here's the PR! #5

See Sweep's progress at the progress dashboard!
Sweep Basic Tier: I'm using GPT-4. You have 1 GPT-4 tickets left for the month and 2 for the day. (tracking ID: 799ce05856)

For more GPT-4 tickets, visit our payment portal. For a one week free trial, try Sweep Pro (unlimited GPT-4 tickets).
Install Sweep Configs: Pull Request

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)

GitHub Actions✓

Here are the GitHub Actions logs prior to making any changes:

Sandbox logs for 2ba9db4
Checking src/sqs/queues.ts for syntax errors... ✅ src/sqs/queues.ts has no syntax errors! 1/1 ✓
Checking src/sqs/queues.ts for syntax errors...
✅ src/sqs/queues.ts has no syntax errors!

Sandbox passed on the latest main, so sandbox checks will be enabled for this issue.


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/garyxuehong/gh4j/blob/2ba9db45793d4a6ed5db9376095fbee383a7cf8f/src/routes/github/webhook/webhook-receiver-post.ts#L27-L150 https://github.com/garyxuehong/gh4j/blob/2ba9db45793d4a6ed5db9376095fbee383a7cf8f/src/sqs/queues.ts#L41-L77

Step 2: ⌨️ Coding

Ran GitHub Actions for b7e8720751f5cc70edd7e5ae9519e295ddd5e1b3:

Ran GitHub Actions for 0ecc70d702d07918740b06deae759626c2d9c5ed:

--- 
+++ 
@@ -8,6 +8,7 @@
 import { branchQueueMessageHandler } from "./branch";
 import { getLogger } from "config/logger";
 import type { BackfillMessagePayload, PushQueueMessagePayload, DeploymentMessagePayload, BranchMessagePayload } from "./sqs.types";
+import { SecretScanningAlertMessagePayload, secretScanningAlertQueueMessageHandler } from "./secret-scanning-alert";
 import { backfillErrorHandler } from "~/src/sqs/backfill-error-handler";

 const LONG_POLLING_INTERVAL_SEC = 3;
@@ -75,6 +76,15 @@
    webhookMetricWrapper(jiraAndGitHubErrorsHandler, "create")
    ),

+   secret_scanning_alert: new SqsQueue({
+       queueName: "secret_scanning_alert",
+       queueUrl: envVars.SQS_SECRET_SCANNING_ALERT_QUEUE_URL,
+       queueRegion: envVars.SQS_SECRET_SCANNING_ALERT_QUEUE_REGION,
+       longPollingIntervalSec: LONG_POLLING_INTERVAL_SEC,
+       timeoutSec: 60,
+       maxAttempts: 5
+   }, secretScanningAlertQueueMessageHandler, webhookMetricWrapper(jiraAndGitHubErrorsHandler, "secret_scanning_alert")),
+
    start: () => {
        logger.info("Starting queues");
        sqsQueues.backfill.start();

Ran GitHub Actions for 0b7cc97d1b90d9fbf84671116c61eec72df4ec3d:

--- 
+++ 
@@ -140,7 +140,7 @@
            await GithubWebhookMiddleware(dependabotAlertWebhookHandler)(context);
            break;
        case "secret_scanning_alert":
-           await GithubWebhookMiddleware(secretScanningAlertWebhookHandler)(context);
+           await sqsQueues.secret_scanning_alert.sendMessage(payload);
            break;
        case "installation":
            if (context.action === "new_permissions_accepted") {

Ran GitHub Actions for 10b0f1f7f48153da7e730651024ccf5b7d7c5855:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/put_secret_scanning_alert_events_into_qu.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.Something wrong? Let us know.

This is an automated message generated by Sweep AI.