Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getSuppressions = async (specPath: string): Promise => {
// find readme.md
try {
const readMe = await amd.findReadMe(path.dirname(specPath))
if (readMe === undefined) {
return undefined
}
const readMeStr = await vfs.readFile(readMe)
const cmd = md.parse(readMeStr)
const suppressionCodeBlock = amd.getCodeBlocksAndHeadings(cmd.markDown).Suppression
if (suppressionCodeBlock === undefined) {
return undefined
}
const suppression = amd.getYamlFromNode(suppressionCodeBlock) as amd.Suppression
if (!it.isArray(suppression.directive)) {
return undefined
}
return suppression
} catch (err) {
log.warn(`Unable to load and parse suppression file. Error: ${err}`)
return undefined
}
}
const main = async (specificationsDirectory: string, profilesDirectory: string) => {
try {
const list = fs.recursiveReaddir(specificationsDirectory);
const specs = [];
let foundMultiApiReadmes = false;
for await (const file of list) {
const f = Path.parse(file);
if (f.base === "readme.enable-multi-api.md") {
foundMultiApiReadmes = true;
const content = (await fs.readFile(file)).toString();
const readMe = cm.parse(content);
const set = new Set();
for (const c of cm.iterate(readMe.markDown)) {
if (
c.type === "code_block" &&
c.info !== null &&
c.info.startsWith("yaml") &&
c.literal !== null
) {
const y = (yaml.load(c.literal) as Code)["input-file"];
if (typeof y === "string") {
set.add(y.replace('$(this-folder)', ''));
} else if (it.isArray(y)) {
for (const i of y) {
let cleanFilePath = i.replace('$(this-folder)', '');
set.add(cleanFilePath);
specs.push(Path.join(f.dir, cleanFilePath));
const main = async (dir: string) => {
try {
const list = fs.recursiveReaddir(dir)
for await (const file of list) {
const f = path.parse(file)
if (f.base === "readme.md") {
console.log(`processing ${file}`)
const content = (await fs.readFile(file)).toString()
const readMe = cm.parse(content)
const set = new Set()
for (const c of cm.iterate(readMe.markDown)) {
if (
c.type === "code_block" &&
c.info !== null &&
c.info.startsWith("yaml") &&
c.literal !== null
) {
const y = (yaml.load(c.literal) as Code)["input-file"]
if (typeof y === "string") {
set.add(y)
} else if (it.isArray(y)) {
for (const i of y) {
set.add(i)
}
}