Skip to content

Conversation

@arcoraven
Copy link
Contributor

@arcoraven arcoraven commented Oct 30, 2024

PR-Codex overview

This PR focuses on updating the webhook functionality to enforce stricter URL validation and improve the clarity of webhook-related code. It renames functions and modifies schemas to ensure only valid HTTPS URLs are accepted.

Detailed summary

  • Changed active property assignment in webhook.ts to simplify logic.
  • Renamed isValidHttpUrl to isValidWebhookUrl in validator.ts.
  • Updated URL validation logic to restrict to HTTPS and localhost for HTTP.
  • Updated addContractSubscription.ts to use the new isValidWebhookUrl function.
  • Renamed createWebhook to createWebhookRoute in route files.
  • Adjusted webhook URL examples in create.ts to reflect new validation rules.
  • Added unit tests for isValidWebhookUrl in validator.test.ts.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

const url = new URL(urlString);
return url.protocol === "http:" || url.protocol === "https:";
const url = new URL(input);
return url.protocol === "https:";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removes http: as a valid protocol

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we still allow 0.0.0.0/127.0.0.1 and localhost?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think this is reasonable.

@arcoraven arcoraven enabled auto-merge (squash) October 30, 2024 20:25
@arcoraven arcoraven merged commit 742e590 into main Oct 30, 2024
5 checks passed
@arcoraven arcoraven deleted the ph/enforceHttpsWebhookUrl branch October 30, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants