@c4a/extract-contract 0.7.8 → 0.7.10-alpha.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/index.js +32 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -21825,6 +21825,26 @@ function refTarget(importer, raw) {
|
|
|
21825
21825
|
const targetPath = posix.normalize(posix.join(posix.dirname(importer), rawPath));
|
|
21826
21826
|
return portablePath(targetPath) ? { targetPath, pointer, external: true } : null;
|
|
21827
21827
|
}
|
|
21828
|
+
function openApiSourceDependencies(path, source) {
|
|
21829
|
+
if (!/\.(?:json|ya?ml)$/iu.test(path))
|
|
21830
|
+
return [];
|
|
21831
|
+
if (!portablePath(path))
|
|
21832
|
+
throw new TypeError(`contract source path is not portable: ${path}`);
|
|
21833
|
+
const parsed = parseYaml(path, source);
|
|
21834
|
+
if (parsed.parseError)
|
|
21835
|
+
throw new TypeError(`${path}: ${parsed.parseError}`);
|
|
21836
|
+
const dependencies = new Set;
|
|
21837
|
+
for (const ref of collectRefs(parsed)) {
|
|
21838
|
+
if (ref.underBaseId && !ref.raw.startsWith("#"))
|
|
21839
|
+
throw new TypeError(`${path}: reference under $id requires an explicit registered URI mapping: ${ref.raw}`);
|
|
21840
|
+
const target = refTarget(path, ref.raw);
|
|
21841
|
+
if (!target)
|
|
21842
|
+
throw new TypeError(`${path}: reference leaves registered source scope: ${ref.raw}`);
|
|
21843
|
+
if (target.external)
|
|
21844
|
+
dependencies.add(target.targetPath);
|
|
21845
|
+
}
|
|
21846
|
+
return [...dependencies];
|
|
21847
|
+
}
|
|
21828
21848
|
function cycleMembers(graph) {
|
|
21829
21849
|
const cycles = new Set;
|
|
21830
21850
|
const visiting = new Set;
|
|
@@ -26463,15 +26483,21 @@ function replaceWithCount(value, pattern, replacement, count) {
|
|
|
26463
26483
|
return replacement(...args.slice(0, -2));
|
|
26464
26484
|
});
|
|
26465
26485
|
}
|
|
26486
|
+
var SECRET_TEXT_KEY = "(?:[A-Za-z0-9_.-]*(?:password|passwd|pwd|secret|token|credential|cookie)[A-Za-z0-9_.-]*|api[-_]?key|access[-_]?(?:key|token)|private[-_]?key|client[-_]?secret|authorization)";
|
|
26487
|
+
var SECRET_TEXT_ASSIGNMENT = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
|
|
26488
|
+
var AUTHORIZATION_TEXT_PATTERN = new RegExp(`(\\bauthorization\\s*:\\s*(?:bearer|basic)\\s+)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^\\s,;]+`, "giu");
|
|
26489
|
+
var QUERY_SECRET_TEXT_PATTERN = new RegExp(`([?&](?:access_token|refresh_token|api_key|password|secret)=)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^&#\\s]+`, "giu");
|
|
26490
|
+
var ASSIGNMENT_SECRET_TEXT_PATTERN = new RegExp(`((?:["']?${SECRET_TEXT_KEY}["']?)\\s*${SECRET_TEXT_ASSIGNMENT})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu");
|
|
26466
26491
|
function redactKnownText(value, count) {
|
|
26492
|
+
if (!value.includes(":") && !value.includes("=") && !value.includes("-----BEGIN ")) {
|
|
26493
|
+
return value;
|
|
26494
|
+
}
|
|
26467
26495
|
let output = value;
|
|
26468
26496
|
output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
|
|
26469
|
-
output = replaceWithCount(output,
|
|
26497
|
+
output = replaceWithCount(output, AUTHORIZATION_TEXT_PATTERN, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
|
|
26470
26498
|
output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
|
|
26471
|
-
output = replaceWithCount(output,
|
|
26472
|
-
|
|
26473
|
-
const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
|
|
26474
|
-
output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
|
|
26499
|
+
output = replaceWithCount(output, QUERY_SECRET_TEXT_PATTERN, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
|
|
26500
|
+
output = replaceWithCount(output, ASSIGNMENT_SECRET_TEXT_PATTERN, (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
|
|
26475
26501
|
return output;
|
|
26476
26502
|
}
|
|
26477
26503
|
function redactBlockedText(value, blocked, count) {
|
|
@@ -27140,6 +27166,7 @@ function contractSourcesToEvidenceAdapterMaterialization(files, invocation) {
|
|
|
27140
27166
|
var CONTRACT_EVIDENCE_ADAPTER_EXPORT = "contractSourcesToEvidenceAdapterMaterialization";
|
|
27141
27167
|
export {
|
|
27142
27168
|
parseContractSources,
|
|
27169
|
+
openApiSourceDependencies,
|
|
27143
27170
|
contractSourcesToEvidenceAdapterResult,
|
|
27144
27171
|
contractSourcesToEvidenceAdapterMaterialization,
|
|
27145
27172
|
CONTRACT_EVIDENCE_ADAPTER_EXPORT
|