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.

18.2 KB
Raw Blame
package opensuite.ui;

import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.util.ArrayList;
import java.util.List;

/**
 * The shared "not yet implemented" affordance, and the source of the roadmap.
 *
 * <p>Open Suite lays out the full interface for a feature before the behaviour
 * behind it exists. Every such feature has an entry here, and the entries are
 * what ROADMAP.md and the Roadmap tab under Discover list. A control may also
 * be given the dialog with {@link #attach}: it names the feature, invites the
 * user to contribute it to the project, and offers a copy of a short anchor
 * for their notes. Whole empty areas can embed {@link #panel()} directly.
 *
 * <p>Each entry carries two facts only, both certain: a stable reference code
 * ({@code OT-<TOOL>-<FEATURE>}) and where the feature lives. We deliberately do
 * not describe what the feature does; the person who picks it up knows it, and we
 * would rather not put a wrong description in their hands. Large features are
 * split into independent sub-units, each its own code, so a contributor can take
 * one and finish it to a high standard. The full set of entries is the roadmap
 * (see {@link #all()}).
 */
public final class Unbuilt {

    /** The canonical project that contributions (pull requests) go to. */
    public static final String PROJECT_URL = "https://github.com/scottsturrock/open-suite";

    private static final List<Unbuilt> ALL = new ArrayList<>();

    private final String code;      // OT-<TOOL>-<FEATURE>[-<PART>]
    private final String location;  // e.g. "Intruder > Resource pool"

    private Unbuilt(String code, String location) {
        this.code = code;
        this.location = location;
        ALL.add(this);
    }

    private static Unbuilt of(String code, String location) {
        return new Unbuilt(code, location);
    }

    // ---- Registry of unbuilt features = the roadmap ------------------------
    // Declaration order is the order shown on the roadmap, grouped by tool.

    public static final Unbuilt EXT_RUNTIMES = of("OT-EXT-RUNTIMES", "Extensions > Installed > Python and Ruby extensions");
    public static final Unbuilt EXT_STORE = of("OT-EXT-STORE", "Extensions > Store > Installing an add-on from inside the suite");
    public static final Unbuilt EXT_SCANCHECK = of("OT-EXT-SCANCHECK", "Extensions > Custom scan checks > Running saved checks during an audit");
    public static final Unbuilt EXT_SCRIPTS = of("OT-EXT-SCRIPTS", "Extensions > Script library > Running saved scripts from the tools");
    public static final Unbuilt DECODER_BROTLI = of("OT-DECODER-BROTLI", "Decoder > Encoding as brotli");

    // A built-in Android device: planned, and not in the interface yet. It is driven by the standard
    // Android Emulator with its free rootable images, fetched on first use.
    private static final String ANDROID = "Android device > ";
    public static final Unbuilt ANDROID_CT = of("OT-ANDROID-CT", ANDROID + "Proxy certificates that Android 17 accepts (Certificate Transparency, issue 46)");
    public static final Unbuilt ANDROID_TAB = of("OT-ANDROID-TAB", ANDROID + "A tab showing the device's screen, used with the mouse and keyboard");
    public static final Unbuilt ANDROID_LIBRARY = of("OT-ANDROID-LIBRARY", ANDROID + "A library of Android versions, fetched on first use, with saved states to roll back to");
    public static final Unbuilt ANDROID_PROXY = of("OT-ANDROID-PROXY", ANDROID + "The device started with the proxy set and the CA in its system store");
    public static final Unbuilt ANDROID_FRIDA = of("OT-ANDROID-FRIDA", ANDROID + "Frida on the device, with a script that skips emulator and root checks");
    public static final Unbuilt ANDROID_SHELL = of("OT-ANDROID-SHELL", ANDROID + "A root shell on the device in a tab, and installing an APK by dropping it");

