@c4a/extract-proto 0.7.1 → 0.7.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.
Files changed (2) hide show
  1. package/index.js +29 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -11404,6 +11404,8 @@ function keyTokens(key) {
11404
11404
  return key.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").replace(/[^A-Za-z0-9]+/gu, "-").toLowerCase().split("-").filter(Boolean);
11405
11405
  }
11406
11406
  function sensitiveKey(key, value) {
11407
+ if (value === INDEXER_OUTPUT_REDACTION_MARKER)
11408
+ return false;
11407
11409
  const tokens = keyTokens(key);
11408
11410
  if (tokens.length === 0)
11409
11411
  return false;
@@ -11445,12 +11447,12 @@ function replaceWithCount(value, pattern, replacement, count) {
11445
11447
  function redactKnownText(value, count) {
11446
11448
  let output = value;
11447
11449
  output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
11448
- output = replaceWithCount(output, /(\bauthorization\s*:\s*(?:bearer|basic)\s+)[^\s,;]+/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
11450
+ 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);
11449
11451
  output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
11450
- output = replaceWithCount(output, /([?&](?:access_token|refresh_token|api_key|password|secret)=)[^&#\s]+/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
11452
+ 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);
11451
11453
  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)";
11452
11454
  const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
11453
- output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
11455
+ output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
11454
11456
  return output;
11455
11457
  }
11456
11458
  function redactBlockedText(value, blocked, count) {
@@ -11718,6 +11720,25 @@ function createIndexerEvidenceAdapterFact(input) {
11718
11720
  FACT_PAYLOADS.set(fact2, payload);
11719
11721
  return fact2;
11720
11722
  }
11723
+ function indexerEvidenceAdapterFactPayloads(result) {
11724
+ const payloads = result.files.flatMap((file) => file.facts.map((fact2) => {
11725
+ const payload = FACT_PAYLOADS.get(fact2);
11726
+ if (payload === undefined) {
11727
+ throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is no longer materialized in this process`);
11728
+ }
11729
+ if (indexerEvidenceAdapterProtocolDigest(payload) !== fact2.payload_digest) {
11730
+ throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is stale`);
11731
+ }
11732
+ return { fact_ref: fact2.fact_ref, payload };
11733
+ })).sort((left, right) => compareCanonicalText(left.fact_ref, right.fact_ref));
11734
+ return assertIndexerOutputSafe({ channel: "ipc-envelope", value: payloads });
11735
+ }
11736
+ function materializeIndexerEvidenceAdapterResult(result) {
11737
+ return {
11738
+ result,
11739
+ fact_payloads: indexerEvidenceAdapterFactPayloads(result)
11740
+ };
11741
+ }
11721
11742
  function indexerEvidenceAdapterOutputDigest(value) {
11722
11743
  return indexerEvidenceAdapterProtocolDigest(value);
11723
11744
  }
@@ -12369,7 +12390,7 @@ function parseProtoSources(files, options = {}) {
12369
12390
  }
12370
12391
 
12371
12392
  // src/index.ts
12372
- var PROTO_EVIDENCE_ADAPTER_EXPORT = "protoSourcesToEvidenceAdapterResult";
12393
+ var PROTO_EVIDENCE_ADAPTER_EXPORT = "protoSourcesToEvidenceAdapterMaterialization";
12373
12394
  function assertModuleAuthorized(moduleRef, invocation) {
12374
12395
  if (moduleRef !== null && !invocation.authorized_scope.module_refs.includes(moduleRef)) {
12375
12396
  throw new TypeError(`Proto module ${moduleRef} escapes authorized scope`);
@@ -12464,8 +12485,12 @@ function protoSourcesToEvidenceAdapterResult(files, invocation) {
12464
12485
  }]
12465
12486
  });
12466
12487
  }
12488
+ function protoSourcesToEvidenceAdapterMaterialization(files, invocation) {
12489
+ return materializeIndexerEvidenceAdapterResult(protoSourcesToEvidenceAdapterResult(files, invocation));
12490
+ }
12467
12491
  export {
12468
12492
  protoSourcesToEvidenceAdapterResult,
12493
+ protoSourcesToEvidenceAdapterMaterialization,
12469
12494
  parseProtoSources,
12470
12495
  lexProto,
12471
12496
  ProtoSyntaxError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/extract-proto",
3
- "version": "0.7.1",
3
+ "version": "0.7.5",
4
4
  "type": "module",
5
5
  "description": "Protocol Buffers IDL catalog parser for Context",
6
6
  "license": "MIT",