accessibility-checker 3.1.47 → 4.0.0-rc.0
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 +194 -314
- package/cjs/bin/achecker.js +293 -0
- package/cjs/bin/achecker.js.map +1 -0
- package/{index.d.ts → cjs/index.d.ts} +142 -143
- package/cjs/index.js +393 -0
- package/cjs/index.js.map +1 -0
- package/{lib → cjs/lib}/ACBrowserManager.d.ts +1 -1
- package/cjs/lib/ACBrowserManager.js +162 -0
- package/cjs/lib/ACBrowserManager.js.map +1 -0
- package/{lib → cjs/lib}/ACConfigManager.d.ts +1 -1
- package/cjs/lib/ACConfigManager.js +363 -0
- package/cjs/lib/ACConfigManager.js.map +1 -0
- package/{lib → cjs/lib}/ACConstants.d.ts +1 -1
- package/cjs/lib/ACConstants.js +98 -0
- package/cjs/lib/ACConstants.js.map +1 -0
- package/cjs/lib/ACEngineManager.js +290 -0
- package/cjs/lib/ACEngineManager.js.map +1 -0
- package/{lib → cjs/lib}/ACHelper.d.ts +1 -1
- package/cjs/lib/ACHelper.js +472 -0
- package/cjs/lib/ACHelper.js.map +1 -0
- package/{lib → cjs/lib}/ACReportManager.d.ts +4 -4
- package/cjs/lib/ACReportManager.js +1165 -0
- package/cjs/lib/ACReportManager.js.map +1 -0
- package/{lib → cjs/lib}/api/IChecker.d.ts +2 -2
- package/cjs/lib/api/IChecker.js.map +1 -0
- package/{lib → cjs/lib}/api/IEngine.d.ts +1 -1
- package/cjs/lib/api/IEngine.js.map +1 -0
- package/cjs/lib/api/IMapper.js.map +1 -0
- package/{lib → cjs/lib}/log/ACMetricsLogger.d.ts +1 -1
- package/cjs/lib/log/ACMetricsLogger.js +148 -0
- package/cjs/lib/log/ACMetricsLogger.js.map +1 -0
- package/{lib → cjs/lib}/reporters/ACReporterCSV.d.ts +2 -2
- package/cjs/lib/reporters/ACReporterCSV.js +214 -0
- package/cjs/lib/reporters/ACReporterCSV.js.map +1 -0
- package/{lib → cjs/lib}/reporters/ACReporterHTML.d.ts +2 -2
- package/cjs/lib/reporters/ACReporterHTML.js +321 -0
- package/cjs/lib/reporters/ACReporterHTML.js.map +1 -0
- package/{lib → cjs/lib}/reporters/ACReporterJSON.d.ts +2 -2
- package/cjs/lib/reporters/ACReporterJSON.js +299 -0
- package/cjs/lib/reporters/ACReporterJSON.js.map +1 -0
- package/{lib → cjs/lib}/reporters/ACReporterXLSX.d.ts +2 -2
- package/cjs/lib/reporters/ACReporterXLSX.js +377 -0
- package/cjs/lib/reporters/ACReporterXLSX.js.map +1 -0
- package/{lib → cjs/lib}/reporters/ReportUtil.d.ts +1 -1
- package/{lib → cjs/lib}/reporters/ReportUtil.js +3 -4
- package/cjs/lib/reporters/ReportUtil.js.map +1 -0
- package/{lib → cjs/lib}/reporters/genReport.js +2 -2
- package/cjs/lib/reporters/genReport.js.map +1 -0
- package/{lib → cjs/lib}/reporters/multiScanData.d.ts +1 -1
- package/cjs/lib/reporters/multiScanData.js +205 -0
- package/cjs/lib/reporters/multiScanData.js.map +1 -0
- package/{lib → cjs/lib}/reporters/multiScanReport.d.ts +2 -1
- package/{lib → cjs/lib}/reporters/multiScanReport.js +264 -280
- package/cjs/lib/reporters/multiScanReport.js.map +1 -0
- package/{lib → cjs/lib}/reporters/multiScanReportUtil.js +9 -12
- package/cjs/lib/reporters/multiScanReportUtil.js.map +1 -0
- package/cjs/package.json +3 -0
- package/mjs/bin/achecker.d.ts +2 -0
- package/mjs/bin/achecker.js +228 -0
- package/mjs/bin/achecker.js.map +1 -0
- package/mjs/index.d.ts +317 -0
- package/mjs/index.js +361 -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/ACConfigManager.d.ts +7 -0
- package/mjs/lib/ACConfigManager.js +317 -0
- package/mjs/lib/ACConfigManager.js.map +1 -0
- package/mjs/lib/ACConstants.d.ts +17 -0
- package/{lib → mjs/lib}/ACConstants.js +9 -11
- package/mjs/lib/ACConstants.js.map +1 -0
- package/mjs/lib/ACEngineManager.d.ts +27 -0
- package/mjs/lib/ACEngineManager.js +243 -0
- package/mjs/lib/ACEngineManager.js.map +1 -0
- package/mjs/lib/ACHelper.d.ts +2 -0
- package/mjs/lib/ACHelper.js +421 -0
- package/mjs/lib/ACHelper.js.map +1 -0
- package/mjs/lib/ACReportManager.d.ts +590 -0
- package/{lib → mjs/lib}/ACReportManager.js +233 -306
- package/mjs/lib/ACReportManager.js.map +1 -0
- package/mjs/lib/api/IChecker.d.ts +139 -0
- package/mjs/lib/api/IChecker.js +8 -0
- package/mjs/lib/api/IChecker.js.map +1 -0
- package/mjs/lib/api/IEngine.d.ts +129 -0
- package/mjs/lib/api/IEngine.js +102 -0
- package/mjs/lib/api/IEngine.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/log/ACMetricsLogger.d.ts +72 -0
- package/mjs/lib/log/ACMetricsLogger.js +136 -0
- package/mjs/lib/log/ACMetricsLogger.js.map +1 -0
- package/mjs/lib/reporters/ACReporterCSV.d.ts +103 -0
- package/{lib → mjs/lib}/reporters/ACReporterCSV.js +28 -33
- package/mjs/lib/reporters/ACReporterCSV.js.map +1 -0
- package/mjs/lib/reporters/ACReporterHTML.d.ts +114 -0
- package/mjs/lib/reporters/ACReporterHTML.js +281 -0
- package/mjs/lib/reporters/ACReporterHTML.js.map +1 -0
- package/mjs/lib/reporters/ACReporterJSON.d.ts +114 -0
- package/{lib → mjs/lib}/reporters/ACReporterJSON.js +41 -44
- package/mjs/lib/reporters/ACReporterJSON.js.map +1 -0
- package/mjs/lib/reporters/ACReporterXLSX.d.ts +109 -0
- package/mjs/lib/reporters/ACReporterXLSX.js +339 -0
- package/mjs/lib/reporters/ACReporterXLSX.js.map +1 -0
- package/mjs/lib/reporters/ReportUtil.d.ts +33 -0
- package/mjs/lib/reporters/ReportUtil.js +60 -0
- package/mjs/lib/reporters/ReportUtil.js.map +1 -0
- package/mjs/lib/reporters/genReport.d.ts +1 -0
- package/mjs/lib/reporters/genReport.js +9 -0
- package/mjs/lib/reporters/genReport.js.map +1 -0
- package/mjs/lib/reporters/multiScanData.d.ts +27 -0
- package/{lib → mjs/lib}/reporters/multiScanData.js +39 -50
- package/mjs/lib/reporters/multiScanData.js.map +1 -0
- package/mjs/lib/reporters/multiScanReport.d.ts +26 -0
- package/mjs/lib/reporters/multiScanReport.js +1676 -0
- package/mjs/lib/reporters/multiScanReport.js.map +1 -0
- package/mjs/lib/reporters/multiScanReportUtil.d.ts +19 -0
- package/mjs/lib/reporters/multiScanReportUtil.js +43 -0
- package/mjs/lib/reporters/multiScanReportUtil.js.map +1 -0
- package/mjs/package.json +3 -0
- package/package.json +10 -4
- package/bin/achecker.js.map +0 -1
- package/index.js +0 -426
- package/index.js.map +0 -1
- package/lib/ACBrowserManager.js +0 -237
- package/lib/ACBrowserManager.js.map +0 -1
- package/lib/ACConfigManager.js +0 -406
- package/lib/ACConfigManager.js.map +0 -1
- package/lib/ACConstants.js.map +0 -1
- package/lib/ACEngineManager.js +0 -305
- package/lib/ACEngineManager.js.map +0 -1
- package/lib/ACHelper.js +0 -526
- package/lib/ACHelper.js.map +0 -1
- package/lib/ACReportManager.js.map +0 -1
- package/lib/api/IChecker.js.map +0 -1
- package/lib/api/IEngine.js.map +0 -1
- package/lib/api/IMapper.js.map +0 -1
- package/lib/log/ACMetricsLogger.js +0 -181
- package/lib/log/ACMetricsLogger.js.map +0 -1
- package/lib/reporters/ACReporterCSV.js.map +0 -1
- package/lib/reporters/ACReporterHTML.js +0 -360
- package/lib/reporters/ACReporterHTML.js.map +0 -1
- package/lib/reporters/ACReporterJSON.js.map +0 -1
- package/lib/reporters/ACReporterXLSX.js +0 -405
- package/lib/reporters/ACReporterXLSX.js.map +0 -1
- package/lib/reporters/ReportUtil.js.map +0 -1
- package/lib/reporters/genReport.js.map +0 -1
- package/lib/reporters/multiScanData.js.map +0 -1
- package/lib/reporters/multiScanReport.js.map +0 -1
- package/lib/reporters/multiScanReportUtil.js.map +0 -1
- /package/{bin → cjs/bin}/achecker.d.ts +0 -0
- /package/{lib → cjs/lib}/ACEngineManager.d.ts +0 -0
- /package/{lib → cjs/lib}/api/IChecker.js +0 -0
- /package/{lib → cjs/lib}/api/IEngine.js +0 -0
- /package/{lib → cjs/lib}/api/IMapper.d.ts +0 -0
- /package/{lib → cjs/lib}/api/IMapper.js +0 -0
- /package/{lib → cjs/lib}/reporters/genReport.d.ts +0 -0
- /package/{lib → cjs/lib}/reporters/multiScanReportUtil.d.ts +0 -0
package/bin/achecker.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
2
|
/******************************************************************************
|
|
4
3
|
Copyright:: 2020- IBM, Inc
|
|
5
4
|
|
|
@@ -15,334 +14,215 @@
|
|
|
15
14
|
See the License for the specific language governing permissions and
|
|
16
15
|
limitations under the License.
|
|
17
16
|
*****************************************************************************/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
41
|
-
default:
|
|
42
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
43
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
44
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
45
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
46
|
-
if (t[2]) _.ops.pop();
|
|
47
|
-
_.trys.pop(); continue;
|
|
17
|
+
import * as aChecker from "../mjs/index.js";
|
|
18
|
+
import * as fs from "fs";
|
|
19
|
+
import * as readline from "readline";
|
|
20
|
+
import * as path from "path";
|
|
21
|
+
let validCLParams = [
|
|
22
|
+
"inputFile"
|
|
23
|
+
];
|
|
24
|
+
let splitCLParams = [
|
|
25
|
+
"policies",
|
|
26
|
+
"failLevels",
|
|
27
|
+
"reportLevels",
|
|
28
|
+
"outputFormat",
|
|
29
|
+
"label"
|
|
30
|
+
];
|
|
31
|
+
function processCommandLine(ACConfig) {
|
|
32
|
+
const [, , ...args] = process.argv;
|
|
33
|
+
let lastArg = null;
|
|
34
|
+
let lastFlag = null;
|
|
35
|
+
for (let arg of args) {
|
|
36
|
+
if (arg.match(/^--.*$/)) {
|
|
37
|
+
lastFlag = arg.substring(2);
|
|
38
|
+
lastArg = null;
|
|
48
39
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
56
|
-
var m = o[Symbol.asyncIterator], i;
|
|
57
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
58
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
59
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
60
|
-
};
|
|
61
|
-
var aChecker = require("../index.js");
|
|
62
|
-
var fs = require('fs');
|
|
63
|
-
var readline = require('readline');
|
|
64
|
-
var path = require("path");
|
|
65
|
-
var validCLParams = [
|
|
66
|
-
"inputFile"
|
|
67
|
-
];
|
|
68
|
-
var splitCLParams = [
|
|
69
|
-
"policies",
|
|
70
|
-
"failLevels",
|
|
71
|
-
"reportLevels",
|
|
72
|
-
"outputFormat",
|
|
73
|
-
"label"
|
|
74
|
-
];
|
|
75
|
-
function processCommandLine(ACConfig) {
|
|
76
|
-
var _a = process.argv, args = _a.slice(2);
|
|
77
|
-
var lastArg = null;
|
|
78
|
-
var lastFlag = null;
|
|
79
|
-
for (var _i = 0, args_1 = args; _i < args_1.length; _i++) {
|
|
80
|
-
var arg = args_1[_i];
|
|
81
|
-
if (arg.match(/^--.*$/)) {
|
|
82
|
-
lastFlag = arg.substring(2);
|
|
83
|
-
lastArg = null;
|
|
84
|
-
}
|
|
85
|
-
else if (lastFlag) {
|
|
86
|
-
if (lastFlag in ACConfig || validCLParams.includes(lastFlag)) {
|
|
87
|
-
if (splitCLParams.includes(lastFlag)) {
|
|
88
|
-
arg = arg.split(",");
|
|
40
|
+
else if (lastFlag) {
|
|
41
|
+
if (lastFlag in ACConfig || validCLParams.includes(lastFlag)) {
|
|
42
|
+
if (splitCLParams.includes(lastFlag)) {
|
|
43
|
+
arg = arg.split(",");
|
|
44
|
+
}
|
|
45
|
+
ACConfig[lastFlag] = arg;
|
|
89
46
|
}
|
|
90
|
-
|
|
47
|
+
lastFlag = lastArg = null;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
lastArg = arg;
|
|
91
51
|
}
|
|
92
|
-
lastFlag = lastArg = null;
|
|
93
52
|
}
|
|
94
|
-
|
|
95
|
-
|
|
53
|
+
if (lastArg) {
|
|
54
|
+
ACConfig.inputFile = lastArg;
|
|
96
55
|
}
|
|
97
56
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
-
var retVal, _i, _a, f, _b, _c;
|
|
105
|
-
return __generator(this, function (_d) {
|
|
106
|
-
switch (_d.label) {
|
|
107
|
-
case 0:
|
|
108
|
-
retVal = [];
|
|
109
|
-
_i = 0, _a = fs.readdirSync(dir);
|
|
110
|
-
_d.label = 1;
|
|
111
|
-
case 1:
|
|
112
|
-
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
113
|
-
f = _a[_i];
|
|
114
|
-
if (!(f[0] === ".")) return [3 /*break*/, 2];
|
|
115
|
-
return [3 /*break*/, 5];
|
|
116
|
-
case 2:
|
|
117
|
-
f = path.join(dir, f);
|
|
118
|
-
if (!fs.lstatSync(f).isDirectory()) return [3 /*break*/, 4];
|
|
119
|
-
_c = (_b = retVal).concat;
|
|
120
|
-
return [4 /*yield*/, getFiles(f)];
|
|
121
|
-
case 3:
|
|
122
|
-
retVal = _c.apply(_b, [_d.sent()]);
|
|
123
|
-
return [3 /*break*/, 5];
|
|
124
|
-
case 4:
|
|
125
|
-
if (f.endsWith(".htm") || f.endsWith(".html")) {
|
|
126
|
-
retVal.push(f);
|
|
127
|
-
}
|
|
128
|
-
_d.label = 5;
|
|
129
|
-
case 5:
|
|
130
|
-
_i++;
|
|
131
|
-
return [3 /*break*/, 1];
|
|
132
|
-
case 6: return [2 /*return*/, retVal];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
function showHelp(config) {
|
|
138
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
-
var lastArg, archiveInfo, _i, _a, archive, _b, _c, policy;
|
|
140
|
-
return __generator(this, function (_d) {
|
|
141
|
-
lastArg = config.inputFile;
|
|
142
|
-
if (!lastArg || lastArg === "help") {
|
|
143
|
-
console.log("Usage: achecker [flags] [command / file / directory / URL]\n\nCommands:\n archives : Display valid archive ids and policy ids\n\nFlags:\n Flags can be set via .achecker.yml or aceconfig.js files. Specifying the flags here\n will override those options.\n\n --ruleArchive : Archive id to use. Run \"achecker archives\" for valid ids\n --policies : Comma separated list of policies. Run \"achecker archives\"\n for valid ids\n --failLevels : Comma separated list of levels that will indicate\n a failure. Valid values: violation,\n potentialviolation, recommendation,\n potentialrecommendation, manual\n --reportLevels : Comma separated list of levels that will be included\n in reports. Valid values: violation,\n potentialviolation, recommendation,\n potentialrecommendation, manual, pass\n --outputFormat : Comma separated list of output report formats.\n Valid values: json, csv, xlsx, or html\n --label : Comma separated list of labels to include in reports\n --outputFolder : Folder to output results and reports\n --baselineFolder : Folder that includes baseline files\n");
|
|
144
|
-
process.exit(-1);
|
|
57
|
+
async function getFiles(dir) {
|
|
58
|
+
let retVal = [];
|
|
59
|
+
for (let f of fs.readdirSync(dir)) {
|
|
60
|
+
if (f[0] === ".") {
|
|
61
|
+
// skip
|
|
145
62
|
}
|
|
146
|
-
else
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
console.log("-----------------------");
|
|
154
|
-
console.log();
|
|
155
|
-
for (_i = 0, _a = config.ruleArchiveSet; _i < _a.length; _i++) {
|
|
156
|
-
archive = _a[_i];
|
|
157
|
-
if (archive.sunset)
|
|
158
|
-
continue;
|
|
159
|
-
console.log("".concat(archive.name, " [").concat(archive.id, "]"));
|
|
160
|
-
for (_b = 0, _c = archive.policies; _b < _c.length; _b++) {
|
|
161
|
-
policy = _c[_b];
|
|
162
|
-
console.log(" - ".concat(policy.name, " [").concat(policy.id, "]"));
|
|
163
|
-
}
|
|
164
|
-
archiveInfo[archive.id] = archive.policies;
|
|
165
|
-
if (archive.latest) {
|
|
166
|
-
archiveInfo['latest'] = archiveInfo[archive.id];
|
|
167
|
-
}
|
|
63
|
+
else {
|
|
64
|
+
f = path.join(dir, f);
|
|
65
|
+
if (fs.lstatSync(f).isDirectory()) {
|
|
66
|
+
retVal = retVal.concat(await getFiles(f));
|
|
67
|
+
}
|
|
68
|
+
else if (f.endsWith(".htm") || f.endsWith(".html")) {
|
|
69
|
+
retVal.push(f);
|
|
168
70
|
}
|
|
169
|
-
process.exit(-1);
|
|
170
71
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
case 7: return [3 /*break*/, 14];
|
|
226
|
-
case 8:
|
|
227
|
-
e_1_1 = _g.sent();
|
|
228
|
-
e_1 = { error: e_1_1 };
|
|
229
|
-
return [3 /*break*/, 14];
|
|
230
|
-
case 9:
|
|
231
|
-
_g.trys.push([9, , 12, 13]);
|
|
232
|
-
if (!(!_d && !_a && (_b = rl_1.return))) return [3 /*break*/, 11];
|
|
233
|
-
return [4 /*yield*/, _b.call(rl_1)];
|
|
234
|
-
case 10:
|
|
235
|
-
_g.sent();
|
|
236
|
-
_g.label = 11;
|
|
237
|
-
case 11: return [3 /*break*/, 13];
|
|
238
|
-
case 12:
|
|
239
|
-
if (e_1) throw e_1.error;
|
|
240
|
-
return [7 /*endfinally*/];
|
|
241
|
-
case 13: return [7 /*endfinally*/];
|
|
242
|
-
case 14: return [3 /*break*/, 16];
|
|
243
|
-
case 15:
|
|
244
|
-
inputs = [filename];
|
|
245
|
-
_g.label = 16;
|
|
246
|
-
case 16:
|
|
247
|
-
retVal = [];
|
|
248
|
-
_i = 0, inputs_1 = inputs;
|
|
249
|
-
_g.label = 17;
|
|
250
|
-
case 17:
|
|
251
|
-
if (!(_i < inputs_1.length)) return [3 /*break*/, 21];
|
|
252
|
-
input = inputs_1[_i];
|
|
253
|
-
isDirectory = false;
|
|
254
|
-
try {
|
|
255
|
-
isDirectory = fs.lstatSync(input).isDirectory();
|
|
256
|
-
}
|
|
257
|
-
catch (e) { }
|
|
258
|
-
if (!isDirectory) return [3 /*break*/, 19];
|
|
259
|
-
_f = (_e = retVal).concat;
|
|
260
|
-
return [4 /*yield*/, getFiles(input)];
|
|
261
|
-
case 18:
|
|
262
|
-
retVal = _f.apply(_e, [_g.sent()]);
|
|
263
|
-
return [3 /*break*/, 20];
|
|
264
|
-
case 19:
|
|
265
|
-
retVal.push(input);
|
|
266
|
-
_g.label = 20;
|
|
267
|
-
case 20:
|
|
268
|
-
_i++;
|
|
269
|
-
return [3 /*break*/, 17];
|
|
270
|
-
case 21: return [2 /*return*/, retVal];
|
|
72
|
+
}
|
|
73
|
+
return retVal;
|
|
74
|
+
}
|
|
75
|
+
async function showHelp(config) {
|
|
76
|
+
let lastArg = config.inputFile;
|
|
77
|
+
if (!lastArg || lastArg === "help") {
|
|
78
|
+
console.log(`Usage: achecker [flags] [command / file / directory / URL]
|
|
79
|
+
|
|
80
|
+
Commands:
|
|
81
|
+
archives : Display valid archive ids and policy ids
|
|
82
|
+
|
|
83
|
+
Flags:
|
|
84
|
+
Flags can be set via .achecker.yml or aceconfig.js files. Specifying the flags here
|
|
85
|
+
will override those options.
|
|
86
|
+
|
|
87
|
+
--ruleArchive : Archive id to use. Run "achecker archives" for valid ids
|
|
88
|
+
--policies : Comma separated list of policies. Run "achecker archives"
|
|
89
|
+
for valid ids
|
|
90
|
+
--failLevels : Comma separated list of levels that will indicate
|
|
91
|
+
a failure. Valid values: violation,
|
|
92
|
+
potentialviolation, recommendation,
|
|
93
|
+
potentialrecommendation, manual
|
|
94
|
+
--reportLevels : Comma separated list of levels that will be included
|
|
95
|
+
in reports. Valid values: violation,
|
|
96
|
+
potentialviolation, recommendation,
|
|
97
|
+
potentialrecommendation, manual, pass
|
|
98
|
+
--outputFormat : Comma separated list of output report formats.
|
|
99
|
+
Valid values: json, csv, xlsx, or html
|
|
100
|
+
--label : Comma separated list of labels to include in reports
|
|
101
|
+
--outputFolder : Folder to output results and reports
|
|
102
|
+
--baselineFolder : Folder that includes baseline files
|
|
103
|
+
`);
|
|
104
|
+
process.exit(-1);
|
|
105
|
+
}
|
|
106
|
+
else if (lastArg === "archives") {
|
|
107
|
+
let archiveInfo = {
|
|
108
|
+
"latest": []
|
|
109
|
+
};
|
|
110
|
+
console.log();
|
|
111
|
+
console.log("Archive [Archive Id]");
|
|
112
|
+
console.log(" - Policy [Policy Id]:");
|
|
113
|
+
console.log("-----------------------");
|
|
114
|
+
console.log();
|
|
115
|
+
for (const archive of config.ruleArchiveSet) {
|
|
116
|
+
if (archive.sunset)
|
|
117
|
+
continue;
|
|
118
|
+
console.log(`${archive.name} [${archive.id}]`);
|
|
119
|
+
for (const policy of archive.policies) {
|
|
120
|
+
console.log(` - ${policy.name} [${policy.id}]`);
|
|
121
|
+
}
|
|
122
|
+
archiveInfo[archive.id] = archive.policies;
|
|
123
|
+
if (archive.latest) {
|
|
124
|
+
archiveInfo['latest'] = archiveInfo[archive.id];
|
|
125
|
+
}
|
|
271
126
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
try {
|
|
292
|
-
isFile = fs.lstatSync(f).isFile();
|
|
293
|
-
f = path.resolve(f);
|
|
127
|
+
process.exit(-1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function getInputFileList() {
|
|
131
|
+
let config = await aChecker.getConfig();
|
|
132
|
+
processCommandLine(config);
|
|
133
|
+
await showHelp(config);
|
|
134
|
+
let inputs = [];
|
|
135
|
+
let filename = config.inputFile.trim();
|
|
136
|
+
if (filename.endsWith(".txt")) {
|
|
137
|
+
const fileStream = fs.createReadStream(filename);
|
|
138
|
+
const rl = readline.createInterface({
|
|
139
|
+
input: fileStream,
|
|
140
|
+
crlfDelay: Infinity
|
|
141
|
+
});
|
|
142
|
+
// Note: we use the crlfDelay option to recognize all instances of CR LF
|
|
143
|
+
// ('\r\n') in input.txt as a single line break.
|
|
144
|
+
for await (const line of rl) {
|
|
145
|
+
if (line.trim().length === 0) {
|
|
294
146
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return [3 /*break*/, 5];
|
|
301
|
-
case 3: return [4 /*yield*/, aChecker.getCompliance(f, f.replace(/^(https?:|file:)\/\//, "").replace(/[:?&=]/g, "_"))];
|
|
302
|
-
case 4:
|
|
303
|
-
result = _b.sent();
|
|
304
|
-
_b.label = 5;
|
|
305
|
-
case 5:
|
|
306
|
-
if (result) {
|
|
307
|
-
if (aChecker.assertCompliance(result.report) === 0) {
|
|
308
|
-
console.log("Passed:", f);
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
failures.push({
|
|
312
|
-
file: f,
|
|
313
|
-
report: result.report
|
|
314
|
-
});
|
|
315
|
-
console.log("Failed:", f);
|
|
316
|
-
}
|
|
147
|
+
else if (line.startsWith(path.sep)) {
|
|
148
|
+
inputs.push(line);
|
|
149
|
+
}
|
|
150
|
+
else if (line.match(/[a-z]{4,5}:\/\//)) {
|
|
151
|
+
inputs.push(line);
|
|
317
152
|
}
|
|
318
153
|
else {
|
|
319
|
-
|
|
320
|
-
console.log("Error:", f);
|
|
154
|
+
inputs.push(path.join(path.dirname(filename), line));
|
|
321
155
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
inputs = [filename];
|
|
160
|
+
}
|
|
161
|
+
let retVal = [];
|
|
162
|
+
for (const input of inputs) {
|
|
163
|
+
let isDirectory = false;
|
|
164
|
+
try {
|
|
165
|
+
isDirectory = fs.lstatSync(input).isDirectory();
|
|
166
|
+
}
|
|
167
|
+
catch (e) { }
|
|
168
|
+
if (isDirectory) {
|
|
169
|
+
retVal = retVal.concat(await getFiles(input));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
retVal.push(input);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return retVal;
|
|
176
|
+
}
|
|
177
|
+
// Prepare the configuration
|
|
178
|
+
getInputFileList().then(async (rptInputFiles) => {
|
|
179
|
+
let idx = 0;
|
|
180
|
+
let failures = [];
|
|
181
|
+
let errors = 0;
|
|
182
|
+
for (let f of rptInputFiles) {
|
|
183
|
+
let result;
|
|
184
|
+
let isFile = false;
|
|
185
|
+
try {
|
|
186
|
+
isFile = fs.lstatSync(f).isFile();
|
|
187
|
+
f = path.resolve(f);
|
|
188
|
+
}
|
|
189
|
+
catch (e) { }
|
|
190
|
+
if (isFile) {
|
|
191
|
+
result = await aChecker.getCompliance("file://" + f, f.replace(/^file:\/\//, "").replace(/[:?&=]/g, "_"));
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
result = await aChecker.getCompliance(f, f.replace(/^(https?:|file:)\/\//, "").replace(/[:?&=]/g, "_"));
|
|
195
|
+
}
|
|
196
|
+
if (result) {
|
|
197
|
+
if (aChecker.assertCompliance(result.report) === 0) {
|
|
198
|
+
console.log("Passed:", f);
|
|
335
199
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
process.exitCode = 1;
|
|
200
|
+
else {
|
|
201
|
+
failures.push({
|
|
202
|
+
file: f,
|
|
203
|
+
report: result.report
|
|
204
|
+
});
|
|
205
|
+
console.log("Failed:", f);
|
|
343
206
|
}
|
|
344
|
-
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
++errors;
|
|
210
|
+
console.log("Error:", f);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (failures.length > 0) {
|
|
214
|
+
console.log();
|
|
215
|
+
console.log("Failing scan details:");
|
|
216
|
+
console.log();
|
|
217
|
+
for (const fail of failures) {
|
|
218
|
+
console.log(aChecker.stringifyResults(fail.report));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
console.log();
|
|
222
|
+
console.log(`${rptInputFiles.length - failures.length - errors} of ${rptInputFiles.length} passed.`);
|
|
223
|
+
await aChecker.close();
|
|
224
|
+
if (failures.length !== 0 || errors !== 0) {
|
|
225
|
+
process.exitCode = 1;
|
|
345
226
|
}
|
|
346
227
|
});
|
|
347
|
-
|
|
348
|
-
//# sourceMappingURL=achecker.js.map
|
|
228
|
+
//# sourceMappingURL=achecker.js.map
|