@plune-ai/playwright 0.7.3 → 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.
- package/dist/index.cjs +47 -0
- package/dist/index.js +47 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -402,6 +402,7 @@ function readEnv(env = process.env) {
|
|
|
402
402
|
...shardError !== void 0 ? { shardError } : {},
|
|
403
403
|
...configurationError !== void 0 ? { configurationError } : {},
|
|
404
404
|
...importTimeout !== void 0 ? { importTimeout } : {},
|
|
405
|
+
secretCheck: !["0", "false", "no", "off"].includes(value(env, "PLUNE_SECRET_CHECK")?.toLowerCase() ?? ""),
|
|
405
406
|
ignored: UNSUPPORTED_VARS.filter((name) => value(env, name) !== void 0),
|
|
406
407
|
warnings
|
|
407
408
|
};
|
|
@@ -748,6 +749,30 @@ function maskCredentials(text) {
|
|
|
748
749
|
"$1$2\u2039credential\u203A"
|
|
749
750
|
).replace(/\b(PLUNE_[A-Z0-9_]*=)(?!‹)[^\s'"\x60;,)]+/g, "$1\u2039env-secret\u203A").replace(QUERY_PARAM, "$1\u2039credential\u203A").replace(/\b([a-z][\w+.-]*:\/\/)[^\s/@'"\x60]+@/gi, "$1\u2039credential\u203A@");
|
|
750
751
|
}
|
|
752
|
+
function credentialsIn(text) {
|
|
753
|
+
const masked = maskCredentials(text);
|
|
754
|
+
if (masked === text) return [];
|
|
755
|
+
const found = [];
|
|
756
|
+
let from = 0;
|
|
757
|
+
let at = 0;
|
|
758
|
+
for (let open = masked.indexOf("\u2039", at); open >= 0; open = masked.indexOf("\u2039", at)) {
|
|
759
|
+
const start = from + (open - at);
|
|
760
|
+
let close = masked.indexOf("\u203A", open);
|
|
761
|
+
while (close >= 0 && masked[close + 1] === "\u2039") close = masked.indexOf("\u203A", close + 1);
|
|
762
|
+
if (close < 0) break;
|
|
763
|
+
const next = masked.indexOf("\u2039", close + 1);
|
|
764
|
+
const tail = masked.slice(close + 1, next < 0 ? void 0 : next);
|
|
765
|
+
const end = next < 0 ? text.length - tail.length : text.indexOf(tail, start);
|
|
766
|
+
if (end < start) break;
|
|
767
|
+
const marker = masked.slice(open, close + 1);
|
|
768
|
+
if (!(end - start === marker.length && text.startsWith(marker, start))) {
|
|
769
|
+
found.push({ line: text.slice(0, start).split("\n").length, length: end - start });
|
|
770
|
+
}
|
|
771
|
+
from = end + tail.length;
|
|
772
|
+
at = close + 1 + tail.length;
|
|
773
|
+
}
|
|
774
|
+
return found;
|
|
775
|
+
}
|
|
751
776
|
function snapshotAt(at, files) {
|
|
752
777
|
let source = files.get(at.file);
|
|
753
778
|
if (source === void 0) {
|
|
@@ -1760,6 +1785,27 @@ async function startRun(passed, declared2) {
|
|
|
1760
1785
|
log(`::warning::${stats.deferred} result(s) were not delivered to Plune \u2014 see the reporting step's log.`);
|
|
1761
1786
|
}
|
|
1762
1787
|
}
|
|
1788
|
+
async function warnOfSecrets(result) {
|
|
1789
|
+
const of = printable(result.title ?? result.resultKey);
|
|
1790
|
+
const say = (what, text) => {
|
|
1791
|
+
for (const { line, length } of credentialsIn(text)) {
|
|
1792
|
+
log(
|
|
1793
|
+
`plune: ${what} of "${of}" holds what looks like a secret on line ${line} (${length} characters) \u2014 sent as it is; mask it in the test, or set PLUNE_SECRET_CHECK=0 to turn this check off.`
|
|
1794
|
+
);
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
const error = result.errorContext ?? result.failure?.headline;
|
|
1798
|
+
if (error !== void 0) say("the error text", error);
|
|
1799
|
+
for (const file of result.files ?? []) {
|
|
1800
|
+
if (!isTextType(file.contentType)) continue;
|
|
1801
|
+
let bytes = file.body;
|
|
1802
|
+
if (bytes === void 0 && file.path !== void 0) {
|
|
1803
|
+
const size = await import_fs.promises.stat(file.path).then((s) => s.size, () => Infinity);
|
|
1804
|
+
if (size <= TEXT_BYTES) bytes = await import_fs.promises.readFile(file.path).catch(() => void 0);
|
|
1805
|
+
}
|
|
1806
|
+
if (bytes !== void 0 && bytes.length <= TEXT_BYTES) say(`the attachment "${printable(file.name)}"`, bytes.toString("utf8"));
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1763
1809
|
const shardLines = [];
|
|
1764
1810
|
return {
|
|
1765
1811
|
get runId() {
|
|
@@ -1773,6 +1819,7 @@ async function startRun(passed, declared2) {
|
|
|
1773
1819
|
},
|
|
1774
1820
|
async add(result) {
|
|
1775
1821
|
const { codeAt, ...rest } = result;
|
|
1822
|
+
if (env.secretCheck) await warnOfSecrets(result);
|
|
1776
1823
|
const text = codeAt === void 0 ? void 0 : snapshotAt(codeAt, specFiles);
|
|
1777
1824
|
if (text !== void 0) snapshotByKey.set(result.resultKey, text);
|
|
1778
1825
|
buffer.push({ ...rest, keys: bound(result.keys) });
|
package/dist/index.js
CHANGED
|
@@ -368,6 +368,7 @@ function readEnv(env = process.env) {
|
|
|
368
368
|
...shardError !== void 0 ? { shardError } : {},
|
|
369
369
|
...configurationError !== void 0 ? { configurationError } : {},
|
|
370
370
|
...importTimeout !== void 0 ? { importTimeout } : {},
|
|
371
|
+
secretCheck: !["0", "false", "no", "off"].includes(value(env, "PLUNE_SECRET_CHECK")?.toLowerCase() ?? ""),
|
|
371
372
|
ignored: UNSUPPORTED_VARS.filter((name) => value(env, name) !== void 0),
|
|
372
373
|
warnings
|
|
373
374
|
};
|
|
@@ -714,6 +715,30 @@ function maskCredentials(text) {
|
|
|
714
715
|
"$1$2\u2039credential\u203A"
|
|
715
716
|
).replace(/\b(PLUNE_[A-Z0-9_]*=)(?!‹)[^\s'"\x60;,)]+/g, "$1\u2039env-secret\u203A").replace(QUERY_PARAM, "$1\u2039credential\u203A").replace(/\b([a-z][\w+.-]*:\/\/)[^\s/@'"\x60]+@/gi, "$1\u2039credential\u203A@");
|
|
716
717
|
}
|
|
718
|
+
function credentialsIn(text) {
|
|
719
|
+
const masked = maskCredentials(text);
|
|
720
|
+
if (masked === text) return [];
|
|
721
|
+
const found = [];
|
|
722
|
+
let from = 0;
|
|
723
|
+
let at = 0;
|
|
724
|
+
for (let open = masked.indexOf("\u2039", at); open >= 0; open = masked.indexOf("\u2039", at)) {
|
|
725
|
+
const start = from + (open - at);
|
|
726
|
+
let close = masked.indexOf("\u203A", open);
|
|
727
|
+
while (close >= 0 && masked[close + 1] === "\u2039") close = masked.indexOf("\u203A", close + 1);
|
|
728
|
+
if (close < 0) break;
|
|
729
|
+
const next = masked.indexOf("\u2039", close + 1);
|
|
730
|
+
const tail = masked.slice(close + 1, next < 0 ? void 0 : next);
|
|
731
|
+
const end = next < 0 ? text.length - tail.length : text.indexOf(tail, start);
|
|
732
|
+
if (end < start) break;
|
|
733
|
+
const marker = masked.slice(open, close + 1);
|
|
734
|
+
if (!(end - start === marker.length && text.startsWith(marker, start))) {
|
|
735
|
+
found.push({ line: text.slice(0, start).split("\n").length, length: end - start });
|
|
736
|
+
}
|
|
737
|
+
from = end + tail.length;
|
|
738
|
+
at = close + 1 + tail.length;
|
|
739
|
+
}
|
|
740
|
+
return found;
|
|
741
|
+
}
|
|
717
742
|
function snapshotAt(at, files) {
|
|
718
743
|
let source = files.get(at.file);
|
|
719
744
|
if (source === void 0) {
|
|
@@ -1726,6 +1751,27 @@ async function startRun(passed, declared2) {
|
|
|
1726
1751
|
log(`::warning::${stats.deferred} result(s) were not delivered to Plune \u2014 see the reporting step's log.`);
|
|
1727
1752
|
}
|
|
1728
1753
|
}
|
|
1754
|
+
async function warnOfSecrets(result) {
|
|
1755
|
+
const of = printable(result.title ?? result.resultKey);
|
|
1756
|
+
const say = (what, text) => {
|
|
1757
|
+
for (const { line, length } of credentialsIn(text)) {
|
|
1758
|
+
log(
|
|
1759
|
+
`plune: ${what} of "${of}" holds what looks like a secret on line ${line} (${length} characters) \u2014 sent as it is; mask it in the test, or set PLUNE_SECRET_CHECK=0 to turn this check off.`
|
|
1760
|
+
);
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1763
|
+
const error = result.errorContext ?? result.failure?.headline;
|
|
1764
|
+
if (error !== void 0) say("the error text", error);
|
|
1765
|
+
for (const file of result.files ?? []) {
|
|
1766
|
+
if (!isTextType(file.contentType)) continue;
|
|
1767
|
+
let bytes = file.body;
|
|
1768
|
+
if (bytes === void 0 && file.path !== void 0) {
|
|
1769
|
+
const size = await disk.stat(file.path).then((s) => s.size, () => Infinity);
|
|
1770
|
+
if (size <= TEXT_BYTES) bytes = await disk.readFile(file.path).catch(() => void 0);
|
|
1771
|
+
}
|
|
1772
|
+
if (bytes !== void 0 && bytes.length <= TEXT_BYTES) say(`the attachment "${printable(file.name)}"`, bytes.toString("utf8"));
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1729
1775
|
const shardLines = [];
|
|
1730
1776
|
return {
|
|
1731
1777
|
get runId() {
|
|
@@ -1739,6 +1785,7 @@ async function startRun(passed, declared2) {
|
|
|
1739
1785
|
},
|
|
1740
1786
|
async add(result) {
|
|
1741
1787
|
const { codeAt, ...rest } = result;
|
|
1788
|
+
if (env.secretCheck) await warnOfSecrets(result);
|
|
1742
1789
|
const text = codeAt === void 0 ? void 0 : snapshotAt(codeAt, specFiles);
|
|
1743
1790
|
if (text !== void 0) snapshotByKey.set(result.resultKey, text);
|
|
1744
1791
|
buffer.push({ ...rest, keys: bound(result.keys) });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plune-ai/playwright",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Report Playwright results to Plune — a reporter and, later, a test importer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"playwright",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"tsup": "^8.0.0",
|
|
39
39
|
"typescript": "^5.4.0",
|
|
40
40
|
"vitest": "^1.6.0",
|
|
41
|
-
"@plune-ai/cli": "0.39.
|
|
41
|
+
"@plune-ai/cli": "0.39.7"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|