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.

2.1 KB
Raw Blame
package opensuite.core;

import opensuite.testkit.Expect;
import opensuite.testkit.Harness;

import java.util.List;

/** The names shown for a finding's classification numbers, and the marks a user sets on it. */
public final class ClassificationsTest {
    public void run() {
        Harness.suite("classifications");

        Harness.test("a finding's CWE and OWASP tags read as the standards' own titles", () -> {
            Issue i = Issue.builder("Cross Site Scripting (Reflected)").cwe(79).tags("OWASP_2021_A03", "WSTG-v42-INPV-01")
                    .references("https://example.org/a\nhttps://example.org/a\n\nhttps://example.org/b").build();
            List<Classifications.Entry> c = Classifications.of(i);
            Expect.equal(c.size(), 2, "its CWE entry and one Top 10 category");
            Expect.isTrue(c.get(0).label().startsWith("CWE-79: Improper Neutralization of Input"), "the CWE title");
            Expect.equal(c.get(0).link(), "https://cwe.mitre.org/data/definitions/79.html", "where the CWE entry is described");
            Expect.equal(c.get(1).label(), "OWASP Top 10 A03:2021 Injection", "the Top 10 category");
            Expect.equal(Classifications.references(i).size(), 2, "references without repeats or blank lines");
        });

        Harness.test("an unknown CWE number is still named by its number", () -> {
            Expect.equal(Classifications.of(Issue.builder("x").cwe(99999).build()).get(0).label(), "CWE-99999", "no title, no colon");
            Expect.equal(Classifications.of(Issue.builder("x").build()).size(), 0, "nothing to classify");
        });

        Harness.test("a finding marked false positive says so and keeps what it was reported as", () -> {
            Issue i = Issue.builder("x").high().build();
            Expect.equal(i.severityLabel(), "High", "as reported");
            i.setFalsePositive(true);
            Expect.equal(i.severityLabel(), "False positive", "as the user marked it");
            Expect.equal(i.severity(), Issue.Severity.HIGH, "the reported severity is kept");
            Expect.equal(i.attack(), "", "no payload unless one was sent");
        });
    }
}