Skip to content

Commit

Permalink
[connectors] 🔒 remove potential user data leak in dd (subdomain name) (
Browse files Browse the repository at this point in the history
…#8856)

* 🔒 remove potential user data leak (subdomain name)

* refactor: add a function getEndpointFromUrl

* 📝
  • Loading branch information
aubin-tchoi authored Nov 22, 2024
1 parent d5dc3ba commit 6c81562
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions connectors/src/connectors/zendesk/lib/zendesk_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import { ZendeskBrandResource } from "@connectors/resources/zendesk_resources";
const ZENDESK_RATE_LIMIT_MAX_RETRIES = 5;
const ZENDESK_RATE_LIMIT_TIMEOUT_SECONDS = 60;

/**
* Retrieves the endpoint part from a URL used to call the Zendesk API.
*/
function getEndpointFromUrl(url: string): string {
return url.split("api/v2")[1] as string;
}

export function createZendeskClient({
accessToken,
subdomain,
Expand Down Expand Up @@ -137,7 +144,7 @@ async function fetchFromZendeskWithRetries({
if (rawResponse.status === 404) {
logger.error(
{ rawResponse, text: rawResponse.text },
`[Zendesk] Zendesk API 404 error on: ${url}`
`[Zendesk] Zendesk API 404 error on: ${getEndpointFromUrl(url)}`
);
return null;
}
Expand All @@ -158,7 +165,12 @@ async function fetchFromZendeskWithRetries({
}
}
logger.error(
{ rawResponse, response, status: rawResponse.status },
{
rawResponse,
response,
status: rawResponse.status,
endpoint: getEndpointFromUrl(url),
},
"[Zendesk] Zendesk API error"
);
throw new Error("Zendesk API error.");
Expand Down

0 comments on commit 6c81562

Please sign in to comment.