Skip to content

Commit

Permalink
fix: Fix path traversal vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
bcldvd committed Feb 25, 2022
1 parent a61ab5a commit c3e4c56
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/helpers/inlineSVG.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import { readFileSync } from 'fs';
import { join } from 'path';

export default function inlineSVG(iconName) {
const path = join(__dirname, `../assets/img/${iconName}.svg`);
const path = join(__dirname, `../assets/img/${iconNameWhitelist(iconName)}.svg`);
return readFileSync(path, 'utf8');
}

function iconNameWhitelist(iconName) {
const fallbackIconName = 'warning'
const whitelist = ['warning', 'exit'];
if (!whitelist.includes(iconName)) {
return fallbackIconName;
}
return iconName;
}

0 comments on commit c3e4c56

Please sign in to comment.