@c4a/extract-contract 0.7.0 → 0.7.4
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 +29 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -26295,6 +26295,8 @@ function keyTokens(key) {
|
|
|
26295
26295
|
return key.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").replace(/[^A-Za-z0-9]+/gu, "-").toLowerCase().split("-").filter(Boolean);
|
|
26296
26296
|
}
|
|
26297
26297
|
function sensitiveKey(key, value) {
|
|
26298
|
+
if (value === INDEXER_OUTPUT_REDACTION_MARKER)
|
|
26299
|
+
return false;
|
|
26298
26300
|
const tokens = keyTokens(key);
|
|
26299
26301
|
if (tokens.length === 0)
|
|
26300
26302
|
return false;
|
|
@@ -26336,12 +26338,12 @@ function replaceWithCount(value, pattern, replacement, count) {
|
|
|
26336
26338
|
function redactKnownText(value, count) {
|
|
26337
26339
|
let output = value;
|
|
26338
26340
|
output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
|
|
26339
|
-
output = replaceWithCount(output,
|
|
26341
|
+
output = replaceWithCount(output, new RegExp(`(\\bauthorization\\s*:\\s*(?:bearer|basic)\\s+)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^\\s,;]+`, "giu"), (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
|
|
26340
26342
|
output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
|
|
26341
|
-
output = replaceWithCount(output,
|
|
26343
|
+
output = replaceWithCount(output, new RegExp(`([?&](?:access_token|refresh_token|api_key|password|secret)=)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^&#\\s]+`, "giu"), (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
|
|
26342
26344
|
const 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)";
|
|
26343
26345
|
const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
|
|
26344
|
-
output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
|
|
26346
|
+
output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
|
|
26345
26347
|
return output;
|
|
26346
26348
|
}
|
|
26347
26349
|
function redactBlockedText(value, blocked, count) {
|
|
@@ -26609,6 +26611,25 @@ function createIndexerEvidenceAdapterFact(input) {
|
|
|
26609
26611
|
FACT_PAYLOADS.set(fact2, payload);
|
|
26610
26612
|
return fact2;
|
|
26611
26613
|
}
|
|
26614
|
+
function indexerEvidenceAdapterFactPayloads(result) {
|
|
26615
|
+
const payloads = result.files.flatMap((file) => file.facts.map((fact2) => {
|
|
26616
|
+
const payload = FACT_PAYLOADS.get(fact2);
|
|
26617
|
+
if (payload === undefined) {
|
|
26618
|
+
throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is no longer materialized in this process`);
|
|
26619
|
+
}
|
|
26620
|
+
if (indexerEvidenceAdapterProtocolDigest(payload) !== fact2.payload_digest) {
|
|
26621
|
+
throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is stale`);
|
|
26622
|
+
}
|
|
26623
|
+
return { fact_ref: fact2.fact_ref, payload };
|
|
26624
|
+
})).sort((left, right) => compareCanonicalText(left.fact_ref, right.fact_ref));
|
|
26625
|
+
return assertIndexerOutputSafe({ channel: "ipc-envelope", value: payloads });
|
|
26626
|
+
}
|
|
26627
|
+
function materializeIndexerEvidenceAdapterResult(result) {
|
|
26628
|
+
return {
|
|
26629
|
+
result,
|
|
26630
|
+
fact_payloads: indexerEvidenceAdapterFactPayloads(result)
|
|
26631
|
+
};
|
|
26632
|
+
}
|
|
26612
26633
|
function indexerEvidenceAdapterOutputDigest(value) {
|
|
26613
26634
|
return indexerEvidenceAdapterProtocolDigest(value);
|
|
26614
26635
|
}
|
|
@@ -26983,11 +27004,15 @@ function contractSourcesToEvidenceAdapterResult(files, invocation) {
|
|
|
26983
27004
|
}]
|
|
26984
27005
|
});
|
|
26985
27006
|
}
|
|
27007
|
+
function contractSourcesToEvidenceAdapterMaterialization(files, invocation) {
|
|
27008
|
+
return materializeIndexerEvidenceAdapterResult(contractSourcesToEvidenceAdapterResult(files, invocation));
|
|
27009
|
+
}
|
|
26986
27010
|
|
|
26987
27011
|
// src/index.ts
|
|
26988
|
-
var CONTRACT_EVIDENCE_ADAPTER_EXPORT = "
|
|
27012
|
+
var CONTRACT_EVIDENCE_ADAPTER_EXPORT = "contractSourcesToEvidenceAdapterMaterialization";
|
|
26989
27013
|
export {
|
|
26990
27014
|
parseContractSources,
|
|
26991
27015
|
contractSourcesToEvidenceAdapterResult,
|
|
27016
|
+
contractSourcesToEvidenceAdapterMaterialization,
|
|
26992
27017
|
CONTRACT_EVIDENCE_ADAPTER_EXPORT
|
|
26993
27018
|
};
|