@plune-ai/playwright 0.7.2 → 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 +66 -4
- package/dist/index.js +66 -4
- 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) {
|
|
@@ -847,7 +872,13 @@ function textRefusal(bytes) {
|
|
|
847
872
|
}
|
|
848
873
|
return void 0;
|
|
849
874
|
}
|
|
850
|
-
function
|
|
875
|
+
function withoutTargets(result) {
|
|
876
|
+
if (result.targets === void 0) return result;
|
|
877
|
+
const { targets: _targets, ...rest } = result;
|
|
878
|
+
return rest;
|
|
879
|
+
}
|
|
880
|
+
function onDisk(deferred) {
|
|
881
|
+
const result = withoutTargets(deferred);
|
|
851
882
|
if (!("files" in result) || result.files === void 0) return result;
|
|
852
883
|
const { files, ...rest } = result;
|
|
853
884
|
const kept = files.filter((f) => f.path !== void 0).map(({ body: _body, ...file }) => file);
|
|
@@ -1399,6 +1430,7 @@ async function startRun(passed, declared2) {
|
|
|
1399
1430
|
let runId = null;
|
|
1400
1431
|
let joined = false;
|
|
1401
1432
|
let offline = token === "";
|
|
1433
|
+
let targetsRefused = false;
|
|
1402
1434
|
let done = false;
|
|
1403
1435
|
const shortened = /* @__PURE__ */ new Set();
|
|
1404
1436
|
const specFiles = /* @__PURE__ */ new Map();
|
|
@@ -1668,16 +1700,24 @@ async function startRun(passed, declared2) {
|
|
|
1668
1700
|
await send(submissions, filesByKey);
|
|
1669
1701
|
}
|
|
1670
1702
|
async function send(submissions, filesByKey) {
|
|
1671
|
-
for (const
|
|
1703
|
+
for (const packedPart of packed(submissions)) {
|
|
1704
|
+
let part = targetsRefused ? packedPart.map(withoutTargets) : packedPart;
|
|
1672
1705
|
if (offline) {
|
|
1673
1706
|
defer(part);
|
|
1674
1707
|
continue;
|
|
1675
1708
|
}
|
|
1676
|
-
const
|
|
1709
|
+
const post = (results) => client.post(
|
|
1677
1710
|
`/v1/runs/${runId}/results`,
|
|
1678
1711
|
// The job's combination on every batch; a refusal of it is a 422 said below as it came.
|
|
1679
|
-
{ results
|
|
1712
|
+
{ results, ...configuration !== void 0 ? { configuration } : {} }
|
|
1680
1713
|
);
|
|
1714
|
+
let out = await post(part);
|
|
1715
|
+
if (!out.ok && out.kind === "invalid" && out.status === 400 && part.some((r) => r.targets !== void 0)) {
|
|
1716
|
+
if (!targetsRefused) log("plune: the platform does not take targets on a result yet \u2014 the results are sent without them.");
|
|
1717
|
+
targetsRefused = true;
|
|
1718
|
+
part = part.map(withoutTargets);
|
|
1719
|
+
out = await post(part);
|
|
1720
|
+
}
|
|
1681
1721
|
const counts = out.ok ? out.body?.counts : void 0;
|
|
1682
1722
|
const told = COUNTED.filter((k) => typeof counts?.[k] === "number");
|
|
1683
1723
|
if (told.length > 0) {
|
|
@@ -1745,6 +1785,27 @@ async function startRun(passed, declared2) {
|
|
|
1745
1785
|
log(`::warning::${stats.deferred} result(s) were not delivered to Plune \u2014 see the reporting step's log.`);
|
|
1746
1786
|
}
|
|
1747
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
|
+
}
|
|
1748
1809
|
const shardLines = [];
|
|
1749
1810
|
return {
|
|
1750
1811
|
get runId() {
|
|
@@ -1758,6 +1819,7 @@ async function startRun(passed, declared2) {
|
|
|
1758
1819
|
},
|
|
1759
1820
|
async add(result) {
|
|
1760
1821
|
const { codeAt, ...rest } = result;
|
|
1822
|
+
if (env.secretCheck) await warnOfSecrets(result);
|
|
1761
1823
|
const text = codeAt === void 0 ? void 0 : snapshotAt(codeAt, specFiles);
|
|
1762
1824
|
if (text !== void 0) snapshotByKey.set(result.resultKey, text);
|
|
1763
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) {
|
|
@@ -813,7 +838,13 @@ function textRefusal(bytes) {
|
|
|
813
838
|
}
|
|
814
839
|
return void 0;
|
|
815
840
|
}
|
|
816
|
-
function
|
|
841
|
+
function withoutTargets(result) {
|
|
842
|
+
if (result.targets === void 0) return result;
|
|
843
|
+
const { targets: _targets, ...rest } = result;
|
|
844
|
+
return rest;
|
|
845
|
+
}
|
|
846
|
+
function onDisk(deferred) {
|
|
847
|
+
const result = withoutTargets(deferred);
|
|
817
848
|
if (!("files" in result) || result.files === void 0) return result;
|
|
818
849
|
const { files, ...rest } = result;
|
|
819
850
|
const kept = files.filter((f) => f.path !== void 0).map(({ body: _body, ...file }) => file);
|
|
@@ -1365,6 +1396,7 @@ async function startRun(passed, declared2) {
|
|
|
1365
1396
|
let runId = null;
|
|
1366
1397
|
let joined = false;
|
|
1367
1398
|
let offline = token === "";
|
|
1399
|
+
let targetsRefused = false;
|
|
1368
1400
|
let done = false;
|
|
1369
1401
|
const shortened = /* @__PURE__ */ new Set();
|
|
1370
1402
|
const specFiles = /* @__PURE__ */ new Map();
|
|
@@ -1634,16 +1666,24 @@ async function startRun(passed, declared2) {
|
|
|
1634
1666
|
await send(submissions, filesByKey);
|
|
1635
1667
|
}
|
|
1636
1668
|
async function send(submissions, filesByKey) {
|
|
1637
|
-
for (const
|
|
1669
|
+
for (const packedPart of packed(submissions)) {
|
|
1670
|
+
let part = targetsRefused ? packedPart.map(withoutTargets) : packedPart;
|
|
1638
1671
|
if (offline) {
|
|
1639
1672
|
defer(part);
|
|
1640
1673
|
continue;
|
|
1641
1674
|
}
|
|
1642
|
-
const
|
|
1675
|
+
const post = (results) => client.post(
|
|
1643
1676
|
`/v1/runs/${runId}/results`,
|
|
1644
1677
|
// The job's combination on every batch; a refusal of it is a 422 said below as it came.
|
|
1645
|
-
{ results
|
|
1678
|
+
{ results, ...configuration !== void 0 ? { configuration } : {} }
|
|
1646
1679
|
);
|
|
1680
|
+
let out = await post(part);
|
|
1681
|
+
if (!out.ok && out.kind === "invalid" && out.status === 400 && part.some((r) => r.targets !== void 0)) {
|
|
1682
|
+
if (!targetsRefused) log("plune: the platform does not take targets on a result yet \u2014 the results are sent without them.");
|
|
1683
|
+
targetsRefused = true;
|
|
1684
|
+
part = part.map(withoutTargets);
|
|
1685
|
+
out = await post(part);
|
|
1686
|
+
}
|
|
1647
1687
|
const counts = out.ok ? out.body?.counts : void 0;
|
|
1648
1688
|
const told = COUNTED.filter((k) => typeof counts?.[k] === "number");
|
|
1649
1689
|
if (told.length > 0) {
|
|
@@ -1711,6 +1751,27 @@ async function startRun(passed, declared2) {
|
|
|
1711
1751
|
log(`::warning::${stats.deferred} result(s) were not delivered to Plune \u2014 see the reporting step's log.`);
|
|
1712
1752
|
}
|
|
1713
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
|
+
}
|
|
1714
1775
|
const shardLines = [];
|
|
1715
1776
|
return {
|
|
1716
1777
|
get runId() {
|
|
@@ -1724,6 +1785,7 @@ async function startRun(passed, declared2) {
|
|
|
1724
1785
|
},
|
|
1725
1786
|
async add(result) {
|
|
1726
1787
|
const { codeAt, ...rest } = result;
|
|
1788
|
+
if (env.secretCheck) await warnOfSecrets(result);
|
|
1727
1789
|
const text = codeAt === void 0 ? void 0 : snapshotAt(codeAt, specFiles);
|
|
1728
1790
|
if (text !== void 0) snapshotByKey.set(result.resultKey, text);
|
|
1729
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",
|