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.

5.7 KB
Raw Blame
package opensuite.ui.settings;

import opensuite.core.ProjectOptions;
import opensuite.core.Settings;
import opensuite.core.SuiteContext;
import opensuite.ui.Sections;

import javax.swing.*;
import java.awt.*;

/**
 * Settings of Open Suite's own that the reference has no page for. Each sits as
 * one more block at the foot of the page whose subject it shares: what the
 * history records under Scope, what the project file keeps under Logging, and
 * how much traffic is held in memory under Performance.
 */
final class ProjectExtras {

    private ProjectExtras() { }

    /** Project > Scope: whether out-of-scope traffic is recorded at all. */
    static void history(SettingsPage p, SuiteContext ctx) {
        Settings s = ctx.settings();
        String[] choices = {"Ask each time", "Stop logging out-of-scope traffic", "Keep logging all traffic"};
        String[] keys = {"ask", "stop", "keep"};
        JComboBox<String> onScope = opensuite.ui.Ui.combo(choices);
        Runnable show = () -> {
            String current = ProjectOptions.outOfScopeChoice(s);
            for (int i = 0; i < keys.length; i++) if (keys[i].equals(current)) onScope.setSelectedIndex(i);
        };
        show.run();
        onScope.addActionListener(e -> s.set(ProjectOptions.OUT_OF_SCOPE_CHOICE, keys[onScope.getSelectedIndex()]));
        p.block("Out-of-scope history logging", SettingsPage.Kind.PROJECT,
                "With out-of-scope logging disabled, the proxy still forwards all traffic but records only in-scope traffic in the "
              + "history, the site map and the Logger, so that unrelated browser traffic to other sites is not stored in the project.",
                () -> { s.setBool(ProjectOptions.LOG_OUT_OF_SCOPE, true); s.set(ProjectOptions.OUT_OF_SCOPE_CHOICE, "ask"); show.run(); },
                SettingsPage.check(s, ProjectOptions.LOG_OUT_OF_SCOPE, true, "Log out-of-scope traffic"),
                SettingsPage.line(22, Sections.caption("When an item is added to scope:"), 7, onScope));
    }

    /** Project > Logging: what the project file keeps of an audit and of large responses. */
    static void file(SettingsPage p, SuiteContext ctx) {
        Settings s = ctx.settings();
        JTextField cap = SettingsPage.number(s, ProjectOptions.BODY_CAP_KB, 0, 8);
        p.block("Project file contents", SettingsPage.Kind.PROJECT,
                "An audit sends thousands of probe requests per endpoint. By default the project stores each probe's request and response "
              + "headers and the response length, and excludes the response body; each finding retains its own full request and response.",
                () -> { s.setBool(ProjectOptions.KEEP_AUDIT_BODIES, false); s.setInt(ProjectOptions.BODY_CAP_KB, 0); cap.setText("0"); },
                SettingsPage.check(s, ProjectOptions.KEEP_AUDIT_BODIES, false, "Keep full audit responses in the project (much larger file)"),
                SettingsPage.line(22, Sections.caption("Maximum response body size:"), 7, cap, 5, Sections.caption("KB")),
                Sections.text("0 stores every body in full. With a limit set, a larger response body is truncated to the limit when the project is "
                        + "written, and the viewer indicates this; the full length is recorded. Useful for sites that serve large downloads or media through the proxy."));
    }

    /** Suite > Performance: how much audit and WebSocket traffic the session holds in memory. */
    static void memory(SettingsPage p, SuiteContext ctx) {
        Settings s = ctx.settings();
        JTextField mem = SettingsPage.number(s, ProjectOptions.AUDIT_MEMORY_MB, ProjectOptions.DEFAULT_AUDIT_MEMORY_MB, 8);
        JTextField ws = SettingsPage.number(s, ProjectOptions.WS_MEMORY_MB, ProjectOptions.DEFAULT_WS_MEMORY_MB, 8);
        // The stores take the new caps as they are typed.
        java.util.function.Consumer<String> apply = key -> {
            if (ProjectOptions.AUDIT_MEMORY_MB.equals(key)) ctx.store().setAuditCapBytes(ProjectOptions.auditMemoryBytes(s));
            if (ProjectOptions.WS_MEMORY_MB.equals(key)) ctx.wsStore().setCapBytes(ProjectOptions.wsMemoryBytes(s));
        };
        for (JTextField f : new JTextField[] { mem, ws }) {
            String key = f == mem ? ProjectOptions.AUDIT_MEMORY_MB : ProjectOptions.WS_MEMORY_MB;
            f.getDocument().addDocumentListener(new javax.swing.event.DocumentListener() {
                public void insertUpdate(javax.swing.event.DocumentEvent e) { apply.accept(key); }
                public void removeUpdate(javax.swing.event.DocumentEvent e) { apply.accept(key); }
                public void changedUpdate(javax.swing.event.DocumentEvent e) { apply.accept(key); }
            });
        }
        JLabel a = Sections.caption("Audit traffic kept in memory:"), w = Sections.caption("WebSocket frames kept in memory:");
        int width = Math.max(a.getPreferredSize().width, w.getPreferredSize().width);
        a.setPreferredSize(new Dimension(width, 18));
        w.setPreferredSize(new Dimension(width, 18));
        p.block("Traffic kept in memory", SettingsPage.Kind.PROJECT,
                "The Logger shows every probe sent by an audit while the session is open. Beyond these limits, the oldest probes and frames "
              + "are discarded as new ones arrive, so that a long audit cannot exhaust memory. 0 disables the limit. Findings, crawl traffic and "
              + "manual traffic are never discarded.",
                () -> { mem.setText(String.valueOf(ProjectOptions.DEFAULT_AUDIT_MEMORY_MB)); ws.setText(String.valueOf(ProjectOptions.DEFAULT_WS_MEMORY_MB)); },
                SettingsPage.line(22, a, 7, mem, 5, Sections.caption("MB")),
                SettingsPage.line(22, w, 7, ws, 5, Sections.caption("MB")));
    }
}