    // 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_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");
    public static final Unbuilt SCAN_POINTS_ARRAY = of("OT-SCAN-POINTS-ARRAY", SCAN + "Insertion points strategy > Array insertion points");
    public static final Unbuilt SCAN_POINTS_LIMIT = of("OT-SCAN-POINTS-LIMIT", SCAN + "Insertion points strategy > Insertion point limits");
    public static final Unbuilt SCAN_CHECKS = of("OT-SCAN-CHECKS", SCAN + "Scan checks > Applying the ticked checks to this scan only");
    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 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");
    public static final Unbuilt SCAN_POINTS_RELOCATE = of("OT-SCAN-POINTS-RELOCATE", SCAN + "Insertion points strategy > Payload relocation rules");
    public static final Unbuilt SCAN_BROWSER = of("OT-SCAN-BROWSER", SCAN + "Browser behaviour > Out-of-scope resources, and Read timeout for site resources");
    public static final Unbuilt SCAN_CLICKS = of("OT-SCAN-CLICKS", SCAN + "Discovery logic > Click all pointer clickable elements, and Application uses fragments for routing");
    public static final Unbuilt SCAN_JAVASCRIPT = of("OT-SCAN-JAVASCRIPT", SCAN + "JavaScript analysis > Static analysis, missing site resources and the two time limits");

    /** Where a whole group is found, said once under its heading on the roadmap; null for a group that needs none. */
    public static String where(String group) {
        return "Scan configuration".equals(group)
                ? "All of these are on one page: Dashboard > New scan > Scan configuration, with Custom chosen in the list. "
                  + "Each entry names the page in the list on the left, then the section. The controls are there but greyed out. "
                  + "In the code the page is `src/opensuite/dashboard/ScanConfigPanel.java`, and its `notYet(...)` call lists the greyed controls."
                : "Android device".equals(group)
                ? "Planned, and not in the interface yet: an Android device inside Open Suite, for testing mobile apps without a phone. "
                  + "It runs the standard Android Emulator with its free rootable images, and comes up already set to send its traffic through the proxy."
                : null;
    }


    public String code()     { return code; }
    public String location() { return location; }

    /** The tool/group this feature belongs to, for grouping on the roadmap. */
    public String group() {
        int i = location.indexOf(" > ");
        return i < 0 ? location : location.substring(0, i);
    }

    /** The whole registry, in declaration order: the roadmap. */
    public static List<Unbuilt> all() {
        return java.util.Collections.unmodifiableList(ALL);
    }

    /** The feature name without its tool prefix, as the roadmap shows it. */
    public String feature() {
        int i = location.indexOf(" > ");
        return i < 0 ? location : location.substring(i + 3);
    }

    /**
     * The roadmap as Markdown, grouped by tool in registry order. ROADMAP.md in
     * the repository is this text; regenerate it with
     * {@code java -cp build opensuite.ui.Unbuilt ROADMAP.md} after changing the
     * registry, so the file and the interface never disagree.
     */
    public static String markdown() {
        StringBuilder b = new StringBuilder();
        b.append("# Roadmap\n\n");
        b.append("Open Suite is developed in the open. Each feature below is present in the interface ")
         .append("but not yet implemented. To implement one, open a pull request on ")
         .append("[the main project](").append(PROJECT_URL).append("). Accepted work is ")
         .append("merged with full credit. To discuss a feature or request prioritisation, ")
         .append("[open an issue](").append(PROJECT_URL).append("/issues).\n\n");
        b.append("Reference codes are stable: quote one in an issue or pull request title. ")
         .append("Large features are split so that each entry can be completed independently.\n\n");
        b.append("This file is generated from the registry in `src/opensuite/ui/Unbuilt.java`, ")
         .append("which also drives the Roadmap tab under Discover; do not edit it by hand.\n");
        String group = null;
        for (Unbuilt u : ALL) {
            String g = u.location.contains(" > ") ? u.group() : "Suite";
            if (!g.equals(group)) {
                group = g;
                b.append("\n## ").append(g).append("\n\n");
                if (where(g) != null) b.append(where(g)).append("\n\n");
                b.append("| Feature | Reference |\n|---|---|\n");
            }
            b.append("| ").append(u.feature()).append(" | `").append(u.code).append("` |\n");
        }
        b.append("\n").append(ALL.size()).append(" open items.\n");
        return b.toString();
    }

