Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main inline with next #399

Merged
merged 4 commits into from
Nov 9, 2024
Merged

main inline with next #399

merged 4 commits into from
Nov 9, 2024

Conversation

potts99
Copy link
Collaborator

@potts99 potts99 commented Nov 9, 2024

No description provided.

* chore: add extra events (#397)

* chore: save logging to file

* chore: hide fields feature flags

* feat: right click context

* fix: hide scroll

* fix: create first issue tbn

* fix: portal nav fix

* fix: portal layout ui

* chore: code cleanuo

* chore: favicon

const url = webhook.url;

if (url.includes("discord.com")) {

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

'
discord.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.

Copilot Autofix AI 3 months ago

To fix the problem, we need to parse the URL and check its host against a whitelist of allowed hosts. This ensures that the URL is indeed pointing to a legitimate Discord domain and not a malicious one. We will use the url module from Node.js to parse the URL and then check the host.

  1. Import the url module.
  2. Parse the URL to extract the host.
  3. Check the host against a whitelist of allowed hosts.
Suggested changeset 1
apps/api/src/lib/notifications/webhook.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/api/src/lib/notifications/webhook.ts b/apps/api/src/lib/notifications/webhook.ts
--- a/apps/api/src/lib/notifications/webhook.ts
+++ b/apps/api/src/lib/notifications/webhook.ts
@@ -1,2 +1,3 @@
 import axios from "axios";
+import { URL } from "url";
 
@@ -19,4 +20,6 @@
   const url = webhook.url;
+  const parsedUrl = new URL(url);
+  const allowedHosts = ["discord.com", "www.discord.com"];
 
-  if (url.includes("discord.com")) {
+  if (allowedHosts.includes(parsedUrl.host)) {
     const discordMessage = {
EOF
@@ -1,2 +1,3 @@
import axios from "axios";
import { URL } from "url";

@@ -19,4 +20,6 @@
const url = webhook.url;
const parsedUrl = new URL(url);
const allowedHosts = ["discord.com", "www.discord.com"];

if (url.includes("discord.com")) {
if (allowedHosts.includes(parsedUrl.host)) {
const discordMessage = {
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link

vercel bot commented Nov 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Updated (UTC)
docs ⬜️ Skipped (Inspect) Nov 9, 2024 3:26pm
peppermint ⬜️ Skipped (Inspect) Nov 9, 2024 3:26pm

@potts99 potts99 merged commit 7cbda17 into next Nov 9, 2024
4 of 5 checks passed
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.

1 participant