Skip to content

Commit

Permalink
fix: ensure only elements in each types element are name and `mem…
Browse files Browse the repository at this point in the history
…bers`
  • Loading branch information
mcarvin8 committed Nov 13, 2024
1 parent 8b15f88 commit 2ab6e60
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/helpers/parsePackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ export async function parsePackageXml(xmlContent: string): Promise<SalesforcePac
if (!Array.isArray(type.name) || type.name.length !== 1 || typeof type.name[0] !== 'string') {
throw new Error('Invalid package.xml: Each <types> block must have exactly one <name> element.');
}
// Validate that only "name" and "members" keys are present
const allowedTypesKeys = new Set(['name', 'members']);
const typeKeys = Object.keys(type);
const hasUnexpectedTypesKeys = typeKeys.some((key) => !allowedTypesKeys.has(key));

if (hasUnexpectedTypesKeys) {
throw new Error('Invalid package.xml: Each <types> block must contain only <name> and <members> tags.');
}
const name = type.name[0];
const members = Array.isArray(type.members) ? type.members.flat() : type.members;
return {
Expand Down

0 comments on commit 2ab6e60

Please sign in to comment.