lazyscout 0.3.3 → 0.3.6
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.js
CHANGED
|
@@ -244,6 +244,25 @@ function redactUrl(value) {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
// ../../packages/core/dist/safety/blocklist.js
|
|
247
|
+
var SESSION_ENDING_KEYWORDS = [
|
|
248
|
+
"log out",
|
|
249
|
+
"logout",
|
|
250
|
+
"log out",
|
|
251
|
+
"sign out",
|
|
252
|
+
"signout",
|
|
253
|
+
"sign out",
|
|
254
|
+
"\u0E2D\u0E2D\u0E01\u0E08\u0E32\u0E01\u0E23\u0E30\u0E1A\u0E1A",
|
|
255
|
+
"\u0E2D\u0E2D\u0E01\u0E08\u0E32\u0E01\u0E23\u0E30\u0E1A\u0E1A"
|
|
256
|
+
];
|
|
257
|
+
function isSessionEndingLabel(...labels) {
|
|
258
|
+
const haystack = labels.filter(Boolean).join(" ").toLowerCase();
|
|
259
|
+
if (!haystack.trim())
|
|
260
|
+
return false;
|
|
261
|
+
return SESSION_ENDING_KEYWORDS.some((keyword) => haystack.includes(keyword.toLowerCase()));
|
|
262
|
+
}
|
|
263
|
+
function isUnsafeAutoClick(...labels) {
|
|
264
|
+
return isSessionEndingLabel(...labels);
|
|
265
|
+
}
|
|
247
266
|
var MAX_BLOCK_KEYWORDS = 100;
|
|
248
267
|
var MAX_KEYWORD_LENGTH = 80;
|
|
249
268
|
function normalizeBlockedKeywords(value) {
|
|
@@ -506,13 +525,6 @@ function collectPageData() {
|
|
|
506
525
|
};
|
|
507
526
|
}
|
|
508
527
|
|
|
509
|
-
// ../../packages/explorer/dist/safety.js
|
|
510
|
-
function canFollowLink(href, accessibleName, keywords = []) {
|
|
511
|
-
if (!href)
|
|
512
|
-
return false;
|
|
513
|
-
return !isBlockedLabel(keywords, accessibleName, href);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
528
|
// ../../packages/explorer/dist/mapToPageModel.js
|
|
517
529
|
function toUIElement(raw, keywords) {
|
|
518
530
|
return {
|
|
@@ -663,35 +675,64 @@ async function launchBrowser(options = {}) {
|
|
|
663
675
|
void error;
|
|
664
676
|
}
|
|
665
677
|
}
|
|
666
|
-
throw new ExplorerError("browser-error", `unable to launch a browser (tried: ${failures.join(", ")})`, 'Please install Google Chrome or Microsoft Edge or run "npx playwright install chromium" and try again');
|
|
678
|
+
throw new ExplorerError("browser-error", `unable to launch a browser (tried: ${failures.join(", ")})`, options.userDataDir ? "Close any other LazyScout browser for this Project \u2014 the login browser and a recording both hold its profile \u2014 and try again" : 'Please install Google Chrome or Microsoft Edge or run "npx playwright install chromium" and try again');
|
|
667
679
|
}
|
|
668
680
|
|
|
669
|
-
// ../../packages/explorer/dist/
|
|
670
|
-
var
|
|
681
|
+
// ../../packages/explorer/dist/scopedExplorer.js
|
|
682
|
+
var DEFAULT_LIMITS = {
|
|
671
683
|
maxPages: 20,
|
|
684
|
+
maxStates: 80,
|
|
672
685
|
maxDepth: 3,
|
|
673
|
-
pageTimeoutMs: 2e4,
|
|
674
|
-
totalTimeoutMs: 12e4,
|
|
675
|
-
waitAfterNavigationMs: 750,
|
|
676
|
-
maxStatesPerPage: 8,
|
|
677
686
|
maxActionsPerState: 8,
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
687
|
+
maxTotalActions: 200,
|
|
688
|
+
maxActionRetries: 2,
|
|
689
|
+
explorationTimeoutMs: 3e5
|
|
690
|
+
};
|
|
691
|
+
var DEFAULT_CONFIG = {
|
|
692
|
+
mode: "site",
|
|
693
|
+
debug: false,
|
|
694
|
+
limits: DEFAULT_LIMITS,
|
|
695
|
+
continueAfterLogin: true
|
|
682
696
|
};
|
|
683
|
-
async function
|
|
684
|
-
const config2 = {
|
|
697
|
+
async function exploreWithScope(startUrl, explorationConfig = {}, exploreOptions = {}) {
|
|
698
|
+
const config2 = {
|
|
699
|
+
...DEFAULT_CONFIG,
|
|
700
|
+
...explorationConfig,
|
|
701
|
+
limits: { ...DEFAULT_LIMITS, ...explorationConfig.limits }
|
|
702
|
+
};
|
|
703
|
+
const legacyOptions = {
|
|
704
|
+
maxPages: config2.limits.maxPages,
|
|
705
|
+
maxDepth: config2.limits.maxDepth,
|
|
706
|
+
maxStatesPerPage: config2.limits.maxActionsPerState,
|
|
707
|
+
maxActionsPerState: config2.limits.maxActionsPerState,
|
|
708
|
+
maxTotalStates: config2.limits.maxStates,
|
|
709
|
+
actionTimeoutMs: 3e3,
|
|
710
|
+
stateDiscoveryTimeoutMs: 500,
|
|
711
|
+
pageTimeoutMs: 25e3,
|
|
712
|
+
totalTimeoutMs: config2.limits.explorationTimeoutMs,
|
|
713
|
+
waitAfterNavigationMs: 750,
|
|
714
|
+
blockedKeywords: [],
|
|
715
|
+
maxNavigationProbesPerPage: 8,
|
|
716
|
+
...exploreOptions
|
|
717
|
+
};
|
|
685
718
|
const startedAt = Date.now();
|
|
686
|
-
const
|
|
719
|
+
const logs = [];
|
|
720
|
+
const debug = (message, context2) => {
|
|
721
|
+
if (config2.debug) {
|
|
722
|
+
logs.push({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "debug", message, context: context2 });
|
|
723
|
+
}
|
|
724
|
+
logs.push({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "info", message, context: context2 });
|
|
725
|
+
};
|
|
726
|
+
const check = checkTargetUrl(startUrl, LOCAL_QA_POLICY);
|
|
687
727
|
if (!check.ok)
|
|
688
728
|
throw new ExplorerError(check.code, check.message);
|
|
689
729
|
const origin = check.url.origin;
|
|
690
730
|
const entryUrl = normalizeUrl(check.url.toString());
|
|
691
731
|
const pages = [];
|
|
692
732
|
const issues = [];
|
|
693
|
-
const
|
|
694
|
-
const
|
|
733
|
+
const visitedStates = /* @__PURE__ */ new Set();
|
|
734
|
+
const visitedUrls = /* @__PURE__ */ new Set();
|
|
735
|
+
const stateQueue = [];
|
|
695
736
|
const actionGraph = {
|
|
696
737
|
states: [],
|
|
697
738
|
edges: [],
|
|
@@ -700,247 +741,744 @@ async function exploreWebsite(startUrl, options = {}, policy = LOCAL_QA_POLICY)
|
|
|
700
741
|
failedActionKeys: [],
|
|
701
742
|
blockedActionKeys: []
|
|
702
743
|
};
|
|
703
|
-
let
|
|
704
|
-
let
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
744
|
+
let totalActionsExecuted = 0;
|
|
745
|
+
let totalActionsBlocked = 0;
|
|
746
|
+
let totalActionsFailed = 0;
|
|
747
|
+
let totalActionsRetried = 0;
|
|
748
|
+
let urlsSkippedByScope = 0;
|
|
749
|
+
let endReason = "queue-exhausted";
|
|
750
|
+
function isWithinScope(url) {
|
|
751
|
+
if (!config2.scopePath)
|
|
752
|
+
return true;
|
|
753
|
+
try {
|
|
754
|
+
const path = new URL(url).pathname;
|
|
755
|
+
const scope = config2.scopePath.replace(/\/$/, "");
|
|
756
|
+
return path === scope || path.startsWith(scope + "/");
|
|
757
|
+
} catch {
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
function isSessionEnding(name, text) {
|
|
762
|
+
return isSessionEndingLabel(name, text);
|
|
763
|
+
}
|
|
764
|
+
async function discoverNavigationRegions(page) {
|
|
765
|
+
const candidates = [];
|
|
766
|
+
try {
|
|
767
|
+
const navItems = await page.evaluate(() => {
|
|
768
|
+
const results = [];
|
|
769
|
+
const navRegions = document.querySelectorAll('nav a[href], aside a[href], [role="navigation"] a[href], [role="menu"] [role="menuitem"], [role="menubar"] [role="menuitem"]');
|
|
770
|
+
navRegions.forEach((el) => {
|
|
771
|
+
const anchor = el;
|
|
772
|
+
const name = el.getAttribute("aria-label") || el.textContent?.replace(/\s+/g, " ").trim() || "";
|
|
773
|
+
if (!name || name.length > 80)
|
|
774
|
+
return;
|
|
775
|
+
const cssSel = el.id ? `#${CSS.escape(el.id)}` : `${el.tagName.toLowerCase()}[href="${anchor.getAttribute("href") || ""}"]`;
|
|
776
|
+
results.push({
|
|
777
|
+
name: name.slice(0, 80),
|
|
778
|
+
role: el.getAttribute("role") || "link",
|
|
779
|
+
href: anchor.href || null,
|
|
780
|
+
cssSelector: cssSel
|
|
781
|
+
});
|
|
782
|
+
});
|
|
783
|
+
return results.slice(0, 40);
|
|
784
|
+
});
|
|
785
|
+
for (const item of navItems) {
|
|
786
|
+
if (!item.href)
|
|
787
|
+
continue;
|
|
788
|
+
const action = {
|
|
789
|
+
id: `nav|${item.cssSelector}`,
|
|
790
|
+
type: "navigate",
|
|
791
|
+
description: `Navigate to \u201C${item.name}\u201D via sidebar`,
|
|
792
|
+
target: item.name,
|
|
793
|
+
selector: item.cssSelector,
|
|
794
|
+
locator: { role: item.role, name: item.name },
|
|
795
|
+
safe: true
|
|
796
|
+
};
|
|
797
|
+
if (isSessionEnding(item.name, void 0)) {
|
|
798
|
+
action.safe = false;
|
|
799
|
+
action.reason = "session-ending action";
|
|
800
|
+
}
|
|
801
|
+
if (isBlockedLabel(legacyOptions.blockedKeywords, item.name, item.href)) {
|
|
802
|
+
action.safe = false;
|
|
803
|
+
action.reason = "Action matched the Project click filter";
|
|
804
|
+
}
|
|
805
|
+
candidates.push({
|
|
806
|
+
priority: 2,
|
|
807
|
+
action,
|
|
808
|
+
locator: { role: item.role, name: item.name },
|
|
809
|
+
kind: "sidebar-nav",
|
|
810
|
+
restoreStrategy: "goto"
|
|
811
|
+
});
|
|
720
812
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
813
|
+
} catch {
|
|
814
|
+
}
|
|
815
|
+
return candidates;
|
|
816
|
+
}
|
|
817
|
+
async function discoverSafeCandidates(page, currentState) {
|
|
818
|
+
const candidates = [];
|
|
819
|
+
for (const link of currentState.controls.filter((c) => c.kind === "link" && c.href)) {
|
|
820
|
+
if (isSessionEnding(link.accessibleName, link.text)) {
|
|
821
|
+
candidates.push({
|
|
822
|
+
priority: 10,
|
|
823
|
+
action: {
|
|
824
|
+
id: `${currentState.id}|navigate|${link.cssSelector}`,
|
|
825
|
+
type: "navigate",
|
|
826
|
+
description: `Navigate to \u201C${link.accessibleName}\u201D`,
|
|
827
|
+
target: link.accessibleName,
|
|
828
|
+
selector: link.cssSelector,
|
|
829
|
+
locator: { role: link.role, name: link.accessibleName },
|
|
830
|
+
safe: false,
|
|
831
|
+
reason: "session-ending action"
|
|
832
|
+
},
|
|
833
|
+
locator: { role: link.role, name: link.accessibleName },
|
|
834
|
+
kind: "navigation-link",
|
|
835
|
+
restoreStrategy: "goto"
|
|
836
|
+
});
|
|
728
837
|
continue;
|
|
729
838
|
}
|
|
730
|
-
const
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
839
|
+
const blocked = isBlockedLabel(legacyOptions.blockedKeywords, link.accessibleName, link.href, link.text);
|
|
840
|
+
candidates.push({
|
|
841
|
+
priority: blocked ? 10 : 1,
|
|
842
|
+
action: {
|
|
843
|
+
id: `${currentState.id}|navigate|${link.cssSelector}`,
|
|
844
|
+
type: "navigate",
|
|
845
|
+
description: `Navigate to \u201C${link.accessibleName}\u201D`,
|
|
846
|
+
target: link.accessibleName,
|
|
847
|
+
selector: link.cssSelector,
|
|
848
|
+
locator: { role: link.role, name: link.accessibleName },
|
|
849
|
+
safe: !blocked,
|
|
850
|
+
reason: blocked ? "Action matched the Project click filter" : void 0
|
|
851
|
+
},
|
|
852
|
+
locator: { role: link.role, name: link.accessibleName },
|
|
853
|
+
kind: "navigation-link",
|
|
854
|
+
restoreStrategy: "goto"
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
try {
|
|
858
|
+
const navCandidates = await discoverNavigationRegions(page);
|
|
859
|
+
candidates.push(...navCandidates);
|
|
860
|
+
} catch {
|
|
861
|
+
}
|
|
862
|
+
for (const interaction of currentState.interactions.filter((i) => i.kind === "tab")) {
|
|
863
|
+
const blocked = isBlockedLabel(legacyOptions.blockedKeywords, interaction.name);
|
|
864
|
+
candidates.push({
|
|
865
|
+
priority: blocked ? 10 : 3,
|
|
866
|
+
action: {
|
|
867
|
+
id: `${currentState.id}|selectTab|${interaction.cssSelector}`,
|
|
868
|
+
type: "selectTab",
|
|
869
|
+
description: `Select tab \u201C${interaction.name}\u201D`,
|
|
870
|
+
target: interaction.name,
|
|
871
|
+
selector: interaction.cssSelector,
|
|
872
|
+
locator: { role: interaction.role, name: interaction.name },
|
|
873
|
+
safe: !blocked,
|
|
874
|
+
reason: blocked ? "Action matched the Project click filter" : void 0
|
|
875
|
+
},
|
|
876
|
+
locator: { role: interaction.role, name: interaction.name },
|
|
877
|
+
kind: "tab",
|
|
878
|
+
restoreStrategy: "select-tab"
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
const paginationSelectors = '[aria-label*="page" i], [aria-label*="\u0E2B\u0E19\u0E49\u0E32" i], .pagination a, .pager a, [rel="next"], [rel="prev"]';
|
|
882
|
+
try {
|
|
883
|
+
const pagItems = await page.evaluate((sel) => {
|
|
884
|
+
return Array.from(document.querySelectorAll(sel)).filter((el) => {
|
|
885
|
+
const htmlEl = el;
|
|
886
|
+
return htmlEl.offsetParent !== null;
|
|
887
|
+
}).slice(0, 10).map((el) => ({
|
|
888
|
+
name: el.getAttribute("aria-label") || el.textContent?.replace(/\s+/g, " ").trim() || "",
|
|
889
|
+
role: el.getAttribute("role") || "link",
|
|
890
|
+
href: el.href || null,
|
|
891
|
+
cssSelector: el.id ? `#${CSS.escape(el.id)}` : el.tagName.toLowerCase()
|
|
892
|
+
}));
|
|
893
|
+
}, paginationSelectors);
|
|
894
|
+
for (const item of pagItems) {
|
|
895
|
+
if (!item.name)
|
|
896
|
+
continue;
|
|
897
|
+
const blocked = isSessionEnding(item.name, void 0);
|
|
898
|
+
candidates.push({
|
|
899
|
+
priority: blocked ? 10 : 4,
|
|
900
|
+
action: {
|
|
901
|
+
id: `${currentState.id}|pagination|${item.cssSelector}`,
|
|
902
|
+
type: "pagination",
|
|
903
|
+
description: `Go to page \u201C${item.name}\u201D`,
|
|
904
|
+
target: item.name,
|
|
905
|
+
selector: item.cssSelector,
|
|
906
|
+
locator: { role: item.role, name: item.name },
|
|
907
|
+
safe: !blocked,
|
|
908
|
+
reason: blocked ? "session-ending action" : void 0
|
|
909
|
+
},
|
|
910
|
+
locator: { role: item.role, name: item.name },
|
|
911
|
+
kind: "pagination",
|
|
912
|
+
restoreStrategy: "goto"
|
|
913
|
+
});
|
|
734
914
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
915
|
+
} catch {
|
|
916
|
+
}
|
|
917
|
+
for (const interaction of currentState.interactions.filter((i) => i.kind === "dialog" || i.kind === "drawer" || i.kind === "popover")) {
|
|
918
|
+
const blocked = isBlockedLabel(legacyOptions.blockedKeywords, interaction.name);
|
|
919
|
+
candidates.push({
|
|
920
|
+
priority: blocked ? 10 : 5,
|
|
921
|
+
action: {
|
|
922
|
+
id: `${currentState.id}|openModal|${interaction.cssSelector}`,
|
|
923
|
+
type: "openModal",
|
|
924
|
+
description: `Open \u201C${interaction.name}\u201D`,
|
|
925
|
+
target: interaction.name,
|
|
926
|
+
selector: interaction.cssSelector,
|
|
927
|
+
locator: { role: interaction.role, name: interaction.name },
|
|
928
|
+
safe: !blocked,
|
|
929
|
+
reason: blocked ? "Action matched the Project click filter" : void 0
|
|
930
|
+
},
|
|
931
|
+
locator: { role: interaction.role, name: interaction.name },
|
|
932
|
+
kind: "modal-opener",
|
|
933
|
+
restoreStrategy: "close-dialog"
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
for (const interaction of currentState.interactions.filter((i) => i.kind === "dropdown")) {
|
|
937
|
+
const blocked = isBlockedLabel(legacyOptions.blockedKeywords, interaction.name);
|
|
938
|
+
candidates.push({
|
|
939
|
+
priority: blocked ? 10 : 6,
|
|
940
|
+
action: {
|
|
941
|
+
id: `${currentState.id}|openDropdown|${interaction.cssSelector}`,
|
|
942
|
+
type: "openDropdown",
|
|
943
|
+
description: `Open dropdown \u201C${interaction.name}\u201D`,
|
|
944
|
+
target: interaction.name,
|
|
945
|
+
selector: interaction.cssSelector,
|
|
946
|
+
locator: { role: interaction.role, name: interaction.name },
|
|
947
|
+
safe: !blocked,
|
|
948
|
+
reason: blocked ? "Action matched the Project click filter" : void 0
|
|
949
|
+
},
|
|
950
|
+
locator: { role: interaction.role, name: interaction.name },
|
|
951
|
+
kind: "dropdown",
|
|
952
|
+
restoreStrategy: "goto"
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
for (const interaction of currentState.interactions.filter((i) => i.kind === "accordion")) {
|
|
956
|
+
const blocked = isBlockedLabel(legacyOptions.blockedKeywords, interaction.name);
|
|
957
|
+
candidates.push({
|
|
958
|
+
priority: blocked ? 10 : 7,
|
|
959
|
+
action: {
|
|
960
|
+
id: `${currentState.id}|expandAccordion|${interaction.cssSelector}`,
|
|
961
|
+
type: "expandAccordion",
|
|
962
|
+
description: `Expand \u201C${interaction.name}\u201D`,
|
|
963
|
+
target: interaction.name,
|
|
964
|
+
selector: interaction.cssSelector,
|
|
965
|
+
locator: { role: interaction.role, name: interaction.name },
|
|
966
|
+
safe: !blocked,
|
|
967
|
+
reason: blocked ? "Action matched the Project click filter" : void 0
|
|
968
|
+
},
|
|
969
|
+
locator: { role: interaction.role, name: interaction.name },
|
|
970
|
+
kind: "accordion",
|
|
971
|
+
restoreStrategy: "goto"
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
try {
|
|
975
|
+
const bcItems = await page.evaluate(() => {
|
|
976
|
+
return Array.from(document.querySelectorAll('nav[aria-label*="breadcrumb" i] a, .breadcrumb a, [role="navigation"] ol a')).filter((el) => el.offsetParent !== null).slice(0, 10).map((el) => ({
|
|
977
|
+
name: el.textContent?.replace(/\s+/g, " ").trim() || "",
|
|
978
|
+
href: el.href || null,
|
|
979
|
+
cssSelector: el.id ? `#${CSS.escape(el.id)}` : "a"
|
|
980
|
+
}));
|
|
981
|
+
});
|
|
982
|
+
for (const item of bcItems) {
|
|
983
|
+
if (!item.name || !item.href)
|
|
984
|
+
continue;
|
|
985
|
+
candidates.push({
|
|
986
|
+
priority: 8,
|
|
987
|
+
action: {
|
|
988
|
+
id: `${currentState.id}|breadcrumb|${item.cssSelector}`,
|
|
989
|
+
type: "breadcrumb",
|
|
990
|
+
description: `Navigate breadcrumb \u201C${item.name}\u201D`,
|
|
991
|
+
target: item.name,
|
|
992
|
+
selector: item.cssSelector,
|
|
993
|
+
locator: { name: item.name },
|
|
994
|
+
safe: true
|
|
995
|
+
},
|
|
996
|
+
locator: { name: item.name },
|
|
997
|
+
kind: "breadcrumb",
|
|
998
|
+
restoreStrategy: "goto"
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
} catch {
|
|
1002
|
+
}
|
|
1003
|
+
for (const button of currentState.controls.filter((c) => c.kind === "button" && !c.disabled && !c.destructive && c.accessibleName)) {
|
|
1004
|
+
if (isSessionEnding(button.accessibleName, button.text)) {
|
|
1005
|
+
candidates.push({
|
|
1006
|
+
priority: 10,
|
|
1007
|
+
action: {
|
|
1008
|
+
id: `${currentState.id}|navigate|${button.cssSelector}`,
|
|
1009
|
+
type: "navigate",
|
|
1010
|
+
description: `Navigate by clicking \u201C${button.accessibleName}\u201D`,
|
|
1011
|
+
target: button.accessibleName,
|
|
1012
|
+
selector: button.cssSelector,
|
|
1013
|
+
locator: { role: button.role, name: button.accessibleName },
|
|
1014
|
+
safe: false,
|
|
1015
|
+
reason: "session-ending action"
|
|
1016
|
+
},
|
|
1017
|
+
locator: { role: button.role, name: button.accessibleName },
|
|
1018
|
+
kind: "other-safe",
|
|
1019
|
+
restoreStrategy: "goto"
|
|
1020
|
+
});
|
|
742
1021
|
continue;
|
|
743
1022
|
}
|
|
744
|
-
|
|
745
|
-
|
|
1023
|
+
const blocked = isBlockedLabel(legacyOptions.blockedKeywords, button.accessibleName, button.text);
|
|
1024
|
+
candidates.push({
|
|
1025
|
+
priority: blocked ? 10 : 9,
|
|
1026
|
+
action: {
|
|
1027
|
+
id: `${currentState.id}|navigate|${button.cssSelector}`,
|
|
1028
|
+
type: "navigate",
|
|
1029
|
+
description: `Navigate by clicking \u201C${button.accessibleName}\u201D`,
|
|
1030
|
+
target: button.accessibleName,
|
|
1031
|
+
selector: button.cssSelector,
|
|
1032
|
+
locator: { role: button.role, name: button.accessibleName },
|
|
1033
|
+
safe: !blocked,
|
|
1034
|
+
reason: blocked ? "Action matched the Project click filter" : void 0
|
|
1035
|
+
},
|
|
1036
|
+
locator: { role: button.role, name: button.accessibleName },
|
|
1037
|
+
kind: "other-safe",
|
|
1038
|
+
restoreStrategy: "goto"
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
candidates.sort((a, b) => a.priority - b.priority);
|
|
1042
|
+
return candidates;
|
|
1043
|
+
}
|
|
1044
|
+
async function restoreState(page, targetUrl, strategy, _entryFlow) {
|
|
1045
|
+
switch (strategy) {
|
|
1046
|
+
case "goto":
|
|
1047
|
+
await page.goto(targetUrl, { waitUntil: "domcontentloaded", timeout: legacyOptions.pageTimeoutMs }).catch(() => void 0);
|
|
1048
|
+
await page.waitForTimeout(legacyOptions.waitAfterNavigationMs);
|
|
1049
|
+
break;
|
|
1050
|
+
case "reload":
|
|
1051
|
+
await page.reload({ waitUntil: "domcontentloaded", timeout: legacyOptions.pageTimeoutMs }).catch(() => void 0);
|
|
1052
|
+
await page.waitForTimeout(legacyOptions.waitAfterNavigationMs);
|
|
1053
|
+
break;
|
|
1054
|
+
case "close-dialog":
|
|
1055
|
+
try {
|
|
1056
|
+
await page.keyboard.press("Escape");
|
|
1057
|
+
await page.waitForTimeout(300);
|
|
1058
|
+
} catch {
|
|
1059
|
+
}
|
|
1060
|
+
break;
|
|
1061
|
+
case "select-tab":
|
|
1062
|
+
await page.waitForTimeout(legacyOptions.stateDiscoveryTimeoutMs);
|
|
1063
|
+
break;
|
|
1064
|
+
case "entry-replay":
|
|
1065
|
+
for (const step of _entryFlow) {
|
|
1066
|
+
try {
|
|
1067
|
+
if (step.action.selector) {
|
|
1068
|
+
await page.locator(step.action.selector).click({ timeout: legacyOptions.actionTimeoutMs }).catch(() => void 0);
|
|
1069
|
+
await page.waitForTimeout(legacyOptions.stateDiscoveryTimeoutMs);
|
|
1070
|
+
}
|
|
1071
|
+
} catch {
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
break;
|
|
1075
|
+
case "none":
|
|
1076
|
+
default:
|
|
1077
|
+
break;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
function isAuthLost(currentUrl, page) {
|
|
1081
|
+
try {
|
|
1082
|
+
const path = new URL(currentUrl).pathname.toLowerCase();
|
|
1083
|
+
return path.includes("/login") || path.includes("/signin") || path.includes("/auth");
|
|
1084
|
+
} catch {
|
|
1085
|
+
return false;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
async function executeWithRetry(page, candidate, currentUrl, entryFlow, maxRetries) {
|
|
1089
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
1090
|
+
try {
|
|
1091
|
+
let locator2;
|
|
1092
|
+
if (candidate.locator.cssSelector) {
|
|
1093
|
+
locator2 = page.locator(candidate.locator.cssSelector).first();
|
|
1094
|
+
} else if (candidate.locator.role && candidate.locator.name) {
|
|
1095
|
+
locator2 = page.getByRole(candidate.locator.role, {
|
|
1096
|
+
name: candidate.locator.name
|
|
1097
|
+
});
|
|
1098
|
+
} else if (candidate.locator.testId) {
|
|
1099
|
+
locator2 = page.getByTestId(candidate.locator.testId);
|
|
1100
|
+
} else {
|
|
1101
|
+
return { success: false };
|
|
1102
|
+
}
|
|
1103
|
+
await locator2.click({ timeout: legacyOptions.actionTimeoutMs });
|
|
1104
|
+
await page.waitForTimeout(legacyOptions.stateDiscoveryTimeoutMs);
|
|
1105
|
+
const newUrl = page.url();
|
|
1106
|
+
return { success: true, newUrl };
|
|
1107
|
+
} catch (_error) {
|
|
1108
|
+
if (attempt < maxRetries) {
|
|
1109
|
+
totalActionsRetried++;
|
|
1110
|
+
debug(`Retrying action: ${candidate.action.description} (attempt ${attempt + 1}/${maxRetries})`, {
|
|
1111
|
+
actionId: candidate.action.id,
|
|
1112
|
+
retryCount: attempt + 1
|
|
1113
|
+
});
|
|
1114
|
+
await restoreState(page, currentUrl, candidate.restoreStrategy, entryFlow);
|
|
1115
|
+
await page.waitForTimeout(500);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return { success: false };
|
|
1120
|
+
}
|
|
1121
|
+
async function exploreModal(page, parentState, _sourceUrl, entryFlow) {
|
|
1122
|
+
try {
|
|
1123
|
+
const hasDialog = await page.evaluate(() => {
|
|
1124
|
+
return !!(document.querySelector('[role="dialog"]') || document.querySelector("dialog[open]") || document.querySelector('[aria-modal="true"]'));
|
|
1125
|
+
});
|
|
1126
|
+
if (!hasDialog)
|
|
1127
|
+
return { candidates: [] };
|
|
1128
|
+
const raw = await page.evaluate(collectPageData);
|
|
1129
|
+
const pageModel = mapToPageModel(raw, { url: page.url(), finalUrl: page.url(), depth: parentState.depth ?? 0, statusCode: 200 }, legacyOptions.blockedKeywords);
|
|
1130
|
+
const modalState = pageModel.state;
|
|
1131
|
+
if (!modalState)
|
|
1132
|
+
return { candidates: [] };
|
|
1133
|
+
if (visitedStates.has(modalState.id))
|
|
1134
|
+
return { candidates: [] };
|
|
1135
|
+
visitedStates.add(modalState.id);
|
|
1136
|
+
addState(actionGraph, modalState);
|
|
1137
|
+
debug(`State discovered: ${modalState.name} (modal)`, { stateId: modalState.id, url: page.url() });
|
|
1138
|
+
const modalCandidates = await discoverSafeCandidates(page, modalState);
|
|
1139
|
+
const safeCandidates = modalCandidates.filter((c) => c.action.safe).slice(0, legacyOptions.maxActionsPerState);
|
|
1140
|
+
for (const mc of safeCandidates) {
|
|
1141
|
+
if (actionGraph.visitedActionKeys.includes(mc.action.id) || actionGraph.failedActionKeys.includes(mc.action.id))
|
|
746
1142
|
continue;
|
|
747
|
-
if (!
|
|
748
|
-
|
|
1143
|
+
if (!mc.action.safe) {
|
|
1144
|
+
addEdge(actionGraph, modalState.id, void 0, mc.action, "blocked");
|
|
1145
|
+
actionGraph.blockedActionKeys.push(mc.action.id);
|
|
1146
|
+
totalActionsBlocked++;
|
|
1147
|
+
debug(`Blocked: ${mc.action.target} (${mc.action.reason || "unsafe"})`, {
|
|
1148
|
+
actionId: mc.action.id,
|
|
1149
|
+
stateId: modalState.id
|
|
1150
|
+
});
|
|
749
1151
|
continue;
|
|
750
1152
|
}
|
|
751
|
-
const
|
|
752
|
-
|
|
1153
|
+
const result = await executeWithRetry(page, mc, page.url(), entryFlow, config2.limits.maxActionRetries);
|
|
1154
|
+
totalActionsExecuted++;
|
|
1155
|
+
if (!result.success) {
|
|
1156
|
+
totalActionsFailed++;
|
|
1157
|
+
addEdge(actionGraph, modalState.id, void 0, mc.action, "failed");
|
|
1158
|
+
actionGraph.failedActionKeys.push(mc.action.id);
|
|
1159
|
+
debug(`Failed: ${mc.action.target}`, { actionId: mc.action.id, stateId: modalState.id });
|
|
753
1160
|
continue;
|
|
754
|
-
|
|
1161
|
+
}
|
|
1162
|
+
actionGraph.visitedActionKeys.push(mc.action.id);
|
|
1163
|
+
const newRaw = await page.evaluate(collectPageData);
|
|
1164
|
+
const newModel = mapToPageModel(newRaw, { url: page.url(), finalUrl: page.url(), depth: parentState.depth ?? 0, statusCode: 200 }, legacyOptions.blockedKeywords);
|
|
1165
|
+
const newState = newModel.state;
|
|
1166
|
+
if (newState && !visitedStates.has(newState.id)) {
|
|
1167
|
+
visitedStates.add(newState.id);
|
|
1168
|
+
addState(actionGraph, newState);
|
|
1169
|
+
addEdge(actionGraph, modalState.id, newState.id, mc.action, "visited");
|
|
1170
|
+
debug(`New state in modal: ${newState.name}`, { stateId: newState.id });
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
try {
|
|
1174
|
+
await page.keyboard.press("Escape");
|
|
1175
|
+
await page.waitForTimeout(300);
|
|
1176
|
+
} catch {
|
|
755
1177
|
}
|
|
1178
|
+
return { state: modalState, candidates: modalCandidates };
|
|
1179
|
+
} catch {
|
|
1180
|
+
return { candidates: [] };
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
const launched = await launchBrowser(legacyOptions.browserProfileDir ? { userDataDir: legacyOptions.browserProfileDir } : {});
|
|
1184
|
+
const { context, label: browserLabel } = launched;
|
|
1185
|
+
let targetStartUrl = entryUrl;
|
|
1186
|
+
if (config2.startPath) {
|
|
1187
|
+
try {
|
|
1188
|
+
targetStartUrl = new URL(config2.startPath, entryUrl).toString();
|
|
1189
|
+
debug(`Start path resolved: ${targetStartUrl}`);
|
|
1190
|
+
} catch {
|
|
1191
|
+
debug(`Invalid start path: ${config2.startPath}, using base URL`);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
try {
|
|
1195
|
+
context.setDefaultTimeout(legacyOptions.pageTimeoutMs);
|
|
1196
|
+
const page = await context.newPage();
|
|
1197
|
+
debug(`Navigating to: ${redactUrl(targetStartUrl)}`);
|
|
1198
|
+
const response = await page.goto(targetStartUrl, {
|
|
1199
|
+
waitUntil: "domcontentloaded",
|
|
1200
|
+
timeout: legacyOptions.pageTimeoutMs
|
|
1201
|
+
});
|
|
1202
|
+
if (!response || response.status() >= 400 && response.status() < 600) {
|
|
1203
|
+
const status = response?.status();
|
|
1204
|
+
if (status && status >= 400) {
|
|
1205
|
+
issues.push({
|
|
1206
|
+
url: targetStartUrl,
|
|
1207
|
+
code: "http-error",
|
|
1208
|
+
message: `The server returned HTTP ${status}.`
|
|
1209
|
+
});
|
|
1210
|
+
endReason = "queue-exhausted";
|
|
1211
|
+
}
|
|
1212
|
+
} else {
|
|
1213
|
+
await page.waitForLoadState("networkidle", { timeout: Math.min(legacyOptions.pageTimeoutMs, 5e3) }).catch(() => void 0);
|
|
1214
|
+
await page.waitForTimeout(legacyOptions.waitAfterNavigationMs);
|
|
1215
|
+
const raw = await page.evaluate(collectPageData);
|
|
1216
|
+
const initialPage = mapToPageModel(raw, { url: targetStartUrl, finalUrl: page.url(), depth: 0, statusCode: response.status() }, legacyOptions.blockedKeywords);
|
|
1217
|
+
pages.push(initialPage);
|
|
1218
|
+
visitedUrls.add(normalizeUrl(initialPage.finalUrl));
|
|
1219
|
+
if (initialPage.state) {
|
|
1220
|
+
visitedStates.add(initialPage.state.id);
|
|
1221
|
+
addState(actionGraph, initialPage.state);
|
|
1222
|
+
debug(`State discovered: ${initialPage.state.name}`, {
|
|
1223
|
+
stateId: initialPage.state.id,
|
|
1224
|
+
url: redactUrl(initialPage.finalUrl)
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
const entryFlow = [];
|
|
1228
|
+
if (config2.startPath && config2.startPath !== "/") {
|
|
1229
|
+
entryFlow.push({
|
|
1230
|
+
url: targetStartUrl,
|
|
1231
|
+
action: {
|
|
1232
|
+
id: "entry|start-path",
|
|
1233
|
+
type: "navigate",
|
|
1234
|
+
description: `Navigate to start path: ${config2.startPath}`,
|
|
1235
|
+
target: config2.startPath,
|
|
1236
|
+
safe: true
|
|
1237
|
+
},
|
|
1238
|
+
stateId: initialPage.state?.id
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
stateQueue.push({
|
|
1242
|
+
url: initialPage.finalUrl,
|
|
1243
|
+
stateId: initialPage.state?.id,
|
|
1244
|
+
depth: 0,
|
|
1245
|
+
entryFlow
|
|
1246
|
+
});
|
|
1247
|
+
while (stateQueue.length > 0) {
|
|
1248
|
+
if (pages.length >= config2.limits.maxPages) {
|
|
1249
|
+
endReason = "max-pages-reached";
|
|
1250
|
+
debug(`Limit reached: max pages (${config2.limits.maxPages})`);
|
|
1251
|
+
break;
|
|
1252
|
+
}
|
|
1253
|
+
if (actionGraph.states.length >= config2.limits.maxStates) {
|
|
1254
|
+
endReason = "max-states-reached";
|
|
1255
|
+
debug(`Limit reached: max states (${config2.limits.maxStates})`);
|
|
1256
|
+
break;
|
|
1257
|
+
}
|
|
1258
|
+
if (totalActionsExecuted >= config2.limits.maxTotalActions) {
|
|
1259
|
+
endReason = "max-total-actions-reached";
|
|
1260
|
+
debug(`Limit reached: max total actions (${config2.limits.maxTotalActions})`);
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
if (Date.now() - startedAt > config2.limits.explorationTimeoutMs) {
|
|
1264
|
+
endReason = "timeout-reached";
|
|
1265
|
+
debug(`Limit reached: timeout (${config2.limits.explorationTimeoutMs}ms)`);
|
|
1266
|
+
break;
|
|
1267
|
+
}
|
|
1268
|
+
const item = stateQueue.shift();
|
|
1269
|
+
if (item.depth > config2.limits.maxDepth)
|
|
1270
|
+
continue;
|
|
1271
|
+
const currentUrl = normalizeUrl(page.url());
|
|
1272
|
+
const targetUrl = normalizeUrl(item.url);
|
|
1273
|
+
if (currentUrl !== targetUrl) {
|
|
1274
|
+
try {
|
|
1275
|
+
await page.goto(item.url, { waitUntil: "domcontentloaded", timeout: legacyOptions.pageTimeoutMs });
|
|
1276
|
+
await page.waitForTimeout(legacyOptions.waitAfterNavigationMs);
|
|
1277
|
+
} catch (error) {
|
|
1278
|
+
issues.push(toExploreIssue(item.url, error));
|
|
1279
|
+
continue;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
if (isAuthLost(page.url(), page)) {
|
|
1283
|
+
debug(`Auth lost, attempting recovery`, { url: redactUrl(page.url()) });
|
|
1284
|
+
try {
|
|
1285
|
+
await page.goto(item.url, { waitUntil: "domcontentloaded", timeout: legacyOptions.pageTimeoutMs });
|
|
1286
|
+
await page.waitForTimeout(legacyOptions.waitAfterNavigationMs);
|
|
1287
|
+
if (isAuthLost(page.url(), page)) {
|
|
1288
|
+
debug(`Auth recovery failed`, { url: redactUrl(page.url()) });
|
|
1289
|
+
issues.push({
|
|
1290
|
+
url: item.url,
|
|
1291
|
+
code: "auth-lost",
|
|
1292
|
+
message: "Authentication was lost during exploration and could not be recovered."
|
|
1293
|
+
});
|
|
1294
|
+
endReason = "auth-lost-unrecoverable";
|
|
1295
|
+
break;
|
|
1296
|
+
}
|
|
1297
|
+
debug(`Auth recovered`);
|
|
1298
|
+
} catch {
|
|
1299
|
+
endReason = "auth-lost-unrecoverable";
|
|
1300
|
+
break;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
const raw2 = await page.evaluate(collectPageData);
|
|
1304
|
+
const currentModel = mapToPageModel(raw2, { url: item.url, finalUrl: page.url(), depth: item.depth, statusCode: 200 }, legacyOptions.blockedKeywords);
|
|
1305
|
+
const currentState = currentModel.state;
|
|
1306
|
+
if (!currentState)
|
|
1307
|
+
continue;
|
|
1308
|
+
if (!visitedStates.has(currentState.id)) {
|
|
1309
|
+
visitedStates.add(currentState.id);
|
|
1310
|
+
addState(actionGraph, currentState);
|
|
1311
|
+
}
|
|
1312
|
+
if (config2.mode === "current-page")
|
|
1313
|
+
continue;
|
|
1314
|
+
const candidates = await discoverSafeCandidates(page, currentState);
|
|
1315
|
+
const safeActions = candidates.filter((c) => c.action.safe).filter((c) => !actionGraph.visitedActionKeys.includes(c.action.id)).filter((c) => !actionGraph.failedActionKeys.includes(c.action.id)).slice(0, config2.limits.maxActionsPerState);
|
|
1316
|
+
debug(`State: ${currentState.name} \u2014 Found ${candidates.length} candidates, ${safeActions.length} safe`, {
|
|
1317
|
+
stateId: currentState.id,
|
|
1318
|
+
url: redactUrl(page.url()),
|
|
1319
|
+
queueSize: stateQueue.length
|
|
1320
|
+
});
|
|
1321
|
+
for (const candidate of candidates) {
|
|
1322
|
+
if (!candidate.action.safe && candidate.action.reason) {
|
|
1323
|
+
totalActionsBlocked++;
|
|
1324
|
+
addEdge(actionGraph, currentState.id, void 0, candidate.action, "blocked");
|
|
1325
|
+
actionGraph.blockedActionKeys.push(candidate.action.id);
|
|
1326
|
+
const blockReason = isSessionEnding(candidate.action.target, void 0) ? "session-ending action" : candidate.action.reason;
|
|
1327
|
+
debug(`Blocked: ${candidate.action.target} (${blockReason})`, {
|
|
1328
|
+
actionId: candidate.action.id,
|
|
1329
|
+
stateId: currentState.id
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
for (const candidate of safeActions) {
|
|
1334
|
+
if (totalActionsExecuted >= config2.limits.maxTotalActions)
|
|
1335
|
+
break;
|
|
1336
|
+
if (Date.now() - startedAt > config2.limits.explorationTimeoutMs)
|
|
1337
|
+
break;
|
|
1338
|
+
actionGraph.visitedActionKeys.push(candidate.action.id);
|
|
1339
|
+
const beforeUrl = page.url();
|
|
1340
|
+
if (candidate.kind === "navigation-link" || candidate.kind === "sidebar-nav" || candidate.kind === "breadcrumb") {
|
|
1341
|
+
const href = candidate.action.target;
|
|
1342
|
+
if (href && !isWithinScope(href)) {
|
|
1343
|
+
urlsSkippedByScope++;
|
|
1344
|
+
debug(`Skipped: ${candidate.action.target} (outside scope ${config2.scopePath || "root"})`, {
|
|
1345
|
+
actionId: candidate.action.id,
|
|
1346
|
+
reason: `outside scope ${config2.scopePath || "root"}`
|
|
1347
|
+
});
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
const result = await executeWithRetry(page, candidate, beforeUrl, item.entryFlow, config2.limits.maxActionRetries);
|
|
1352
|
+
totalActionsExecuted++;
|
|
1353
|
+
if (!result.success) {
|
|
1354
|
+
totalActionsFailed++;
|
|
1355
|
+
addEdge(actionGraph, currentState.id, void 0, candidate.action, "failed");
|
|
1356
|
+
actionGraph.failedActionKeys.push(candidate.action.id);
|
|
1357
|
+
debug(`Failed: ${candidate.action.target}`, { actionId: candidate.action.id });
|
|
1358
|
+
await restoreState(page, beforeUrl, candidate.restoreStrategy, item.entryFlow);
|
|
1359
|
+
continue;
|
|
1360
|
+
}
|
|
1361
|
+
const afterUrl = page.url();
|
|
1362
|
+
const normalizedAfter = normalizeUrl(afterUrl);
|
|
1363
|
+
if (!isWithinScope(afterUrl)) {
|
|
1364
|
+
urlsSkippedByScope++;
|
|
1365
|
+
debug(`Skipped (after navigation): ${redactUrl(afterUrl)} (outside scope)`, {
|
|
1366
|
+
url: redactUrl(afterUrl),
|
|
1367
|
+
reason: "outside scope"
|
|
1368
|
+
});
|
|
1369
|
+
await restoreState(page, beforeUrl, candidate.restoreStrategy, item.entryFlow);
|
|
1370
|
+
continue;
|
|
1371
|
+
}
|
|
1372
|
+
if (isAuthLost(afterUrl, page)) {
|
|
1373
|
+
debug(`Auth lost after action: ${candidate.action.target}`, { url: redactUrl(afterUrl) });
|
|
1374
|
+
await restoreState(page, beforeUrl, "goto", item.entryFlow);
|
|
1375
|
+
continue;
|
|
1376
|
+
}
|
|
1377
|
+
const newRaw = await page.evaluate(collectPageData);
|
|
1378
|
+
const newModel = mapToPageModel(newRaw, { url: beforeUrl, finalUrl: afterUrl, depth: item.depth + 1, statusCode: 200 }, legacyOptions.blockedKeywords);
|
|
1379
|
+
const newState = newModel.state;
|
|
1380
|
+
if (newState && !visitedStates.has(newState.id)) {
|
|
1381
|
+
visitedStates.add(newState.id);
|
|
1382
|
+
addState(actionGraph, newState);
|
|
1383
|
+
addEdge(actionGraph, currentState.id, newState.id, candidate.action, "visited");
|
|
1384
|
+
debug(`New state: ${newState.name}`, { stateId: newState.id, url: redactUrl(afterUrl) });
|
|
1385
|
+
if (!visitedUrls.has(normalizedAfter)) {
|
|
1386
|
+
visitedUrls.add(normalizedAfter);
|
|
1387
|
+
if (isSameOrigin(afterUrl, origin) && isCrawlableUrl(afterUrl)) {
|
|
1388
|
+
pages.push(newModel);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
await exploreModal(page, newState, afterUrl, item.entryFlow);
|
|
1392
|
+
const newEntryFlow = [...item.entryFlow, { url: afterUrl, action: candidate.action, stateId: newState.id }];
|
|
1393
|
+
stateQueue.push({
|
|
1394
|
+
url: afterUrl,
|
|
1395
|
+
stateId: newState.id,
|
|
1396
|
+
depth: item.depth + 1,
|
|
1397
|
+
entryFlow: newEntryFlow
|
|
1398
|
+
});
|
|
1399
|
+
} else if (newState) {
|
|
1400
|
+
addEdge(actionGraph, currentState.id, newState.id, candidate.action, "visited");
|
|
1401
|
+
} else {
|
|
1402
|
+
addEdge(actionGraph, currentState.id, void 0, candidate.action, "visited");
|
|
1403
|
+
}
|
|
1404
|
+
if (normalizedAfter !== normalizeUrl(beforeUrl)) {
|
|
1405
|
+
await restoreState(page, beforeUrl, candidate.restoreStrategy, item.entryFlow);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
} catch (error) {
|
|
1411
|
+
issues.push(toExploreIssue(targetStartUrl || entryUrl, error));
|
|
1412
|
+
if (endReason === "queue-exhausted") {
|
|
1413
|
+
endReason = "browser-crash";
|
|
756
1414
|
}
|
|
757
1415
|
} finally {
|
|
758
1416
|
await launched.close().catch(() => void 0);
|
|
759
1417
|
}
|
|
760
|
-
|
|
1418
|
+
const summary = {
|
|
1419
|
+
pagesDiscovered: pages.length,
|
|
1420
|
+
statesDiscovered: actionGraph.states.length,
|
|
1421
|
+
transitions: actionGraph.edges.filter((e) => e.status === "visited").length,
|
|
1422
|
+
actionsExecuted: totalActionsExecuted,
|
|
1423
|
+
actionsBlocked: totalActionsBlocked,
|
|
1424
|
+
actionsFailed: totalActionsFailed,
|
|
1425
|
+
actionsRetried: totalActionsRetried,
|
|
1426
|
+
urlsSkippedByScope,
|
|
1427
|
+
endReason,
|
|
1428
|
+
endReasonDetail: getEndReasonDetail(endReason, config2)
|
|
1429
|
+
};
|
|
1430
|
+
const stats = {
|
|
1431
|
+
browser: browserLabel,
|
|
1432
|
+
pagesVisited: pages.length,
|
|
1433
|
+
urlsSkipped: urlsSkippedByScope,
|
|
1434
|
+
durationMs: Date.now() - startedAt,
|
|
1435
|
+
limitReached: endReason,
|
|
1436
|
+
summary,
|
|
1437
|
+
discoveryLogs: logs
|
|
1438
|
+
};
|
|
761
1439
|
return {
|
|
762
1440
|
startUrl: entryUrl,
|
|
763
1441
|
origin,
|
|
764
1442
|
pages,
|
|
765
1443
|
issues,
|
|
766
|
-
stats
|
|
767
|
-
browser: browserLabel,
|
|
768
|
-
pagesVisited: pages.length,
|
|
769
|
-
urlsSkipped,
|
|
770
|
-
durationMs: Date.now() - startedAt,
|
|
771
|
-
limitReached
|
|
772
|
-
},
|
|
1444
|
+
stats,
|
|
773
1445
|
actionGraph
|
|
774
1446
|
};
|
|
775
1447
|
}
|
|
776
|
-
function addNavigationEdges(pages, graph, keywords) {
|
|
777
|
-
for (const page of pages) {
|
|
778
|
-
const source = page.state;
|
|
779
|
-
if (!source)
|
|
780
|
-
continue;
|
|
781
|
-
for (const link of page.links) {
|
|
782
|
-
if (!link.href || !link.accessibleName)
|
|
783
|
-
continue;
|
|
784
|
-
const safe = canFollowLink(link.href, link.accessibleName, keywords);
|
|
785
|
-
const target = pages.find((candidate) => candidate.finalUrl === link.href || candidate.url === link.href)?.state;
|
|
786
|
-
const action = {
|
|
787
|
-
id: `${source.id}|navigate|${link.cssSelector}`,
|
|
788
|
-
type: "navigate",
|
|
789
|
-
description: `Navigate to \u201C${link.accessibleName}\u201D`,
|
|
790
|
-
target: link.accessibleName,
|
|
791
|
-
selector: link.cssSelector,
|
|
792
|
-
locator: { role: link.role, name: link.accessibleName },
|
|
793
|
-
safe,
|
|
794
|
-
reason: safe ? void 0 : "Link matched the Project click filter and was not opened"
|
|
795
|
-
};
|
|
796
|
-
addEdge(graph, source.id, target?.id, action, safe && target ? "visited" : safe ? "discovered" : "blocked");
|
|
797
|
-
if (!safe)
|
|
798
|
-
graph.blockedActionKeys.push(action.id);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
1448
|
function addState(graph, state) {
|
|
803
|
-
if (!state || graph.states.some((
|
|
1449
|
+
if (!state || graph.states.some((s) => s.id === state.id))
|
|
804
1450
|
return;
|
|
805
1451
|
graph.states.push(state);
|
|
806
1452
|
graph.visitedStateIds.push(state.id);
|
|
807
1453
|
}
|
|
808
|
-
async function discoverSafeStates(page, source, config2, origin, graph) {
|
|
809
|
-
const initial = source.state;
|
|
810
|
-
if (!initial || graph.states.length >= config2.maxTotalStates)
|
|
811
|
-
return;
|
|
812
|
-
const sourceUrl = source.finalUrl;
|
|
813
|
-
const interactions = initial.interactions.slice(0, config2.maxActionsPerState);
|
|
814
|
-
let statesForPage = 1;
|
|
815
|
-
for (const interaction of interactions) {
|
|
816
|
-
if (statesForPage >= config2.maxStatesPerPage || graph.states.length >= config2.maxTotalStates)
|
|
817
|
-
break;
|
|
818
|
-
const action = actionFromInteraction(initial.id, interaction, config2.blockedKeywords);
|
|
819
|
-
const actionKey = action.id;
|
|
820
|
-
if (graph.visitedActionKeys.includes(actionKey) || graph.failedActionKeys.includes(actionKey))
|
|
821
|
-
continue;
|
|
822
|
-
if (!action.safe) {
|
|
823
|
-
addEdge(graph, initial.id, void 0, action, "blocked");
|
|
824
|
-
graph.blockedActionKeys.push(actionKey);
|
|
825
|
-
continue;
|
|
826
|
-
}
|
|
827
|
-
try {
|
|
828
|
-
await page.locator(interaction.cssSelector).click({ timeout: config2.actionTimeoutMs });
|
|
829
|
-
await page.waitForTimeout(config2.stateDiscoveryTimeoutMs);
|
|
830
|
-
if (!isSameOrigin(page.url(), origin)) {
|
|
831
|
-
addEdge(graph, initial.id, void 0, { ...action, safe: false, reason: "Action left the approved origin" }, "blocked");
|
|
832
|
-
graph.blockedActionKeys.push(actionKey);
|
|
833
|
-
continue;
|
|
834
|
-
}
|
|
835
|
-
const raw = await page.evaluate(collectPageData);
|
|
836
|
-
const observed = mapToPageModel(raw, {
|
|
837
|
-
url: page.url(),
|
|
838
|
-
finalUrl: page.url(),
|
|
839
|
-
depth: source.depth,
|
|
840
|
-
statusCode: source.statusCode
|
|
841
|
-
}, config2.blockedKeywords).state;
|
|
842
|
-
if (!observed)
|
|
843
|
-
continue;
|
|
844
|
-
addState(graph, observed);
|
|
845
|
-
addEdge(graph, initial.id, observed.id, action, "visited");
|
|
846
|
-
graph.visitedActionKeys.push(actionKey);
|
|
847
|
-
if (observed.id !== initial.id)
|
|
848
|
-
statesForPage += 1;
|
|
849
|
-
} catch (error) {
|
|
850
|
-
addEdge(graph, initial.id, void 0, action, "failed");
|
|
851
|
-
graph.failedActionKeys.push(actionKey);
|
|
852
|
-
} finally {
|
|
853
|
-
await page.goto(sourceUrl, { waitUntil: "domcontentloaded", timeout: config2.pageTimeoutMs }).catch(() => void 0);
|
|
854
|
-
await page.waitForTimeout(Math.min(config2.waitAfterNavigationMs, 300));
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
function actionFromInteraction(stateId2, interaction, keywords) {
|
|
859
|
-
const type = interaction.kind === "tab" ? "selectTab" : interaction.kind === "accordion" ? "expandAccordion" : interaction.kind === "dropdown" ? "openDropdown" : interaction.expanded ? "closeDialog" : "openModal";
|
|
860
|
-
const blocked = isBlockedLabel(keywords, interaction.name);
|
|
861
|
-
const description = `${type === "selectTab" ? "Select" : type === "expandAccordion" ? "Expand" : "Open"} \u201C${interaction.name}\u201D`;
|
|
862
|
-
return {
|
|
863
|
-
id: `${stateId2}|${type}|${interaction.cssSelector}`,
|
|
864
|
-
type,
|
|
865
|
-
description,
|
|
866
|
-
target: interaction.name,
|
|
867
|
-
selector: interaction.cssSelector,
|
|
868
|
-
locator: { role: interaction.role, name: interaction.name },
|
|
869
|
-
safe: !blocked,
|
|
870
|
-
reason: blocked ? "Action matched the Project click filter and was not executed" : void 0
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
1454
|
function addEdge(graph, fromStateId, toStateId, action, status) {
|
|
874
1455
|
const id = `${fromStateId}|${action.id}|${toStateId ?? status}`;
|
|
875
1456
|
if (graph.edges.some((edge) => edge.id === id))
|
|
876
1457
|
return;
|
|
877
1458
|
graph.edges.push({ id, fromStateId, toStateId, action, status });
|
|
878
1459
|
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
};
|
|
902
|
-
page.on("request", onRequest);
|
|
903
|
-
page.on("response", onResponse);
|
|
904
|
-
const response = await page.goto(item.url, {
|
|
905
|
-
waitUntil: "domcontentloaded",
|
|
906
|
-
timeout: config2.pageTimeoutMs
|
|
907
|
-
});
|
|
908
|
-
const status = response?.status();
|
|
909
|
-
if (status !== void 0 && status >= 400) {
|
|
910
|
-
return {
|
|
911
|
-
kind: "issue",
|
|
912
|
-
issue: { url: item.url, code: "http-error", message: `The server returned HTTP ${status}.` }
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
await page.waitForLoadState("networkidle", { timeout: Math.min(config2.pageTimeoutMs, 5e3) }).catch(() => void 0);
|
|
916
|
-
await page.waitForTimeout(config2.waitAfterNavigationMs);
|
|
917
|
-
const challengeText = `${await page.title()} ${await page.locator("body").innerText().catch(() => "")}`.toLowerCase();
|
|
918
|
-
if (challengeText.includes("cloudflare") || challengeText.includes("checking your browser") || challengeText.includes("verify you are human") || challengeText.includes("just a moment")) {
|
|
919
|
-
return {
|
|
920
|
-
kind: "issue",
|
|
921
|
-
issue: {
|
|
922
|
-
url: item.url,
|
|
923
|
-
code: "cloudflare",
|
|
924
|
-
message: "Cloudflare/browser challenge \u2014 self check the website in a browser and try again"
|
|
925
|
-
}
|
|
926
|
-
};
|
|
927
|
-
}
|
|
928
|
-
const finalUrl = page.url();
|
|
929
|
-
const raw = await page.evaluate(collectPageData);
|
|
930
|
-
page.off("request", onRequest);
|
|
931
|
-
page.off("response", onResponse);
|
|
932
|
-
return {
|
|
933
|
-
kind: "page",
|
|
934
|
-
page: mapToPageModel(raw, {
|
|
935
|
-
url: item.url,
|
|
936
|
-
finalUrl,
|
|
937
|
-
depth: item.depth,
|
|
938
|
-
statusCode: status,
|
|
939
|
-
apiRequests
|
|
940
|
-
}, keywords)
|
|
941
|
-
};
|
|
942
|
-
} catch (error) {
|
|
943
|
-
return { kind: "issue", issue: toExploreIssue(item.url, error) };
|
|
1460
|
+
function getEndReasonDetail(reason, config2) {
|
|
1461
|
+
switch (reason) {
|
|
1462
|
+
case "queue-exhausted":
|
|
1463
|
+
return "All discoverable states have been explored within the configured scope.";
|
|
1464
|
+
case "max-pages-reached":
|
|
1465
|
+
return `Maximum page limit (${config2.limits.maxPages}) reached.`;
|
|
1466
|
+
case "max-states-reached":
|
|
1467
|
+
return `Maximum state limit (${config2.limits.maxStates}) reached.`;
|
|
1468
|
+
case "max-depth-reached":
|
|
1469
|
+
return `Maximum depth limit (${config2.limits.maxDepth}) reached.`;
|
|
1470
|
+
case "max-total-actions-reached":
|
|
1471
|
+
return `Maximum total actions limit (${config2.limits.maxTotalActions}) reached.`;
|
|
1472
|
+
case "timeout-reached":
|
|
1473
|
+
return `Exploration timeout (${config2.limits.explorationTimeoutMs}ms) reached.`;
|
|
1474
|
+
case "no-safe-actions-remaining":
|
|
1475
|
+
return "No safe actions remain to explore.";
|
|
1476
|
+
case "auth-lost-unrecoverable":
|
|
1477
|
+
return "Authentication was lost and could not be recovered.";
|
|
1478
|
+
case "browser-crash":
|
|
1479
|
+
return "Browser crashed or became unresponsive.";
|
|
1480
|
+
default:
|
|
1481
|
+
return "Exploration ended.";
|
|
944
1482
|
}
|
|
945
1483
|
}
|
|
946
1484
|
|
|
@@ -1564,7 +2102,7 @@ function translateStep(step) {
|
|
|
1564
2102
|
}
|
|
1565
2103
|
}
|
|
1566
2104
|
function translate(value) {
|
|
1567
|
-
return value.replace(/^(.+) page displays required controls$/, "$1 \u0E41\u0E2A\u0E14\u0E07
|
|
2105
|
+
return value.replace(/^(.+) page displays required controls$/, "$1 \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19").replace(/^All (\d+) controls detected on the page are visible\.$/, "\u0E1E\u0E1A\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E1A\u0E19\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14 $1 \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25\u0E2D\u0E22\u0E39\u0E48").replace(/^(.+) is required$/, "$1 \u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19").replace(/^Submit (.+) with valid data$/, "\u0E2A\u0E48\u0E07 $1 \u0E14\u0E49\u0E27\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07").replace(/^Navigate to (.+)$/, "\u0E44\u0E1B\u0E22\u0E31\u0E07 $1").replace(/^The application is available at (.+)$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E1E\u0E23\u0E49\u0E2D\u0E21\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19\u0E17\u0E35\u0E48 $1").replace(/^The application is available$/, "\u0E23\u0E30\u0E1A\u0E1A\u0E1E\u0E23\u0E49\u0E2D\u0E21\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19").replace(/^Valid test data is prepared$/, "\u0E40\u0E15\u0E23\u0E35\u0E22\u0E21\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E41\u0E25\u0E49\u0E27").replace(/^Disposable test data is prepared$/, "\u0E40\u0E15\u0E23\u0E35\u0E22\u0E21\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E25\u0E1A\u0E44\u0E14\u0E49\u0E41\u0E25\u0E49\u0E27").replace(/^Leave "(.+)" empty$/, '\u0E40\u0E27\u0E49\u0E19\u0E0A\u0E48\u0E2D\u0E07 "$1" \u0E27\u0E48\u0E32\u0E07\u0E44\u0E27\u0E49').replace(/^Select "(.+)"$/, '\u0E40\u0E25\u0E37\u0E2D\u0E01 "$1"').replace(/^Verify that a validation message is displayed for the empty required field, and the form is not submitted\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E0A\u0E48\u0E2D\u0E07\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19\u0E0B\u0E36\u0E48\u0E07\u0E40\u0E27\u0E49\u0E19\u0E27\u0E48\u0E32\u0E07 \u0E41\u0E25\u0E30\u0E1F\u0E2D\u0E23\u0E4C\u0E21\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E2A\u0E48\u0E07").replace(/^The browser navigates to (.+) and the page "(.+)" is displayed\.$/, '\u0E40\u0E1A\u0E23\u0E32\u0E27\u0E4C\u0E40\u0E0B\u0E2D\u0E23\u0E4C\u0E44\u0E1B\u0E22\u0E31\u0E07 $1 \u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E2B\u0E19\u0E49\u0E32 "$2"').replace(/^The browser navigates to (.+)\.$/, "\u0E40\u0E1A\u0E23\u0E32\u0E27\u0E4C\u0E40\u0E0B\u0E2D\u0E23\u0E4C\u0E44\u0E1B\u0E22\u0E31\u0E07 $1").replace(/^Dialog "(.+)" is visible\.$/, '\u0E01\u0E25\u0E48\u0E2D\u0E07\u0E42\u0E15\u0E49\u0E15\u0E2D\u0E1A "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Validation message "(.+)" is visible\.$/, '\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19 "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Heading "(.+)" is visible\.$/, '\u0E2B\u0E31\u0E27\u0E02\u0E49\u0E2D "$1" \u0E41\u0E2A\u0E14\u0E07\u0E2D\u0E22\u0E39\u0E48').replace(/^Observed state requires tester review before automation\.$/, "\u0E2A\u0E16\u0E32\u0E19\u0E30\u0E17\u0E35\u0E48\u0E1E\u0E1A\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E01\u0E48\u0E2D\u0E19\u0E17\u0E33 Automation").replace(/^Verify "(.+)" action \(manual\)$/, '\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A action "$1" \u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07').replace(/^Open (.+)$/, "\u0E40\u0E1B\u0E34\u0E14 $1").replace(/^The page is reachable and rendered$/, "\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E1B\u0E34\u0E14\u0E41\u0E25\u0E30\u0E41\u0E2A\u0E14\u0E07\u0E1C\u0E25\u0E44\u0E14\u0E49").replace(/^Expected behavior is not known from static exploration; review manually\.$/, "\u0E44\u0E21\u0E48\u0E17\u0E23\u0E32\u0E1A\u0E1E\u0E24\u0E15\u0E34\u0E01\u0E23\u0E23\u0E21\u0E08\u0E32\u0E01\u0E01\u0E32\u0E23\u0E2A\u0E33\u0E23\u0E27\u0E08\u0E41\u0E1A\u0E1A static \u0E01\u0E23\u0E38\u0E13\u0E32\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07").replace(/^Verify that the result is displayed according to application requirements \(needs review by tester\)\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A\u0E27\u0E48\u0E32\u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E41\u0E2A\u0E14\u0E07\u0E15\u0E32\u0E21\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E02\u0E2D\u0E07\u0E23\u0E30\u0E1A\u0E1A (\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E2B\u0E49\u0E1C\u0E39\u0E49\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A)").replace(/^Generated from elements detected on the page\.$/, "\u0E2A\u0E23\u0E49\u0E32\u0E07\u0E08\u0E32\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E15\u0E23\u0E27\u0E08\u0E1E\u0E1A\u0E1A\u0E19\u0E2B\u0E19\u0E49\u0E32\u0E40\u0E27\u0E47\u0E1A").replace(/^Evidence: the field has the HTML "required" attribute\.$/, '\u0E2B\u0E25\u0E31\u0E01\u0E10\u0E32\u0E19: \u0E0A\u0E48\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E21\u0E35\u0E41\u0E2D\u0E15\u0E17\u0E23\u0E34\u0E1A\u0E34\u0E27\u0E15\u0E4C HTML "required"').replace(/^No "required" attribute found — confirm with the specification whether this field is mandatory\.$/, '\u0E44\u0E21\u0E48\u0E1E\u0E1A\u0E41\u0E2D\u0E15\u0E17\u0E23\u0E34\u0E1A\u0E34\u0E27\u0E15\u0E4C "required" \u2014 \u0E42\u0E1B\u0E23\u0E14\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E01\u0E31\u0E1A\u0E02\u0E49\u0E2D\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E27\u0E48\u0E32\u0E0A\u0E48\u0E2D\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E19\u0E35\u0E49\u0E1A\u0E31\u0E07\u0E04\u0E31\u0E1A\u0E01\u0E23\u0E2D\u0E01\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48').replace(/^Sample values are placeholders — replace them with real test data before running\.$/, "\u0E04\u0E48\u0E32\u0E15\u0E31\u0E27\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E40\u0E1E\u0E35\u0E22\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E41\u0E17\u0E19\u0E17\u0E35\u0E48 \u2014 \u0E40\u0E1B\u0E25\u0E35\u0E48\u0E22\u0E19\u0E40\u0E1B\u0E47\u0E19\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E08\u0E23\u0E34\u0E07\u0E01\u0E48\u0E2D\u0E19\u0E40\u0E23\u0E34\u0E48\u0E21\u0E17\u0E14\u0E2A\u0E2D\u0E1A").replace(/^Explorer did not open this page — expected result needs review\.$/, "Explorer \u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E40\u0E1B\u0E34\u0E14\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49 \u2014 \u0E1C\u0E25\u0E25\u0E31\u0E1E\u0E18\u0E4C\u0E17\u0E35\u0E48\u0E04\u0E32\u0E14\u0E2B\u0E27\u0E31\u0E07\u0E15\u0E49\u0E2D\u0E07\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E15\u0E23\u0E27\u0E08\u0E2A\u0E2D\u0E1A").replace(/^Detected as a potentially destructive action — Explorer did not click it\.$/, "\u0E15\u0E23\u0E27\u0E08\u0E1E\u0E1A\u0E27\u0E48\u0E32\u0E2D\u0E32\u0E08\u0E40\u0E1B\u0E47\u0E19\u0E01\u0E32\u0E23\u0E01\u0E23\u0E30\u0E17\u0E33\u0E17\u0E35\u0E48\u0E17\u0E33\u0E25\u0E32\u0E22\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25 \u2014 Explorer \u0E08\u0E36\u0E07\u0E44\u0E21\u0E48\u0E44\u0E14\u0E49\u0E04\u0E25\u0E34\u0E01").replace(/^Manually trigger (.+) "(.+)" in a safe test environment$/, '\u0E2A\u0E31\u0E48\u0E07\u0E43\u0E0A\u0E49\u0E07\u0E32\u0E19 $1 "$2" \u0E14\u0E49\u0E27\u0E22\u0E15\u0E19\u0E40\u0E2D\u0E07\u0E43\u0E19\u0E2A\u0E20\u0E32\u0E1E\u0E41\u0E27\u0E14\u0E25\u0E49\u0E2D\u0E21\u0E17\u0E14\u0E2A\u0E2D\u0E1A\u0E17\u0E35\u0E48\u0E1B\u0E25\u0E2D\u0E14\u0E20\u0E31\u0E22');
|
|
1568
2106
|
}
|
|
1569
2107
|
function safeNormalize(url) {
|
|
1570
2108
|
try {
|
|
@@ -1652,17 +2190,19 @@ function generateTestData(pages) {
|
|
|
1652
2190
|
var UTF8_BOM = "\uFEFF";
|
|
1653
2191
|
var CSV_COLUMNS = [
|
|
1654
2192
|
"TC_ID",
|
|
1655
|
-
"Module",
|
|
1656
2193
|
"Folder",
|
|
1657
|
-
"Tags",
|
|
1658
|
-
"Requirements",
|
|
1659
2194
|
"Title",
|
|
1660
|
-
"Preconditions",
|
|
1661
|
-
"Test_Steps",
|
|
1662
|
-
"Expected_Result",
|
|
1663
2195
|
"Type",
|
|
1664
2196
|
"Priority",
|
|
2197
|
+
"Test_Steps",
|
|
2198
|
+
"Expected_Result",
|
|
1665
2199
|
"Automation_Status",
|
|
2200
|
+
"Preconditions",
|
|
2201
|
+
"Notes",
|
|
2202
|
+
"Tags",
|
|
2203
|
+
// Canonical fields are retained after the visible table columns so exported suites can be imported losslessly.
|
|
2204
|
+
"Module",
|
|
2205
|
+
"Requirements",
|
|
1666
2206
|
"Source_URL"
|
|
1667
2207
|
];
|
|
1668
2208
|
var TEST_DATA_CSV_COLUMNS = [
|
|
@@ -1685,17 +2225,18 @@ function toRow(values) {
|
|
|
1685
2225
|
function testCaseRow(testCase) {
|
|
1686
2226
|
return toRow([
|
|
1687
2227
|
testCase.id,
|
|
1688
|
-
testCase.module,
|
|
1689
|
-
testCase.folder ?? "",
|
|
1690
|
-
(testCase.tags ?? []).join(", "),
|
|
1691
|
-
(testCase.requirements ?? []).join(", "),
|
|
2228
|
+
testCase.folder ?? testCase.module,
|
|
1692
2229
|
testCase.title,
|
|
1693
|
-
testCase.preconditions.join("\n"),
|
|
1694
|
-
describeSteps(testCase.steps),
|
|
1695
|
-
testCase.expectedResult,
|
|
1696
2230
|
testCase.type,
|
|
1697
2231
|
testCase.priority,
|
|
2232
|
+
describeSteps(testCase.steps),
|
|
2233
|
+
testCase.expectedResult,
|
|
1698
2234
|
testCase.automationStatus,
|
|
2235
|
+
testCase.preconditions.join("\n"),
|
|
2236
|
+
testCase.notes ?? "",
|
|
2237
|
+
(testCase.tags ?? []).join(", "),
|
|
2238
|
+
testCase.module,
|
|
2239
|
+
(testCase.requirements ?? []).join(", "),
|
|
1699
2240
|
testCase.sourceUrl
|
|
1700
2241
|
]);
|
|
1701
2242
|
}
|
|
@@ -1723,9 +2264,20 @@ function exportTestCasesToCsv(testCases, testData = []) {
|
|
|
1723
2264
|
// src/commands/scan.ts
|
|
1724
2265
|
async function runScan(options) {
|
|
1725
2266
|
console.log(`checking scan ${redactUrl(options.url)} ...`);
|
|
1726
|
-
const result = await
|
|
1727
|
-
|
|
1728
|
-
|
|
2267
|
+
const result = await exploreWithScope(options.url, {
|
|
2268
|
+
startPath: options.startPath,
|
|
2269
|
+
scopePath: options.scopePath,
|
|
2270
|
+
mode: options.mode ?? "site",
|
|
2271
|
+
debug: options.debug ?? false,
|
|
2272
|
+
limits: {
|
|
2273
|
+
maxPages: options.maxPages ?? 20,
|
|
2274
|
+
maxDepth: options.maxDepth ?? 3,
|
|
2275
|
+
maxStates: 80,
|
|
2276
|
+
maxActionsPerState: 8,
|
|
2277
|
+
maxTotalActions: 200,
|
|
2278
|
+
maxActionRetries: 2,
|
|
2279
|
+
explorationTimeoutMs: 3e5
|
|
2280
|
+
}
|
|
1729
2281
|
});
|
|
1730
2282
|
const testCases = generateTestCases(result.pages);
|
|
1731
2283
|
const testData = generateTestData(result.pages);
|
|
@@ -1735,10 +2287,31 @@ async function runScan(options) {
|
|
|
1735
2287
|
for (const issue of result.issues) {
|
|
1736
2288
|
console.log(` ! ${issue.url} \u2014 ${issue.message}`);
|
|
1737
2289
|
}
|
|
2290
|
+
const summary = result.stats.summary;
|
|
2291
|
+
if (summary) {
|
|
2292
|
+
console.log(`
|
|
2293
|
+
Exploration Summary:`);
|
|
2294
|
+
console.log(` Pages discovered: ${summary.pagesDiscovered}`);
|
|
2295
|
+
console.log(` UI states discovered: ${summary.statesDiscovered}`);
|
|
2296
|
+
console.log(` Transitions: ${summary.transitions}`);
|
|
2297
|
+
console.log(
|
|
2298
|
+
` Actions \u2014 Executed: ${summary.actionsExecuted} | Blocked: ${summary.actionsBlocked} | Failed: ${summary.actionsFailed} | Retried: ${summary.actionsRetried}`
|
|
2299
|
+
);
|
|
2300
|
+
console.log(` URLs skipped by scope: ${summary.urlsSkippedByScope}`);
|
|
2301
|
+
console.log(` End reason: ${summary.endReason}${summary.endReasonDetail ? ` \u2014 ${summary.endReasonDetail}` : ""}`);
|
|
2302
|
+
}
|
|
1738
2303
|
console.log(
|
|
1739
2304
|
`
|
|
1740
2305
|
Summary: ${result.pages.length} pages \xB7 ${testCases.length} test cases \xB7 ${testData.length} test data \xB7 ${(result.stats.durationMs / 1e3).toFixed(1)} seconds \xB7 Using ${result.stats.browser}`
|
|
1741
2306
|
);
|
|
2307
|
+
if (result.stats.discoveryLogs && result.stats.discoveryLogs.length > 0) {
|
|
2308
|
+
console.log(`
|
|
2309
|
+
Discovery Logs:`);
|
|
2310
|
+
for (const log of result.stats.discoveryLogs) {
|
|
2311
|
+
const prefix = log.level === "blocked" ? "\u{1F6AB}" : log.level === "skipped" ? "\u23ED\uFE0F" : log.level === "error" ? "\u274C" : log.level === "retry" ? "\u{1F504}" : log.level === "debug" ? "\u{1F50D}" : " ";
|
|
2312
|
+
console.log(`${prefix} ${log.message}`);
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
1742
2315
|
if (result.pages.length === 0) {
|
|
1743
2316
|
console.error("Failed to open the website, no data to save");
|
|
1744
2317
|
process.exitCode = 1;
|
|
@@ -1746,7 +2319,8 @@ Summary: ${result.pages.length} pages \xB7 ${testCases.length} test cases \xB7 $
|
|
|
1746
2319
|
}
|
|
1747
2320
|
const csvPath = resolve(options.csvPath ?? "lazyscout-testcases.csv");
|
|
1748
2321
|
await writeFile(csvPath, exportTestCasesToCsv(testCases, testData), "utf8");
|
|
1749
|
-
console.log(`
|
|
2322
|
+
console.log(`
|
|
2323
|
+
Saved CSV: ${csvPath}`);
|
|
1750
2324
|
if (options.jsonPath) {
|
|
1751
2325
|
const jsonPath = resolve(options.jsonPath);
|
|
1752
2326
|
await writeFile(jsonPath, JSON.stringify({ ...result, testCases, testData }, null, 2), "utf8");
|
|
@@ -1757,249 +2331,52 @@ Summary: ${result.pages.length} pages \xB7 ${testCases.length} test cases \xB7 $
|
|
|
1757
2331
|
// src/commands/serve.ts
|
|
1758
2332
|
import { dirname as dirname3, join as join3 } from "node:path";
|
|
1759
2333
|
import { fileURLToPath } from "node:url";
|
|
1760
|
-
|
|
1761
|
-
// ../server/dist/app.js
|
|
1762
|
-
import Fastify from "fastify";
|
|
1763
|
-
import fastifyStatic from "@fastify/static";
|
|
1764
|
-
|
|
1765
|
-
// ../server/dist/config.js
|
|
1766
|
-
var config = {
|
|
1767
|
-
host: process.env.HOST ?? "127.0.0.1",
|
|
1768
|
-
port: Number(process.env.PORT ?? 4e3),
|
|
1769
|
-
urlPolicy: process.env.LAZYSCOUT_MODE === "public" ? PUBLIC_SAAS_POLICY : LOCAL_QA_POLICY,
|
|
1770
|
-
limits: {
|
|
1771
|
-
maxPages: 20,
|
|
1772
|
-
maxDepth: 3
|
|
1773
|
-
}
|
|
1774
|
-
};
|
|
1775
|
-
function clamp(value, min, max, fallback) {
|
|
1776
|
-
if (value === void 0 || Number.isNaN(value))
|
|
1777
|
-
return fallback;
|
|
1778
|
-
return Math.min(Math.max(Math.trunc(value), min), max);
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
// ../server/dist/toApiError.js
|
|
1782
|
-
function toApiError(error) {
|
|
1783
|
-
if (error instanceof ExplorerError) {
|
|
1784
|
-
const status = error.code === "invalid-url" || error.code === "blocked-url" ? 400 : 502;
|
|
1785
|
-
return {
|
|
1786
|
-
status,
|
|
1787
|
-
body: {
|
|
1788
|
-
error: {
|
|
1789
|
-
code: error.code,
|
|
1790
|
-
message: redactSensitiveText(error.message),
|
|
1791
|
-
hint: error.hint ? redactSensitiveText(error.hint) : void 0
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
};
|
|
1795
|
-
}
|
|
1796
|
-
return {
|
|
1797
|
-
status: 500,
|
|
1798
|
-
body: {
|
|
1799
|
-
error: {
|
|
1800
|
-
code: "internal-error",
|
|
1801
|
-
message: "An internal error occurred while analyzing the website.",
|
|
1802
|
-
hint: "Try again, or review the server logs for more details."
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
};
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
// ../server/dist/routes/analyze.js
|
|
1809
|
-
function registerAnalyzeRoute(app) {
|
|
1810
|
-
app.post("/api/analyze", async (request, reply) => {
|
|
1811
|
-
const body = request.body ?? {};
|
|
1812
|
-
if (typeof body.url !== "string" || !body.url.trim()) {
|
|
1813
|
-
return reply.status(400).send({
|
|
1814
|
-
error: { code: "invalid-url", message: "Provide a URL to analyze." }
|
|
1815
|
-
});
|
|
1816
|
-
}
|
|
1817
|
-
const check = checkTargetUrl(body.url, config.urlPolicy);
|
|
1818
|
-
if (!check.ok) {
|
|
1819
|
-
return reply.status(400).send({ error: { code: check.code, message: check.message } });
|
|
1820
|
-
}
|
|
1821
|
-
try {
|
|
1822
|
-
const result = await exploreWebsite(check.url.toString(), {
|
|
1823
|
-
maxPages: clamp(body.maxPages, 1, config.limits.maxPages, config.limits.maxPages),
|
|
1824
|
-
maxDepth: clamp(body.maxDepth, 0, config.limits.maxDepth, config.limits.maxDepth),
|
|
1825
|
-
waitAfterNavigationMs: clamp(body.waitAfterNavigationMs, 0, 5e3, 750),
|
|
1826
|
-
blockedKeywords: normalizeBlockedKeywords(body.blockedKeywords)
|
|
1827
|
-
}, config.urlPolicy);
|
|
1828
|
-
if (result.pages.length === 0) {
|
|
1829
|
-
const firstIssue = result.issues[0];
|
|
1830
|
-
throw new ExplorerError(firstIssue?.code ?? "navigation-failed", firstIssue?.message ?? "Could not open the website.", "Check that the URL is correct and the website is available.");
|
|
1831
|
-
}
|
|
1832
|
-
const testCases = [
|
|
1833
|
-
...generateTestCases(result.pages, { language: body.language ?? "en" }),
|
|
1834
|
-
...generateStateFlowTestCases(result.actionGraph)
|
|
1835
|
-
];
|
|
1836
|
-
const runEvents = [
|
|
1837
|
-
{
|
|
1838
|
-
timestamp: new Date(Date.now() - result.stats.durationMs).toISOString(),
|
|
1839
|
-
eventType: "run-started",
|
|
1840
|
-
result: "running",
|
|
1841
|
-
message: "Explorer run started"
|
|
1842
|
-
},
|
|
1843
|
-
...result.pages.flatMap((page) => [
|
|
1844
|
-
{
|
|
1845
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1846
|
-
eventType: "page-discovered",
|
|
1847
|
-
currentUrl: page.finalUrl,
|
|
1848
|
-
currentStateId: page.state?.id,
|
|
1849
|
-
result: "passed",
|
|
1850
|
-
message: `Page discovered: ${page.title || page.finalUrl}`
|
|
1851
|
-
},
|
|
1852
|
-
...(page.state?.interactions ?? []).map((interaction) => ({
|
|
1853
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1854
|
-
eventType: result.actionGraph.blockedActionKeys.some((key) => key.endsWith(`|${interaction.cssSelector}`)) ? "action-blocked" : "action-discovered",
|
|
1855
|
-
currentUrl: page.finalUrl,
|
|
1856
|
-
currentStateId: page.state?.id,
|
|
1857
|
-
result: result.actionGraph.blockedActionKeys.some((key) => key.endsWith(`|${interaction.cssSelector}`)) ? "blocked" : "warning",
|
|
1858
|
-
message: `${interaction.kind}: ${interaction.name}`
|
|
1859
|
-
}))
|
|
1860
|
-
]),
|
|
1861
|
-
...result.actionGraph.states.map((state) => ({
|
|
1862
|
-
timestamp: state.discoveredAt,
|
|
1863
|
-
eventType: "state-discovered",
|
|
1864
|
-
currentUrl: state.url,
|
|
1865
|
-
currentStateId: state.id,
|
|
1866
|
-
result: "passed",
|
|
1867
|
-
message: `State observed: ${state.name || state.title || state.url}`
|
|
1868
|
-
})),
|
|
1869
|
-
...result.actionGraph.edges.map((edge) => ({
|
|
1870
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1871
|
-
eventType: edge.status === "blocked" ? "action-blocked" : edge.status === "failed" ? "action-failed" : edge.status === "visited" ? "action-executed" : "transition-discovered",
|
|
1872
|
-
currentUrl: result.actionGraph.states.find((state) => state.id === edge.fromStateId)?.url,
|
|
1873
|
-
currentStateId: edge.fromStateId,
|
|
1874
|
-
action: edge.action,
|
|
1875
|
-
result: edge.status === "blocked" ? "blocked" : edge.status === "failed" ? "failed" : edge.status === "visited" ? "passed" : "warning",
|
|
1876
|
-
message: edge.action.description
|
|
1877
|
-
})),
|
|
1878
|
-
...result.issues.map((issue) => ({
|
|
1879
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1880
|
-
eventType: "error",
|
|
1881
|
-
currentUrl: issue.url,
|
|
1882
|
-
result: "failed",
|
|
1883
|
-
error: issue.message,
|
|
1884
|
-
message: issue.message
|
|
1885
|
-
})),
|
|
1886
|
-
{
|
|
1887
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1888
|
-
eventType: "run-completed",
|
|
1889
|
-
result: result.issues.length ? "warning" : "passed",
|
|
1890
|
-
durationMs: result.stats.durationMs,
|
|
1891
|
-
message: "Analysis completed"
|
|
1892
|
-
}
|
|
1893
|
-
];
|
|
1894
|
-
const response = {
|
|
1895
|
-
startUrl: result.startUrl,
|
|
1896
|
-
origin: result.origin,
|
|
1897
|
-
pages: result.pages,
|
|
1898
|
-
testCases,
|
|
1899
|
-
testData: generateTestData(result.pages),
|
|
1900
|
-
issues: result.issues,
|
|
1901
|
-
stats: result.stats,
|
|
1902
|
-
actionGraph: result.actionGraph,
|
|
1903
|
-
runEvents,
|
|
1904
|
-
apiChecks: body.includeApiChecks ? buildApiChecks(result.pages) : []
|
|
1905
|
-
};
|
|
1906
|
-
return reply.send(response);
|
|
1907
|
-
} catch (error) {
|
|
1908
|
-
request.log.error({ message: redactSensitiveText(error instanceof Error ? error.message : String(error)) }, "analyze failed");
|
|
1909
|
-
const { status, body: errorBody } = toApiError(error);
|
|
1910
|
-
return reply.status(status).send(errorBody);
|
|
1911
|
-
}
|
|
1912
|
-
});
|
|
1913
|
-
}
|
|
1914
|
-
function generateStateFlowTestCases(graph) {
|
|
1915
|
-
const states = new Map(graph.states.map((state) => [state.id, state]));
|
|
1916
|
-
let sequence = 1;
|
|
1917
|
-
return graph.edges.flatMap((edge) => {
|
|
1918
|
-
if (edge.status !== "visited" || !edge.toStateId || edge.fromStateId === edge.toStateId)
|
|
1919
|
-
return [];
|
|
1920
|
-
const target = states.get(edge.toStateId);
|
|
1921
|
-
const source = states.get(edge.fromStateId);
|
|
1922
|
-
if (!target || !source)
|
|
1923
|
-
return [];
|
|
1924
|
-
const observation = expectedObservation(target);
|
|
1925
|
-
const id = `TC-FLOW-${String(sequence).padStart(3, "0")}`;
|
|
1926
|
-
sequence += 1;
|
|
1927
|
-
return [
|
|
1928
|
-
{
|
|
1929
|
-
id,
|
|
1930
|
-
module: "FLOW",
|
|
1931
|
-
tags: ["state-flow"],
|
|
1932
|
-
title: `${edge.action.description} reaches ${target.name}`,
|
|
1933
|
-
preconditions: [`The application is available at ${source.url}`],
|
|
1934
|
-
steps: [
|
|
1935
|
-
{ type: "navigate", url: source.url },
|
|
1936
|
-
{
|
|
1937
|
-
type: "click",
|
|
1938
|
-
target: {
|
|
1939
|
-
role: edge.action.locator?.role,
|
|
1940
|
-
name: edge.action.locator?.name,
|
|
1941
|
-
cssSelector: edge.action.selector
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
],
|
|
1945
|
-
expectedResult: observation ?? "Observed state requires tester review before automation.",
|
|
1946
|
-
type: target.type === "validation" || target.type === "error" ? "validation" : "positive",
|
|
1947
|
-
priority: "medium",
|
|
1948
|
-
automationStatus: observation ? "ready" : "needs-review",
|
|
1949
|
-
sourceUrl: source.url,
|
|
1950
|
-
notes: observation ? "Generated from an observed UI state transition." : "Explorer observed a new UI state but no stable assertion text."
|
|
1951
|
-
}
|
|
1952
|
-
];
|
|
1953
|
-
});
|
|
1954
|
-
}
|
|
1955
|
-
function expectedObservation(state) {
|
|
1956
|
-
if (state.visibleDialogs[0])
|
|
1957
|
-
return `Dialog "${state.visibleDialogs[0]}" is visible.`;
|
|
1958
|
-
if (state.validationMessages[0])
|
|
1959
|
-
return `Validation message "${state.validationMessages[0]}" is visible.`;
|
|
1960
|
-
if (state.headings[0])
|
|
1961
|
-
return `Heading "${state.headings[0]}" is visible.`;
|
|
1962
|
-
return void 0;
|
|
1963
|
-
}
|
|
1964
|
-
function buildApiChecks(pages) {
|
|
1965
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1966
|
-
const checks = [];
|
|
1967
|
-
for (const page of pages)
|
|
1968
|
-
for (const request of page.apiRequests) {
|
|
1969
|
-
const key = `${request.method}:${request.url}`;
|
|
1970
|
-
if (seen.has(key))
|
|
1971
|
-
continue;
|
|
1972
|
-
seen.add(key);
|
|
1973
|
-
const authRequired = request.status === 401 || request.status === 403;
|
|
1974
|
-
const safeMethod = ["GET", "HEAD", "OPTIONS"].includes(request.method.toUpperCase());
|
|
1975
|
-
checks.push({
|
|
1976
|
-
id: `API-${String(checks.length + 1).padStart(3, "0")}`,
|
|
1977
|
-
method: request.method,
|
|
1978
|
-
url: request.url,
|
|
1979
|
-
observedStatus: request.status,
|
|
1980
|
-
expectedStatus: authRequired ? void 0 : request.status && request.status < 400 ? 200 : void 0,
|
|
1981
|
-
sourceUrl: request.sourceUrl,
|
|
1982
|
-
durationMs: request.durationMs,
|
|
1983
|
-
status: !safeMethod ? "needs-review" : authRequired ? "needs-auth" : request.status && request.status >= 400 ? "needs-review" : "observed",
|
|
1984
|
-
note: !safeMethod ? "Observation only. LazyScout does not replay state-changing API methods automatically." : authRequired ? "Requires auth profile or token before execution." : void 0
|
|
1985
|
-
});
|
|
1986
|
-
}
|
|
1987
|
-
return checks;
|
|
2334
|
+
|
|
2335
|
+
// ../server/dist/app.js
|
|
2336
|
+
import Fastify from "fastify";
|
|
2337
|
+
import fastifyStatic from "@fastify/static";
|
|
2338
|
+
|
|
2339
|
+
// ../server/dist/config.js
|
|
2340
|
+
var config = {
|
|
2341
|
+
host: process.env.HOST ?? "127.0.0.1",
|
|
2342
|
+
port: Number(process.env.PORT ?? 4e3),
|
|
2343
|
+
urlPolicy: process.env.LAZYSCOUT_MODE === "public" ? PUBLIC_SAAS_POLICY : LOCAL_QA_POLICY,
|
|
2344
|
+
limits: {
|
|
2345
|
+
maxPages: 20,
|
|
2346
|
+
maxDepth: 3
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
function clamp(value, min, max, fallback) {
|
|
2350
|
+
if (value === void 0 || Number.isNaN(value))
|
|
2351
|
+
return fallback;
|
|
2352
|
+
return Math.min(Math.max(Math.trunc(value), min), max);
|
|
1988
2353
|
}
|
|
1989
2354
|
|
|
1990
|
-
// ../server/dist/
|
|
1991
|
-
function
|
|
1992
|
-
|
|
1993
|
-
const
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2355
|
+
// ../server/dist/toApiError.js
|
|
2356
|
+
function toApiError(error) {
|
|
2357
|
+
if (error instanceof ExplorerError) {
|
|
2358
|
+
const status = error.code === "invalid-url" || error.code === "blocked-url" ? 400 : 502;
|
|
2359
|
+
return {
|
|
2360
|
+
status,
|
|
2361
|
+
body: {
|
|
2362
|
+
error: {
|
|
2363
|
+
code: error.code,
|
|
2364
|
+
message: redactSensitiveText(error.message),
|
|
2365
|
+
hint: error.hint ? redactSensitiveText(error.hint) : void 0
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
return {
|
|
2371
|
+
status: 500,
|
|
2372
|
+
body: {
|
|
2373
|
+
error: {
|
|
2374
|
+
code: "internal-error",
|
|
2375
|
+
message: "An internal error occurred while analyzing the website.",
|
|
2376
|
+
hint: "Try again, or review the server logs for more details."
|
|
2377
|
+
}
|
|
1998
2378
|
}
|
|
1999
|
-
|
|
2000
|
-
const filename = `lazyscout-testcases-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.csv`;
|
|
2001
|
-
return reply.header("Content-Type", "text/csv; charset=utf-8").header("Content-Disposition", `attachment; filename="${filename}"`).send(csv);
|
|
2002
|
-
});
|
|
2379
|
+
};
|
|
2003
2380
|
}
|
|
2004
2381
|
|
|
2005
2382
|
// ../server/dist/workspace.js
|
|
@@ -2279,6 +2656,217 @@ function enqueueMutation(key, action) {
|
|
|
2279
2656
|
});
|
|
2280
2657
|
}
|
|
2281
2658
|
|
|
2659
|
+
// ../server/dist/routes/analyze.js
|
|
2660
|
+
function registerAnalyzeRoute(app, workspaceRoot) {
|
|
2661
|
+
app.post("/api/analyze", async (request, reply) => {
|
|
2662
|
+
const body = request.body ?? {};
|
|
2663
|
+
if (typeof body.url !== "string" || !body.url.trim()) {
|
|
2664
|
+
return reply.status(400).send({
|
|
2665
|
+
error: { code: "invalid-url", message: "Provide a URL to analyze." }
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
const check = checkTargetUrl(body.url, config.urlPolicy);
|
|
2669
|
+
if (!check.ok) {
|
|
2670
|
+
return reply.status(400).send({ error: { code: check.code, message: check.message } });
|
|
2671
|
+
}
|
|
2672
|
+
const browserProfileDir = body.projectId ? await browserProfileDirectory(workspaceRoot, body.projectId).catch(() => void 0) : void 0;
|
|
2673
|
+
try {
|
|
2674
|
+
const result = await exploreWithScope(check.url.toString(), {
|
|
2675
|
+
startPath: body.startPath,
|
|
2676
|
+
scopePath: body.scopePath,
|
|
2677
|
+
mode: body.mode ?? "site",
|
|
2678
|
+
debug: body.debug ?? false,
|
|
2679
|
+
limits: {
|
|
2680
|
+
maxPages: clamp(body.maxPages, 1, config.limits.maxPages, config.limits.maxPages),
|
|
2681
|
+
maxDepth: clamp(body.maxDepth, 0, config.limits.maxDepth, config.limits.maxDepth),
|
|
2682
|
+
maxStates: 80,
|
|
2683
|
+
maxActionsPerState: 8,
|
|
2684
|
+
maxTotalActions: 200,
|
|
2685
|
+
maxActionRetries: 2,
|
|
2686
|
+
explorationTimeoutMs: 3e5
|
|
2687
|
+
}
|
|
2688
|
+
}, {
|
|
2689
|
+
waitAfterNavigationMs: clamp(body.waitAfterNavigationMs, 0, 5e3, 750),
|
|
2690
|
+
blockedKeywords: normalizeBlockedKeywords(body.blockedKeywords),
|
|
2691
|
+
...browserProfileDir ? { browserProfileDir } : {}
|
|
2692
|
+
});
|
|
2693
|
+
if (result.pages.length === 0) {
|
|
2694
|
+
const firstIssue = result.issues[0];
|
|
2695
|
+
throw new ExplorerError(firstIssue?.code ?? "navigation-failed", firstIssue?.message ?? "Could not open the website.", "Check that the URL is correct and the website is available.");
|
|
2696
|
+
}
|
|
2697
|
+
const testCases = [
|
|
2698
|
+
...generateTestCases(result.pages, { language: body.language ?? "en" }),
|
|
2699
|
+
...body.language === "th" ? localizeThai(generateStateFlowTestCases(result.actionGraph)) : generateStateFlowTestCases(result.actionGraph)
|
|
2700
|
+
];
|
|
2701
|
+
const runEvents = [
|
|
2702
|
+
{
|
|
2703
|
+
timestamp: new Date(Date.now() - result.stats.durationMs).toISOString(),
|
|
2704
|
+
eventType: "run-started",
|
|
2705
|
+
result: "running",
|
|
2706
|
+
message: "Explorer run started"
|
|
2707
|
+
},
|
|
2708
|
+
...result.pages.flatMap((page) => [
|
|
2709
|
+
{
|
|
2710
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2711
|
+
eventType: "page-discovered",
|
|
2712
|
+
currentUrl: page.finalUrl,
|
|
2713
|
+
currentStateId: page.state?.id,
|
|
2714
|
+
result: "passed",
|
|
2715
|
+
message: `Page discovered: ${page.title || page.finalUrl}`
|
|
2716
|
+
},
|
|
2717
|
+
...(page.state?.interactions ?? []).map((interaction) => ({
|
|
2718
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2719
|
+
eventType: result.actionGraph.blockedActionKeys.some((key) => key.endsWith(`|${interaction.cssSelector}`)) ? "action-blocked" : "action-discovered",
|
|
2720
|
+
currentUrl: page.finalUrl,
|
|
2721
|
+
currentStateId: page.state?.id,
|
|
2722
|
+
result: result.actionGraph.blockedActionKeys.some((key) => key.endsWith(`|${interaction.cssSelector}`)) ? "blocked" : "warning",
|
|
2723
|
+
message: `${interaction.kind}: ${interaction.name}`
|
|
2724
|
+
}))
|
|
2725
|
+
]),
|
|
2726
|
+
...result.actionGraph.states.map((state) => ({
|
|
2727
|
+
timestamp: state.discoveredAt,
|
|
2728
|
+
eventType: "state-discovered",
|
|
2729
|
+
currentUrl: state.url,
|
|
2730
|
+
currentStateId: state.id,
|
|
2731
|
+
result: "passed",
|
|
2732
|
+
message: `State observed: ${state.name || state.title || state.url}`
|
|
2733
|
+
})),
|
|
2734
|
+
...result.actionGraph.edges.map((edge) => ({
|
|
2735
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2736
|
+
eventType: edge.status === "blocked" ? "action-blocked" : edge.status === "failed" ? "action-failed" : edge.status === "visited" ? "action-executed" : "transition-discovered",
|
|
2737
|
+
currentUrl: result.actionGraph.states.find((state) => state.id === edge.fromStateId)?.url,
|
|
2738
|
+
currentStateId: edge.fromStateId,
|
|
2739
|
+
action: edge.action,
|
|
2740
|
+
result: edge.status === "blocked" ? "blocked" : edge.status === "failed" ? "failed" : edge.status === "visited" ? "passed" : "warning",
|
|
2741
|
+
message: edge.action.description
|
|
2742
|
+
})),
|
|
2743
|
+
...result.issues.map((issue) => ({
|
|
2744
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2745
|
+
eventType: "error",
|
|
2746
|
+
currentUrl: issue.url,
|
|
2747
|
+
result: "failed",
|
|
2748
|
+
error: issue.message,
|
|
2749
|
+
message: issue.message
|
|
2750
|
+
})),
|
|
2751
|
+
{
|
|
2752
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2753
|
+
eventType: "run-completed",
|
|
2754
|
+
result: result.issues.length ? "warning" : "passed",
|
|
2755
|
+
durationMs: result.stats.durationMs,
|
|
2756
|
+
message: "Analysis completed"
|
|
2757
|
+
}
|
|
2758
|
+
];
|
|
2759
|
+
const response = {
|
|
2760
|
+
startUrl: result.startUrl,
|
|
2761
|
+
origin: result.origin,
|
|
2762
|
+
pages: result.pages,
|
|
2763
|
+
testCases,
|
|
2764
|
+
testData: generateTestData(result.pages),
|
|
2765
|
+
issues: result.issues,
|
|
2766
|
+
stats: result.stats,
|
|
2767
|
+
actionGraph: result.actionGraph,
|
|
2768
|
+
runEvents,
|
|
2769
|
+
apiChecks: body.includeApiChecks ? buildApiChecks(result.pages) : []
|
|
2770
|
+
};
|
|
2771
|
+
return reply.send(response);
|
|
2772
|
+
} catch (error) {
|
|
2773
|
+
request.log.error({ message: redactSensitiveText(error instanceof Error ? error.message : String(error)) }, "analyze failed");
|
|
2774
|
+
const { status, body: errorBody } = toApiError(error);
|
|
2775
|
+
return reply.status(status).send(errorBody);
|
|
2776
|
+
}
|
|
2777
|
+
});
|
|
2778
|
+
}
|
|
2779
|
+
function generateStateFlowTestCases(graph) {
|
|
2780
|
+
const states = new Map(graph.states.map((state) => [state.id, state]));
|
|
2781
|
+
let sequence = 1;
|
|
2782
|
+
return graph.edges.flatMap((edge) => {
|
|
2783
|
+
if (edge.status !== "visited" || !edge.toStateId || edge.fromStateId === edge.toStateId)
|
|
2784
|
+
return [];
|
|
2785
|
+
const target = states.get(edge.toStateId);
|
|
2786
|
+
const source = states.get(edge.fromStateId);
|
|
2787
|
+
if (!target || !source)
|
|
2788
|
+
return [];
|
|
2789
|
+
const observation = expectedObservation(target);
|
|
2790
|
+
const id = `TC-FLOW-${String(sequence).padStart(3, "0")}`;
|
|
2791
|
+
sequence += 1;
|
|
2792
|
+
return [
|
|
2793
|
+
{
|
|
2794
|
+
id,
|
|
2795
|
+
module: "FLOW",
|
|
2796
|
+
tags: ["state-flow"],
|
|
2797
|
+
title: `${edge.action.description} reaches ${target.name}`,
|
|
2798
|
+
preconditions: [`The application is available at ${source.url}`],
|
|
2799
|
+
steps: [
|
|
2800
|
+
{ type: "navigate", url: source.url },
|
|
2801
|
+
{
|
|
2802
|
+
type: "click",
|
|
2803
|
+
target: {
|
|
2804
|
+
role: edge.action.locator?.role,
|
|
2805
|
+
name: edge.action.locator?.name,
|
|
2806
|
+
cssSelector: edge.action.selector
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
],
|
|
2810
|
+
expectedResult: observation ?? "Observed state requires tester review before automation.",
|
|
2811
|
+
type: target.type === "validation" || target.type === "error" ? "validation" : "positive",
|
|
2812
|
+
priority: "medium",
|
|
2813
|
+
automationStatus: observation ? "ready" : "needs-review",
|
|
2814
|
+
sourceUrl: source.url,
|
|
2815
|
+
notes: observation ? "Generated from an observed UI state transition." : "Explorer observed a new UI state but no stable assertion text."
|
|
2816
|
+
}
|
|
2817
|
+
];
|
|
2818
|
+
});
|
|
2819
|
+
}
|
|
2820
|
+
function expectedObservation(state) {
|
|
2821
|
+
if (state.visibleDialogs[0])
|
|
2822
|
+
return `Dialog "${state.visibleDialogs[0]}" is visible.`;
|
|
2823
|
+
if (state.validationMessages[0])
|
|
2824
|
+
return `Validation message "${state.validationMessages[0]}" is visible.`;
|
|
2825
|
+
if (state.headings[0])
|
|
2826
|
+
return `Heading "${state.headings[0]}" is visible.`;
|
|
2827
|
+
return void 0;
|
|
2828
|
+
}
|
|
2829
|
+
function buildApiChecks(pages) {
|
|
2830
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2831
|
+
const checks = [];
|
|
2832
|
+
for (const page of pages)
|
|
2833
|
+
for (const request of page.apiRequests) {
|
|
2834
|
+
const key = `${request.method}:${request.url}`;
|
|
2835
|
+
if (seen.has(key))
|
|
2836
|
+
continue;
|
|
2837
|
+
seen.add(key);
|
|
2838
|
+
const authRequired = request.status === 401 || request.status === 403;
|
|
2839
|
+
const safeMethod = ["GET", "HEAD", "OPTIONS"].includes(request.method.toUpperCase());
|
|
2840
|
+
checks.push({
|
|
2841
|
+
id: `API-${String(checks.length + 1).padStart(3, "0")}`,
|
|
2842
|
+
method: request.method,
|
|
2843
|
+
url: request.url,
|
|
2844
|
+
observedStatus: request.status,
|
|
2845
|
+
expectedStatus: authRequired ? void 0 : request.status && request.status < 400 ? 200 : void 0,
|
|
2846
|
+
sourceUrl: request.sourceUrl,
|
|
2847
|
+
durationMs: request.durationMs,
|
|
2848
|
+
status: !safeMethod ? "needs-review" : authRequired ? "needs-auth" : request.status && request.status >= 400 ? "needs-review" : "observed",
|
|
2849
|
+
note: !safeMethod ? "Observation only. LazyScout does not replay state-changing API methods automatically." : authRequired ? "Requires auth profile or token before execution." : void 0
|
|
2850
|
+
});
|
|
2851
|
+
}
|
|
2852
|
+
return checks;
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
// ../server/dist/routes/exportCsv.js
|
|
2856
|
+
function registerExportCsvRoute(app) {
|
|
2857
|
+
app.post("/api/export/csv", async (request, reply) => {
|
|
2858
|
+
const body = request.body ?? {};
|
|
2859
|
+
if (!Array.isArray(body.testCases) || body.testCases.length === 0) {
|
|
2860
|
+
return reply.status(400).send({
|
|
2861
|
+
error: { code: "empty-export", message: "There are no Test Cases to export." }
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
const csv = exportTestCasesToCsv(body.testCases, Array.isArray(body.testData) ? body.testData : []);
|
|
2865
|
+
const filename = `lazyscout-testcases-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.csv`;
|
|
2866
|
+
return reply.header("Content-Type", "text/csv; charset=utf-8").header("Content-Disposition", `attachment; filename="${filename}"`).send(csv);
|
|
2867
|
+
});
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2282
2870
|
// ../server/dist/routes/automationRun.js
|
|
2283
2871
|
var MAX_STEPS = 100;
|
|
2284
2872
|
var MAX_LOGS = 250;
|
|
@@ -2779,8 +3367,6 @@ function debugLocator(stage, detail) {
|
|
|
2779
3367
|
console.log(`[LazyScout:${stage}]`, safe);
|
|
2780
3368
|
}
|
|
2781
3369
|
async function ensureSafeClick(target, fallbackLabel, blockedKeywords) {
|
|
2782
|
-
if (blockedKeywords.length === 0)
|
|
2783
|
-
return;
|
|
2784
3370
|
const labels = await Promise.all([
|
|
2785
3371
|
target.getAttribute("aria-label").catch(() => null),
|
|
2786
3372
|
target.getAttribute("title").catch(() => null),
|
|
@@ -2788,7 +3374,10 @@ async function ensureSafeClick(target, fallbackLabel, blockedKeywords) {
|
|
|
2788
3374
|
target.getAttribute("id").catch(() => null),
|
|
2789
3375
|
target.innerText().catch(() => "")
|
|
2790
3376
|
]);
|
|
2791
|
-
|
|
3377
|
+
const values = [fallbackLabel, ...labels.map((value) => value ?? void 0)];
|
|
3378
|
+
if (isUnsafeAutoClick(...values))
|
|
3379
|
+
throw new Error(`Blocked by mandatory safety policy: ${fallbackLabel}`);
|
|
3380
|
+
if (isBlockedLabel(blockedKeywords, ...values)) {
|
|
2792
3381
|
throw new Error(`Blocked by the Project click filter: ${fallbackLabel}`);
|
|
2793
3382
|
}
|
|
2794
3383
|
}
|
|
@@ -3295,7 +3884,7 @@ function buildApp(options = {}) {
|
|
|
3295
3884
|
const appVersion = options.appVersion ?? process.env.npm_package_version ?? "0.0.0-dev";
|
|
3296
3885
|
const workspaceRoot = resolveWorkspaceRoot(options.workspaceRoot);
|
|
3297
3886
|
app.get("/api/health", async () => ({ status: "ok", version: appVersion, workspaceRoot }));
|
|
3298
|
-
registerAnalyzeRoute(app);
|
|
3887
|
+
registerAnalyzeRoute(app, workspaceRoot);
|
|
3299
3888
|
registerExportCsvRoute(app);
|
|
3300
3889
|
registerAutomationRunRoute(app, workspaceRoot);
|
|
3301
3890
|
registerApiCheckRunRoute(app);
|
|
@@ -3330,7 +3919,7 @@ async function openInBrowser(url) {
|
|
|
3330
3919
|
}
|
|
3331
3920
|
|
|
3332
3921
|
// src/version.ts
|
|
3333
|
-
var VERSION = true ? "0.3.
|
|
3922
|
+
var VERSION = true ? "0.3.6" : "0.0.0-dev";
|
|
3334
3923
|
|
|
3335
3924
|
// src/commands/serve.ts
|
|
3336
3925
|
var DEFAULT_PORT = 4321;
|
|
@@ -3383,6 +3972,17 @@ Default: 20
|
|
|
3383
3972
|
--max-depth <n> Maximum crawl depth.
|
|
3384
3973
|
Default: 3
|
|
3385
3974
|
|
|
3975
|
+
--start-path <path> Continue exploration from this path after login.
|
|
3976
|
+
Example: /admin/users
|
|
3977
|
+
|
|
3978
|
+
--scope-path <path> Limit exploration to this section.
|
|
3979
|
+
Example: /admin
|
|
3980
|
+
|
|
3981
|
+
--mode <mode> Exploration mode: current-page, scope, site.
|
|
3982
|
+
Default: site
|
|
3983
|
+
|
|
3984
|
+
--debug Show detailed exploration logs.
|
|
3985
|
+
|
|
3386
3986
|
Web Interface Options
|
|
3387
3987
|
--port <port> Port used by the LazyScout web interface.
|
|
3388
3988
|
Default: 4321
|
|
@@ -3401,6 +4001,8 @@ npx lazyscout scan http://localhost:5173
|
|
|
3401
4001
|
|
|
3402
4002
|
npx lazyscout scan https://example.com --max-pages 10 --csv report.csv
|
|
3403
4003
|
|
|
4004
|
+
npx lazyscout scan https://example.com --start-path /admin --scope-path /admin --mode scope --debug
|
|
4005
|
+
|
|
3404
4006
|
Explorer Behavior
|
|
3405
4007
|
LazyScout only explores URLs within the same origin.
|
|
3406
4008
|
It follows links and tries a small, safe set of UI controls such as tabs and dialogs.
|
|
@@ -3418,7 +4020,11 @@ async function main() {
|
|
|
3418
4020
|
"max-depth": { type: "string" },
|
|
3419
4021
|
port: { type: "string" },
|
|
3420
4022
|
workspace: { type: "string" },
|
|
3421
|
-
"no-open": { type: "boolean", default: false }
|
|
4023
|
+
"no-open": { type: "boolean", default: false },
|
|
4024
|
+
"start-path": { type: "string" },
|
|
4025
|
+
"scope-path": { type: "string" },
|
|
4026
|
+
mode: { type: "string" },
|
|
4027
|
+
debug: { type: "boolean", default: false }
|
|
3422
4028
|
}
|
|
3423
4029
|
});
|
|
3424
4030
|
if (values.version) {
|
|
@@ -3446,12 +4052,22 @@ async function main() {
|
|
|
3446
4052
|
process.exitCode = 1;
|
|
3447
4053
|
return;
|
|
3448
4054
|
}
|
|
4055
|
+
const mode = values.mode;
|
|
4056
|
+
if (mode && mode !== "current-page" && mode !== "scope" && mode !== "site") {
|
|
4057
|
+
console.error(`Invalid mode "${mode}". Use: current-page, scope, or site`);
|
|
4058
|
+
process.exitCode = 1;
|
|
4059
|
+
return;
|
|
4060
|
+
}
|
|
3449
4061
|
await runScan({
|
|
3450
4062
|
url,
|
|
3451
4063
|
csvPath: values.csv,
|
|
3452
4064
|
jsonPath: values.json,
|
|
3453
4065
|
maxPages: values["max-pages"] ? Number(values["max-pages"]) : void 0,
|
|
3454
|
-
maxDepth: values["max-depth"] ? Number(values["max-depth"]) : void 0
|
|
4066
|
+
maxDepth: values["max-depth"] ? Number(values["max-depth"]) : void 0,
|
|
4067
|
+
startPath: values["start-path"],
|
|
4068
|
+
scopePath: values["scope-path"],
|
|
4069
|
+
mode,
|
|
4070
|
+
debug: values.debug
|
|
3455
4071
|
});
|
|
3456
4072
|
return;
|
|
3457
4073
|
}
|