Skip to content

A free, open-source alternative to Burp Suite: an intercepting proxy and web app security testing suite with Repeater, Intruder, Collaborator and a built-in OWASP ZAP scanner. Linux, AGPL-3.0.

Scan configuration: common GraphQL endpoints, a site map limit, the settings' timeouts

scottsturrockfd57044d3369
diff --git a/ROADMAP.md b/ROADMAP.md
index c60400c..005e906 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -27,7 +27,6 @@ All of these are on one page: Dashboard > New scan > Scan configuration, with Cu
| Feature | Reference |
|---|---|
-| API crawling > Test common GraphQL endpoints | `OT-SCAN-GRAPHQL-COMMON` |
| API crawling > Switching API definitions, SOAP WSDL and GraphQL introspection off | `OT-SCAN-API-SWITCHES` |
| Crawl behaviour > Crawl strategy, and Crawl speed under View advanced settings | `OT-SCAN-CRAWL-STRATEGY` |
| Crawl behaviour > Handling repeated timeouts during crawl | `OT-SCAN-CRAWL-TIMEOUTS` |
@@ -37,7 +36,7 @@ All of these are on one page: Dashboard > New scan > Scan configuration, with Cu
| Audit behaviour > Handling repeated timeouts during audit | `OT-SCAN-AUDIT-TIMEOUTS` |
| Insertion points strategy > Nested insertion points | `OT-SCAN-POINTS-NESTED` |
| Login behaviour > Authenticated crawl only, and Testing login functions | `OT-SCAN-LOGIN` |
-| Discovery logic > Maximum items to request from site map, and Maximum hidden links to follow | `OT-SCAN-DISCOVERY-LIMITS` |
+| Discovery logic > Maximum hidden links to follow | `OT-SCAN-DISCOVERY-LIMITS` |
| Insertion points strategy > Set insertion point types > Parameter name | `OT-SCAN-POINTS-NAME` |
| Audit behaviour > Audit strategy (the four tick boxes), and Issue noise reduction | `OT-SCAN-AUDIT-STRATEGY` |
| Insertion points strategy > Handling frequent insertion points | `OT-SCAN-POINTS-FREQUENT` |
@@ -46,4 +45,4 @@ All of these are on one page: Dashboard > New scan > Scan configuration, with Cu
| Discovery logic > Click all pointer clickable elements, and Application uses fragments for routing | `OT-SCAN-CLICKS` |
| JavaScript analysis > Static analysis, missing site resources and the two time limits | `OT-SCAN-JAVASCRIPT` |
-23 open items.
+22 open items.
diff --git a/src/opensuite/dashboard/DashboardTool.java b/src/opensuite/dashboard/DashboardTool.java
index 8e9b332..76a1689 100644
--- a/src/opensuite/dashboard/DashboardTool.java
+++ b/src/opensuite/dashboard/DashboardTool.java
@@ -840,8 +840,10 @@ public class DashboardTool implements ToolModule {
sp.setBorder(BorderFactory.createLineBorder(Ui.GRID));
sp.getVerticalScrollBar().setUnitIncrement(16);
t.setFillsViewportHeight(true);
- t.setBackground(Theme.BG);
- sp.getViewport().setBackground(Theme.BG);
+ // On the dark theme the page's own grey is the stripe colour, so the table stands on the darker ground and its rows alternate.
+ Color ground = Theme.dark ? Theme.CONTENT : Theme.BG;
+ t.setBackground(ground);
+ sp.getViewport().setBackground(ground);
return sp;
}
diff --git a/src/opensuite/dashboard/ScanConfigPanel.java b/src/opensuite/dashboard/ScanConfigPanel.java
index d7d8f17..b200b35 100644
--- a/src/opensuite/dashboard/ScanConfigPanel.java
+++ b/src/opensuite/dashboard/ScanConfigPanel.java
@@ -51,7 +51,7 @@ public final class ScanConfigPanel extends JPanel {
// ---- Crawl behaviour
private final JTextField maxDepth = num("4", 126);
private final JComboBox<String> crawlStrategy = Ui.combo(new String[]{"Fastest", "Faster", "Normal", "More complete", "Most complete"});
- private final JLabel strategyNote = Ui.label("");
+ private final JTextArea strategyNote = opensuite.ui.Sections.fill(opensuite.ui.Sections.text(""));
private final JTextField maxCrawlMin = num("150", 74);
private final JTextField maxLocations = num("1500", 74);
private final JTextField maxRequests = num("", 74);
@@ -252,8 +252,8 @@ public final class ScanConfigPanel extends JPanel {
// What the scan engine cannot do yet stays on the page, greyed, so the page keeps its shape.
notYet(crawlStrategy, crawlSpeed, crawlTimeouts, crawlTimeoutPct, crawlAuthFailures, crawlRetries,
authenticatedOnly, selfRegister, triggerFailures,
- apiDefinitions, apiWsdl, apiGraphql, apiGraphqlCommon,
- fetchOutOfScope, resourceTimeout, sitemapItems, hiddenLinkCount, clickPointer, fragments,
+ apiDefinitions, apiWsdl, apiGraphql,
+ fetchOutOfScope, resourceTimeout, hiddenLinkCount, clickPointer, fragments,
skipIneffective, maintainSession, followRedirects, parallelPhases, consolidatePassive,
failChecks, failPoints, failItems, failPct, followUpPasses,
jsStatic, jsMissing, jsOutOfScope, jsDynamicSecs, jsStaticSecs,
@@ -359,7 +359,7 @@ public final class ScanConfigPanel extends JPanel {
Ui.note("Choose a strategy and crawl depth to balance crawl coverage and speed based on your application's structure."),
row(depthLabel, maxDepth, plain("steps from start URL")),
row(strategyLabel, crawlStrategy),
- OptionsPage.indent(strategyNote, depthLabel.getPreferredSize().width + 5),
+ strategyNote,
Box.createVerticalStrut(4),
row(advanced),
para("We recommend that you only change the advanced settings when an application needs it."));
@@ -439,6 +439,7 @@ public final class ScanConfigPanel extends JPanel {
c = Ui.label("Application uses fragments for routing");
b.setPreferredSize(a.getPreferredSize());
c.setPreferredSize(new Dimension(a.getPreferredSize().width + 21, c.getPreferredSize().height));
+ requestSitemap.addItemListener(e -> sitemapItems.setEnabled(requestSitemap.isSelected()));
p.section("Discovery logic",
Ui.note("Configure how Open Suite discovers and interacts with different types of content when crawling your site."),
submitForms, requestRobots, requestSitemap,
@@ -577,7 +578,7 @@ public final class ScanConfigPanel extends JPanel {
static ScanConfig customDefaults() {
ScanConfig b = ScanConfig.preset("Balanced");
return new ScanConfig("Custom", 4, 150, true, true, 0, 10, 0, "MEDIUM", "MEDIUM", b.injectableMask(), b.rpcMask(), 0, 0,
- new ScanConfig.Options(true, true, true, true, "", -1, -1, 1500, 0, null));
+ new ScanConfig.Options(true, true, true, true, "", -1, -1, 1500, 0, null, false, 1000));
}
/**
@@ -636,6 +637,8 @@ public final class ScanConfigPanel extends JPanel {
requestTimeout.setText(o.auditTimeoutSecs() < 0 ? "" : String.valueOf(o.auditTimeoutSecs()));
put(maxLocations, o.maxLocations(), true);
put(maxRequests, o.maxRequests(), true);
+ apiGraphqlCommon.setSelected(o.graphqlCommon());
+ put(sitemapItems, o.sitemapMax(), true);
if (o.skips() != null) {
List<SkipRule> some = new ArrayList<>(), all = new ArrayList<>();
for (ScanConfig.Skip s : o.skips())
@@ -658,7 +661,8 @@ public final class ScanConfigPanel extends JPanel {
requestRobots.isSelected(), requestSitemap.isSelected(), hiddenLinks.isSelected(), clickAll.isSelected(),
customAgent.isSelected() ? userAgent.getText().strip() : "",
timeoutOf(crawlConnectSecs, crawlRequestSecs), timeoutOf(connectTimeout, requestTimeout),
- intOf(maxLocations, 0), intOf(maxRequests, 0), skips);
+ intOf(maxLocations, 0), intOf(maxRequests, 0), skips,
+ apiGraphqlCommon.isSelected(), intOf(sitemapItems, 0));
}
/** The engine configuration the controls describe. */
diff --git a/src/opensuite/engine/ScanConfig.java b/src/opensuite/engine/ScanConfig.java
index 71a7a88..90a9776 100644
--- a/src/opensuite/engine/ScanConfig.java
+++ b/src/opensuite/engine/ScanConfig.java
@@ -91,9 +91,11 @@ public record ScanConfig(
int auditTimeoutSecs,
int maxLocations, // stop a site's crawl at this many unique locations
int maxRequests, // stop a site's crawl at this many requests
- java.util.List<Skip> skips
+ java.util.List<Skip> skips,
+ boolean graphqlCommon, // ask the usual GraphQL addresses of each site for a schema
+ int sitemapMax // take at most this many addresses from a site map (0 = all of them)
) {
- public static final Options DEFAULT = new Options(true, true, true, false, "", -1, -1, 0, 0, null);
+ public static final Options DEFAULT = new Options(true, true, true, false, "", -1, -1, 0, 0, null, false, 0);
public Options {
if (userAgent == null) userAgent = "";
if (skips != null) skips = java.util.List.copyOf(skips);
diff --git a/src/opensuite/engine/ScanConfigStore.java b/src/opensuite/engine/ScanConfigStore.java
index eb1140f..56e8319 100644
--- a/src/opensuite/engine/ScanConfigStore.java
+++ b/src/opensuite/engine/ScanConfigStore.java
@@ -76,6 +76,8 @@ public final class ScanConfigStore {
p.setProperty("auditTimeoutSecs", String.valueOf(o.auditTimeoutSecs()));
p.setProperty("maxLocations", String.valueOf(o.maxLocations()));
p.setProperty("maxRequests", String.valueOf(o.maxRequests()));
+ p.setProperty("graphqlCommon", String.valueOf(o.graphqlCommon()));
+ p.setProperty("sitemapMax", String.valueOf(o.sitemapMax()));
if (o.skips() != null) {
p.setProperty("skips", String.valueOf(o.skips().size()));
for (int i = 0; i < o.skips().size(); i++) {
@@ -126,7 +128,8 @@ public final class ScanConfigStore {
bool(p, "robots", d.robots()), bool(p, "sitemap", d.sitemap()), bool(p, "hiddenLinks", d.hiddenLinks()),
bool(p, "clickAll", d.clickAll()), p.getProperty("userAgent", d.userAgent()),
num(p, "crawlTimeoutSecs", d.crawlTimeoutSecs()), num(p, "auditTimeoutSecs", d.auditTimeoutSecs()),
- num(p, "maxLocations", d.maxLocations()), num(p, "maxRequests", d.maxRequests()), skips);
+ num(p, "maxLocations", d.maxLocations()), num(p, "maxRequests", d.maxRequests()), skips,
+ bool(p, "graphqlCommon", d.graphqlCommon()), num(p, "sitemapMax", d.sitemapMax()));
}
public static boolean delete(String name) {
diff --git a/src/opensuite/engine/ZapApi.java b/src/opensuite/engine/ZapApi.java
index 0079152..c36b07b 100644
--- a/src/opensuite/engine/ZapApi.java
+++ b/src/opensuite/engine/ZapApi.java
@@ -327,6 +327,22 @@ public final class ZapApi {
call("ajaxSpider", "action", "setOptionLogoutAvoidance", p("Boolean", String.valueOf(on)));
}
+ /** Ask the address for its GraphQL schema and request what it describes; false when it is not such an endpoint. */
+ public boolean importGraphql(String endpoint) {
+ try { checked(call("graphql", "action", "importUrl", p("endurl", endpoint))); return true; }
+ catch (Exception e) { return false; }
+ }
+
+ /** Fetch the address through the engine, so it is recorded with the site, and give the body of a 200 answer ("" for any other). */
+ public String fetchBody(String url) throws Exception {
+ List<JsonValue> got = arr(call("core", "action", "accessUrl", p("url", url, "followRedirects", "true")), "accessUrl");
+ if (got.isEmpty()) return "";
+ JsonValue last = got.get(got.size() - 1);
+ String head = str(last, "responseHeader");
+ String body = str(last, "responseBody");
+ return head != null && head.matches("(?s)HTTP/\\S+ 200\\b.*") && body != null ? body : "";
+ }
+
/** Read the WSDL at the address and request each operation it describes; they join the site's addresses. */
public void importWsdl(String url) throws Exception {
call("soap", "action", "importUrl", p("url", url));
diff --git a/src/opensuite/engine/ZapScanner.java b/src/opensuite/engine/ZapScanner.java
index 4103eeb..2c618ab 100644
--- a/src/opensuite/engine/ZapScanner.java
+++ b/src/opensuite/engine/ZapScanner.java
@@ -360,9 +360,10 @@ public final class ZapScanner {
api.setSpiderMaxDuration(cfg.crawlDurationMin());
api.setSpiderProcessForms(cfg.submitForms());
ScanConfig.Options o = cfg.more();
- api.setSpiderSources(o.robots(), o.sitemap(), o.hiddenLinks());
+ // A site map with a limit is read here, not by the engine, which takes all of one.
+ api.setSpiderSources(o.robots(), o.sitemap() && o.sitemapMax() <= 0, o.hiddenLinks());
api.setUserAgent(o.userAgent());
- api.setTimeoutSecs(o.crawlTimeoutSecs());
+ api.setTimeoutSecs(timeoutFor(o.crawlTimeoutSecs()));
} catch (Exception ignore) { /* use the engine defaults */ }
// Everything the engine does in this job stays inside the suite scope.
@@ -392,6 +393,7 @@ public final class ZapScanner {
if (!several) {
// A scan of one site that cannot start has nothing else to do: the failure is the scan's.
api.accessUrl(seed.url());
+ readSitemap(site, cfg.more(), crawlTask);
// 0 = no per-node child limit: crawl every in-scope link within the
// depth budget, instead of stopping after 20 links per page.
c.sid = api.spiderScan(seed.url(), 0, scopeContext);
@@ -406,6 +408,7 @@ public final class ZapScanner {
try {
api.accessUrl(seed.url());
if (crawlTask.cancelled()) { c.error = "Stopped"; return; }
+ readSitemap(site, cfg.more(), crawlTask);
String sid = api.spiderScan(seed.url(), 0, scopeContext);
if (sid == null || sid.isBlank()) { c.error = "The engine did not start the crawl"; return; }
c.began = c.lastNew = System.currentTimeMillis();
@@ -499,6 +502,7 @@ public final class ZapScanner {
if (cut != null) crawlTask.log(several ? label(c.seed) + ": " + cut : cut);
try { for (String u : api.spiderOutOfScope(id)) noteSkipped(u); } catch (Exception ignore) { /* the list is then shorter */ }
readWsdls(site, crawlTask);
+ if (cfg.more().graphqlCommon()) tryGraphql(site, crawlTask);
if (several && c.lastLoc <= 0) {
// Nothing came back from it at all: there is nothing to crawl further or to audit.
crawlTask.log("No page could be fetched from " + label(c.seed) + ": it is left out of the rest of the scan");
@@ -811,7 +815,7 @@ public final class ZapScanner {
private void applyAuditOptions(ScanConfig cfg) throws Exception {
ScanConfig.Options o = cfg.more();
api.setUserAgent(o.userAgent());
- api.setTimeoutSecs(o.auditTimeoutSecs());
+ api.setTimeoutSecs(timeoutFor(o.auditTimeoutSecs()));
api.setSkippedParams(o.skips());
}
@@ -832,6 +836,70 @@ public final class ZapScanner {
return false;
}
+ /** Where a GraphQL endpoint usually is. */
+ static final String[] GRAPHQL_PATHS = {"/graphql", "/api/graphql", "/v1/graphql", "/v2/graphql", "/api/v1/graphql",
+ "/graphql/v1", "/graphiql", "/query", "/api/query", "/graphql.php", "/graphql/console", "/gql", "/api/gql"};
+
+ /** After a site's crawl: the usual GraphQL addresses are asked for a schema, whether or not a page links to them. */
+ private void tryGraphql(String site, ScanTask task) {
+ String base = site.endsWith("/") ? site.substring(0, site.length() - 1) : site;
+ for (String path : GRAPHQL_PATHS) {
+ if (task.cancelled()) return;
+ if (api.importGraphql(base + path)) task.log("Found a GraphQL endpoint at " + base + path + " and requested what its schema describes");
+ }
+ }
+
+ /** The addresses a site map lists, in its order: the {@code loc} of each entry. */
+ public static java.util.List<String> sitemapLocations(String xml) {
+ java.util.List<String> out = new ArrayList<>();
+ if (xml == null) return out;
+ java.util.regex.Matcher m = java.util.regex.Pattern.compile("(?is)<loc>\\s*(?:<!\\[CDATA\\[)?\\s*(.*?)\\s*(?:\\]\\]>)?\\s*</loc>").matcher(xml);
+ while (m.find()) {
+ String u = m.group(1).replace("&amp;", "&").replace("&apos;", "'").replace("&quot;", "\"").replace("&lt;", "<").replace("&gt;", ">");
+ if (!u.isBlank()) out.add(u);
+ }
+ return out;
+ }
+
+ /**
+ * Before a site's crawl, when the configuration limits what is taken from a site map: the map is
+ * fetched here, a map of maps is followed one level, and the first addresses of the site, up to the
+ * limit, are requested. The crawl that follows starts from them as well as from the scan's address.
+ */
+ private void readSitemap(String site, ScanConfig.Options o, ScanTask task) {
+ if (!o.sitemap() || o.sitemapMax() <= 0) return;
+ String base = site.endsWith("/") ? site.substring(0, site.length() - 1) : site;
+ try {
+ String xml = api.fetchBody(base + "/sitemap.xml");
+ java.util.List<String> listed = sitemapLocations(xml);
+ if (xml.toLowerCase(java.util.Locale.ROOT).contains("<sitemapindex")) {
+ java.util.List<String> maps = listed;
+ listed = new ArrayList<>();
+ for (int i = 0; i < maps.size() && i < 10 && listed.size() < o.sitemapMax(); i++) {
+ if (task.cancelled()) return;
+ if (!maps.get(i).startsWith(base + "/")) continue;
+ listed.addAll(sitemapLocations(api.fetchBody(maps.get(i))));
+ try { api.deleteSiteNode(maps.get(i)); } catch (Exception ignore) { /* as above */ }
+ }
+ }
+ // The crawl starts from everything recorded for the site, and would read all of a map it found there.
+ try { api.deleteSiteNode(base + "/sitemap.xml"); } catch (Exception ignore) { /* not recorded: nothing to take out */ }
+ java.util.Set<String> taken = new java.util.LinkedHashSet<>();
+ for (String u : listed) {
+ if (taken.size() >= o.sitemapMax()) break;
+ if (u.startsWith(base + "/") || u.equals(base)) taken.add(u);
+ }
+ for (String u : taken) {
+ if (task.cancelled()) return;
+ try { api.accessUrl(u); } catch (Exception ignore) { /* one address that does not answer */ }
+ }
+ if (!listed.isEmpty())
+ task.log("Site map of " + base + ": requested " + taken.size() + " of the " + listed.size() + " addresses it lists (limit " + o.sitemapMax() + ")");
+ } catch (Exception e) {
+ task.log("The site map of " + base + " could not be read: " + e.getMessage());
+ }
+ }
+
/** After a site's crawl: each WSDL it found by such an address is read, and its operations requested. */
private void readWsdls(String site, ScanTask task) {
java.util.List<String> found;
@@ -849,6 +917,17 @@ public final class ZapScanner {
}
}
+ /** A scan's timeout in seconds: its own when it sets one (0 is none), else the one in Settings > Network > Connections > Timeouts. */
+ private static int timeoutFor(int own) {
+ return own >= 0 ? own : globalTimeoutSecs(opensuite.core.HttpClient.defaultConnectTimeoutMs, opensuite.core.HttpClient.defaultReadTimeoutMs);
+ }
+
+ /** The engine has one timeout where the settings have two: the longer is taken, and 0 when either is without limit. */
+ public static int globalTimeoutSecs(int connectMs, int readMs) {
+ if (connectMs == Integer.MAX_VALUE || readMs == Integer.MAX_VALUE) return 0;
+ return Math.max(1, (int) Math.ceil(Math.max(connectMs, readMs) / 1000.0));
+ }
+
/** What to say when a crawl has reached a limit of its configuration, or null while it is inside them. */
public static String crawlCap(ScanConfig.Options o, int locations, int requests) {
if (o.maxLocations() > 0 && locations >= o.maxLocations())
diff --git a/src/opensuite/ui/Ui.java b/src/opensuite/ui/Ui.java
index 0fc59ab..8674f7a 100644
--- a/src/opensuite/ui/Ui.java
+++ b/src/opensuite/ui/Ui.java
@@ -19,7 +19,8 @@ public final class Ui {
public static final Color ACCENT = Theme.ACCENT;
public static final Color PANEL_BG = Theme.SURFACE;
public static final Color GRID = Theme.BORDER;
- public static final Color ERROR_RED = new Color(0xCC, 0x00, 0x00);
+ /** Red for a warning in text: a lighter one on the dark theme, where the usual red cannot be read. */
+ public static final Color ERROR_RED = Theme.dark ? new Color(0xFF, 0x6B, 0x68) : new Color(0xCC, 0x00, 0x00);
public static final Color ZEBRA = Theme.ACCENT_FAINT;
public static final Color SELECTION = Theme.ACCENT_LIGHT;
diff --git a/src/opensuite/ui/Unbuilt.java b/src/opensuite/ui/Unbuilt.java
index cfa3cd3..f3bb777 100644
--- a/src/opensuite/ui/Unbuilt.java
+++ b/src/opensuite/ui/Unbuilt.java
@@ -56,7 +56,6 @@ public final class Unbuilt {
// The custom scan configuration: every entry is a greyed control on that one page. Each names
// the page in the list on its left, then the section or the control.
private static final String SCAN = "Scan configuration > ";
- public static final Unbuilt SCAN_GRAPHQL_COMMON = of("OT-SCAN-GRAPHQL-COMMON", SCAN + "API crawling > Test common GraphQL endpoints");
public static final Unbuilt SCAN_API_SWITCHES = of("OT-SCAN-API-SWITCHES", SCAN + "API crawling > Switching API definitions, SOAP WSDL and GraphQL introspection off");
public static final Unbuilt SCAN_CRAWL_STRATEGY = of("OT-SCAN-CRAWL-STRATEGY", SCAN + "Crawl behaviour > Crawl strategy, and Crawl speed under View advanced settings");
public static final Unbuilt SCAN_CRAWL_TIMEOUTS = of("OT-SCAN-CRAWL-TIMEOUTS", SCAN + "Crawl behaviour > Handling repeated timeouts during crawl");
@@ -66,7 +65,7 @@ public final class Unbuilt {
public static final Unbuilt SCAN_AUDIT_TIMEOUTS = of("OT-SCAN-AUDIT-TIMEOUTS", SCAN + "Audit behaviour > Handling repeated timeouts during audit");
public static final Unbuilt SCAN_POINTS_NESTED = of("OT-SCAN-POINTS-NESTED", SCAN + "Insertion points strategy > Nested insertion points");
public static final Unbuilt SCAN_LOGIN = of("OT-SCAN-LOGIN", SCAN + "Login behaviour > Authenticated crawl only, and Testing login functions");
- public static final Unbuilt SCAN_DISCOVERY_LIMITS = of("OT-SCAN-DISCOVERY-LIMITS", SCAN + "Discovery logic > Maximum items to request from site map, and Maximum hidden links to follow");
+ public static final Unbuilt SCAN_DISCOVERY_LIMITS = of("OT-SCAN-DISCOVERY-LIMITS", SCAN + "Discovery logic > Maximum hidden links to follow");
public static final Unbuilt SCAN_POINTS_NAME = of("OT-SCAN-POINTS-NAME", SCAN + "Insertion points strategy > Set insertion point types > Parameter name");
public static final Unbuilt SCAN_AUDIT_STRATEGY = of("OT-SCAN-AUDIT-STRATEGY", SCAN + "Audit behaviour > Audit strategy (the four tick boxes), and Issue noise reduction");
public static final Unbuilt SCAN_POINTS_FREQUENT = of("OT-SCAN-POINTS-FREQUENT", SCAN + "Insertion points strategy > Handling frequent insertion points");
diff --git a/tests/opensuite/dashboard/ScanWizardTest.java b/tests/opensuite/dashboard/ScanWizardTest.java
index b884c4c..93f65ec 100644
--- a/tests/opensuite/dashboard/ScanWizardTest.java
+++ b/tests/opensuite/dashboard/ScanWizardTest.java
@@ -137,12 +137,21 @@ public final class ScanWizardTest {
Expect.equal(re.typeId(), -1, "an XML attribute is matched anywhere");
Expect.isTrue(java.util.regex.Pattern.matches(re.regex(), "xmlns:soap"), "an expression matches");
- opensuite.engine.ScanConfig.Options lim = new opensuite.engine.ScanConfig.Options(true, true, true, false, "", -1, -1, 100, 500, null);
+ opensuite.engine.ScanConfig.Options lim = new opensuite.engine.ScanConfig.Options(true, true, true, false, "", -1, -1, 100, 500, null, false, 0);
Expect.isTrue(opensuite.engine.ZapScanner.crawlCap(lim, 99, 499) == null, "inside both limits");
Expect.isTrue(opensuite.engine.ZapScanner.crawlCap(lim, 100, 0).contains("100 unique locations"), "at the locations limit");
Expect.isTrue(opensuite.engine.ZapScanner.crawlCap(lim, 5, 500).contains("500 requests"), "at the requests limit");
Expect.isTrue(opensuite.engine.ZapScanner.crawlCap(opensuite.engine.ScanConfig.Options.DEFAULT, 99999, 99999) == null, "no limits set");
+ Expect.equal(opensuite.engine.ZapScanner.globalTimeoutSecs(120_000, 120_000), 120, "the settings' own");
+ Expect.equal(opensuite.engine.ZapScanner.globalTimeoutSecs(15_000, 30_000), 30, "the longer of the two");
+ Expect.equal(opensuite.engine.ZapScanner.globalTimeoutSecs(Integer.MAX_VALUE, 30_000), 0, "no limit in the settings is no limit");
+ Expect.equal(o.sitemapMax(), 1000, "site map limit of a custom configuration");
+ Expect.isTrue(!o.graphqlCommon(), "common GraphQL endpoints are not tried unless ticked");
+ java.util.List<String> locs = opensuite.engine.ZapScanner.sitemapLocations(
+ "<urlset><url><loc> http://a.test/one?a=1&amp;b=2 </loc></url><url><loc><![CDATA[http://a.test/two]]></loc></url><url><LOC>http://a.test/three</LOC></url></urlset>");
+ Expect.equal(locs, java.util.List.of("http://a.test/one?a=1&b=2", "http://a.test/two", "http://a.test/three"), "the addresses of a site map, in order");
+ Expect.isTrue(opensuite.engine.ZapScanner.sitemapLocations("not a map").isEmpty(), "nothing from what is not one");
Expect.isTrue(opensuite.engine.ZapScanner.asksForWsdl("http://a.test/soap/calc?wsdl"), "the usual form");
Expect.isTrue(opensuite.engine.ZapScanner.asksForWsdl("http://a.test/Service.svc?singleWsdl"), "the single-file form");
Expect.isTrue(opensuite.engine.ZapScanner.asksForWsdl("http://a.test/s?x=1&WSDL"), "whatever its case, among other parameters");
diff --git a/tests/opensuite/engine/ScanConfigStoreTest.java b/tests/opensuite/engine/ScanConfigStoreTest.java
index 22bc810..a9075ff 100644
--- a/tests/opensuite/engine/ScanConfigStoreTest.java
+++ b/tests/opensuite/engine/ScanConfigStoreTest.java
@@ -33,7 +33,7 @@ public final class ScanConfigStoreTest {
Harness.test("the options of a custom configuration are saved with it", () -> {
ScanConfig.Options o = new ScanConfig.Options(false, true, false, true, "Probe/1.0 (test)", 0, 45, 1500, 20000,
java.util.List.of(new ScanConfig.Skip("Cookie", "Is", "asp.net_sessionid", false),
- new ScanConfig.Skip("XML attribute", "Matches regex", "xmlns.*", true)));
+ new ScanConfig.Skip("XML attribute", "Matches regex", "xmlns.*", true)), true, 250);
save("With options", ScanConfig.preset("Fast").with(o));
Expect.equal(load("With options").more(), o, "every option, and both lists of parameters");
save("Plain", ScanConfig.preset("Fast"));