fix: harden install XML guard and remove no-op placeholder replacement

This commit is contained in:
Dicky Moore 2026-02-07 17:37:51 +00:00
parent 76df097957
commit 0b3023cdf5
2 changed files with 12 additions and 4 deletions

View File

@ -32,8 +32,9 @@ let failed = 0;
/** /**
* Recursively collect files from a mix of files/directories. * Recursively collect files from a mix of files/directories.
*/ */
async function collectFiles(targets, allowedExtensions) { async function collectFiles(targets, allowedExtensions, excludedFiles = new Set()) {
const files = []; const files = [];
const normalizedExcludes = new Set([...excludedFiles].map((p) => path.resolve(p)));
const walk = async (targetPath) => { const walk = async (targetPath) => {
if (!(await fs.pathExists(targetPath))) { if (!(await fs.pathExists(targetPath))) {
@ -42,6 +43,10 @@ async function collectFiles(targets, allowedExtensions) {
const stat = await fs.stat(targetPath); const stat = await fs.stat(targetPath);
if (stat.isFile()) { if (stat.isFile()) {
const normalizedTargetPath = path.resolve(targetPath);
if (normalizedExcludes.has(normalizedTargetPath)) {
return;
}
if (allowedExtensions.has(path.extname(targetPath))) { if (allowedExtensions.has(path.extname(targetPath))) {
files.push(targetPath); files.push(targetPath);
} }
@ -58,6 +63,9 @@ async function collectFiles(targets, allowedExtensions) {
await walk(fullPath); await walk(fullPath);
continue; continue;
} }
if (normalizedExcludes.has(path.resolve(fullPath))) {
continue;
}
if (allowedExtensions.has(path.extname(entry.name))) { if (allowedExtensions.has(path.extname(entry.name))) {
files.push(fullPath); files.push(fullPath);
} }
@ -273,9 +281,10 @@ async function runTests() {
]; ];
const allowedExtensions = new Set(['.md', '.yaml', '.yml', '.xml']); const allowedExtensions = new Set(['.md', '.yaml', '.yml', '.xml']);
const forbiddenRef = 'validate-workflow.xml'; const forbiddenRef = 'validate-workflow.xml';
const excludedFile = path.join(projectRoot, 'src', 'core', 'tasks', 'validate-workflow.xml');
const offenders = []; const offenders = [];
const files = await collectFiles(searchTargets, allowedExtensions); const files = await collectFiles(searchTargets, allowedExtensions, new Set([excludedFile]));
for (const fullPath of files) { for (const fullPath of files) {
const content = await fs.readFile(fullPath, 'utf8'); const content = await fs.readFile(fullPath, 'utf8');
if (content.includes(forbiddenRef)) { if (content.includes(forbiddenRef)) {

View File

@ -80,8 +80,7 @@ class AgentCommandGenerator {
.replaceAll('{{module}}', agent.module) .replaceAll('{{module}}', agent.module)
.replaceAll('{{path}}', agentPathInModule) .replaceAll('{{path}}', agentPathInModule)
.replaceAll('{{description}}', agent.description || `${agent.name} agent`) .replaceAll('{{description}}', agent.description || `${agent.name} agent`)
.replaceAll('_bmad', this.bmadFolderName) .replaceAll('_bmad', this.bmadFolderName);
.replaceAll('_bmad', '_bmad');
} }
/** /**