@c4a/extract-style 0.7.5 → 0.7.9
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 +17 -9
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -22022,15 +22022,21 @@ function replaceWithCount(value, pattern, replacement, count) {
|
|
|
22022
22022
|
return replacement(...args.slice(0, -2));
|
|
22023
22023
|
});
|
|
22024
22024
|
}
|
|
22025
|
+
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)";
|
|
22026
|
+
var SECRET_TEXT_ASSIGNMENT = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
|
|
22027
|
+
var AUTHORIZATION_TEXT_PATTERN = new RegExp(`(\\bauthorization\\s*:\\s*(?:bearer|basic)\\s+)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^\\s,;]+`, "giu");
|
|
22028
|
+
var QUERY_SECRET_TEXT_PATTERN = new RegExp(`([?&](?:access_token|refresh_token|api_key|password|secret)=)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^&#\\s]+`, "giu");
|
|
22029
|
+
var ASSIGNMENT_SECRET_TEXT_PATTERN = new RegExp(`((?:["']?${SECRET_TEXT_KEY}["']?)\\s*${SECRET_TEXT_ASSIGNMENT})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu");
|
|
22025
22030
|
function redactKnownText(value, count) {
|
|
22031
|
+
if (!value.includes(":") && !value.includes("=") && !value.includes("-----BEGIN ")) {
|
|
22032
|
+
return value;
|
|
22033
|
+
}
|
|
22026
22034
|
let output = value;
|
|
22027
22035
|
output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
|
|
22028
|
-
output = replaceWithCount(output,
|
|
22036
|
+
output = replaceWithCount(output, AUTHORIZATION_TEXT_PATTERN, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
|
|
22029
22037
|
output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
|
|
22030
|
-
output = replaceWithCount(output,
|
|
22031
|
-
|
|
22032
|
-
const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
|
|
22033
|
-
output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
|
|
22038
|
+
output = replaceWithCount(output, QUERY_SECRET_TEXT_PATTERN, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
|
|
22039
|
+
output = replaceWithCount(output, ASSIGNMENT_SECRET_TEXT_PATTERN, (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
|
|
22034
22040
|
return output;
|
|
22035
22041
|
}
|
|
22036
22042
|
function redactBlockedText(value, blocked, count) {
|
|
@@ -22648,7 +22654,7 @@ function classifySpecifier(importer, specifier, files) {
|
|
|
22648
22654
|
return { resolution: "package-or-load-path", resolved_path: null, specifier };
|
|
22649
22655
|
}
|
|
22650
22656
|
function locator(path2, rule2, qualifiedItemPath) {
|
|
22651
|
-
return { path: path2, line: rule2.source?.start?.line ?? 1, column: rule2.source?.start?.column ?? 1, qualified_item_path: qualifiedItemPath };
|
|
22657
|
+
return { path: path2, line: rule2.source?.start?.line ?? 1, end_line: rule2.source?.end?.line ?? rule2.source?.start?.line ?? 1, column: rule2.source?.start?.column ?? 1, qualified_item_path: qualifiedItemPath };
|
|
22652
22658
|
}
|
|
22653
22659
|
function collectStyleImports(input) {
|
|
22654
22660
|
const imports = [];
|
|
@@ -22713,7 +22719,7 @@ var STATE_PSEUDOS = new Set([
|
|
|
22713
22719
|
var GENERIC_MODULE_NAMES = new Set(["global", "index", "style", "styles", "theme", "themes", "token", "tokens", "variable", "variables"]);
|
|
22714
22720
|
var DYNAMIC_SELECTOR_TOKEN = "c4a_dynamic_";
|
|
22715
22721
|
function locator2(path2, rule2, qualifiedItemPath) {
|
|
22716
|
-
return { path: path2, line: rule2.source?.start?.line ?? 1, column: rule2.source?.start?.column ?? 1, qualified_item_path: qualifiedItemPath };
|
|
22722
|
+
return { path: path2, line: rule2.source?.start?.line ?? 1, end_line: rule2.source?.end?.line ?? rule2.source?.start?.line ?? 1, column: rule2.source?.start?.column ?? 1, qualified_item_path: qualifiedItemPath };
|
|
22717
22723
|
}
|
|
22718
22724
|
function sorted(values) {
|
|
22719
22725
|
return [...values].sort((left, right) => left.localeCompare(right));
|
|
@@ -22923,7 +22929,7 @@ function collectStyleSelectors(input) {
|
|
|
22923
22929
|
// src/styleTokens.ts
|
|
22924
22930
|
var import_postcss_value_parser2 = __toESM(require_lib(), 1);
|
|
22925
22931
|
function locator3(path2, node2, qualifiedItemPath) {
|
|
22926
|
-
return { path: path2, line: node2.source?.start?.line ?? 1, column: node2.source?.start?.column ?? 1, qualified_item_path: qualifiedItemPath };
|
|
22932
|
+
return { path: path2, line: node2.source?.start?.line ?? 1, end_line: node2.source?.end?.line ?? node2.source?.start?.line ?? 1, column: node2.source?.start?.column ?? 1, qualified_item_path: qualifiedItemPath };
|
|
22927
22933
|
}
|
|
22928
22934
|
function firstWord(nodes) {
|
|
22929
22935
|
const node2 = nodes.find((item) => item.type === "word" || item.type === "string");
|
|
@@ -22993,6 +22999,8 @@ function parseRoot(path2, source, syntax) {
|
|
|
22993
22999
|
}
|
|
22994
23000
|
function parseStyleDocument(path2, source, syntax, files) {
|
|
22995
23001
|
const document2 = empty(path2, syntax, "analyzed");
|
|
23002
|
+
document2.lines = source.split(`
|
|
23003
|
+
`).length;
|
|
22996
23004
|
let root2;
|
|
22997
23005
|
try {
|
|
22998
23006
|
root2 = parseRoot(path2, source, syntax);
|
|
@@ -23068,7 +23076,7 @@ function analyzedFacts(document2, invocation, moduleRef) {
|
|
|
23068
23076
|
facts.push(fact2({ invocation, document: document2, moduleRef, locator: locator4, kind, signature, payload }));
|
|
23069
23077
|
};
|
|
23070
23078
|
const root2 = { path: document2.path, line: 1, column: 1, qualified_item_path: "file" };
|
|
23071
|
-
add(root2, "source-file", { catalog: document2.syntax, tier: "lightweight-evidence" }, { path: document2.path, syntax: document2.syntax });
|
|
23079
|
+
add(root2, "source-file", { catalog: document2.syntax, tier: "lightweight-evidence" }, { path: document2.path, syntax: document2.syntax, lines: document2.lines });
|
|
23072
23080
|
for (const item of document2.imports)
|
|
23073
23081
|
add(item.locator, "style-import", { import_ref: item.import_ref, kind: item.kind, specifier_digest: item.specifier_digest, resolution: item.resolution, resolved_path: item.resolved_path }, item);
|
|
23074
23082
|
for (const item of document2.tokens)
|