accessibility-checker 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/achecker.js +213 -262
- package/bin/achecker.js.map +1 -1
- package/cjs/bin/achecker.d.ts +2 -0
- package/cjs/bin/achecker.js +306 -0
- package/cjs/bin/achecker.js.map +1 -0
- package/cjs/index.d.ts +319 -0
- package/cjs/index.js +402 -0
- package/cjs/index.js.map +1 -0
- package/cjs/lib/ACBrowserManager.d.ts +22 -0
- package/cjs/lib/ACBrowserManager.js +172 -0
- package/cjs/lib/ACBrowserManager.js.map +1 -0
- package/cjs/lib/ACEngineManager.d.ts +19 -0
- package/cjs/lib/ACEngineManager.js +457 -0
- package/cjs/lib/ACEngineManager.js.map +1 -0
- package/cjs/lib/ACHelper.d.ts +2 -0
- package/cjs/lib/ACHelper.js +678 -0
- package/cjs/lib/ACHelper.js.map +1 -0
- package/cjs/lib/api/IChecker.d.ts +28 -0
- package/cjs/lib/api/IChecker.js +11 -0
- package/cjs/lib/api/IChecker.js.map +1 -0
- package/cjs/lib/api/IMapper.d.ts +37 -0
- package/cjs/lib/api/IMapper.js +18 -0
- package/cjs/lib/api/IMapper.js.map +1 -0
- package/cjs/lib/common/api-ext/Fetch.d.ts +17 -0
- package/cjs/lib/common/api-ext/Fetch.js +95 -0
- package/cjs/lib/common/api-ext/Fetch.js.map +1 -0
- package/cjs/lib/common/api-ext/IAbstractAPI.d.ts +33 -0
- package/cjs/lib/common/api-ext/IAbstractAPI.js +18 -0
- package/cjs/lib/common/api-ext/IAbstractAPI.js.map +1 -0
- package/cjs/lib/common/config/ACConfigManager.d.ts +13 -0
- package/cjs/lib/common/config/ACConfigManager.js +483 -0
- package/cjs/lib/common/config/ACConfigManager.js.map +1 -0
- package/cjs/lib/common/config/ACConstants.d.ts +17 -0
- package/cjs/lib/common/config/ACConstants.js +111 -0
- package/cjs/lib/common/config/ACConstants.js.map +1 -0
- package/cjs/lib/common/config/IArchive.d.ts +37 -0
- package/cjs/lib/common/config/IArchive.js +18 -0
- package/cjs/lib/common/config/IArchive.js.map +1 -0
- package/cjs/lib/common/config/IConfig.d.ts +152 -0
- package/cjs/lib/common/config/IConfig.js +36 -0
- package/cjs/lib/common/config/IConfig.js.map +1 -0
- package/cjs/lib/common/engine/IBounds.d.ts +21 -0
- package/cjs/lib/common/engine/IBounds.js +18 -0
- package/cjs/lib/common/engine/IBounds.js.map +1 -0
- package/cjs/lib/common/engine/IChecker.d.ts +23 -0
- package/cjs/lib/common/engine/IChecker.js +18 -0
- package/cjs/lib/common/engine/IChecker.js.map +1 -0
- package/cjs/lib/common/engine/IEngine.d.ts +39 -0
- package/cjs/lib/common/engine/IEngine.js +18 -0
- package/cjs/lib/common/engine/IEngine.js.map +1 -0
- package/cjs/lib/common/engine/IGuideline.d.ts +53 -0
- package/cjs/lib/common/engine/IGuideline.js +37 -0
- package/cjs/lib/common/engine/IGuideline.js.map +1 -0
- package/cjs/lib/common/engine/IMapper.d.ts +32 -0
- package/cjs/lib/common/engine/IMapper.js +18 -0
- package/cjs/lib/common/engine/IMapper.js.map +1 -0
- package/cjs/lib/common/engine/IReport.d.ts +143 -0
- package/cjs/lib/common/engine/IReport.js +44 -0
- package/cjs/lib/common/engine/IReport.js.map +1 -0
- package/cjs/lib/common/engine/IRule.d.ts +100 -0
- package/cjs/lib/common/engine/IRule.js +87 -0
- package/cjs/lib/common/engine/IRule.js.map +1 -0
- package/cjs/lib/common/engine/IRuleset.d.ts +20 -0
- package/cjs/lib/common/engine/IRuleset.js +18 -0
- package/cjs/lib/common/engine/IRuleset.js.map +1 -0
- package/cjs/lib/common/report/ACReporterCSV.d.ts +28 -0
- package/cjs/lib/common/report/ACReporterCSV.js +75 -0
- package/cjs/lib/common/report/ACReporterCSV.js.map +1 -0
- package/cjs/lib/common/report/ACReporterHTML.d.ts +27 -0
- package/cjs/lib/common/report/ACReporterHTML.js +61 -0
- package/cjs/lib/common/report/ACReporterHTML.js.map +1 -0
- package/cjs/lib/common/report/ACReporterJSON.d.ts +36 -0
- package/cjs/lib/common/report/ACReporterJSON.js +109 -0
- package/cjs/lib/common/report/ACReporterJSON.js.map +1 -0
- package/cjs/lib/common/report/ACReporterMetrics.d.ts +78 -0
- package/cjs/lib/common/report/ACReporterMetrics.js +135 -0
- package/cjs/lib/common/report/ACReporterMetrics.js.map +1 -0
- package/cjs/lib/common/report/ACReporterXLSX.d.ts +38 -0
- package/cjs/lib/common/report/ACReporterXLSX.js +996 -0
- package/cjs/lib/common/report/ACReporterXLSX.js.map +1 -0
- package/cjs/lib/common/report/BaselineManager.d.ts +169 -0
- package/cjs/lib/common/report/BaselineManager.js +382 -0
- package/cjs/lib/common/report/BaselineManager.js.map +1 -0
- package/cjs/lib/common/report/ReporterManager.d.ts +79 -0
- package/cjs/lib/common/report/ReporterManager.js +469 -0
- package/cjs/lib/common/report/ReporterManager.js.map +1 -0
- package/cjs/lib/common/report/genReport.d.ts +1 -0
- package/cjs/lib/common/report/genReport.js +12 -0
- package/cjs/lib/common/report/genReport.js.map +1 -0
- package/cjs/package.json +3 -0
- package/index.js +21 -63
- package/index.js.map +1 -1
- package/lib/ACBrowserManager.js +138 -203
- package/lib/ACBrowserManager.js.map +1 -1
- package/lib/ACEngineManager.js +395 -402
- package/lib/ACEngineManager.js.map +1 -1
- package/lib/ACHelper.js +581 -642
- package/lib/ACHelper.js.map +1 -1
- package/lib/common/api-ext/Fetch.js +58 -78
- package/lib/common/api-ext/Fetch.js.map +1 -1
- package/lib/common/config/ACConfigManager.js +271 -281
- package/lib/common/config/ACConfigManager.js.map +1 -1
- package/lib/common/config/ACConstants.js +38 -4
- package/lib/common/config/ACConstants.js.map +1 -1
- package/lib/common/config/IConfig.d.ts +1 -1
- package/lib/common/report/ACReporterCSV.js +42 -77
- package/lib/common/report/ACReporterCSV.js.map +1 -1
- package/lib/common/report/ACReporterHTML.js +15 -48
- package/lib/common/report/ACReporterHTML.js.map +1 -1
- package/lib/common/report/ACReporterJSON.js +59 -94
- package/lib/common/report/ACReporterJSON.js.map +1 -1
- package/lib/common/report/ACReporterMetrics.js +45 -108
- package/lib/common/report/ACReporterMetrics.js.map +1 -1
- package/lib/common/report/ACReporterXLSX.js +282 -300
- package/lib/common/report/ACReporterXLSX.js.map +1 -1
- package/lib/common/report/BaselineManager.js +82 -56
- package/lib/common/report/BaselineManager.js.map +1 -1
- package/lib/common/report/ReporterManager.js +125 -190
- package/lib/common/report/ReporterManager.js.map +1 -1
- package/lib/common/report/genReport.js +2 -2
- package/mjs/bin/achecker.d.ts +2 -0
- package/mjs/bin/achecker.js +236 -0
- package/mjs/bin/achecker.js.map +1 -0
- package/mjs/index.d.ts +319 -0
- package/mjs/index.js +368 -0
- package/mjs/index.js.map +1 -0
- package/mjs/lib/ACBrowserManager.d.ts +22 -0
- package/mjs/lib/ACBrowserManager.js +121 -0
- package/mjs/lib/ACBrowserManager.js.map +1 -0
- package/mjs/lib/ACEngineManager.d.ts +19 -0
- package/mjs/lib/ACEngineManager.js +397 -0
- package/mjs/lib/ACEngineManager.js.map +1 -0
- package/mjs/lib/ACHelper.d.ts +2 -0
- package/mjs/lib/ACHelper.js +614 -0
- package/mjs/lib/ACHelper.js.map +1 -0
- package/mjs/lib/api/IChecker.d.ts +28 -0
- package/mjs/lib/api/IChecker.js +8 -0
- package/mjs/lib/api/IChecker.js.map +1 -0
- package/mjs/lib/api/IMapper.d.ts +37 -0
- package/mjs/lib/api/IMapper.js +17 -0
- package/mjs/lib/api/IMapper.js.map +1 -0
- package/mjs/lib/common/api-ext/Fetch.d.ts +17 -0
- package/mjs/lib/common/api-ext/Fetch.js +45 -0
- package/mjs/lib/common/api-ext/Fetch.js.map +1 -0
- package/mjs/lib/common/api-ext/IAbstractAPI.d.ts +33 -0
- package/mjs/lib/common/api-ext/IAbstractAPI.js +17 -0
- package/mjs/lib/common/api-ext/IAbstractAPI.js.map +1 -0
- package/mjs/lib/common/config/ACConfigManager.d.ts +13 -0
- package/mjs/lib/common/config/ACConfigManager.js +421 -0
- package/mjs/lib/common/config/ACConfigManager.js.map +1 -0
- package/mjs/lib/common/config/ACConstants.d.ts +17 -0
- package/mjs/lib/common/config/ACConstants.js +75 -0
- package/mjs/lib/common/config/ACConstants.js.map +1 -0
- package/mjs/lib/common/config/IArchive.d.ts +37 -0
- package/mjs/lib/common/config/IArchive.js +17 -0
- package/mjs/lib/common/config/IArchive.js.map +1 -0
- package/mjs/lib/common/config/IConfig.d.ts +152 -0
- package/mjs/lib/common/config/IConfig.js +33 -0
- package/mjs/lib/common/config/IConfig.js.map +1 -0
- package/mjs/lib/common/engine/IBounds.d.ts +21 -0
- package/mjs/lib/common/engine/IBounds.js +17 -0
- package/mjs/lib/common/engine/IBounds.js.map +1 -0
- package/mjs/lib/common/engine/IChecker.d.ts +23 -0
- package/mjs/lib/common/engine/IChecker.js +17 -0
- package/mjs/lib/common/engine/IChecker.js.map +1 -0
- package/mjs/lib/common/engine/IEngine.d.ts +39 -0
- package/mjs/lib/common/engine/IEngine.js +17 -0
- package/mjs/lib/common/engine/IEngine.js.map +1 -0
- package/mjs/lib/common/engine/IGuideline.d.ts +53 -0
- package/mjs/lib/common/engine/IGuideline.js +34 -0
- package/mjs/lib/common/engine/IGuideline.js.map +1 -0
- package/mjs/lib/common/engine/IMapper.d.ts +32 -0
- package/mjs/lib/common/engine/IMapper.js +17 -0
- package/mjs/lib/common/engine/IMapper.js.map +1 -0
- package/mjs/lib/common/engine/IReport.d.ts +143 -0
- package/mjs/lib/common/engine/IReport.js +36 -0
- package/mjs/lib/common/engine/IReport.js.map +1 -0
- package/mjs/lib/common/engine/IRule.d.ts +100 -0
- package/mjs/lib/common/engine/IRule.js +79 -0
- package/mjs/lib/common/engine/IRule.js.map +1 -0
- package/mjs/lib/common/engine/IRuleset.d.ts +20 -0
- package/mjs/lib/common/engine/IRuleset.js +17 -0
- package/mjs/lib/common/engine/IRuleset.js.map +1 -0
- package/mjs/lib/common/report/ACReporterCSV.d.ts +28 -0
- package/mjs/lib/common/report/ACReporterCSV.js +60 -0
- package/mjs/lib/common/report/ACReporterCSV.js.map +1 -0
- package/mjs/lib/common/report/ACReporterHTML.d.ts +27 -0
- package/mjs/lib/common/report/ACReporterHTML.js +46 -0
- package/mjs/lib/common/report/ACReporterHTML.js.map +1 -0
- package/mjs/lib/common/report/ACReporterJSON.d.ts +36 -0
- package/mjs/lib/common/report/ACReporterJSON.js +94 -0
- package/mjs/lib/common/report/ACReporterJSON.js.map +1 -0
- package/mjs/lib/common/report/ACReporterMetrics.d.ts +78 -0
- package/mjs/lib/common/report/ACReporterMetrics.js +122 -0
- package/mjs/lib/common/report/ACReporterMetrics.js.map +1 -0
- package/mjs/lib/common/report/ACReporterXLSX.d.ts +38 -0
- package/mjs/lib/common/report/ACReporterXLSX.js +948 -0
- package/mjs/lib/common/report/ACReporterXLSX.js.map +1 -0
- package/mjs/lib/common/report/BaselineManager.d.ts +169 -0
- package/mjs/lib/common/report/BaselineManager.js +348 -0
- package/mjs/lib/common/report/BaselineManager.js.map +1 -0
- package/mjs/lib/common/report/ReporterManager.d.ts +79 -0
- package/mjs/lib/common/report/ReporterManager.js +469 -0
- package/mjs/lib/common/report/ReporterManager.js.map +1 -0
- package/mjs/lib/common/report/genReport.d.ts +1 -0
- package/mjs/lib/common/report/genReport.js +9 -0
- package/mjs/lib/common/report/genReport.js.map +1 -0
- package/mjs/package.json +3 -0
- package/package.json +10 -4
package/lib/ACHelper.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,209 +41,128 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
41
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
42
|
});
|
|
10
43
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
45
|
exports.getComplianceHelper = getComplianceHelper;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const fs_1 = require("fs");
|
|
47
|
+
const path_1 = require("path");
|
|
48
|
+
const ACBrowserManager_js_1 = require("./ACBrowserManager.js");
|
|
49
|
+
const ACEngineManager_js_1 = require("./ACEngineManager.js");
|
|
50
|
+
const ACConfigManager_js_1 = require("./common/config/ACConfigManager.js");
|
|
51
|
+
const ReporterManager_js_1 = require("./common/report/ReporterManager.js");
|
|
52
|
+
const BaselineManager_js_1 = require("./common/report/BaselineManager.js");
|
|
53
|
+
let loggerCreate = function (type) {
|
|
48
54
|
return logger;
|
|
49
55
|
};
|
|
50
|
-
|
|
51
|
-
debug:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
Config && Config.DEBUG && console.debug.apply(console, output);
|
|
57
|
-
},
|
|
58
|
-
info: function () {
|
|
59
|
-
var output = [];
|
|
60
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
61
|
-
output[_i] = arguments[_i];
|
|
62
|
-
}
|
|
63
|
-
Config && Config.DEBUG && console.info.apply(console, output);
|
|
64
|
-
},
|
|
65
|
-
error: function () {
|
|
66
|
-
var output = [];
|
|
67
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
68
|
-
output[_i] = arguments[_i];
|
|
69
|
-
}
|
|
70
|
-
Config && Config.DEBUG && console.error.apply(console, output);
|
|
71
|
-
},
|
|
72
|
-
warn: function () {
|
|
73
|
-
var output = [];
|
|
74
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
75
|
-
output[_i] = arguments[_i];
|
|
76
|
-
}
|
|
77
|
-
Config && Config.DEBUG && console.warn.apply(console, output);
|
|
78
|
-
},
|
|
56
|
+
let logger = {
|
|
57
|
+
debug: (...output) => { Config && Config.DEBUG && console.debug(...output); },
|
|
58
|
+
info: (...output) => { Config && Config.DEBUG && console.info(...output); },
|
|
59
|
+
error: (...output) => { Config && Config.DEBUG && console.error(...output); },
|
|
60
|
+
warn: (...output) => { Config && Config.DEBUG && console.warn(...output); },
|
|
79
61
|
create: loggerCreate
|
|
80
62
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
MyFS.prototype.writeFileSync = function (filePath, data) {
|
|
87
|
-
var outFile = this.prepFileSync(filePath);
|
|
63
|
+
let Config;
|
|
64
|
+
let checkPolicy = false;
|
|
65
|
+
class MyFS {
|
|
66
|
+
writeFileSync(filePath, data) {
|
|
67
|
+
let outFile = this.prepFileSync(filePath);
|
|
88
68
|
(0, fs_1.writeFileSync)(outFile, data);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
69
|
+
}
|
|
70
|
+
prepFileSync(filePath) {
|
|
71
|
+
let outDir = (0, path_1.resolve)(Config.outputFolder);
|
|
72
|
+
let outFile = (0, path_1.join)(outDir, filePath);
|
|
93
73
|
if (!(0, fs_1.existsSync)((0, path_1.dirname)(outFile))) {
|
|
94
74
|
(0, fs_1.mkdirSync)((0, path_1.dirname)(outFile), { recursive: true });
|
|
95
75
|
}
|
|
96
76
|
return outFile;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
Config && Config.DEBUG && console.debug.apply(console, output);
|
|
104
|
-
};
|
|
105
|
-
MyFS.prototype.info = function () {
|
|
106
|
-
var output = [];
|
|
107
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
108
|
-
output[_i] = arguments[_i];
|
|
109
|
-
}
|
|
110
|
-
Config && Config.DEBUG && console.info.apply(console, output);
|
|
111
|
-
};
|
|
112
|
-
MyFS.prototype.error = function () {
|
|
113
|
-
var output = [];
|
|
114
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
115
|
-
output[_i] = arguments[_i];
|
|
116
|
-
}
|
|
117
|
-
Config && Config.DEBUG && console.error.apply(console, output);
|
|
118
|
-
};
|
|
119
|
-
MyFS.prototype.loadBaseline = function (label) {
|
|
120
|
-
var baselineFile = (0, path_1.join)((0, path_1.join)(process.cwd(), Config.baselineFolder), label + ".json");
|
|
77
|
+
}
|
|
78
|
+
log(...output) { Config && Config.DEBUG && console.debug(...output); }
|
|
79
|
+
info(...output) { Config && Config.DEBUG && console.info(...output); }
|
|
80
|
+
error(...output) { Config && Config.DEBUG && console.error(...output); }
|
|
81
|
+
loadBaseline(label) {
|
|
82
|
+
let baselineFile = (0, path_1.join)((0, path_1.join)(process.cwd(), Config.baselineFolder), label + ".json");
|
|
121
83
|
if (!(0, fs_1.existsSync)(baselineFile))
|
|
122
84
|
return null;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
85
|
+
if (typeof require !== "undefined") {
|
|
86
|
+
return require(baselineFile);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return JSON.parse((0, fs_1.readFileSync)(baselineFile).toString());
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
getChecker() {
|
|
126
93
|
return ACEngineManager_js_1.ACEngineManager.getChecker();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
}());
|
|
94
|
+
}
|
|
95
|
+
}
|
|
130
96
|
function initialize() {
|
|
131
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
absAPI = new MyFS();
|
|
145
|
-
refactorMap = {};
|
|
146
|
-
rules = ACEngineManager_js_1.ACEngineManager.getRulesSync();
|
|
147
|
-
for (_i = 0, rules_1 = rules; _i < rules_1.length; _i++) {
|
|
148
|
-
rule = rules_1[_i];
|
|
149
|
-
if (rule.refactor) {
|
|
150
|
-
for (key in rule.refactor) {
|
|
151
|
-
refactorMap[key] = rule;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
_b = (_a = ReporterManager_js_1.ReporterManager).initialize;
|
|
156
|
-
_c = [Config, absAPI];
|
|
157
|
-
return [4 /*yield*/, ACEngineManager_js_1.ACEngineManager.getRulesets()];
|
|
158
|
-
case 3:
|
|
159
|
-
_b.apply(_a, _c.concat([_d.sent()]));
|
|
160
|
-
BaselineManager_js_1.BaselineManager.initialize(Config, absAPI, refactorMap);
|
|
161
|
-
return [2 /*return*/];
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
if (Config)
|
|
99
|
+
return;
|
|
100
|
+
Config = yield ACConfigManager_js_1.ACConfigManager.getConfigUnsupported();
|
|
101
|
+
yield ACEngineManager_js_1.ACEngineManager.loadEngineLocal();
|
|
102
|
+
let absAPI = new MyFS();
|
|
103
|
+
let refactorMap = {};
|
|
104
|
+
let rules = ACEngineManager_js_1.ACEngineManager.getRulesSync();
|
|
105
|
+
for (const rule of rules) {
|
|
106
|
+
if (rule.refactor) {
|
|
107
|
+
for (const key in rule.refactor) {
|
|
108
|
+
refactorMap[key] = rule;
|
|
109
|
+
}
|
|
162
110
|
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
try {
|
|
167
|
-
// If cucumber is the platform...
|
|
168
|
-
var AfterAll = require('cucumber').AfterAll;
|
|
169
|
-
AfterAll(function (done) {
|
|
170
|
-
// const rulePack = `${Config.rulePack}`;
|
|
171
|
-
initialize()
|
|
172
|
-
.then(function () { return ReporterManager_js_1.ReporterManager.generateSummaries(); })
|
|
173
|
-
.then(function () { return ACBrowserManager_js_1.ACBrowserManager.close(); })
|
|
174
|
-
.then(done);
|
|
111
|
+
}
|
|
112
|
+
ReporterManager_js_1.ReporterManager.initialize(Config, absAPI, yield ACEngineManager_js_1.ACEngineManager.getRulesets());
|
|
113
|
+
BaselineManager_js_1.BaselineManager.initialize(Config, absAPI, refactorMap);
|
|
175
114
|
});
|
|
176
115
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// const rulePack = `${Config.rulePack}
|
|
116
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
+
try {
|
|
118
|
+
// If cucumber is the platform...
|
|
119
|
+
let module = (yield Promise.resolve(`${"cucumber"}`).then(s => __importStar(require(s))));
|
|
120
|
+
let { AfterAll } = require('cucumber');
|
|
121
|
+
if (module.default.AfterAll) {
|
|
122
|
+
module.default.AfterAll(function (done) {
|
|
123
|
+
// const rulePack = `${Config.rulePack}`;
|
|
185
124
|
initialize()
|
|
186
|
-
.then(
|
|
187
|
-
.then(
|
|
125
|
+
.then(() => ReporterManager_js_1.ReporterManager.generateSummaries())
|
|
126
|
+
.then(() => ACBrowserManager_js_1.ACBrowserManager.close())
|
|
188
127
|
.then(done);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
done && done();
|
|
192
|
-
}
|
|
193
|
-
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
194
130
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
131
|
+
catch (e) {
|
|
132
|
+
if (typeof (after) !== "undefined") {
|
|
133
|
+
after(function (done) {
|
|
134
|
+
if (Config) {
|
|
135
|
+
if (this.timeout) {
|
|
136
|
+
this.timeout(300000);
|
|
137
|
+
}
|
|
138
|
+
// const rulePack = `${Config.rulePack}/ace`;
|
|
139
|
+
initialize()
|
|
140
|
+
.then(() => ReporterManager_js_1.ReporterManager.generateSummaries())
|
|
141
|
+
.then(() => ACBrowserManager_js_1.ACBrowserManager.close())
|
|
142
|
+
.then(done);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
done();
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
process.on('beforeExit', function () {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
152
|
if (Config) {
|
|
200
153
|
initialize()
|
|
201
|
-
.then(
|
|
154
|
+
.then(() => ReporterManager_js_1.ReporterManager.generateSummaries());
|
|
202
155
|
ACBrowserManager_js_1.ACBrowserManager.close();
|
|
203
156
|
}
|
|
204
|
-
return [2 /*return*/];
|
|
205
157
|
});
|
|
206
158
|
});
|
|
207
|
-
}
|
|
159
|
+
}
|
|
208
160
|
}
|
|
209
|
-
}
|
|
161
|
+
}))();
|
|
210
162
|
function areValidPolicy(valPolicies, curPol) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
for (
|
|
163
|
+
let isValPol = false;
|
|
164
|
+
let errorPolicy = "";
|
|
165
|
+
for (let i = 0; i < curPol.length; ++i) {
|
|
214
166
|
if (valPolicies.indexOf(curPol[i]) === -1) {
|
|
215
167
|
errorPolicy += "" + curPol[i] + ",";
|
|
216
168
|
}
|
|
@@ -220,16 +172,25 @@ function areValidPolicy(valPolicies, curPol) {
|
|
|
220
172
|
}
|
|
221
173
|
if (errorPolicy.length > 0) {
|
|
222
174
|
errorPolicy = errorPolicy.substr(0, errorPolicy.length - 1);
|
|
223
|
-
console.log(
|
|
175
|
+
console.log(`[WARN] InvalidPolicies: Invalid policies "${errorPolicy}". Valid policy ids are: ${valPolicies}`);
|
|
224
176
|
}
|
|
225
177
|
if (!isValPol) {
|
|
226
|
-
|
|
178
|
+
const errStr = `[ERROR] ValidPoliciesMissing: No valid policy has been provided. Valid policy ids for the specified archive are: ${valPolicies}`;
|
|
227
179
|
console.error(errStr);
|
|
228
180
|
throw new Error(errStr);
|
|
229
181
|
}
|
|
230
182
|
}
|
|
231
183
|
function getComplianceHelper(content, label) {
|
|
232
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
yield initialize();
|
|
186
|
+
Config.DEBUG && console.log("START 'aChecker.getCompliance' function");
|
|
187
|
+
if (!content) {
|
|
188
|
+
console.error("aChecker: Unable to get compliance of null or undefined object");
|
|
189
|
+
//return null;
|
|
190
|
+
throw new Error("aChecker: Unable to get compliance of null or undefined object");
|
|
191
|
+
}
|
|
192
|
+
// Variable Decleration
|
|
193
|
+
let URL;
|
|
233
194
|
// Since we need to handle multiple variation of possible ways to scan items, we need to handle
|
|
234
195
|
// each one differently as each one requires specific actions/setup.
|
|
235
196
|
// Handle the following:
|
|
@@ -239,501 +200,479 @@ function getComplianceHelper(content, label) {
|
|
|
239
200
|
// URL (String)
|
|
240
201
|
// document
|
|
241
202
|
function getParsed(content) {
|
|
242
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (
|
|
249
|
-
|
|
250
|
-
if (isURLRegex.test(content)) {
|
|
251
|
-
URL = content;
|
|
252
|
-
}
|
|
253
|
-
// Since this is a string, we consider this as either URL or local file
|
|
254
|
-
// so build an iframe based on this and get the frame doc and then scan this.
|
|
255
|
-
return [2 /*return*/, ACBrowserManager_js_1.ACBrowserManager.buildIframeAndGetDoc(content)];
|
|
256
|
-
}
|
|
257
|
-
else if (ACEngineManager_js_1.ACEngineManager.isSelenium(content) || ACEngineManager_js_1.ACEngineManager.isPuppeteer(content) || ACEngineManager_js_1.ACEngineManager.isPlaywright(content) || ACEngineManager_js_1.ACEngineManager.isWebDriverIO(content)) {
|
|
258
|
-
}
|
|
259
|
-
// Handle Array of nodes
|
|
260
|
-
else if (content instanceof Array) {
|
|
261
|
-
// TODO: Supporting Array of nodes, possible future enhancenment
|
|
262
|
-
}
|
|
263
|
-
// Handle single node (HTMLElement)
|
|
264
|
-
else if (content.nodeType === 1) {
|
|
265
|
-
// In the case this is a node, there is nothing special that needs to be done at this time,
|
|
266
|
-
// the engine will be able to handle this. Adding this block here as we may need to add some filtering
|
|
267
|
-
// of rules or rule sets for this case depending on if a special ruleset needs to be created or not.
|
|
268
|
-
content = content;
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
if (!content)
|
|
205
|
+
return null;
|
|
206
|
+
// Handle local file and URL's
|
|
207
|
+
if (typeof content === "string") {
|
|
208
|
+
let isURLRegex = /^(ftp|http|https):\/\//;
|
|
209
|
+
if (isURLRegex.test(content)) {
|
|
210
|
+
URL = content;
|
|
269
211
|
}
|
|
270
|
-
//
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
212
|
+
// Since this is a string, we consider this as either URL or local file
|
|
213
|
+
// so build an iframe based on this and get the frame doc and then scan this.
|
|
214
|
+
return ACBrowserManager_js_1.ACBrowserManager.buildIframeAndGetDoc(content);
|
|
215
|
+
}
|
|
216
|
+
else if (ACEngineManager_js_1.ACEngineManager.isSelenium(content) || ACEngineManager_js_1.ACEngineManager.isPuppeteer(content) || ACEngineManager_js_1.ACEngineManager.isPlaywright(content) || ACEngineManager_js_1.ACEngineManager.isWebDriverIO(content)) {
|
|
217
|
+
}
|
|
218
|
+
// Handle Array of nodes
|
|
219
|
+
else if (content instanceof Array) {
|
|
220
|
+
// TODO: Supporting Array of nodes, possible future enhancenment
|
|
221
|
+
}
|
|
222
|
+
// Handle single node (HTMLElement)
|
|
223
|
+
else if (content.nodeType === 1) {
|
|
224
|
+
// In the case this is a node, there is nothing special that needs to be done at this time,
|
|
225
|
+
// the engine will be able to handle this. Adding this block here as we may need to add some filtering
|
|
226
|
+
// of rules or rule sets for this case depending on if a special ruleset needs to be created or not.
|
|
227
|
+
content = content;
|
|
228
|
+
}
|
|
229
|
+
// handle scanning document
|
|
230
|
+
else if (content.nodeType === 9) {
|
|
231
|
+
// In the case this is a document element, simply send the document object to the engine for now
|
|
232
|
+
// we will need to do some filtering to remove any karma related aspects, which requires to do a
|
|
233
|
+
// document clone, and then string the karma scripts that are added and then send this document
|
|
234
|
+
// to the engine.
|
|
235
|
+
// TODO: Investigate best approach to perform filtering
|
|
236
|
+
content = content;
|
|
237
|
+
}
|
|
238
|
+
return content;
|
|
281
239
|
});
|
|
282
240
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
case 7:
|
|
317
|
-
if (!ACEngineManager_js_1.ACEngineManager.isPlaywright(parsed)) return [3 /*break*/, 9];
|
|
318
|
-
Config.DEBUG && console.log("ACHelper.ts:getComplianceHelper:Playwright");
|
|
319
|
-
return [4 /*yield*/, getComplianceHelperPuppeteer(label, parsed, curPol)];
|
|
320
|
-
case 8: return [2 /*return*/, _a.sent()];
|
|
321
|
-
case 9:
|
|
322
|
-
if (!ACEngineManager_js_1.ACEngineManager.isWebDriverIO(parsed)) return [3 /*break*/, 11];
|
|
323
|
-
Config.DEBUG && console.log("ACHelper.ts:getComplianceHelper:Playwright");
|
|
324
|
-
return [4 /*yield*/, getComplianceHelperWebDriverIO(label, parsed, curPol)];
|
|
325
|
-
case 10: return [2 /*return*/, _a.sent()];
|
|
326
|
-
case 11:
|
|
327
|
-
Config.DEBUG && console.log("ACHelper.ts:getComplianceHelper:Local");
|
|
328
|
-
return [4 /*yield*/, getComplianceHelperLocal(label, parsed, curPol)];
|
|
329
|
-
case 12: return [2 /*return*/, _a.sent()];
|
|
330
|
-
}
|
|
331
|
-
});
|
|
241
|
+
let parsed = yield getParsed(content);
|
|
242
|
+
if (!parsed) {
|
|
243
|
+
console.error("Invalid content: " + content);
|
|
244
|
+
throw new Error("Invalid content: " + content);
|
|
245
|
+
}
|
|
246
|
+
yield ACEngineManager_js_1.ACEngineManager.loadEngine(parsed);
|
|
247
|
+
// Get the Data when the scan is started
|
|
248
|
+
// Start time will be in milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now.
|
|
249
|
+
let policies = Config.policies;
|
|
250
|
+
let curPol = null;
|
|
251
|
+
if (policies) {
|
|
252
|
+
curPol = JSON.parse(JSON.stringify(policies));
|
|
253
|
+
}
|
|
254
|
+
if (ACEngineManager_js_1.ACEngineManager.isSelenium(parsed)) {
|
|
255
|
+
Config.DEBUG && console.log("getComplianceHelper:Selenium");
|
|
256
|
+
return yield getComplianceHelperSelenium(label, parsed, curPol);
|
|
257
|
+
}
|
|
258
|
+
else if (ACEngineManager_js_1.ACEngineManager.isPuppeteer(parsed)) {
|
|
259
|
+
Config.DEBUG && console.log("ACHelper.ts:getComplianceHelper:Puppeteer");
|
|
260
|
+
return yield getComplianceHelperPuppeteer(label, parsed, curPol);
|
|
261
|
+
}
|
|
262
|
+
else if (ACEngineManager_js_1.ACEngineManager.isPlaywright(parsed)) {
|
|
263
|
+
Config.DEBUG && console.log("ACHelper.ts:getComplianceHelper:Playwright");
|
|
264
|
+
return yield getComplianceHelperPuppeteer(label, parsed, curPol);
|
|
265
|
+
}
|
|
266
|
+
else if (ACEngineManager_js_1.ACEngineManager.isWebDriverIO(parsed)) {
|
|
267
|
+
Config.DEBUG && console.log("ACHelper.ts:getComplianceHelper:Playwright");
|
|
268
|
+
return yield getComplianceHelperWebDriverIO(label, parsed, curPol);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
Config.DEBUG && console.log("ACHelper.ts:getComplianceHelper:Local");
|
|
272
|
+
return yield getComplianceHelperLocal(label, parsed, curPol);
|
|
273
|
+
}
|
|
332
274
|
});
|
|
333
275
|
}
|
|
334
276
|
function getComplianceHelperSelenium(label, parsed, curPol) {
|
|
335
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
277
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
+
try {
|
|
279
|
+
let startScan = Date.now();
|
|
280
|
+
// NOTE: Engine should already be loaded
|
|
281
|
+
let browser = parsed;
|
|
282
|
+
// Selenium
|
|
283
|
+
let scriptStr = `let cb = arguments[arguments.length - 1];
|
|
284
|
+
try {
|
|
285
|
+
|
|
286
|
+
const valueToLevel = (reportValue) => {
|
|
287
|
+
let reportLevel;
|
|
288
|
+
if (reportValue[1] === "PASS") {
|
|
289
|
+
reportLevel = "pass";
|
|
290
|
+
}
|
|
291
|
+
else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") {
|
|
292
|
+
reportLevel = "manual";
|
|
293
|
+
}
|
|
294
|
+
else if (reportValue[0] === "VIOLATION") {
|
|
295
|
+
if (reportValue[1] === "FAIL") {
|
|
296
|
+
reportLevel = "violation";
|
|
297
|
+
}
|
|
298
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
299
|
+
reportLevel = "potentialviolation";
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
else if (reportValue[0] === "RECOMMENDATION") {
|
|
303
|
+
if (reportValue[1] === "FAIL") {
|
|
304
|
+
reportLevel = "recommendation";
|
|
305
|
+
}
|
|
306
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
307
|
+
reportLevel = "potentialrecommendation";
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return reportLevel;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const getCounts = (engineReport) => {
|
|
314
|
+
let counts = {
|
|
315
|
+
violation: 0,
|
|
316
|
+
potentialviolation: 0,
|
|
317
|
+
recommendation: 0,
|
|
318
|
+
potentialrecommendation: 0,
|
|
319
|
+
manual: 0,
|
|
320
|
+
pass: 0
|
|
321
|
+
}
|
|
322
|
+
for (const issue of engineReport.results) {
|
|
323
|
+
++counts[issue.level];
|
|
324
|
+
}
|
|
325
|
+
return counts;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
let policies = ${JSON.stringify(Config.policies)};
|
|
330
|
+
|
|
331
|
+
let checker = new window.ace_ibma.Checker();
|
|
332
|
+
let customRulesets = ${JSON.stringify(ACEngineManager_js_1.ACEngineManager.customRulesets)};
|
|
333
|
+
customRulesets.forEach((rs) => checker.addRuleset(rs));
|
|
334
|
+
setTimeout(function() {
|
|
335
|
+
checker.check(document, policies).then(function(report) {
|
|
336
|
+
for (const result of report.results) {
|
|
337
|
+
delete result.node;
|
|
338
|
+
result.level = valueToLevel(result.value)
|
|
339
|
+
}
|
|
340
|
+
report.summary ||= {};
|
|
341
|
+
report.summary.counts ||= getCounts(report);
|
|
342
|
+
let reportLevels = ${JSON.stringify((Config.reportLevels || []).concat(Config.failLevels || []).map(lvl => lvl.toString()))};
|
|
343
|
+
// Filter out pass results unless they asked for them in reports
|
|
344
|
+
// We don't want to mess with baseline functions, but pass results can break the response object
|
|
345
|
+
report.results = report.results.filter(result => reportLevels.includes(result.level) || result.level !== "pass");
|
|
346
|
+
cb(report);
|
|
347
|
+
})
|
|
348
|
+
},0)
|
|
349
|
+
} catch (e) {
|
|
350
|
+
cb(e);
|
|
351
|
+
}`;
|
|
352
|
+
let manage = browser.manage();
|
|
353
|
+
if (manage.timeouts) {
|
|
354
|
+
manage.timeouts().setScriptTimeout(60000);
|
|
355
|
+
}
|
|
356
|
+
else if (manage.setTimeouts) {
|
|
357
|
+
manage.setTimeouts({
|
|
358
|
+
"script": 60000
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
let report = yield browser.executeAsyncScript(scriptStr);
|
|
362
|
+
const getPolicies = "return new window.ace_ibma.Checker().rulesetIds;";
|
|
363
|
+
if (curPol != null && !checkPolicy) {
|
|
364
|
+
checkPolicy = true;
|
|
365
|
+
const valPolicies = ACEngineManager_js_1.ACEngineManager.customRulesets.map(rs => rs.id).concat(yield browser.executeScript(getPolicies));
|
|
366
|
+
areValidPolicy(valPolicies, curPol);
|
|
367
|
+
}
|
|
368
|
+
// If there is something to report...
|
|
369
|
+
let finalReport;
|
|
370
|
+
if (report.results) {
|
|
371
|
+
// Add URL to the result object
|
|
372
|
+
const url = yield browser.getCurrentUrl();
|
|
373
|
+
const title = yield browser.getTitle();
|
|
374
|
+
let origReport = JSON.parse(JSON.stringify(report));
|
|
375
|
+
if (Config.captureScreenshots && browser.takeScreenshot) {
|
|
376
|
+
const image = yield browser.takeScreenshot();
|
|
379
377
|
origReport.screenshot = image;
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
finalReport = ReporterManager_js_1.ReporterManager.addEngineReport("Selenium", startScan, url, title, label, origReport);
|
|
383
|
-
_c.label = 8;
|
|
384
|
-
case 8: return [2 /*return*/, {
|
|
385
|
-
"report": finalReport,
|
|
386
|
-
"webdriver": parsed
|
|
387
|
-
}];
|
|
388
|
-
case 9:
|
|
389
|
-
err_1 = _c.sent();
|
|
390
|
-
console.error(err_1);
|
|
391
|
-
return [2 /*return*/, Promise.reject(err_1)];
|
|
392
|
-
case 10:
|
|
393
|
-
;
|
|
394
|
-
return [2 /*return*/];
|
|
378
|
+
}
|
|
379
|
+
finalReport = ReporterManager_js_1.ReporterManager.addEngineReport("Selenium", startScan, url, title, label, origReport);
|
|
395
380
|
}
|
|
396
|
-
|
|
381
|
+
return {
|
|
382
|
+
"report": finalReport,
|
|
383
|
+
"webdriver": parsed
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
catch (err) {
|
|
387
|
+
console.error(err);
|
|
388
|
+
return Promise.reject(err);
|
|
389
|
+
}
|
|
390
|
+
;
|
|
397
391
|
});
|
|
398
392
|
}
|
|
399
393
|
function getComplianceHelperWebDriverIO(label, parsed, curPol) {
|
|
400
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
var
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
});
|
|
472
|
-
}, { policies: Config.policies, customRulesets: ACEngineManager_js_1.ACEngineManager.customRulesets, reportLevels: (Config.reportLevels || []).concat(Config.failLevels || []).map(function (lvl) { return lvl.toString(); }) })];
|
|
473
|
-
case 1:
|
|
474
|
-
report = _c.sent();
|
|
475
|
-
if (!(curPol != null && !checkPolicy)) return [3 /*break*/, 3];
|
|
476
|
-
_b = (_a = ACEngineManager_js_1.ACEngineManager.customRulesets.map(function (rs) { return rs.id; })).concat;
|
|
477
|
-
return [4 /*yield*/, page.execute(function () { return (new window.ace_ibma.Checker().rulesetIds); })];
|
|
478
|
-
case 2:
|
|
479
|
-
valPolicies = _b.apply(_a, [_c.sent()]);
|
|
480
|
-
checkPolicy = true;
|
|
481
|
-
areValidPolicy(valPolicies, curPol);
|
|
482
|
-
_c.label = 3;
|
|
483
|
-
case 3:
|
|
484
|
-
finalReport = void 0;
|
|
485
|
-
if (!report.results) return [3 /*break*/, 8];
|
|
486
|
-
return [4 /*yield*/, page.execute(function () { return document.location.href; })];
|
|
487
|
-
case 4:
|
|
488
|
-
url = _c.sent();
|
|
489
|
-
return [4 /*yield*/, page.execute(function () { return document.location.title; })];
|
|
490
|
-
case 5:
|
|
491
|
-
title = _c.sent();
|
|
492
|
-
origReport = JSON.parse(JSON.stringify(report));
|
|
493
|
-
if (!Config.captureScreenshots) return [3 /*break*/, 7];
|
|
494
|
-
return [4 /*yield*/, page.screenshot({
|
|
495
|
-
fullPage: true,
|
|
496
|
-
encoding: "base64"
|
|
497
|
-
})];
|
|
498
|
-
case 6:
|
|
499
|
-
image = _c.sent();
|
|
500
|
-
origReport.screenshot = image;
|
|
501
|
-
_c.label = 7;
|
|
502
|
-
case 7:
|
|
503
|
-
finalReport = ReporterManager_js_1.ReporterManager.addEngineReport("Puppeteer", startScan, url, title, label, origReport);
|
|
504
|
-
_c.label = 8;
|
|
505
|
-
case 8:
|
|
506
|
-
page.aceBusy = false;
|
|
507
|
-
return [2 /*return*/, {
|
|
508
|
-
"report": finalReport,
|
|
509
|
-
"puppeteer": parsed
|
|
510
|
-
}];
|
|
511
|
-
case 9:
|
|
512
|
-
err_2 = _c.sent();
|
|
513
|
-
console.error(err_2);
|
|
514
|
-
return [2 /*return*/, Promise.reject(err_2)];
|
|
515
|
-
case 10:
|
|
516
|
-
;
|
|
517
|
-
return [2 /*return*/];
|
|
394
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
395
|
+
try {
|
|
396
|
+
const startScan = Date.now();
|
|
397
|
+
// NOTE: Engine should already be loaded
|
|
398
|
+
const page = parsed;
|
|
399
|
+
let report = yield page.executeAsync(({ policies, customRulesets, reportLevels }, done) => {
|
|
400
|
+
const valueToLevel = (reportValue) => {
|
|
401
|
+
let reportLevel;
|
|
402
|
+
if (reportValue[1] === "PASS") {
|
|
403
|
+
reportLevel = "pass";
|
|
404
|
+
}
|
|
405
|
+
else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") {
|
|
406
|
+
reportLevel = "manual";
|
|
407
|
+
}
|
|
408
|
+
else if (reportValue[0] === "VIOLATION") {
|
|
409
|
+
if (reportValue[1] === "FAIL") {
|
|
410
|
+
reportLevel = "violation";
|
|
411
|
+
}
|
|
412
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
413
|
+
reportLevel = "potentialviolation";
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
else if (reportValue[0] === "RECOMMENDATION") {
|
|
417
|
+
if (reportValue[1] === "FAIL") {
|
|
418
|
+
reportLevel = "recommendation";
|
|
419
|
+
}
|
|
420
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
421
|
+
reportLevel = "potentialrecommendation";
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return reportLevel;
|
|
425
|
+
};
|
|
426
|
+
const getCounts = (engineReport) => {
|
|
427
|
+
let counts = {
|
|
428
|
+
violation: 0,
|
|
429
|
+
potentialviolation: 0,
|
|
430
|
+
recommendation: 0,
|
|
431
|
+
potentialrecommendation: 0,
|
|
432
|
+
manual: 0,
|
|
433
|
+
pass: 0
|
|
434
|
+
};
|
|
435
|
+
for (const issue of engineReport.results) {
|
|
436
|
+
++counts[issue.level];
|
|
437
|
+
}
|
|
438
|
+
return counts;
|
|
439
|
+
};
|
|
440
|
+
let checker = new window.ace_ibma.Checker();
|
|
441
|
+
customRulesets.forEach((rs) => checker.addRuleset(rs));
|
|
442
|
+
return new Promise((resolve, reject) => {
|
|
443
|
+
setTimeout(function () {
|
|
444
|
+
checker.check(document, policies).then(function (report) {
|
|
445
|
+
var _a;
|
|
446
|
+
for (const result of report.results) {
|
|
447
|
+
delete result.node;
|
|
448
|
+
result.level = valueToLevel(result.value);
|
|
449
|
+
}
|
|
450
|
+
report.summary || (report.summary = {});
|
|
451
|
+
(_a = report.summary).counts || (_a.counts = getCounts(report));
|
|
452
|
+
// Filter out pass results unless they asked for them in reports
|
|
453
|
+
// We don't want to mess with baseline functions, but pass results can break the response object
|
|
454
|
+
report.results = report.results.filter(result => reportLevels.includes(result.level) || result.level !== "pass");
|
|
455
|
+
resolve(report);
|
|
456
|
+
done(report);
|
|
457
|
+
});
|
|
458
|
+
}, 0);
|
|
459
|
+
});
|
|
460
|
+
}, { policies: Config.policies, customRulesets: ACEngineManager_js_1.ACEngineManager.customRulesets, reportLevels: (Config.reportLevels || []).concat(Config.failLevels || []).map(lvl => lvl.toString()) });
|
|
461
|
+
if (curPol != null && !checkPolicy) {
|
|
462
|
+
const valPolicies = ACEngineManager_js_1.ACEngineManager.customRulesets.map(rs => rs.id).concat(yield page.execute(() => (new window.ace_ibma.Checker().rulesetIds)));
|
|
463
|
+
checkPolicy = true;
|
|
464
|
+
areValidPolicy(valPolicies, curPol);
|
|
518
465
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
page = parsed;
|
|
531
|
-
return [4 /*yield*/, page.evaluate(function (_a) {
|
|
532
|
-
var policies = _a.policies, customRulesets = _a.customRulesets, reportLevels = _a.reportLevels;
|
|
533
|
-
var valueToLevel = function (reportValue) {
|
|
534
|
-
var reportLevel;
|
|
535
|
-
if (reportValue[1] === "PASS") {
|
|
536
|
-
reportLevel = "pass";
|
|
537
|
-
}
|
|
538
|
-
else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") {
|
|
539
|
-
reportLevel = "manual";
|
|
540
|
-
}
|
|
541
|
-
else if (reportValue[0] === "VIOLATION") {
|
|
542
|
-
if (reportValue[1] === "FAIL") {
|
|
543
|
-
reportLevel = "violation";
|
|
544
|
-
}
|
|
545
|
-
else if (reportValue[1] === "POTENTIAL") {
|
|
546
|
-
reportLevel = "potentialviolation";
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
else if (reportValue[0] === "RECOMMENDATION") {
|
|
550
|
-
if (reportValue[1] === "FAIL") {
|
|
551
|
-
reportLevel = "recommendation";
|
|
552
|
-
}
|
|
553
|
-
else if (reportValue[1] === "POTENTIAL") {
|
|
554
|
-
reportLevel = "potentialrecommendation";
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return reportLevel;
|
|
558
|
-
};
|
|
559
|
-
var getCounts = function (engineReport) {
|
|
560
|
-
var counts = {
|
|
561
|
-
violation: 0,
|
|
562
|
-
potentialviolation: 0,
|
|
563
|
-
recommendation: 0,
|
|
564
|
-
potentialrecommendation: 0,
|
|
565
|
-
manual: 0,
|
|
566
|
-
pass: 0
|
|
567
|
-
};
|
|
568
|
-
for (var _i = 0, _a = engineReport.results; _i < _a.length; _i++) {
|
|
569
|
-
var issue = _a[_i];
|
|
570
|
-
++counts[issue.level];
|
|
571
|
-
}
|
|
572
|
-
return counts;
|
|
573
|
-
};
|
|
574
|
-
var checker = new window.ace_ibma.Checker();
|
|
575
|
-
customRulesets.forEach(function (rs) { return checker.addRuleset(rs); });
|
|
576
|
-
return new Promise(function (resolve, reject) {
|
|
577
|
-
setTimeout(function () {
|
|
578
|
-
checker.check(document, policies).then(function (report) {
|
|
579
|
-
var _a;
|
|
580
|
-
for (var _i = 0, _b = report.results; _i < _b.length; _i++) {
|
|
581
|
-
var result = _b[_i];
|
|
582
|
-
delete result.node;
|
|
583
|
-
result.level = valueToLevel(result.value);
|
|
584
|
-
}
|
|
585
|
-
report.summary || (report.summary = {});
|
|
586
|
-
(_a = report.summary).counts || (_a.counts = getCounts(report));
|
|
587
|
-
// Filter out pass results unless they asked for them in reports
|
|
588
|
-
// We don't want to mess with baseline functions, but pass results can break the response object
|
|
589
|
-
report.results = report.results.filter(function (result) { return reportLevels.includes(result.level) || result.level !== "pass"; });
|
|
590
|
-
resolve(report);
|
|
591
|
-
});
|
|
592
|
-
}, 0);
|
|
593
|
-
});
|
|
594
|
-
}, { policies: Config.policies, customRulesets: ACEngineManager_js_1.ACEngineManager.customRulesets, reportLevels: (Config.reportLevels || []).concat(Config.failLevels || []).map(function (lvl) { return lvl.toString(); }) })];
|
|
595
|
-
case 1:
|
|
596
|
-
report = _c.sent();
|
|
597
|
-
if (!(curPol != null && !checkPolicy)) return [3 /*break*/, 3];
|
|
598
|
-
_b = (_a = ACEngineManager_js_1.ACEngineManager.customRulesets.map(function (rs) { return rs.id; })).concat;
|
|
599
|
-
return [4 /*yield*/, page.evaluate("new window.ace_ibma.Checker().rulesetIds")];
|
|
600
|
-
case 2:
|
|
601
|
-
valPolicies = _b.apply(_a, [_c.sent()]);
|
|
602
|
-
checkPolicy = true;
|
|
603
|
-
areValidPolicy(valPolicies, curPol);
|
|
604
|
-
_c.label = 3;
|
|
605
|
-
case 3:
|
|
606
|
-
finalReport = void 0;
|
|
607
|
-
if (!report.results) return [3 /*break*/, 8];
|
|
608
|
-
return [4 /*yield*/, page.evaluate("document.location.href")];
|
|
609
|
-
case 4:
|
|
610
|
-
url = _c.sent();
|
|
611
|
-
return [4 /*yield*/, page.evaluate("document.location.title")];
|
|
612
|
-
case 5:
|
|
613
|
-
title = _c.sent();
|
|
614
|
-
origReport = JSON.parse(JSON.stringify(report));
|
|
615
|
-
if (!Config.captureScreenshots) return [3 /*break*/, 7];
|
|
616
|
-
return [4 /*yield*/, page.screenshot({
|
|
617
|
-
fullPage: true,
|
|
618
|
-
encoding: "base64"
|
|
619
|
-
})];
|
|
620
|
-
case 6:
|
|
621
|
-
image = _c.sent();
|
|
466
|
+
let finalReport;
|
|
467
|
+
// If there is something to report...
|
|
468
|
+
if (report.results) {
|
|
469
|
+
let url = yield page.execute(() => document.location.href);
|
|
470
|
+
let title = yield page.execute(() => document.location.title);
|
|
471
|
+
let origReport = JSON.parse(JSON.stringify(report));
|
|
472
|
+
if (Config.captureScreenshots) {
|
|
473
|
+
let image = yield page.screenshot({
|
|
474
|
+
fullPage: true,
|
|
475
|
+
encoding: "base64"
|
|
476
|
+
});
|
|
622
477
|
origReport.screenshot = image;
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
finalReport = ReporterManager_js_1.ReporterManager.addEngineReport("Puppeteer", startScan, url, title, label, origReport);
|
|
626
|
-
_c.label = 8;
|
|
627
|
-
case 8:
|
|
628
|
-
page.aceBusy = false;
|
|
629
|
-
return [2 /*return*/, {
|
|
630
|
-
"report": finalReport,
|
|
631
|
-
"puppeteer": parsed
|
|
632
|
-
}];
|
|
633
|
-
case 9:
|
|
634
|
-
err_3 = _c.sent();
|
|
635
|
-
console.error(err_3);
|
|
636
|
-
return [2 /*return*/, Promise.reject(err_3)];
|
|
637
|
-
case 10:
|
|
638
|
-
;
|
|
639
|
-
return [2 /*return*/];
|
|
478
|
+
}
|
|
479
|
+
finalReport = ReporterManager_js_1.ReporterManager.addEngineReport("Puppeteer", startScan, url, title, label, origReport);
|
|
640
480
|
}
|
|
641
|
-
|
|
481
|
+
page.aceBusy = false;
|
|
482
|
+
return {
|
|
483
|
+
"report": finalReport,
|
|
484
|
+
"puppeteer": parsed
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
catch (err) {
|
|
488
|
+
console.error(err);
|
|
489
|
+
return Promise.reject(err);
|
|
490
|
+
}
|
|
491
|
+
;
|
|
642
492
|
});
|
|
643
493
|
}
|
|
644
|
-
function
|
|
645
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
494
|
+
function getComplianceHelperPuppeteer(label, parsed, curPol) {
|
|
495
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
496
|
+
try {
|
|
497
|
+
const startScan = Date.now();
|
|
498
|
+
// NOTE: Engine should already be loaded
|
|
499
|
+
const page = parsed;
|
|
500
|
+
let report = yield page.evaluate(({ policies, customRulesets, reportLevels }) => {
|
|
501
|
+
const valueToLevel = (reportValue) => {
|
|
502
|
+
let reportLevel;
|
|
503
|
+
if (reportValue[1] === "PASS") {
|
|
504
|
+
reportLevel = "pass";
|
|
505
|
+
}
|
|
506
|
+
else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") {
|
|
507
|
+
reportLevel = "manual";
|
|
508
|
+
}
|
|
509
|
+
else if (reportValue[0] === "VIOLATION") {
|
|
510
|
+
if (reportValue[1] === "FAIL") {
|
|
511
|
+
reportLevel = "violation";
|
|
658
512
|
}
|
|
659
|
-
else if (reportValue[
|
|
660
|
-
|
|
661
|
-
reportLevel = "violation";
|
|
662
|
-
}
|
|
663
|
-
else if (reportValue[1] === "POTENTIAL") {
|
|
664
|
-
reportLevel = "potentialviolation";
|
|
665
|
-
}
|
|
513
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
514
|
+
reportLevel = "potentialviolation";
|
|
666
515
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
else if (reportValue[1] === "POTENTIAL") {
|
|
672
|
-
reportLevel = "potentialrecommendation";
|
|
673
|
-
}
|
|
516
|
+
}
|
|
517
|
+
else if (reportValue[0] === "RECOMMENDATION") {
|
|
518
|
+
if (reportValue[1] === "FAIL") {
|
|
519
|
+
reportLevel = "recommendation";
|
|
674
520
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
getCounts_1 = function (engineReport) {
|
|
678
|
-
var counts = {
|
|
679
|
-
violation: 0,
|
|
680
|
-
potentialviolation: 0,
|
|
681
|
-
recommendation: 0,
|
|
682
|
-
potentialrecommendation: 0,
|
|
683
|
-
manual: 0,
|
|
684
|
-
pass: 0
|
|
685
|
-
};
|
|
686
|
-
for (var _i = 0, _a = engineReport.results; _i < _a.length; _i++) {
|
|
687
|
-
var issue = _a[_i];
|
|
688
|
-
++counts[issue.level];
|
|
521
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
522
|
+
reportLevel = "potentialrecommendation";
|
|
689
523
|
}
|
|
690
|
-
|
|
524
|
+
}
|
|
525
|
+
return reportLevel;
|
|
526
|
+
};
|
|
527
|
+
const getCounts = (engineReport) => {
|
|
528
|
+
let counts = {
|
|
529
|
+
violation: 0,
|
|
530
|
+
potentialviolation: 0,
|
|
531
|
+
recommendation: 0,
|
|
532
|
+
potentialrecommendation: 0,
|
|
533
|
+
manual: 0,
|
|
534
|
+
pass: 0
|
|
691
535
|
};
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
return
|
|
696
|
-
|
|
536
|
+
for (const issue of engineReport.results) {
|
|
537
|
+
++counts[issue.level];
|
|
538
|
+
}
|
|
539
|
+
return counts;
|
|
540
|
+
};
|
|
541
|
+
let checker = new window.ace_ibma.Checker();
|
|
542
|
+
customRulesets.forEach((rs) => checker.addRuleset(rs));
|
|
543
|
+
return new Promise((resolve, reject) => {
|
|
544
|
+
setTimeout(function () {
|
|
545
|
+
checker.check(document, policies).then(function (report) {
|
|
697
546
|
var _a;
|
|
698
|
-
for (
|
|
699
|
-
var result = _b[_i];
|
|
547
|
+
for (const result of report.results) {
|
|
700
548
|
delete result.node;
|
|
701
|
-
result.level =
|
|
549
|
+
result.level = valueToLevel(result.value);
|
|
702
550
|
}
|
|
703
551
|
report.summary || (report.summary = {});
|
|
704
|
-
(_a = report.summary).counts || (_a.counts =
|
|
705
|
-
var reportLevels = (Config.reportLevels || []).concat(Config.failLevels || []).map(function (lvl) { return lvl.toString(); });
|
|
552
|
+
(_a = report.summary).counts || (_a.counts = getCounts(report));
|
|
706
553
|
// Filter out pass results unless they asked for them in reports
|
|
707
554
|
// We don't want to mess with baseline functions, but pass results can break the response object
|
|
708
|
-
report.results = report.results.filter(
|
|
709
|
-
|
|
710
|
-
})
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
555
|
+
report.results = report.results.filter(result => reportLevels.includes(result.level) || result.level !== "pass");
|
|
556
|
+
resolve(report);
|
|
557
|
+
});
|
|
558
|
+
}, 0);
|
|
559
|
+
});
|
|
560
|
+
}, { policies: Config.policies, customRulesets: ACEngineManager_js_1.ACEngineManager.customRulesets, reportLevels: (Config.reportLevels || []).concat(Config.failLevels || []).map(lvl => lvl.toString()) });
|
|
561
|
+
if (curPol != null && !checkPolicy) {
|
|
562
|
+
const valPolicies = ACEngineManager_js_1.ACEngineManager.customRulesets.map(rs => rs.id).concat(yield page.evaluate("new window.ace_ibma.Checker().rulesetIds"));
|
|
563
|
+
checkPolicy = true;
|
|
564
|
+
areValidPolicy(valPolicies, curPol);
|
|
565
|
+
}
|
|
566
|
+
let finalReport;
|
|
567
|
+
// If there is something to report...
|
|
568
|
+
if (report.results) {
|
|
569
|
+
let url = yield page.evaluate("document.location.href");
|
|
570
|
+
let title = yield page.evaluate("document.location.title");
|
|
571
|
+
let origReport = JSON.parse(JSON.stringify(report));
|
|
572
|
+
if (Config.captureScreenshots) {
|
|
573
|
+
let image = yield page.screenshot({
|
|
574
|
+
fullPage: true,
|
|
575
|
+
encoding: "base64"
|
|
576
|
+
});
|
|
577
|
+
origReport.screenshot = image;
|
|
578
|
+
}
|
|
579
|
+
finalReport = ReporterManager_js_1.ReporterManager.addEngineReport("Puppeteer", startScan, url, title, label, origReport);
|
|
580
|
+
}
|
|
581
|
+
page.aceBusy = false;
|
|
582
|
+
return {
|
|
583
|
+
"report": finalReport,
|
|
584
|
+
"puppeteer": parsed
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
catch (err) {
|
|
588
|
+
console.error(err);
|
|
589
|
+
return Promise.reject(err);
|
|
590
|
+
}
|
|
591
|
+
;
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
function getComplianceHelperLocal(label, parsed, curPol) {
|
|
595
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
596
|
+
try {
|
|
597
|
+
const valueToLevel = (reportValue) => {
|
|
598
|
+
let reportLevel;
|
|
599
|
+
if (reportValue[1] === "PASS") {
|
|
600
|
+
reportLevel = "pass";
|
|
601
|
+
}
|
|
602
|
+
else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") {
|
|
603
|
+
reportLevel = "manual";
|
|
604
|
+
}
|
|
605
|
+
else if (reportValue[0] === "VIOLATION") {
|
|
606
|
+
if (reportValue[1] === "FAIL") {
|
|
607
|
+
reportLevel = "violation";
|
|
717
608
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
if (report.results) {
|
|
721
|
-
url = parsed.location && parsed.location.href;
|
|
722
|
-
origReport = JSON.parse(JSON.stringify(report));
|
|
723
|
-
finalReport = ReporterManager_js_1.ReporterManager.addEngineReport("Native", startScan, url, parsed.title, label, origReport);
|
|
609
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
610
|
+
reportLevel = "potentialviolation";
|
|
724
611
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
612
|
+
}
|
|
613
|
+
else if (reportValue[0] === "RECOMMENDATION") {
|
|
614
|
+
if (reportValue[1] === "FAIL") {
|
|
615
|
+
reportLevel = "recommendation";
|
|
616
|
+
}
|
|
617
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
618
|
+
reportLevel = "potentialrecommendation";
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
return reportLevel;
|
|
622
|
+
};
|
|
623
|
+
const getCounts = (engineReport) => {
|
|
624
|
+
let counts = {
|
|
625
|
+
violation: 0,
|
|
626
|
+
potentialviolation: 0,
|
|
627
|
+
recommendation: 0,
|
|
628
|
+
potentialrecommendation: 0,
|
|
629
|
+
manual: 0,
|
|
630
|
+
pass: 0
|
|
631
|
+
};
|
|
632
|
+
for (const issue of engineReport.results) {
|
|
633
|
+
++counts[issue.level];
|
|
634
|
+
}
|
|
635
|
+
return counts;
|
|
636
|
+
};
|
|
637
|
+
let startScan = Date.now();
|
|
638
|
+
let checker = ACEngineManager_js_1.ACEngineManager.getChecker();
|
|
639
|
+
ACEngineManager_js_1.ACEngineManager.customRulesets.forEach((rs) => checker.addGuideline(rs));
|
|
640
|
+
let report = yield checker.check(parsed, Config.policies)
|
|
641
|
+
.then(function (report) {
|
|
642
|
+
var _a;
|
|
643
|
+
for (const result of report.results) {
|
|
644
|
+
delete result.node;
|
|
645
|
+
result.level = valueToLevel(result.value);
|
|
646
|
+
}
|
|
647
|
+
report.summary || (report.summary = {});
|
|
648
|
+
(_a = report.summary).counts || (_a.counts = getCounts(report));
|
|
649
|
+
let reportLevels = (Config.reportLevels || []).concat(Config.failLevels || []).map(lvl => lvl.toString());
|
|
650
|
+
// Filter out pass results unless they asked for them in reports
|
|
651
|
+
// We don't want to mess with baseline functions, but pass results can break the response object
|
|
652
|
+
report.results = report.results.filter(result => reportLevels.includes(result.level) || result.level !== "pass");
|
|
653
|
+
return report;
|
|
654
|
+
});
|
|
655
|
+
if (curPol != null && !checkPolicy) {
|
|
656
|
+
let valPolicies = checker.getGuidelineIds();
|
|
657
|
+
checkPolicy = true;
|
|
658
|
+
areValidPolicy(valPolicies, curPol);
|
|
659
|
+
}
|
|
660
|
+
let finalReport;
|
|
661
|
+
// If there is something to report...
|
|
662
|
+
if (report.results) {
|
|
663
|
+
let url = parsed.location && parsed.location.href;
|
|
664
|
+
let origReport = JSON.parse(JSON.stringify(report));
|
|
665
|
+
finalReport = ReporterManager_js_1.ReporterManager.addEngineReport("Native", startScan, url, parsed.title, label, origReport);
|
|
735
666
|
}
|
|
736
|
-
|
|
667
|
+
return {
|
|
668
|
+
"report": finalReport
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
catch (err) {
|
|
672
|
+
console.error(err);
|
|
673
|
+
return Promise.reject(err);
|
|
674
|
+
}
|
|
675
|
+
;
|
|
737
676
|
});
|
|
738
677
|
}
|
|
739
678
|
//# sourceMappingURL=ACHelper.js.map
|