Skip to content

Commit

Permalink
Add categories for the parsers.
Browse files Browse the repository at this point in the history
Parsers now have a category to simplify the adaption in the user
interface.
  • Loading branch information
uhafner committed Oct 5, 2024
1 parent e3b088d commit 55abb91
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ public String getHelp() {
public String getUrl() {
return "https://github.com/arminc/clair-scanner";
}

@Override
public Type getType() {
return Type.VULNERABILITY;

Check warning on line 39 in src/main/java/edu/hm/hafner/analysis/registry/ClairDescriptor.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/edu/hm/hafner/analysis/registry/ClairDescriptor.java#L39

Added line #L39 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import edu.hm.hafner.analysis.parser.CodeCheckerParser;

/**
* A descriptor for the Codechecker parser.
* A descriptor for the CodeChecker parser.
*
*/
class CodeCheckerDescriptor extends ParserDescriptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,9 @@ private static String getCodeFragment(final DuplicationGroup duplicationGroup) {
public String getDescription(final Issue issue) {
return getDuplicateCode(issue.getAdditionalProperties());
}

@Override
public Type getType() {
return Type.DUPLICATION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ protected Collection<? extends IssueParser> createParsers() {
public String getUrl() {
return "https://errorprone.info";
}

@Override
public Type getType() {
return Type.BUG;

Check warning on line 34 in src/main/java/edu/hm/hafner/analysis/registry/ErrorProneDescriptor.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/edu/hm/hafner/analysis/registry/ErrorProneDescriptor.java#L34

Added line #L34 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ public String getPattern() {
public String getDescription(final Issue issue) {
return messages.get().getMessage(issue.getType());
}

@Override
public Type getType() {
return Type.BUG;

Check warning on line 55 in src/main/java/edu/hm/hafner/analysis/registry/FindBugsDescriptor.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/edu/hm/hafner/analysis/registry/FindBugsDescriptor.java#L55

Added line #L55 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public String getHelp() {
public String getUrl() {
return "https://dwheeler.com/flawfinder/";
}

@Override
public Type getType() {
return Type.VULNERABILITY;

Check warning on line 36 in src/main/java/edu/hm/hafner/analysis/registry/FlawfinderDescriptor.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/edu/hm/hafner/analysis/registry/FlawfinderDescriptor.java#L36

Added line #L36 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ public String getUrl() {
public String getIconUrl() {
return "https://raw.githubusercontent.com/jeremylong/DependencyCheck/main/src/site/resources/images/logo.svg";
}

@Override
public Type getType() {
return Type.VULNERABILITY;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public String getName() {
return name;
}

/**
* Returns the type of the parser. The type is used to customize parsers in the UI.
* This default implementation returns {@link Type#WARNING}.
*
* @return the type of the parser
*/
public Type getType() {
return Type.WARNING;

Check warning on line 57 in src/main/java/edu/hm/hafner/analysis/registry/ParserDescriptor.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/edu/hm/hafner/analysis/registry/ParserDescriptor.java#L57

Added line #L57 was not covered by tests
}

/**
* Creates a new {@link IssueParser} instance.
*
Expand Down Expand Up @@ -138,7 +148,9 @@ public enum Type {
/** A parser that scans the output of a build tool to find bugs. */
BUG,
/** A parser that scans the output of a build tool to find vulnerabilities. */
VULNERABILITY
VULNERABILITY,
/** A parser that scans the output of a build tool to find vulnerabilities. */
DUPLICATION
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ public String getUrl() {
public String getIconUrl() {
return "https://pnpm.io/img/pnpm-no-name-with-frame.svg";
}

@Override
public Type getType() {
return Type.VULNERABILITY;

Check warning on line 47 in src/main/java/edu/hm/hafner/analysis/registry/PnpmAuditDescriptor.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/edu/hm/hafner/analysis/registry/PnpmAuditDescriptor.java#L47

Added line #L47 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ public String getUrl() {
public String getIconUrl() {
return "https://raw.githubusercontent.com/returntocorp/semgrep/develop/semgrep.svg";
}

@Override
public Type getType() {
return Type.VULNERABILITY;

Check warning on line 41 in src/main/java/edu/hm/hafner/analysis/registry/SemgrepDescriptor.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/edu/hm/hafner/analysis/registry/SemgrepDescriptor.java#L41

Added line #L41 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ public String getUrl() {
public String getIconUrl() {
return "https://raw.githubusercontent.com/spotbugs/spotbugs.github.io/master/images/logos/spotbugs_icon_only_zoom_256px.png";
}

@Override
public Type getType() {
return Type.BUG;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ public String getUrl() {
public String getIconUrl() {
return "https://github.com/aquasecurity/trivy/blob/main/docs/imgs/logo.png?raw=true";
}

@Override
public Type getType() {
return Type.VULNERABILITY;

Check warning on line 47 in src/main/java/edu/hm/hafner/analysis/registry/TrivyDescriptor.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/edu/hm/hafner/analysis/registry/TrivyDescriptor.java#L47

Added line #L47 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ public String getUrl() {
public String getIconUrl() {
return "https://upload.wikimedia.org/wikipedia/commons/0/00/Yocto_Project_logo.svg";
}

@Override
public Type getType() {
return Type.VULNERABILITY;

Check warning on line 47 in src/main/java/edu/hm/hafner/analysis/registry/YoctoScannerDescriptor.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/edu/hm/hafner/analysis/registry/YoctoScannerDescriptor.java#L47

Added line #L47 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import edu.hm.hafner.analysis.parser.violations.ZptLintAdapter;

/**
* A descriptor for the Yui Compressor parser.
* A descriptor for the ZPT Lint parser.
*
* @author Lorenz Munsch
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import edu.hm.hafner.analysis.Report;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.analysis.registry.ParserDescriptor.Option;
import edu.hm.hafner.analysis.registry.ParserDescriptor.Type;
import edu.hm.hafner.util.ResourceTest;

import static edu.hm.hafner.analysis.assertions.Assertions.*;
Expand Down Expand Up @@ -37,7 +38,8 @@ void shouldFindSomeParsers() {
var parserRegistry = new ParserRegistry();

assertThat(parserRegistry).hasIds(SPOTBUGS, CHECKSTYLE, PMD).hasNames("SpotBugs", "CheckStyle", "PMD");
assertThat(parserRegistry.get(SPOTBUGS)).hasId(SPOTBUGS).hasName("SpotBugs");
assertThat(parserRegistry.get(SPOTBUGS)).hasId(SPOTBUGS).hasName("SpotBugs").hasType(Type.BUG);
assertThat(parserRegistry.get("owasp-dependency-check")).hasName("OWASP Dependency Check").hasType(Type.VULNERABILITY);
assertThat(parserRegistry.contains(SPOTBUGS)).isTrue();
assertThat(parserRegistry.contains("nothing")).isFalse();
List<ParserDescriptor> descriptors = parserRegistry.getAllDescriptors();
Expand All @@ -49,6 +51,7 @@ void shouldFindSomeParsers() {
void shouldConfigureCpdParser() {
var parserRegistry = new ParserRegistry();
var cpdDescriptor = parserRegistry.get("cpd");
assertThat(cpdDescriptor).hasType(Type.DUPLICATION).hasName("CPD");

IssueParser parser = cpdDescriptor.createParser();

Expand Down

0 comments on commit 55abb91

Please sign in to comment.