@xliic/cicd-core-node
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -68,2 +68,6 @@ "use strict"; | ||
const [parsed, mapping] = yield parse_1.bundle(rootDir, filename); | ||
if ("error" in parsed) { | ||
result[filename] = parsed; | ||
continue; | ||
} | ||
const apiData = Buffer.from(JSON.stringify(parsed), "utf8"); | ||
@@ -81,2 +85,6 @@ result[filename] = withMapping(yield api_1.updateApi(apiId, apiData, options), mapping); | ||
const [parsed, mapping] = yield parse_1.bundle(rootDir, filename); | ||
if ("error" in parsed) { | ||
result[filename] = parsed; | ||
continue; | ||
} | ||
const apiName = makeName(filename); | ||
@@ -149,2 +157,3 @@ const apiData = Buffer.from(JSON.stringify(parsed), "utf8"); | ||
function auditFileMap(rootDir, fileMap, failureConditions, options) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -156,3 +165,3 @@ const summary = {}; | ||
? remote.description | ||
: `Unexpected error: ${remote.statusCode} ${remote.error}`; | ||
: `Unexpected error: ${(_a = remote.statusCode) !== null && _a !== void 0 ? _a : ""} ${remote.error}`; | ||
summary[filename] = { | ||
@@ -159,0 +168,0 @@ apiId: null, |
@@ -24,2 +24,3 @@ "use strict"; | ||
const $Ref = require("@xliic/json-schema-ref-parser/lib/ref"); | ||
const errors_1 = require("@xliic/json-schema-ref-parser/lib/util/errors"); | ||
const openapi_ast_node_1 = require("@xliic/openapi-ast-node"); | ||
@@ -53,8 +54,14 @@ const destinationMap = { | ||
canRead: (file) => { | ||
return url.isFileSystemPath(file.url); | ||
return true; | ||
}, | ||
read: (file) => __awaiter(this, void 0, void 0, function* () { | ||
return fs.readFileSync(path_1.resolve(rootDir, url.toFileSystemPath(file.url)), { | ||
encoding: "utf-8", | ||
}); | ||
const filename = path_1.resolve(rootDir, url.toFileSystemPath(file.url)); | ||
try { | ||
return fs.readFileSync(filename, { | ||
encoding: "utf-8", | ||
}); | ||
} | ||
catch (err) { | ||
throw new errors_1.ResolverError({ message: `Error reading file "${filename}: ${err.message}"` }, filename); | ||
} | ||
}), | ||
@@ -131,4 +138,5 @@ }; | ||
}; | ||
const bundled = yield parser.bundle(parsed, { | ||
const options = { | ||
cwd, | ||
continueOnError: true, | ||
resolve: { http: false, file: resolver(rootDir) }, | ||
@@ -189,4 +197,26 @@ hooks: { | ||
}, | ||
}); | ||
return [bundled, state.mapping]; | ||
}; | ||
try { | ||
const bundled = yield parser.bundle(parsed, options); | ||
return [bundled, state.mapping]; | ||
} | ||
catch (errors) { | ||
const uniqueErrors = []; | ||
const exists = (error) => uniqueErrors.some((element) => (element === null || element === void 0 ? void 0 : element.message) === (error === null || error === void 0 ? void 0 : error.message) && | ||
(element === null || element === void 0 ? void 0 : element.source) === (error === null || error === void 0 ? void 0 : error.source) && | ||
(element === null || element === void 0 ? void 0 : element.code) === (error === null || error === void 0 ? void 0 : error.code) && | ||
(element === null || element === void 0 ? void 0 : element.path.join()) === (error === null || error === void 0 ? void 0 : error.path.join())); | ||
for (const error of errors.errors) { | ||
if (!exists(error)) { | ||
uniqueErrors.push(error); | ||
} | ||
} | ||
const messages = uniqueErrors | ||
.map((error) => { | ||
const source = error.source == "" ? path_1.resolve(rootDir, filename) : error.source; | ||
return ` Failed to resolve reference: in ${source} at ${openapi_ast_node_1.joinJsonPointer(error.path)}: ${error.message}`; | ||
}) | ||
.join("\n"); | ||
return [{ error: `Error bundling OpenAPI file:\n${messages}` }, null]; | ||
} | ||
}); | ||
@@ -193,0 +223,0 @@ } |
{ | ||
"name": "@xliic/cicd-core-node", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Performs API contract security audit to get a detailed analysis of the possible vulnerabilities and other issues in the API contract.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -88,2 +88,6 @@ /* | ||
const [parsed, mapping] = await bundle(rootDir, filename); | ||
if ("error" in parsed) { | ||
result[filename] = parsed; | ||
continue; | ||
} | ||
const apiData = Buffer.from(JSON.stringify(parsed), "utf8"); | ||
@@ -110,2 +114,6 @@ result[filename] = withMapping( | ||
const [parsed, mapping] = await bundle(rootDir, filename); | ||
if ("error" in parsed) { | ||
result[filename] = parsed; | ||
continue; | ||
} | ||
const apiName = makeName(filename); | ||
@@ -221,3 +229,3 @@ const apiData = Buffer.from(JSON.stringify(parsed), "utf8"); | ||
? remote.description | ||
: `Unexpected error: ${remote.statusCode} ${remote.error}`; | ||
: `Unexpected error: ${remote.statusCode ?? ""} ${remote.error}`; | ||
summary[filename] = { | ||
@@ -224,0 +232,0 @@ apiId: null, |
@@ -14,2 +14,3 @@ /* | ||
import * as $Ref from "@xliic/json-schema-ref-parser/lib/ref"; | ||
import { ResolverError } from "@xliic/json-schema-ref-parser/lib/util/errors"; | ||
import { parseJsonPointer, joinJsonPointer } from "@xliic/openapi-ast-node"; | ||
@@ -50,8 +51,16 @@ import { JsonMapping, MappingTreeNode } from "./types"; | ||
canRead: (file: any) => { | ||
return url.isFileSystemPath(file.url); | ||
return true; | ||
}, | ||
read: async (file: any) => { | ||
return fs.readFileSync(resolve(rootDir, url.toFileSystemPath(file.url)), { | ||
encoding: "utf-8", | ||
}); | ||
const filename = resolve(rootDir, url.toFileSystemPath(file.url)); | ||
try { | ||
return fs.readFileSync(filename, { | ||
encoding: "utf-8", | ||
}); | ||
} catch (err) { | ||
throw new ResolverError( | ||
{ message: `Error reading file "${filename}: ${err.message}"` }, | ||
filename | ||
); | ||
} | ||
}, | ||
@@ -153,4 +162,5 @@ }; | ||
const bundled = await parser.bundle(parsed, { | ||
const options = { | ||
cwd, | ||
continueOnError: true, | ||
resolve: { http: false, file: resolver(rootDir) }, | ||
@@ -220,5 +230,36 @@ hooks: { | ||
}, | ||
}); | ||
}; | ||
return [bundled, state.mapping]; | ||
try { | ||
const bundled = await parser.bundle(parsed, options); | ||
return [bundled, state.mapping]; | ||
} catch (errors) { | ||
const uniqueErrors = []; | ||
const exists = (error) => | ||
uniqueErrors.some( | ||
(element) => | ||
element?.message === error?.message && | ||
element?.source === error?.source && | ||
element?.code === error?.code && | ||
element?.path.join() === error?.path.join() | ||
); | ||
for (const error of errors.errors) { | ||
if (!exists(error)) { | ||
uniqueErrors.push(error); | ||
} | ||
} | ||
const messages = uniqueErrors | ||
.map((error) => { | ||
const source = | ||
error.source == "" ? resolve(rootDir, filename) : error.source; | ||
return ` Failed to resolve reference: in ${source} at ${joinJsonPointer( | ||
error.path | ||
)}: ${error.message}`; | ||
}) | ||
.join("\n"); | ||
return [{ error: `Error bundling OpenAPI file:\n${messages}` }, null]; | ||
} | ||
} | ||
@@ -225,0 +266,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
139166
90
2997
0