Skip to content

Commit

Permalink
chore: add basic validation to get rid of security vulnerability in u… (
Browse files Browse the repository at this point in the history
#7388)

Co-authored-by: Nayib Gloria <[email protected]>
  • Loading branch information
atarashansky and nayib-jose-gloria authored Nov 18, 2024
1 parent de76673 commit 9b168ef
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ export default function AnimatedNodes({
if (setCellInfoCellType) {
setCellInfoCellType({ cellTypeId, cellTypeName });
} else {
// Validate parameters before navigation
if (!isValidId(cellTypeId) || !isValidId(tissueId)) {
console.error("Invalid cell type or tissue ID");
return;
}

const url = getCellTypeLink({
tissueId,
cellTypeId,
Expand Down Expand Up @@ -282,3 +288,9 @@ function findSVGParent(node: Node | null): SVGElement | undefined {
}
return undefined;
}

function isValidId(id: string | undefined): boolean {
if (!id) return false;
// Must start with letters, followed by : or _, ending with numbers
return /^[a-zA-Z]+[:_][0-9]+$/.test(id);
}

0 comments on commit 9b168ef

Please sign in to comment.