import { Either } from "./mod.ts"; export const validateIdentifier = (token: string) => { return (/^[a-zA-Z0-9_\-:. \/]+$/).test(token) && !token.includes(".."); }; // ensure {@param obj} is a Record with stuff that won't // have the potential for shell injection, just to be super safe. export const validateExecutionEntries = ( obj: Record, ): Either, Record> => { const invalidEntries = Object.entries(obj).filter((e) => !e.every((x) => typeof x === "string" && validateIdentifier(x)) ); if (invalidEntries.length > 0) return Either.left(invalidEntries); return Either.right(> obj); };