    /** Write the roadmap to the file named on the command line (or print it). */
    public static void main(String[] args) throws java.io.IOException {
        if (args.length == 0) { System.out.print(markdown()); return; }
        java.nio.file.Files.writeString(java.nio.file.Path.of(args[0]), markdown());
    }

    /** The clipboard payload: the lines a developer needs to find and build the feature. */
    private String prompt() {
        return "Open Suite (Java/Swing security testing suite, OWASP ZAP engine).\n"
             + "Implement: " + location + "  [" + code + "].\n"
             + "Currently a UI placeholder, not wired to the engine.";
    }

    /** Wire a control so using it opens the dialog. Keeps the control enabled. */
    public void attach(AbstractButton b) {
        b.setToolTipText("not yet implemented - click to contribute");
        b.addActionListener(e -> showDialog(b));
    }

    /** Open the modal "not yet implemented" dialog near the given component. */
    public void showDialog(Component near) {
        Window owner = near == null ? null : SwingUtilities.getWindowAncestor(near);
        final JDialog d = new JDialog(owner, "Not yet implemented", Dialog.ModalityType.APPLICATION_MODAL);
        d.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        JPanel content = content();
        content.setBorder(Ui.pad(20, 24, 18, 24));

        JButton close = Ui.button("Close");
        close.addActionListener(e -> d.dispose());
        JPanel bar = buttonBar(near, close);
        content.add(Box.createVerticalStrut(16));
        content.add(bar);

        d.setContentPane(content);
        d.pack();
        // Roomy: wide enough that nothing wraps awkwardly, tall enough to show
        // every line in full, and never smaller than its packed size.
        Dimension packed = d.getSize();
        d.setSize(Math.max(760, packed.width), packed.height + 24);
        d.setMinimumSize(d.getSize());
        d.setResizable(true);
        d.setLocationRelativeTo(near);
        d.setVisible(true);
    }

    /** An inline placeholder panel for a whole empty area (e.g. an unbuilt pane). */
    public JComponent panel() {
        return panel(true);
    }

