forked from aquasecurity/cloudsploit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuppress.js
26 lines (23 loc) · 895 Bytes
/
suppress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module.exports = {
create: function(suppressions) {
// Creates an object that can post process results to suppress rules
// This allows the client to set to ignore particular failures so that
// they don't affect the overall score
// Suppressions have the format pluginId:region:resourceId, where any
// of the items can be * to indicate match all.
if (!suppressions) suppressions = [];
var expressions = suppressions
.map(function(expr) {
return [
expr,
new RegExp('^' + expr.split('*').join('.*') + '$')
];
});
return function(result) {
var match = expressions.find(function(expression) {
return expression[1].test(result);
});
return match && match[0];
};
}
};