-
Notifications
You must be signed in to change notification settings - Fork 4
/
utils.js
54 lines (47 loc) · 1.12 KB
/
utils.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var fs = require('fs')
var settings = require('./settings.js');
function saveToFile(filename, data)
{
// Save to file
fs.writeFile(filename, data, function(err) {
if(err) {
console.log("Error: " + err.message)
return// console.log(err);
}
console.log("\nResults saved to " + filename);
});
}
function getDisplayPolicy(id)
{
policy = settings.defaultProtectionDisplayPolicy;
var found = false;
for (var i = 0; i < settings.protectionDisplay.length; i++)
{
if (settings.protectionDisplay[i].id == id)
{
policy = settings.protectionDisplay[i];
found = true;
break;
}
}
if (!found)
console.log(id + " is not supported by this tool" )
return (policy);
}
function isProtected(id, value)
{
var isProtected = false;
var policy = getDisplayPolicy(id);
for (var i = 0; i < policy.value.length; i++)
{
if (value === policy.value[i].isProtected)
{
isProtected = true;
break;
}
}
return (isProtected);
}
module.exports.saveToFile = saveToFile;
module.exports.getDisplayPolicy = getDisplayPolicy;
module.exports.isProtected = isProtected;