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.

Audit items: the number columns sort as numbers

scottsturrockf9df20e2a6ee
diff --git a/src/opensuite/dashboard/DashboardTool.java b/src/opensuite/dashboard/DashboardTool.java
index d9179b5..eb32dd4 100644
--- a/src/opensuite/dashboard/DashboardTool.java
+++ b/src/opensuite/dashboard/DashboardTool.java
@@ -1772,6 +1772,9 @@ public class DashboardTool implements ToolModule {
search.putClientProperty("JTextField.placeholderText", "Search");
javax.swing.table.TableRowSorter<AuditItemsModel> sorter = new javax.swing.table.TableRowSorter<>(auditItemsModel);
auditItemsSorter = sorter;
+ // The counts are numbers, and blank where there is none yet: compared as
+ // text, 10 came before 2.
+ for (int c : new int[] {0, AuditItemsModel.ISSUES, 6, 7, 8}) sorter.setComparator(c, NUMBERS_THEN_TEXT);
auditItemsTable.setRowSorter(sorter);
search.getDocument().addDocumentListener(new DocumentListener() {
private void go() {
@@ -1865,6 +1868,14 @@ public class DashboardTool implements ToolModule {
* <p>Requests, errors and times come from the audit requests sent to the
* address itself.
*/
+ /** Numbers in number order, a blank before any number, anything else as text. */
+ static final java.util.Comparator<Object> NUMBERS_THEN_TEXT = (a, b) -> {
+ boolean na = a instanceof Number, nb = b instanceof Number;
+ if (na && nb) return Double.compare(((Number) a).doubleValue(), ((Number) b).doubleValue());
+ if (na != nb) return na ? 1 : -1;
+ return String.valueOf(a).compareTo(String.valueOf(b));
+ };
+
private final class AuditItemsModel extends AbstractTableModel {
private static final int STATUS = 3, RULES = 4, ISSUES = 5;
private final String[] cols = {"#", "Host", "URL", "Status", "Progress",
diff --git a/tests/opensuite/dashboard/LiveViewTest.java b/tests/opensuite/dashboard/LiveViewTest.java
index c627561..7051fd9 100644
--- a/tests/opensuite/dashboard/LiveViewTest.java
+++ b/tests/opensuite/dashboard/LiveViewTest.java
@@ -24,6 +24,12 @@ public final class LiveViewTest {
public void run() {
Harness.suite("Live crawl view");
+ Harness.test("the Audit items counts sort as numbers", () -> {
+ List<Object> col = new ArrayList<>(List.of(10, 2, "", 1, 16));
+ col.sort(DashboardTool.NUMBERS_THEN_TEXT);
+ Expect.equal(col.toString(), "[, 1, 2, 10, 16]", "a blank first, then 1, 2, 10: not 1, 10, 16, 2");
+ });
+
Harness.test("a scan knows the addresses it refuses", () -> {
ScanTask t = new ScanTask(ScanTask.Type.LIVE_ACTIVE, "Crawl of 127.0.0.1", "Crawl");
Expect.isFalse(t.refuses("https://owasp.org/"), "nothing is refused before the limits are known");