@appland/scanner 1.76.3 → 1.76.5
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [@appland/scanner-v1.76.5](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.76.4...@appland/scanner-v1.76.5) (2023-02-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Remove http-dependent code from openapi ([2cae20f](https://github.com/getappmap/appmap-js/commit/2cae20f6cc0ca72123c2288178d1f7a234099cc5))
|
|
7
|
+
* Update minimatch version to match appmap ([2720750](https://github.com/getappmap/appmap-js/commit/2720750d1e3b95c83c4e86a489636267397a9c11))
|
|
8
|
+
|
|
9
|
+
# [@appland/scanner-v1.76.4](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.76.3...@appland/scanner-v1.76.4) (2023-02-24)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* Release notarized Mac OS binaries ([f13e619](https://github.com/getappmap/appmap-js/commit/f13e619648903dbb1989a72c64aab65aa1adf8dc))
|
|
15
|
+
|
|
1
16
|
# [@appland/scanner-v1.76.3](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.76.2...@appland/scanner-v1.76.3) (2023-02-23)
|
|
2
17
|
|
|
3
18
|
|
|
@@ -14,6 +14,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const openapi_1 = require("../openapi");
|
|
16
16
|
const parseRuleDescription_1 = __importDefault(require("./lib/parseRuleDescription"));
|
|
17
|
+
const openapiProvider_1 = __importDefault(require("./lib/openapiProvider"));
|
|
18
|
+
const assert_1 = __importDefault(require("assert"));
|
|
17
19
|
class Options {
|
|
18
20
|
constructor() {
|
|
19
21
|
this.schemata = {};
|
|
@@ -29,7 +31,11 @@ function build(options) {
|
|
|
29
31
|
function matcher(event) {
|
|
30
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
33
|
const clientFragment = (0, openapi_1.forClientRequest)(event);
|
|
32
|
-
|
|
34
|
+
(0, assert_1.default)(event.httpClientRequest);
|
|
35
|
+
if (!event.httpClientRequest.url)
|
|
36
|
+
return [];
|
|
37
|
+
const host = new URL(event.httpClientRequest.url).host;
|
|
38
|
+
const serverSchema = yield (0, openapiProvider_1.default)(host, options.schemata);
|
|
33
39
|
const clientSchema = {
|
|
34
40
|
openapi: '3.0.0',
|
|
35
41
|
info: {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const js_yaml_1 = require("js-yaml");
|
|
16
|
+
const url_1 = require("url");
|
|
17
|
+
const http_1 = __importDefault(require("http"));
|
|
18
|
+
const https_1 = __importDefault(require("https"));
|
|
19
|
+
const promises_1 = require("fs/promises");
|
|
20
|
+
const URLLoader = (protocol) => {
|
|
21
|
+
return (url) => {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
protocol
|
|
24
|
+
.get(url)
|
|
25
|
+
.on('response', (response) => {
|
|
26
|
+
if (response.statusCode !== 200) {
|
|
27
|
+
return reject(`${response.statusCode || ''} ${response.statusMessage || ''}`);
|
|
28
|
+
}
|
|
29
|
+
const data = [];
|
|
30
|
+
response
|
|
31
|
+
.on('data', (chunk) => {
|
|
32
|
+
data.push(Buffer.from(chunk));
|
|
33
|
+
})
|
|
34
|
+
.on('end', () => {
|
|
35
|
+
resolve(Buffer.concat(data));
|
|
36
|
+
});
|
|
37
|
+
})
|
|
38
|
+
.on('error', reject);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const FileLoader = (url) => {
|
|
43
|
+
return (0, promises_1.readFile)((0, url_1.fileURLToPath)(url));
|
|
44
|
+
};
|
|
45
|
+
const ProtocolLoader = {
|
|
46
|
+
'http:': URLLoader(http_1.default),
|
|
47
|
+
'https:': URLLoader(https_1.default),
|
|
48
|
+
'file:': FileLoader,
|
|
49
|
+
};
|
|
50
|
+
const fetch = (urlStr) => {
|
|
51
|
+
const url = new url_1.URL(urlStr);
|
|
52
|
+
const loader = ProtocolLoader[url.protocol];
|
|
53
|
+
if (!loader) {
|
|
54
|
+
throw new Error(`No schema loader for protocol ${url.protocol}`);
|
|
55
|
+
}
|
|
56
|
+
return loader(url);
|
|
57
|
+
};
|
|
58
|
+
const SchemaCache = {};
|
|
59
|
+
const schemaCache = (key, fn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
const cachedResult = SchemaCache[key];
|
|
61
|
+
if (cachedResult) {
|
|
62
|
+
return cachedResult;
|
|
63
|
+
}
|
|
64
|
+
const result = yield fn(key);
|
|
65
|
+
SchemaCache[key] = result;
|
|
66
|
+
return result;
|
|
67
|
+
});
|
|
68
|
+
const fetchSchema = (sourceURL) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
return schemaCache(sourceURL, (sourceURL) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
const data = yield fetch(sourceURL);
|
|
71
|
+
return (0, js_yaml_1.load)(data.toString());
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
74
|
+
const lookup = (host, openapiSchemata) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
const sourceURL = openapiSchemata[host];
|
|
76
|
+
if (!sourceURL) {
|
|
77
|
+
throw new Error(`No OpenAPI schema URL configured for host ${host}. Available hosts are: ${Object.keys(openapiSchemata).join(', ')}`);
|
|
78
|
+
}
|
|
79
|
+
return yield fetchSchema(sourceURL);
|
|
80
|
+
});
|
|
81
|
+
exports.default = lookup;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appland/scanner",
|
|
3
|
-
"version": "1.76.
|
|
3
|
+
"version": "1.76.5",
|
|
4
4
|
"description": "Analyze AppMaps for code flaws",
|
|
5
5
|
"bin": "built/cli.js",
|
|
6
6
|
"files": [
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@appland/client": "^1.5.0",
|
|
64
64
|
"@appland/models": "^2.0.0",
|
|
65
|
-
"@appland/openapi": "1.4.
|
|
65
|
+
"@appland/openapi": "1.4.3",
|
|
66
66
|
"@appland/sql-parser": "^1.5.0",
|
|
67
67
|
"@types/cli-progress": "^3.9.2",
|
|
68
68
|
"ajv": "^8.8.2",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"inquirer": "^8.1.2",
|
|
79
79
|
"js-yaml": "^4.1.0",
|
|
80
80
|
"lru-cache": "^6.0.0",
|
|
81
|
-
"minimatch": "^
|
|
81
|
+
"minimatch": "^5.1.2",
|
|
82
82
|
"octokat": "^0.10.0",
|
|
83
83
|
"openapi-diff": "^0.23.5",
|
|
84
84
|
"ora": "~5",
|