diff --git a/src/helpers/parsePackage.ts b/src/helpers/parsePackage.ts index 7417e1d..95ac685 100644 --- a/src/helpers/parsePackage.ts +++ b/src/helpers/parsePackage.ts @@ -30,6 +30,14 @@ export async function parsePackageXml(xmlContent: string): Promise block must have exactly one 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 block must contain only and tags.'); + } const name = type.name[0]; const members = Array.isArray(type.members) ? type.members.flat() : type.members; return {