@c4a/extract-thrift 0.7.1 → 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.
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
  }
@@ -12331,7 +12352,7 @@ function parseThriftSources(files) {
12331
12352
  }
12332
12353
 
12333
12354
  // src/index.ts
12334
- var THRIFT_EVIDENCE_ADAPTER_EXPORT = "thriftSourcesToEvidenceAdapterResult";
12355
+ var THRIFT_EVIDENCE_ADAPTER_EXPORT = "thriftSourcesToEvidenceAdapterMaterialization";
12335
12356
  function assertModuleAuthorized(moduleRef, invocation) {
12336
12357
  if (moduleRef !== null && !invocation.authorized_scope.module_refs.includes(moduleRef)) {
12337
12358
  throw new TypeError(`Thrift module ${moduleRef} escapes authorized scope`);
@@ -12434,8 +12455,12 @@ function thriftSourcesToEvidenceAdapterResult(files, invocation) {
12434
12455
  }]
12435
12456
  });
12436
12457
  }
12458
+ function thriftSourcesToEvidenceAdapterMaterialization(files, invocation) {
12459
+ return materializeIndexerEvidenceAdapterResult(thriftSourcesToEvidenceAdapterResult(files, invocation));
12460
+ }
12437
12461
  export {
12438
12462
  thriftSourcesToEvidenceAdapterResult,
12463
+ thriftSourcesToEvidenceAdapterMaterialization,
12439
12464
  parseThriftSources,
12440
12465
  lexThrift,
12441
12466
  ThriftSyntaxError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/extract-thrift",
3
- "version": "0.7.1",
3
+ "version": "0.7.4",
4
4
  "type": "module",
5
5
  "description": "Apache Thrift IDL catalog parser for Context",
6
6
  "license": "MIT",