fix(verification-gate): sanitize preference commands with isLikelyCommand (#1138)

This commit is contained in:
Tom Boucher 2026-03-18 10:25:08 -04:00 committed by GitHub
parent 308e328c66
commit 62a8be03da

View file

@ -45,11 +45,12 @@ const PACKAGE_SCRIPT_KEYS = ["typecheck", "lint", "test"] as const;
* 4. None found
*/
export function discoverCommands(options: DiscoverCommandsOptions): DiscoveredCommands {
// 1. Preference commands
// 1. Preference commands (still sanitize — may contain prose from misconfiguration)
if (options.preferenceCommands && options.preferenceCommands.length > 0) {
const filtered = options.preferenceCommands
.map(c => c.trim())
.filter(Boolean);
.filter(Boolean)
.filter(c => isLikelyCommand(c));
if (filtered.length > 0) {
return { commands: filtered, source: "preference" };
}