    /**
     * The inline placeholder, centred in its area when {@code centred}, or as a
     * compact left-aligned block to drop into a page of other sections.
     */
    public JComponent panel(boolean centred) {
        JPanel body = content();
        body.add(Box.createVerticalStrut(14));
        body.add(buttonBar(body, null));
        body.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createLineBorder(Ui.GRID), Ui.pad(18, 20, 18, 20)));
        body.setMaximumSize(new Dimension(720, Integer.MAX_VALUE));
        if (!centred) {
            JPanel wrap = new JPanel(new BorderLayout());
            wrap.setOpaque(false);
            wrap.add(body, BorderLayout.WEST);
            return wrap;
        }
        JPanel wrap = new JPanel(new GridBagLayout());
        wrap.setOpaque(false);
        wrap.setBorder(Ui.pad(24, 24, 24, 24));
        wrap.add(body, new GridBagConstraints());
        return wrap;
    }

    /** The shared message + reference + location + copy-text block. */
    private JPanel content() {
        JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        p.setOpaque(false);

        JLabel h = Ui.heading(location + "  -  not yet implemented");
        h.setAlignmentX(Component.LEFT_ALIGNMENT);
        p.add(h);
        p.add(Box.createVerticalStrut(8));

        // Sized by rows and columns so its preferred height is honest: a wrapping
        // text area otherwise reports a single line and gets clipped when packed.
        JTextArea note = new JTextArea(
            "This feature is on the Open Suite roadmap and has not been implemented "
          + "yet. Open Suite is free and open source, built by its community. "
          + "Contributions are welcome: implement it and open a pull request on the "
          + "main project, where it will be reviewed and merged with full credit as an "
          + "Open Suite contributor. To discuss it or request prioritisation, "
          + "open an issue on the project.", 5, 56);
        note.setFont(Ui.PLAIN);
        note.setEditable(false);
        note.setOpaque(false);
        note.setLineWrap(true);
        note.setWrapStyleWord(true);
        note.setBorder(null);
        note.setFocusable(false);
        note.setAlignmentX(Component.LEFT_ALIGNMENT);
        note.setMaximumSize(new Dimension(Integer.MAX_VALUE, note.getPreferredSize().height));
        p.add(note);
        p.add(Box.createVerticalStrut(12));

        JPanel refs = Ui.form(
            "Reference", monoValue(code),
            "Location",  Ui.label(location));
        refs.setAlignmentX(Component.LEFT_ALIGNMENT);
        refs.setMaximumSize(new Dimension(580, refs.getPreferredSize().height));
        p.add(refs);
        p.add(Box.createVerticalStrut(10));

        JLabel copyHint = Ui.label("\"Copy details\" puts exactly this on the clipboard:");
        copyHint.setForeground(Theme.MUTED);
        copyHint.setAlignmentX(Component.LEFT_ALIGNMENT);
        p.add(copyHint);
        p.add(Box.createVerticalStrut(4));

        // Shown in full, never scrolled or clipped, so what the user sees is
        // precisely what gets copied.
        String text = prompt();
        JTextArea prompt = new JTextArea(text, text.split("\n").length, 1);
        prompt.setFont(Ui.MONO);
        prompt.setEditable(false);
        prompt.setLineWrap(false);
        prompt.setOpaque(true);
        prompt.setBackground(Theme.SURFACE);
        prompt.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createLineBorder(Ui.GRID), Ui.pad(8, 10, 8, 10)));
        prompt.setAlignmentX(Component.LEFT_ALIGNMENT);
        Dimension pd = prompt.getPreferredSize();
        prompt.setPreferredSize(new Dimension(Math.max(540, pd.width), pd.height));
        prompt.setMaximumSize(new Dimension(Integer.MAX_VALUE, pd.height));
        p.add(prompt);
        return p;
    }

    /** Copy / GitHub (and optional Close) row. */
    private JPanel buttonBar(Component near, JButton trailing) {
        JButton copy = Ui.primaryButton("Copy details", "Copy the build note to the clipboard");
        copy.addActionListener(e -> {
            Toolkit.getDefaultToolkit().getSystemClipboard()
                    .setContents(new StringSelection(prompt()), null);
            String was = copy.getText();
            copy.setText("Copied");
            Timer t = new Timer(1200, ev -> copy.setText(was));
            t.setRepeats(false);
            t.start();
        });
        JButton github = Ui.button("Open project on GitHub", "open the Open Suite project page");
        github.addActionListener(e -> openProject(near));

        JPanel bar = new JPanel(new FlowLayout(FlowLayout.LEFT, 8, 0));
        bar.setOpaque(false);
        bar.setAlignmentX(Component.LEFT_ALIGNMENT);
        bar.add(copy);
        bar.add(github);
        if (trailing != null) bar.add(trailing);
        bar.setMaximumSize(new Dimension(640, bar.getPreferredSize().height));
        return bar;
    }

    private static JLabel monoValue(String s) {
        JLabel l = new JLabel(s);
        l.setFont(Ui.MONO);
        return l;
    }

    /** Open the project page in a browser, or copy the URL if that is not possible. */
    public static void openProject(Component near) {
        try {
            if (Desktop.isDesktopSupported()
                    && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
                Desktop.getDesktop().browse(java.net.URI.create(PROJECT_URL));
                return;
            }
        } catch (Exception ignore) {
            // fall through to the clipboard fallback
        }
        Toolkit.getDefaultToolkit().getSystemClipboard()
                .setContents(new StringSelection(PROJECT_URL), null);
        JOptionPane.showMessageDialog(near,
                "Could not open a browser.\nThe project URL has been copied to the clipboard:\n" + PROJECT_URL,
                "Open project", JOptionPane.INFORMATION_MESSAGE);
    }
}