Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/app/api/integrations/jira/credentials/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isSafeUrl } from "@/lib/ssrf-protection";

import { getServerSession } from "next-auth";
import { NextRequest } from "next/server";
import { authOptions } from "@/lib/auth";
Expand Down Expand Up @@ -28,8 +30,12 @@ async function testJiraConnection(
email: string,
token: string
): Promise<boolean> {
const url = `https://${domain}/rest/api/3/myself`;
if (!(await isSafeUrl(url))) {
return false;
}
const auth = Buffer.from(`${email}:${token}`).toString("base64");
const response = await fetch(`https://${domain}/rest/api/3/myself`, {
const response = await fetch(url, {
headers: {
Authorization: `Basic ${auth}`,
Accept: "application/json",
Expand Down
6 changes: 6 additions & 0 deletions src/app/api/integrations/jira/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isSafeUrl } from "@/lib/ssrf-protection";

import { NextRequest } from "next/server";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
Expand Down Expand Up @@ -61,6 +63,10 @@ async function fetchJiraIssues(
jql
)}&maxResults=50&fields=summary,status,created,updated,resolutiondate,assignee,priority`;

if (!(await isSafeUrl(searchUrl))) {
throw new Error("Invalid or unsafe Jira domain.");
}

const response = await fetch(searchUrl, {
headers,
cache: "no-store",
Expand Down
Loading