@c4a/extract-sql 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
@@ -30301,6 +30301,8 @@ function keyTokens(key) {
30301
30301
  return key.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").replace(/[^A-Za-z0-9]+/gu, "-").toLowerCase().split("-").filter(Boolean);
30302
30302
  }
30303
30303
  function sensitiveKey(key, value) {
30304
+ if (value === INDEXER_OUTPUT_REDACTION_MARKER)
30305
+ return false;
30304
30306
  const tokens = keyTokens(key);
30305
30307
  if (tokens.length === 0)
30306
30308
  return false;
@@ -30342,12 +30344,12 @@ function replaceWithCount(value, pattern, replacement, count) {
30342
30344
  function redactKnownText(value, count) {
30343
30345
  let output = value;
30344
30346
  output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
30345
- output = replaceWithCount(output, /(\bauthorization\s*:\s*(?:bearer|basic)\s+)[^\s,;]+/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
30347
+ 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);
30346
30348
  output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
30347
- output = replaceWithCount(output, /([?&](?:access_token|refresh_token|api_key|password|secret)=)[^&#\s]+/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
30349
+ 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);
30348
30350
  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)";
30349
30351
  const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
30350
- output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
30352
+ output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
30351
30353
  return output;
30352
30354
  }
30353
30355
  function redactBlockedText(value, blocked, count) {
@@ -30615,6 +30617,25 @@ function createIndexerEvidenceAdapterFact(input) {
30615
30617
  FACT_PAYLOADS.set(fact2, payload);
30616
30618
  return fact2;
30617
30619
  }
30620
+ function indexerEvidenceAdapterFactPayloads(result) {
30621
+ const payloads = result.files.flatMap((file) => file.facts.map((fact2) => {
30622
+ const payload = FACT_PAYLOADS.get(fact2);
30623
+ if (payload === undefined) {
30624
+ throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is no longer materialized in this process`);
30625
+ }
30626
+ if (indexerEvidenceAdapterProtocolDigest(payload) !== fact2.payload_digest) {
30627
+ throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is stale`);
30628
+ }
30629
+ return { fact_ref: fact2.fact_ref, payload };
30630
+ })).sort((left, right) => compareCanonicalText(left.fact_ref, right.fact_ref));
30631
+ return assertIndexerOutputSafe({ channel: "ipc-envelope", value: payloads });
30632
+ }
30633
+ function materializeIndexerEvidenceAdapterResult(result) {
30634
+ return {
30635
+ result,
30636
+ fact_payloads: indexerEvidenceAdapterFactPayloads(result)
30637
+ };
30638
+ }
30618
30639
  function indexerEvidenceAdapterOutputDigest(value) {
30619
30640
  return indexerEvidenceAdapterProtocolDigest(value);
30620
30641
  }
@@ -31323,11 +31344,15 @@ function sqlSourcesToEvidenceAdapterResult(files, invocation) {
31323
31344
  }]
31324
31345
  });
31325
31346
  }
31347
+ function sqlSourcesToEvidenceAdapterMaterialization(files, invocation) {
31348
+ return materializeIndexerEvidenceAdapterResult(sqlSourcesToEvidenceAdapterResult(files, invocation));
31349
+ }
31326
31350
 
31327
31351
  // src/index.ts
31328
- var SQL_EVIDENCE_ADAPTER_EXPORT = "sqlSourcesToEvidenceAdapterResult";
31352
+ var SQL_EVIDENCE_ADAPTER_EXPORT = "sqlSourcesToEvidenceAdapterMaterialization";
31329
31353
  export {
31330
31354
  sqlSourcesToEvidenceAdapterResult,
31355
+ sqlSourcesToEvidenceAdapterMaterialization,
31331
31356
  splitSqlStatements,
31332
31357
  parseSqlSources,
31333
31358
  SQL_EVIDENCE_ADAPTER_EXPORT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/extract-sql",
3
- "version": "0.7.1",
3
+ "version": "0.7.5",
4
4
  "type": "module",
5
5
  "description": "Dialect-bound lightweight SQL evidence adapter for Context",
6
6
  "license": "MIT",