in eng/tools/suppressions/src/suppressions.ts [117:150]
export function getSuppressionsFromYaml(
tool: string,
path: string,
suppressionsFile: string,
suppressionsYaml: string,
): Suppression[] {
path = resolve(path);
suppressionsFile = resolve(suppressionsFile);
// Treat empty yaml as empty array
const parsedYaml: any = yamlParse(suppressionsYaml) ?? [];
let suppressions: Suppression[];
try {
// Throws if parsedYaml doesn't match schema
suppressions = suppressionSchema.parse(parsedYaml);
} catch (err) {
throw fromError(err);
}
return suppressions
.filter((s) => s.tool === tool)
.filter((s) => {
// Minimatch only allows forward-slashes in patterns and input
const pathPosix: string = path.split(sep).join(posixSep);
return s.paths.some((suppressionPath) => {
const pattern: string = join(dirname(suppressionsFile), suppressionPath)
.split(sep)
.join(posixSep);
return minimatch(pathPosix, pattern);
});
});
}