diff --git a/docs/report-examples/pmd-report.sarif.json b/docs/report-examples/pmd-report.sarif.json index af3c6a7fea..cacf31ad39 100644 --- a/docs/report-examples/pmd-report.sarif.json +++ b/docs/report-examples/pmd-report.sarif.json @@ -14,10 +14,16 @@ "shortDescription": { "text": "Apex classes should declare a sharing model if DML or SOQL/SOSL is used" }, + "fullDescription": { + "text": "Detect classes declared without explicit sharing mode if DML methods are used. This forces the developer to take access restrictions into account before modifying objects." + }, "helpUri": "https://pmd.github.io/pmd/pmd_rules_apex_security.html#apexsharingviolations", "properties": { "ruleset": "Security", - "priority": 3 + "priority": 3, + "tags":[ + "Security" + ] } }, { @@ -25,10 +31,16 @@ "shortDescription": { "text": "Missing ApexDoc comment" }, + "fullDescription": { + "text": "This rule validates that: ApexDoc comments are present for classes, methods, and properties that are public or global, excluding overrides and test classes (as well as the contents of test classes)." + }, "helpUri": "https://pmd.github.io/pmd/pmd_rules_apex_documentation.html#apexdoc", "properties": { "ruleset": "Documentation", - "priority": 3 + "priority": 3, + "tags": [ + "Documentation" + ] } } ] diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLog.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLog.java index 4b2c6a448e..5da99c81e7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLog.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLog.java @@ -549,11 +549,16 @@ public class SarifLog { * The pmd priority of the rule. */ private Integer priority; + /** + * A set of distinct strings that provide additional information. This is SARIF 2.1.0 Schema. + */ + private String[] tags; @java.lang.SuppressWarnings("all") - PropertyBag(final String ruleset, final Integer priority) { + PropertyBag(final String ruleset, final Integer priority, final String[] tags) { this.ruleset = ruleset; this.priority = priority; + this.tags = tags; } @@ -563,6 +568,8 @@ public class SarifLog { private String ruleset; @java.lang.SuppressWarnings("all") private Integer priority; + @java.lang.SuppressWarnings("all") + private String[] tags; @java.lang.SuppressWarnings("all") PropertyBagBuilder() { @@ -588,15 +595,25 @@ public class SarifLog { return this; } + /** + * A set of distinct strings that provide additional information. This is SARIF 2.1.0 Schema. + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + public SarifLog.PropertyBag.PropertyBagBuilder tags(final String[] tags) { + this.tags = tags; + return this; + } + @java.lang.SuppressWarnings("all") public SarifLog.PropertyBag build() { - return new SarifLog.PropertyBag(this.ruleset, this.priority); + return new SarifLog.PropertyBag(this.ruleset, this.priority, this.tags); } @java.lang.Override @java.lang.SuppressWarnings("all") public java.lang.String toString() { - return "SarifLog.PropertyBag.PropertyBagBuilder(ruleset=" + this.ruleset + ", priority=" + this.priority + ")"; + return "SarifLog.PropertyBag.PropertyBagBuilder(ruleset=" + this.ruleset + ", priority=" + this.priority + ", tags=" + this.tags + ")"; } } @@ -621,6 +638,14 @@ public class SarifLog { return this.priority; } + /** + * A set of distinct strings that provide additional information. This is SARIF 2.1.0 Schema. + */ + @java.lang.SuppressWarnings("all") + public String[] getTags() { + return this.tags; + } + /** * The name of the rule set. * @return {@code this}. @@ -641,6 +666,16 @@ public class SarifLog { return this; } + /** + * The set of distinct strings that provide additional information. This is SARIF 2.1.0 Schema. + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + public SarifLog.PropertyBag setTags(final String[] tags) { + this.tags = tags; + return this; + } + @java.lang.Override @java.lang.SuppressWarnings("all") public boolean equals(final java.lang.Object o) { @@ -664,6 +699,11 @@ public class SarifLog { if (this$priority == null ? other$priority != null : !this$priority.equals(other$priority)) { return false; } + final java.lang.Object this$tags = this.getTags(); + final java.lang.Object other$tags = other.getTags(); + if (this$tags == null ? other$tags != null : !this$tags.equals(other$tags)) { + return false; + } return true; } @@ -681,13 +721,15 @@ public class SarifLog { result = result * PRIME + ($ruleset == null ? 43 : $ruleset.hashCode()); final java.lang.Object $priority = this.getPriority(); result = result * PRIME + ($priority == null ? 43 : $priority.hashCode()); + final java.lang.Object $tags = this.getTags(); + result = result * PRIME + ($tags == null ? 43 : $tags.hashCode()); return result; } @java.lang.Override @java.lang.SuppressWarnings("all") public java.lang.String toString() { - return "SarifLog.PropertyBag(ruleset=" + this.getRuleset() + ", priority=" + this.getPriority() + ")"; + return "SarifLog.PropertyBag(ruleset=" + this.getRuleset() + ", priority=" + this.getPriority() + ", tags=" + this.getTags() + ")"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java index 82ddf35d55..7829b3ba15 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java @@ -176,6 +176,7 @@ public class SarifLogBuilder { return ReportingDescriptor.builder() .id(rv.getRule().getName()) .shortDescription(new MultiformatMessage(rv.getDescription())) + .fullDescription(new MultiformatMessage(rv.getRule().getDescription())) .helpUri(rv.getRule().getExternalInfoUrl()) .properties(getRuleProperties(rv)) .build(); @@ -185,6 +186,7 @@ public class SarifLogBuilder { return PropertyBag.builder() .ruleset(rv.getRule().getRuleSetName()) .priority(rv.getRule().getPriority().getPriority()) + .tags(new String[] { rv.getRule().getRuleSetName() }) .build(); } diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json index f8d18a67d4..a35483cf65 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected-multiple.sarif.json @@ -14,9 +14,15 @@ "shortDescription": { "text": "blah" }, + "fullDescription": { + "text": "desc" + }, "properties": { "ruleset": "RuleSet", - "priority": 1 + "priority": 1, + "tags": [ + "RuleSet" + ] } }, { @@ -24,9 +30,15 @@ "shortDescription": { "text": "blah" }, + "fullDescription": { + "text": "desc" + }, "properties": { "ruleset": "RuleSet", - "priority": 5 + "priority": 5, + "tags": [ + "RuleSet" + ] } } ] diff --git a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected.sarif.json b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected.sarif.json index b0419d83ce..ff77f1dc34 100644 --- a/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected.sarif.json +++ b/pmd-core/src/test/resources/net/sourceforge/pmd/renderers/sarif/expected.sarif.json @@ -14,9 +14,15 @@ "shortDescription": { "text": "blah" }, + "fullDescription": { + "text": "desc" + }, "properties": { "ruleset": "RuleSet", - "priority": 5 + "priority": 5, + "tags": [ + "RuleSet" + ] } } ]