accessibility-checker 4.0.0 → 4.0.1
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 +262 -213
- package/bin/achecker.js.map +1 -1
- package/index.js +63 -21
- package/index.js.map +1 -1
- package/lib/ACBrowserManager.js +203 -138
- package/lib/ACBrowserManager.js.map +1 -1
- package/lib/ACEngineManager.js +402 -395
- package/lib/ACEngineManager.js.map +1 -1
- package/lib/ACHelper.js +642 -581
- package/lib/ACHelper.js.map +1 -1
- package/lib/common/api-ext/Fetch.js +78 -58
- package/lib/common/api-ext/Fetch.js.map +1 -1
- package/lib/common/config/ACConfigManager.d.ts +1 -1
- package/lib/common/config/ACConfigManager.js +295 -285
- package/lib/common/config/ACConfigManager.js.map +1 -1
- package/lib/common/config/ACConstants.js +4 -38
- package/lib/common/config/ACConstants.js.map +1 -1
- package/lib/common/config/IConfig.d.ts +1 -1
- package/lib/common/engine/IChecker.d.ts +2 -2
- package/lib/common/engine/IEngine.d.ts +1 -1
- package/lib/common/engine/IGuideline.d.ts +1 -1
- package/lib/common/engine/IMapper.d.ts +1 -1
- package/lib/common/engine/IReport.d.ts +4 -4
- package/lib/common/engine/IRule.d.ts +4 -4
- package/lib/common/engine/IRuleset.d.ts +1 -1
- package/lib/common/report/ACReporterCSV.js +77 -42
- package/lib/common/report/ACReporterCSV.js.map +1 -1
- package/lib/common/report/ACReporterHTML.js +48 -15
- package/lib/common/report/ACReporterHTML.js.map +1 -1
- package/lib/common/report/ACReporterJSON.js +94 -59
- package/lib/common/report/ACReporterJSON.js.map +1 -1
- package/lib/common/report/ACReporterMetrics.js +108 -45
- package/lib/common/report/ACReporterMetrics.js.map +1 -1
- package/lib/common/report/ACReporterXLSX.js +300 -282
- package/lib/common/report/ACReporterXLSX.js.map +1 -1
- package/lib/common/report/BaselineManager.js +56 -82
- package/lib/common/report/BaselineManager.js.map +1 -1
- package/lib/common/report/ReporterManager.js +190 -125
- package/lib/common/report/ReporterManager.js.map +1 -1
- package/lib/common/report/genReport.js +2 -2
- package/package.json +4 -10
- package/cjs/bin/achecker.d.ts +0 -2
- package/cjs/bin/achecker.js +0 -306
- package/cjs/bin/achecker.js.map +0 -1
- package/cjs/index.d.ts +0 -319
- package/cjs/index.js +0 -402
- package/cjs/index.js.map +0 -1
- package/cjs/lib/ACBrowserManager.d.ts +0 -22
- package/cjs/lib/ACBrowserManager.js +0 -172
- package/cjs/lib/ACBrowserManager.js.map +0 -1
- package/cjs/lib/ACEngineManager.d.ts +0 -19
- package/cjs/lib/ACEngineManager.js +0 -457
- package/cjs/lib/ACEngineManager.js.map +0 -1
- package/cjs/lib/ACHelper.d.ts +0 -2
- package/cjs/lib/ACHelper.js +0 -678
- package/cjs/lib/ACHelper.js.map +0 -1
- package/cjs/lib/api/IChecker.d.ts +0 -28
- package/cjs/lib/api/IChecker.js +0 -11
- package/cjs/lib/api/IChecker.js.map +0 -1
- package/cjs/lib/api/IMapper.d.ts +0 -37
- package/cjs/lib/api/IMapper.js +0 -18
- package/cjs/lib/api/IMapper.js.map +0 -1
- package/cjs/lib/common/api-ext/Fetch.d.ts +0 -17
- package/cjs/lib/common/api-ext/Fetch.js +0 -95
- package/cjs/lib/common/api-ext/Fetch.js.map +0 -1
- package/cjs/lib/common/api-ext/IAbstractAPI.d.ts +0 -33
- package/cjs/lib/common/api-ext/IAbstractAPI.js +0 -18
- package/cjs/lib/common/api-ext/IAbstractAPI.js.map +0 -1
- package/cjs/lib/common/config/ACConfigManager.d.ts +0 -13
- package/cjs/lib/common/config/ACConfigManager.js +0 -483
- package/cjs/lib/common/config/ACConfigManager.js.map +0 -1
- package/cjs/lib/common/config/ACConstants.d.ts +0 -17
- package/cjs/lib/common/config/ACConstants.js +0 -111
- package/cjs/lib/common/config/ACConstants.js.map +0 -1
- package/cjs/lib/common/config/IArchive.d.ts +0 -37
- package/cjs/lib/common/config/IArchive.js +0 -18
- package/cjs/lib/common/config/IArchive.js.map +0 -1
- package/cjs/lib/common/config/IConfig.d.ts +0 -152
- package/cjs/lib/common/config/IConfig.js +0 -36
- package/cjs/lib/common/config/IConfig.js.map +0 -1
- package/cjs/lib/common/engine/IBounds.d.ts +0 -21
- package/cjs/lib/common/engine/IBounds.js +0 -18
- package/cjs/lib/common/engine/IBounds.js.map +0 -1
- package/cjs/lib/common/engine/IChecker.d.ts +0 -23
- package/cjs/lib/common/engine/IChecker.js +0 -18
- package/cjs/lib/common/engine/IChecker.js.map +0 -1
- package/cjs/lib/common/engine/IEngine.d.ts +0 -39
- package/cjs/lib/common/engine/IEngine.js +0 -18
- package/cjs/lib/common/engine/IEngine.js.map +0 -1
- package/cjs/lib/common/engine/IGuideline.d.ts +0 -53
- package/cjs/lib/common/engine/IGuideline.js +0 -37
- package/cjs/lib/common/engine/IGuideline.js.map +0 -1
- package/cjs/lib/common/engine/IMapper.d.ts +0 -32
- package/cjs/lib/common/engine/IMapper.js +0 -18
- package/cjs/lib/common/engine/IMapper.js.map +0 -1
- package/cjs/lib/common/engine/IReport.d.ts +0 -143
- package/cjs/lib/common/engine/IReport.js +0 -44
- package/cjs/lib/common/engine/IReport.js.map +0 -1
- package/cjs/lib/common/engine/IRule.d.ts +0 -100
- package/cjs/lib/common/engine/IRule.js +0 -87
- package/cjs/lib/common/engine/IRule.js.map +0 -1
- package/cjs/lib/common/engine/IRuleset.d.ts +0 -20
- package/cjs/lib/common/engine/IRuleset.js +0 -18
- package/cjs/lib/common/engine/IRuleset.js.map +0 -1
- package/cjs/lib/common/report/ACReporterCSV.d.ts +0 -28
- package/cjs/lib/common/report/ACReporterCSV.js +0 -75
- package/cjs/lib/common/report/ACReporterCSV.js.map +0 -1
- package/cjs/lib/common/report/ACReporterHTML.d.ts +0 -27
- package/cjs/lib/common/report/ACReporterHTML.js +0 -61
- package/cjs/lib/common/report/ACReporterHTML.js.map +0 -1
- package/cjs/lib/common/report/ACReporterJSON.d.ts +0 -36
- package/cjs/lib/common/report/ACReporterJSON.js +0 -109
- package/cjs/lib/common/report/ACReporterJSON.js.map +0 -1
- package/cjs/lib/common/report/ACReporterMetrics.d.ts +0 -78
- package/cjs/lib/common/report/ACReporterMetrics.js +0 -135
- package/cjs/lib/common/report/ACReporterMetrics.js.map +0 -1
- package/cjs/lib/common/report/ACReporterXLSX.d.ts +0 -38
- package/cjs/lib/common/report/ACReporterXLSX.js +0 -996
- package/cjs/lib/common/report/ACReporterXLSX.js.map +0 -1
- package/cjs/lib/common/report/BaselineManager.d.ts +0 -169
- package/cjs/lib/common/report/BaselineManager.js +0 -382
- package/cjs/lib/common/report/BaselineManager.js.map +0 -1
- package/cjs/lib/common/report/ReporterManager.d.ts +0 -79
- package/cjs/lib/common/report/ReporterManager.js +0 -469
- package/cjs/lib/common/report/ReporterManager.js.map +0 -1
- package/cjs/lib/common/report/genReport.d.ts +0 -1
- package/cjs/lib/common/report/genReport.js +0 -12
- package/cjs/lib/common/report/genReport.js.map +0 -1
- package/cjs/package.json +0 -3
- package/mjs/bin/achecker.d.ts +0 -2
- package/mjs/bin/achecker.js +0 -236
- package/mjs/bin/achecker.js.map +0 -1
- package/mjs/index.d.ts +0 -319
- package/mjs/index.js +0 -368
- package/mjs/index.js.map +0 -1
- package/mjs/lib/ACBrowserManager.d.ts +0 -22
- package/mjs/lib/ACBrowserManager.js +0 -121
- package/mjs/lib/ACBrowserManager.js.map +0 -1
- package/mjs/lib/ACEngineManager.d.ts +0 -19
- package/mjs/lib/ACEngineManager.js +0 -397
- package/mjs/lib/ACEngineManager.js.map +0 -1
- package/mjs/lib/ACHelper.d.ts +0 -2
- package/mjs/lib/ACHelper.js +0 -614
- package/mjs/lib/ACHelper.js.map +0 -1
- package/mjs/lib/api/IChecker.d.ts +0 -28
- package/mjs/lib/api/IChecker.js +0 -8
- package/mjs/lib/api/IChecker.js.map +0 -1
- package/mjs/lib/api/IMapper.d.ts +0 -37
- package/mjs/lib/api/IMapper.js +0 -17
- package/mjs/lib/api/IMapper.js.map +0 -1
- package/mjs/lib/common/api-ext/Fetch.d.ts +0 -17
- package/mjs/lib/common/api-ext/Fetch.js +0 -45
- package/mjs/lib/common/api-ext/Fetch.js.map +0 -1
- package/mjs/lib/common/api-ext/IAbstractAPI.d.ts +0 -33
- package/mjs/lib/common/api-ext/IAbstractAPI.js +0 -17
- package/mjs/lib/common/api-ext/IAbstractAPI.js.map +0 -1
- package/mjs/lib/common/config/ACConfigManager.d.ts +0 -13
- package/mjs/lib/common/config/ACConfigManager.js +0 -421
- package/mjs/lib/common/config/ACConfigManager.js.map +0 -1
- package/mjs/lib/common/config/ACConstants.d.ts +0 -17
- package/mjs/lib/common/config/ACConstants.js +0 -75
- package/mjs/lib/common/config/ACConstants.js.map +0 -1
- package/mjs/lib/common/config/IArchive.d.ts +0 -37
- package/mjs/lib/common/config/IArchive.js +0 -17
- package/mjs/lib/common/config/IArchive.js.map +0 -1
- package/mjs/lib/common/config/IConfig.d.ts +0 -152
- package/mjs/lib/common/config/IConfig.js +0 -33
- package/mjs/lib/common/config/IConfig.js.map +0 -1
- package/mjs/lib/common/engine/IBounds.d.ts +0 -21
- package/mjs/lib/common/engine/IBounds.js +0 -17
- package/mjs/lib/common/engine/IBounds.js.map +0 -1
- package/mjs/lib/common/engine/IChecker.d.ts +0 -23
- package/mjs/lib/common/engine/IChecker.js +0 -17
- package/mjs/lib/common/engine/IChecker.js.map +0 -1
- package/mjs/lib/common/engine/IEngine.d.ts +0 -39
- package/mjs/lib/common/engine/IEngine.js +0 -17
- package/mjs/lib/common/engine/IEngine.js.map +0 -1
- package/mjs/lib/common/engine/IGuideline.d.ts +0 -53
- package/mjs/lib/common/engine/IGuideline.js +0 -34
- package/mjs/lib/common/engine/IGuideline.js.map +0 -1
- package/mjs/lib/common/engine/IMapper.d.ts +0 -32
- package/mjs/lib/common/engine/IMapper.js +0 -17
- package/mjs/lib/common/engine/IMapper.js.map +0 -1
- package/mjs/lib/common/engine/IReport.d.ts +0 -143
- package/mjs/lib/common/engine/IReport.js +0 -36
- package/mjs/lib/common/engine/IReport.js.map +0 -1
- package/mjs/lib/common/engine/IRule.d.ts +0 -100
- package/mjs/lib/common/engine/IRule.js +0 -79
- package/mjs/lib/common/engine/IRule.js.map +0 -1
- package/mjs/lib/common/engine/IRuleset.d.ts +0 -20
- package/mjs/lib/common/engine/IRuleset.js +0 -17
- package/mjs/lib/common/engine/IRuleset.js.map +0 -1
- package/mjs/lib/common/report/ACReporterCSV.d.ts +0 -28
- package/mjs/lib/common/report/ACReporterCSV.js +0 -60
- package/mjs/lib/common/report/ACReporterCSV.js.map +0 -1
- package/mjs/lib/common/report/ACReporterHTML.d.ts +0 -27
- package/mjs/lib/common/report/ACReporterHTML.js +0 -46
- package/mjs/lib/common/report/ACReporterHTML.js.map +0 -1
- package/mjs/lib/common/report/ACReporterJSON.d.ts +0 -36
- package/mjs/lib/common/report/ACReporterJSON.js +0 -94
- package/mjs/lib/common/report/ACReporterJSON.js.map +0 -1
- package/mjs/lib/common/report/ACReporterMetrics.d.ts +0 -78
- package/mjs/lib/common/report/ACReporterMetrics.js +0 -122
- package/mjs/lib/common/report/ACReporterMetrics.js.map +0 -1
- package/mjs/lib/common/report/ACReporterXLSX.d.ts +0 -38
- package/mjs/lib/common/report/ACReporterXLSX.js +0 -948
- package/mjs/lib/common/report/ACReporterXLSX.js.map +0 -1
- package/mjs/lib/common/report/BaselineManager.d.ts +0 -169
- package/mjs/lib/common/report/BaselineManager.js +0 -348
- package/mjs/lib/common/report/BaselineManager.js.map +0 -1
- package/mjs/lib/common/report/ReporterManager.d.ts +0 -79
- package/mjs/lib/common/report/ReporterManager.js +0 -469
- package/mjs/lib/common/report/ReporterManager.js.map +0 -1
- package/mjs/lib/common/report/genReport.d.ts +0 -1
- package/mjs/lib/common/report/genReport.js +0 -9
- package/mjs/lib/common/report/genReport.js.map +0 -1
- package/mjs/package.json +0 -3
package/lib/ACHelper.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
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
|
-
})();
|
|
35
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,128 +8,209 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
9
|
});
|
|
43
10
|
};
|
|
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
|
+
};
|
|
44
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
39
|
exports.getComplianceHelper = getComplianceHelper;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
var fs_1 = require("fs");
|
|
41
|
+
var path_1 = require("path");
|
|
42
|
+
var ACBrowserManager_js_1 = require("./ACBrowserManager.js");
|
|
43
|
+
var ACEngineManager_js_1 = require("./ACEngineManager.js");
|
|
44
|
+
var ACConfigManager_js_1 = require("./common/config/ACConfigManager.js");
|
|
45
|
+
var ReporterManager_js_1 = require("./common/report/ReporterManager.js");
|
|
46
|
+
var BaselineManager_js_1 = require("./common/report/BaselineManager.js");
|
|
47
|
+
var loggerCreate = function (type) {
|
|
54
48
|
return logger;
|
|
55
49
|
};
|
|
56
|
-
|
|
57
|
-
debug: (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
var logger = {
|
|
51
|
+
debug: function () {
|
|
52
|
+
var output = [];
|
|
53
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
54
|
+
output[_i] = arguments[_i];
|
|
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
|
+
},
|
|
61
79
|
create: loggerCreate
|
|
62
80
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
let outFile = this.prepFileSync(filePath);
|
|
68
|
-
(0, fs_1.writeFileSync)(outFile, data);
|
|
81
|
+
var Config;
|
|
82
|
+
var checkPolicy = false;
|
|
83
|
+
var MyFS = /** @class */ (function () {
|
|
84
|
+
function MyFS() {
|
|
69
85
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
MyFS.prototype.writeFileSync = function (filePath, data) {
|
|
87
|
+
var outFile = this.prepFileSync(filePath);
|
|
88
|
+
(0, fs_1.writeFileSync)(outFile, data);
|
|
89
|
+
};
|
|
90
|
+
MyFS.prototype.prepFileSync = function (filePath) {
|
|
91
|
+
var outDir = (0, path_1.resolve)(Config.outputFolder);
|
|
92
|
+
var outFile = (0, path_1.join)(outDir, filePath);
|
|
73
93
|
if (!(0, fs_1.existsSync)((0, path_1.dirname)(outFile))) {
|
|
74
94
|
(0, fs_1.mkdirSync)((0, path_1.dirname)(outFile), { recursive: true });
|
|
75
95
|
}
|
|
76
96
|
return outFile;
|
|
77
|
-
}
|
|
78
|
-
log
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
let baselineFile = (0, path_1.join)((0, path_1.join)(process.cwd(), Config.baselineFolder), label + ".json");
|
|
83
|
-
if (!(0, fs_1.existsSync)(baselineFile))
|
|
84
|
-
return null;
|
|
85
|
-
if (typeof require !== "undefined") {
|
|
86
|
-
return require(baselineFile);
|
|
97
|
+
};
|
|
98
|
+
MyFS.prototype.log = function () {
|
|
99
|
+
var output = [];
|
|
100
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
101
|
+
output[_i] = arguments[_i];
|
|
87
102
|
}
|
|
88
|
-
|
|
89
|
-
|
|
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];
|
|
90
109
|
}
|
|
91
|
-
|
|
92
|
-
|
|
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");
|
|
121
|
+
if (!(0, fs_1.existsSync)(baselineFile))
|
|
122
|
+
return null;
|
|
123
|
+
return require(baselineFile);
|
|
124
|
+
};
|
|
125
|
+
MyFS.prototype.getChecker = function () {
|
|
93
126
|
return ACEngineManager_js_1.ACEngineManager.getChecker();
|
|
94
|
-
}
|
|
95
|
-
|
|
127
|
+
};
|
|
128
|
+
return MyFS;
|
|
129
|
+
}());
|
|
96
130
|
function initialize() {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
131
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
+
var absAPI, refactorMap, rules, _i, rules_1, rule, key, _a, _b, _c;
|
|
133
|
+
return __generator(this, function (_d) {
|
|
134
|
+
switch (_d.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
if (Config)
|
|
137
|
+
return [2 /*return*/];
|
|
138
|
+
return [4 /*yield*/, ACConfigManager_js_1.ACConfigManager.getConfigUnsupported()];
|
|
139
|
+
case 1:
|
|
140
|
+
Config = _d.sent();
|
|
141
|
+
return [4 /*yield*/, ACEngineManager_js_1.ACEngineManager.loadEngineLocal()];
|
|
142
|
+
case 2:
|
|
143
|
+
_d.sent();
|
|
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*/];
|
|
110
162
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
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);
|
|
114
175
|
});
|
|
115
176
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// const rulePack = `${Config.rulePack}`;
|
|
177
|
+
catch (e) {
|
|
178
|
+
if (typeof (after) !== "undefined") {
|
|
179
|
+
after(function (done) {
|
|
180
|
+
if (Config) {
|
|
181
|
+
if (this.timeout) {
|
|
182
|
+
this.timeout(300000);
|
|
183
|
+
}
|
|
184
|
+
// const rulePack = `${Config.rulePack}/ace`;
|
|
124
185
|
initialize()
|
|
125
|
-
.then(()
|
|
126
|
-
.then(()
|
|
186
|
+
.then(function () { return ReporterManager_js_1.ReporterManager.generateSummaries(); })
|
|
187
|
+
.then(function () { return ACBrowserManager_js_1.ACBrowserManager.close(); })
|
|
127
188
|
.then(done);
|
|
128
|
-
}
|
|
129
|
-
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
done && done();
|
|
192
|
+
}
|
|
193
|
+
});
|
|
130
194
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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* () {
|
|
195
|
+
else {
|
|
196
|
+
process.on('beforeExit', function () {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
+
return __generator(this, function (_a) {
|
|
152
199
|
if (Config) {
|
|
153
200
|
initialize()
|
|
154
|
-
.then(()
|
|
201
|
+
.then(function () { return ReporterManager_js_1.ReporterManager.generateSummaries(); });
|
|
155
202
|
ACBrowserManager_js_1.ACBrowserManager.close();
|
|
156
203
|
}
|
|
204
|
+
return [2 /*return*/];
|
|
157
205
|
});
|
|
158
206
|
});
|
|
159
|
-
}
|
|
207
|
+
});
|
|
160
208
|
}
|
|
161
|
-
}
|
|
209
|
+
}
|
|
162
210
|
function areValidPolicy(valPolicies, curPol) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
for (
|
|
211
|
+
var isValPol = false;
|
|
212
|
+
var errorPolicy = "";
|
|
213
|
+
for (var i = 0; i < curPol.length; ++i) {
|
|
166
214
|
if (valPolicies.indexOf(curPol[i]) === -1) {
|
|
167
215
|
errorPolicy += "" + curPol[i] + ",";
|
|
168
216
|
}
|
|
@@ -172,25 +220,16 @@ function areValidPolicy(valPolicies, curPol) {
|
|
|
172
220
|
}
|
|
173
221
|
if (errorPolicy.length > 0) {
|
|
174
222
|
errorPolicy = errorPolicy.substr(0, errorPolicy.length - 1);
|
|
175
|
-
console.log(
|
|
223
|
+
console.log("[WARN] InvalidPolicies: Invalid policies \"".concat(errorPolicy, "\". Valid policy ids are: ").concat(valPolicies));
|
|
176
224
|
}
|
|
177
225
|
if (!isValPol) {
|
|
178
|
-
|
|
226
|
+
var errStr = "[ERROR] ValidPoliciesMissing: No valid policy has been provided. Valid policy ids for the specified archive are: ".concat(valPolicies);
|
|
179
227
|
console.error(errStr);
|
|
180
228
|
throw new Error(errStr);
|
|
181
229
|
}
|
|
182
230
|
}
|
|
183
231
|
function getComplianceHelper(content, label) {
|
|
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;
|
|
232
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
194
233
|
// Since we need to handle multiple variation of possible ways to scan items, we need to handle
|
|
195
234
|
// each one differently as each one requires specific actions/setup.
|
|
196
235
|
// Handle the following:
|
|
@@ -200,479 +239,501 @@ function getComplianceHelper(content, label) {
|
|
|
200
239
|
// URL (String)
|
|
201
240
|
// document
|
|
202
241
|
function getParsed(content) {
|
|
203
|
-
return __awaiter(this, void 0, void 0, function
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
|
|
242
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
243
|
+
var isURLRegex;
|
|
244
|
+
return __generator(this, function (_a) {
|
|
245
|
+
if (!content)
|
|
246
|
+
return [2 /*return*/, null];
|
|
247
|
+
// Handle local file and URL's
|
|
248
|
+
if (typeof content === "string") {
|
|
249
|
+
isURLRegex = /^(ftp|http|https):\/\//;
|
|
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)];
|
|
211
256
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
content = content;
|
|
237
|
-
}
|
|
238
|
-
return content;
|
|
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;
|
|
269
|
+
}
|
|
270
|
+
// handle scanning document
|
|
271
|
+
else if (content.nodeType === 9) {
|
|
272
|
+
// In the case this is a document element, simply send the document object to the engine for now
|
|
273
|
+
// we will need to do some filtering to remove any karma related aspects, which requires to do a
|
|
274
|
+
// document clone, and then string the karma scripts that are added and then send this document
|
|
275
|
+
// to the engine.
|
|
276
|
+
// TODO: Investigate best approach to perform filtering
|
|
277
|
+
content = content;
|
|
278
|
+
}
|
|
279
|
+
return [2 /*return*/, content];
|
|
280
|
+
});
|
|
239
281
|
});
|
|
240
282
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
283
|
+
var URL, parsed, policies, curPol;
|
|
284
|
+
return __generator(this, function (_a) {
|
|
285
|
+
switch (_a.label) {
|
|
286
|
+
case 0: return [4 /*yield*/, initialize()];
|
|
287
|
+
case 1:
|
|
288
|
+
_a.sent();
|
|
289
|
+
Config.DEBUG && console.log("START 'aChecker.getCompliance' function");
|
|
290
|
+
if (!content) {
|
|
291
|
+
console.error("aChecker: Unable to get compliance of null or undefined object");
|
|
292
|
+
return [2 /*return*/, null];
|
|
293
|
+
}
|
|
294
|
+
return [4 /*yield*/, getParsed(content)];
|
|
295
|
+
case 2:
|
|
296
|
+
parsed = _a.sent();
|
|
297
|
+
if (parsed === null)
|
|
298
|
+
return [2 /*return*/, null];
|
|
299
|
+
return [4 /*yield*/, ACEngineManager_js_1.ACEngineManager.loadEngine(parsed)];
|
|
300
|
+
case 3:
|
|
301
|
+
_a.sent();
|
|
302
|
+
policies = Config.policies;
|
|
303
|
+
curPol = null;
|
|
304
|
+
if (policies) {
|
|
305
|
+
curPol = JSON.parse(JSON.stringify(policies));
|
|
306
|
+
}
|
|
307
|
+
if (!ACEngineManager_js_1.ACEngineManager.isSelenium(parsed)) return [3 /*break*/, 5];
|
|
308
|
+
Config.DEBUG && console.log("getComplianceHelper:Selenium");
|
|
309
|
+
return [4 /*yield*/, getComplianceHelperSelenium(label, parsed, curPol)];
|
|
310
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
311
|
+
case 5:
|
|
312
|
+
if (!ACEngineManager_js_1.ACEngineManager.isPuppeteer(parsed)) return [3 /*break*/, 7];
|
|
313
|
+
Config.DEBUG && console.log("ACHelper.ts:getComplianceHelper:Puppeteer");
|
|
314
|
+
return [4 /*yield*/, getComplianceHelperPuppeteer(label, parsed, curPol)];
|
|
315
|
+
case 6: return [2 /*return*/, _a.sent()];
|
|
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
|
+
});
|
|
274
332
|
});
|
|
275
333
|
}
|
|
276
334
|
function getComplianceHelperSelenium(label, parsed, curPol) {
|
|
277
|
-
return __awaiter(this, void 0, void 0, function
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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();
|
|
335
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
336
|
+
var startScan, browser, scriptStr, manage, report, getPolicies, valPolicies, _a, _b, finalReport, url, title, origReport, image, err_1;
|
|
337
|
+
return __generator(this, function (_c) {
|
|
338
|
+
switch (_c.label) {
|
|
339
|
+
case 0:
|
|
340
|
+
_c.trys.push([0, 9, , 10]);
|
|
341
|
+
startScan = Date.now();
|
|
342
|
+
browser = parsed;
|
|
343
|
+
scriptStr = "let cb = arguments[arguments.length - 1];\ntry {\n\nconst valueToLevel = (reportValue) => {\n let reportLevel;\n if (reportValue[1] === \"PASS\") {\n reportLevel = \"pass\";\n }\n else if ((reportValue[0] === \"VIOLATION\" || reportValue[0] === \"RECOMMENDATION\") && reportValue[1] === \"MANUAL\") {\n reportLevel = \"manual\";\n }\n else if (reportValue[0] === \"VIOLATION\") {\n if (reportValue[1] === \"FAIL\") {\n reportLevel = \"violation\";\n }\n else if (reportValue[1] === \"POTENTIAL\") {\n reportLevel = \"potentialviolation\";\n }\n }\n else if (reportValue[0] === \"RECOMMENDATION\") {\n if (reportValue[1] === \"FAIL\") {\n reportLevel = \"recommendation\";\n }\n else if (reportValue[1] === \"POTENTIAL\") {\n reportLevel = \"potentialrecommendation\";\n }\n }\n return reportLevel;\n}\n\nconst getCounts = (engineReport) => {\n let counts = {\n violation: 0,\n potentialviolation: 0,\n recommendation: 0,\n potentialrecommendation: 0,\n manual: 0,\n pass: 0\n }\n for (const issue of engineReport.results) {\n ++counts[issue.level];\n }\n return counts;\n}\n\n\nlet policies = ".concat(JSON.stringify(Config.policies), ";\n\nlet checker = new window.ace_ibma.Checker();\nlet customRulesets = ").concat(JSON.stringify(ACEngineManager_js_1.ACEngineManager.customRulesets), ";\ncustomRulesets.forEach((rs) => checker.addRuleset(rs));\nsetTimeout(function() {\n checker.check(document, policies).then(function(report) {\n for (const result of report.results) {\n delete result.node;\n result.level = valueToLevel(result.value)\n }\n report.summary ||= {};\n report.summary.counts ||= getCounts(report);\n let reportLevels = ").concat(JSON.stringify((Config.reportLevels || []).concat(Config.failLevels || []).map(function (lvl) { return lvl.toString(); })), ";\n // Filter out pass results unless they asked for them in reports\n // We don't want to mess with baseline functions, but pass results can break the response object\n report.results = report.results.filter(result => reportLevels.includes(result.level) || result.level !== \"pass\");\n cb(report);\n })\n},0)\n} catch (e) {\ncb(e);\n}");
|
|
344
|
+
manage = browser.manage();
|
|
345
|
+
if (manage.timeouts) {
|
|
346
|
+
manage.timeouts().setScriptTimeout(60000);
|
|
347
|
+
}
|
|
348
|
+
else if (manage.setTimeouts) {
|
|
349
|
+
manage.setTimeouts({
|
|
350
|
+
"script": 60000
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return [4 /*yield*/, browser.executeAsyncScript(scriptStr)];
|
|
354
|
+
case 1:
|
|
355
|
+
report = _c.sent();
|
|
356
|
+
getPolicies = "return new window.ace_ibma.Checker().rulesetIds;";
|
|
357
|
+
if (!(curPol != null && !checkPolicy)) return [3 /*break*/, 3];
|
|
358
|
+
checkPolicy = true;
|
|
359
|
+
_b = (_a = ACEngineManager_js_1.ACEngineManager.customRulesets.map(function (rs) { return rs.id; })).concat;
|
|
360
|
+
return [4 /*yield*/, browser.executeScript(getPolicies)];
|
|
361
|
+
case 2:
|
|
362
|
+
valPolicies = _b.apply(_a, [_c.sent()]);
|
|
363
|
+
areValidPolicy(valPolicies, curPol);
|
|
364
|
+
_c.label = 3;
|
|
365
|
+
case 3:
|
|
366
|
+
finalReport = void 0;
|
|
367
|
+
if (!report.results) return [3 /*break*/, 8];
|
|
368
|
+
return [4 /*yield*/, browser.getCurrentUrl()];
|
|
369
|
+
case 4:
|
|
370
|
+
url = _c.sent();
|
|
371
|
+
return [4 /*yield*/, browser.getTitle()];
|
|
372
|
+
case 5:
|
|
373
|
+
title = _c.sent();
|
|
374
|
+
origReport = JSON.parse(JSON.stringify(report));
|
|
375
|
+
if (!(Config.captureScreenshots && browser.takeScreenshot)) return [3 /*break*/, 7];
|
|
376
|
+
return [4 /*yield*/, browser.takeScreenshot()];
|
|
377
|
+
case 6:
|
|
378
|
+
image = _c.sent();
|
|
377
379
|
origReport.screenshot = image;
|
|
378
|
-
|
|
379
|
-
|
|
380
|
+
_c.label = 7;
|
|
381
|
+
case 7:
|
|
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*/];
|
|
380
395
|
}
|
|
381
|
-
|
|
382
|
-
"report": finalReport,
|
|
383
|
-
"webdriver": parsed
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
catch (err) {
|
|
387
|
-
console.error(err);
|
|
388
|
-
return Promise.reject(err);
|
|
389
|
-
}
|
|
390
|
-
;
|
|
396
|
+
});
|
|
391
397
|
});
|
|
392
398
|
}
|
|
393
399
|
function getComplianceHelperWebDriverIO(label, parsed, curPol) {
|
|
394
|
-
return __awaiter(this, void 0, void 0, function
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
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
|
-
var
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
400
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
401
|
+
var startScan, page, report, valPolicies, _a, _b, finalReport, url, title, origReport, image, err_2;
|
|
402
|
+
return __generator(this, function (_c) {
|
|
403
|
+
switch (_c.label) {
|
|
404
|
+
case 0:
|
|
405
|
+
_c.trys.push([0, 9, , 10]);
|
|
406
|
+
startScan = Date.now();
|
|
407
|
+
page = parsed;
|
|
408
|
+
return [4 /*yield*/, page.executeAsync(function (_a, done) {
|
|
409
|
+
var policies = _a.policies, customRulesets = _a.customRulesets, reportLevels = _a.reportLevels;
|
|
410
|
+
var valueToLevel = function (reportValue) {
|
|
411
|
+
var reportLevel;
|
|
412
|
+
if (reportValue[1] === "PASS") {
|
|
413
|
+
reportLevel = "pass";
|
|
414
|
+
}
|
|
415
|
+
else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") {
|
|
416
|
+
reportLevel = "manual";
|
|
417
|
+
}
|
|
418
|
+
else if (reportValue[0] === "VIOLATION") {
|
|
419
|
+
if (reportValue[1] === "FAIL") {
|
|
420
|
+
reportLevel = "violation";
|
|
421
|
+
}
|
|
422
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
423
|
+
reportLevel = "potentialviolation";
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
else if (reportValue[0] === "RECOMMENDATION") {
|
|
427
|
+
if (reportValue[1] === "FAIL") {
|
|
428
|
+
reportLevel = "recommendation";
|
|
429
|
+
}
|
|
430
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
431
|
+
reportLevel = "potentialrecommendation";
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return reportLevel;
|
|
435
|
+
};
|
|
436
|
+
var getCounts = function (engineReport) {
|
|
437
|
+
var counts = {
|
|
438
|
+
violation: 0,
|
|
439
|
+
potentialviolation: 0,
|
|
440
|
+
recommendation: 0,
|
|
441
|
+
potentialrecommendation: 0,
|
|
442
|
+
manual: 0,
|
|
443
|
+
pass: 0
|
|
444
|
+
};
|
|
445
|
+
for (var _i = 0, _a = engineReport.results; _i < _a.length; _i++) {
|
|
446
|
+
var issue = _a[_i];
|
|
447
|
+
++counts[issue.level];
|
|
448
|
+
}
|
|
449
|
+
return counts;
|
|
450
|
+
};
|
|
451
|
+
var checker = new window.ace_ibma.Checker();
|
|
452
|
+
customRulesets.forEach(function (rs) { return checker.addRuleset(rs); });
|
|
453
|
+
return new Promise(function (resolve, reject) {
|
|
454
|
+
setTimeout(function () {
|
|
455
|
+
checker.check(document, policies).then(function (report) {
|
|
456
|
+
var _a;
|
|
457
|
+
for (var _i = 0, _b = report.results; _i < _b.length; _i++) {
|
|
458
|
+
var result = _b[_i];
|
|
459
|
+
delete result.node;
|
|
460
|
+
result.level = valueToLevel(result.value);
|
|
461
|
+
}
|
|
462
|
+
report.summary || (report.summary = {});
|
|
463
|
+
(_a = report.summary).counts || (_a.counts = getCounts(report));
|
|
464
|
+
// Filter out pass results unless they asked for them in reports
|
|
465
|
+
// We don't want to mess with baseline functions, but pass results can break the response object
|
|
466
|
+
report.results = report.results.filter(function (result) { return reportLevels.includes(result.level) || result.level !== "pass"; });
|
|
467
|
+
resolve(report);
|
|
468
|
+
done(report);
|
|
469
|
+
});
|
|
470
|
+
}, 0);
|
|
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();
|
|
477
500
|
origReport.screenshot = image;
|
|
478
|
-
|
|
479
|
-
|
|
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*/];
|
|
480
518
|
}
|
|
481
|
-
|
|
482
|
-
return {
|
|
483
|
-
"report": finalReport,
|
|
484
|
-
"puppeteer": parsed
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
catch (err) {
|
|
488
|
-
console.error(err);
|
|
489
|
-
return Promise.reject(err);
|
|
490
|
-
}
|
|
491
|
-
;
|
|
519
|
+
});
|
|
492
520
|
});
|
|
493
521
|
}
|
|
494
522
|
function getComplianceHelperPuppeteer(label, parsed, curPol) {
|
|
495
|
-
return __awaiter(this, void 0, void 0, function
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
523
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
524
|
+
var startScan, page, report, valPolicies, _a, _b, finalReport, url, title, origReport, image, err_3;
|
|
525
|
+
return __generator(this, function (_c) {
|
|
526
|
+
switch (_c.label) {
|
|
527
|
+
case 0:
|
|
528
|
+
_c.trys.push([0, 9, , 10]);
|
|
529
|
+
startScan = Date.now();
|
|
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();
|
|
622
|
+
origReport.screenshot = image;
|
|
623
|
+
_c.label = 7;
|
|
624
|
+
case 7:
|
|
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*/];
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function getComplianceHelperLocal(label, parsed, curPol) {
|
|
645
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
646
|
+
var valueToLevel_1, getCounts_1, startScan, checker_1, report, valPolicies, finalReport, url, origReport, err_4;
|
|
647
|
+
return __generator(this, function (_a) {
|
|
648
|
+
switch (_a.label) {
|
|
649
|
+
case 0:
|
|
650
|
+
_a.trys.push([0, 2, , 3]);
|
|
651
|
+
valueToLevel_1 = function (reportValue) {
|
|
652
|
+
var reportLevel;
|
|
653
|
+
if (reportValue[1] === "PASS") {
|
|
654
|
+
reportLevel = "pass";
|
|
512
655
|
}
|
|
513
|
-
else if (reportValue[1] === "
|
|
514
|
-
reportLevel = "
|
|
656
|
+
else if ((reportValue[0] === "VIOLATION" || reportValue[0] === "RECOMMENDATION") && reportValue[1] === "MANUAL") {
|
|
657
|
+
reportLevel = "manual";
|
|
515
658
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
659
|
+
else if (reportValue[0] === "VIOLATION") {
|
|
660
|
+
if (reportValue[1] === "FAIL") {
|
|
661
|
+
reportLevel = "violation";
|
|
662
|
+
}
|
|
663
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
664
|
+
reportLevel = "potentialviolation";
|
|
665
|
+
}
|
|
520
666
|
}
|
|
521
|
-
else if (reportValue[
|
|
522
|
-
|
|
667
|
+
else if (reportValue[0] === "RECOMMENDATION") {
|
|
668
|
+
if (reportValue[1] === "FAIL") {
|
|
669
|
+
reportLevel = "recommendation";
|
|
670
|
+
}
|
|
671
|
+
else if (reportValue[1] === "POTENTIAL") {
|
|
672
|
+
reportLevel = "potentialrecommendation";
|
|
673
|
+
}
|
|
523
674
|
}
|
|
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
|
|
675
|
+
return reportLevel;
|
|
535
676
|
};
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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];
|
|
689
|
+
}
|
|
690
|
+
return counts;
|
|
691
|
+
};
|
|
692
|
+
startScan = Date.now();
|
|
693
|
+
checker_1 = ACEngineManager_js_1.ACEngineManager.getChecker();
|
|
694
|
+
ACEngineManager_js_1.ACEngineManager.customRulesets.forEach(function (rs) { return checker_1.addGuideline(rs); });
|
|
695
|
+
return [4 /*yield*/, checker_1.check(parsed, Config.policies)
|
|
696
|
+
.then(function (report) {
|
|
546
697
|
var _a;
|
|
547
|
-
for (
|
|
698
|
+
for (var _i = 0, _b = report.results; _i < _b.length; _i++) {
|
|
699
|
+
var result = _b[_i];
|
|
548
700
|
delete result.node;
|
|
549
|
-
result.level =
|
|
701
|
+
result.level = valueToLevel_1(result.value);
|
|
550
702
|
}
|
|
551
703
|
report.summary || (report.summary = {});
|
|
552
|
-
(_a = report.summary).counts || (_a.counts =
|
|
704
|
+
(_a = report.summary).counts || (_a.counts = getCounts_1(report));
|
|
705
|
+
var reportLevels = (Config.reportLevels || []).concat(Config.failLevels || []).map(function (lvl) { return lvl.toString(); });
|
|
553
706
|
// Filter out pass results unless they asked for them in reports
|
|
554
707
|
// We don't want to mess with baseline functions, but pass results can break the response object
|
|
555
|
-
report.results = report.results.filter(result
|
|
556
|
-
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
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";
|
|
708
|
+
report.results = report.results.filter(function (result) { return reportLevels.includes(result.level) || result.level !== "pass"; });
|
|
709
|
+
return report;
|
|
710
|
+
})];
|
|
711
|
+
case 1:
|
|
712
|
+
report = _a.sent();
|
|
713
|
+
if (curPol != null && !checkPolicy) {
|
|
714
|
+
valPolicies = checker_1.getGuidelineIds();
|
|
715
|
+
checkPolicy = true;
|
|
716
|
+
areValidPolicy(valPolicies, curPol);
|
|
608
717
|
}
|
|
609
|
-
|
|
610
|
-
|
|
718
|
+
finalReport = void 0;
|
|
719
|
+
// If there is something to report...
|
|
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);
|
|
611
724
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
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);
|
|
725
|
+
return [2 /*return*/, {
|
|
726
|
+
"report": finalReport
|
|
727
|
+
}];
|
|
728
|
+
case 2:
|
|
729
|
+
err_4 = _a.sent();
|
|
730
|
+
console.error(err_4);
|
|
731
|
+
return [2 /*return*/, Promise.reject(err_4)];
|
|
732
|
+
case 3:
|
|
733
|
+
;
|
|
734
|
+
return [2 /*return*/];
|
|
666
735
|
}
|
|
667
|
-
|
|
668
|
-
"report": finalReport
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
catch (err) {
|
|
672
|
-
console.error(err);
|
|
673
|
-
return Promise.reject(err);
|
|
674
|
-
}
|
|
675
|
-
;
|
|
736
|
+
});
|
|
676
737
|
});
|
|
677
738
|
}
|
|
678
739
|
//# sourceMappingURL=ACHelper.js.map
|