Skip to content

Commit 0597c63

Browse files
Fix code scanning alert no. 8: Server-side request forgery
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent b4a35a2 commit 0597c63

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/api/functions/entraId.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import {
1212
EntraInvitationResponse,
1313
} from "../../common/types/iam.js";
1414

15+
function validateGroupId(groupId: string): boolean {
16+
const groupIdPattern = /^[a-zA-Z0-9-]+$/; // Adjust the pattern as needed
17+
return groupIdPattern.test(groupId);
18+
}
19+
1520
export async function getEntraIdToken(
1621
clientId: string,
1722
scopes: string[] = ["https://graph.microsoft.com/.default"],
@@ -245,6 +250,12 @@ export async function listGroupMembers(
245250
token: string,
246251
group: string,
247252
): Promise<Array<{ name: string; email: string }>> {
253+
if (!validateGroupId(group)) {
254+
throw new EntraGroupError({
255+
message: "Invalid group ID format",
256+
group,
257+
});
258+
}
248259
try {
249260
const url = `https://graph.microsoft.com/v1.0/groups/${group}/members`;
250261
const response = await fetch(url, {

0 commit comments

Comments
 (0)