@c4a/core 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.
Files changed (2) hide show
  1. package/index.js +11 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -13195,15 +13195,21 @@ function replaceWithCount(value, pattern, replacement, count) {
13195
13195
  return replacement(...args.slice(0, -2));
13196
13196
  });
13197
13197
  }
13198
+ 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)";
13199
+ var SECRET_TEXT_ASSIGNMENT = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
13200
+ var AUTHORIZATION_TEXT_PATTERN = new RegExp(`(\\bauthorization\\s*:\\s*(?:bearer|basic)\\s+)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^\\s,;]+`, "giu");
13201
+ var QUERY_SECRET_TEXT_PATTERN = new RegExp(`([?&](?:access_token|refresh_token|api_key|password|secret)=)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^&#\\s]+`, "giu");
13202
+ var ASSIGNMENT_SECRET_TEXT_PATTERN = new RegExp(`((?:["']?${SECRET_TEXT_KEY}["']?)\\s*${SECRET_TEXT_ASSIGNMENT})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu");
13198
13203
  function redactKnownText(value, count) {
13204
+ if (!value.includes(":") && !value.includes("=") && !value.includes("-----BEGIN ")) {
13205
+ return value;
13206
+ }
13199
13207
  let output = value;
13200
13208
  output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
13201
- 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);
13209
+ output = replaceWithCount(output, AUTHORIZATION_TEXT_PATTERN, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
13202
13210
  output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
13203
- 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);
13204
- 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)";
13205
- const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
13206
- output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
13211
+ output = replaceWithCount(output, QUERY_SECRET_TEXT_PATTERN, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
13212
+ output = replaceWithCount(output, ASSIGNMENT_SECRET_TEXT_PATTERN, (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
13207
13213
  return output;
13208
13214
  }
13209
13215
  function redactBlockedText(value, blocked, count) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/core",
3
- "version": "0.7.8",
3
+ "version": "0.7.10-alpha.1",
4
4
  "type": "module",
5
5
  "description": "Shared extraction types, schemas, and utilities for Context",
6
6
  "license": "MIT",