diff options
author | Aurelien Poscia <aurelien.poscia@sonarsource.com> | 2022-11-09 14:35:07 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-11-15 20:02:59 +0000 |
commit | 53f94935f393750ba08a7e1fa00742acadbadafb (patch) | |
tree | 647e21c0a08c735234f87979c73f961493926037 /sonar-core | |
parent | 59df4a4ad498fa1ce6df396c0b7a6afb70b7ec83 (diff) | |
download | sonarqube-53f94935f393750ba08a7e1fa00742acadbadafb.tar.gz sonarqube-53f94935f393750ba08a7e1fa00742acadbadafb.zip |
SONAR-17564 Import vulnerabilities from a SARIF report
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/sarif/Region.java | 23 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/sarif/Result.java | 17 |
2 files changed, 29 insertions, 11 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/sarif/Region.java b/sonar-core/src/main/java/org/sonar/core/sarif/Region.java index e909fceb9c3..7b4173fce8d 100644 --- a/sonar-core/src/main/java/org/sonar/core/sarif/Region.java +++ b/sonar-core/src/main/java/org/sonar/core/sarif/Region.java @@ -20,18 +20,20 @@ package org.sonar.core.sarif; import com.google.gson.annotations.SerializedName; +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; public class Region { @SerializedName("startLine") - private final int startLine; + private final Integer startLine; @SerializedName("endLine") - private final int endLine; + private final Integer endLine; @SerializedName("startColumn") - private final int startColumn; + private final Integer startColumn; @SerializedName("endColumn") - private final int endColumn; + private final Integer endColumn; - private Region(int startLine, int endLine, int startColumn, int endColumn) { + private Region(Integer startLine, @Nullable Integer endLine, @Nullable Integer startColumn, @Nullable Integer endColumn) { this.startLine = startLine; this.endLine = endLine; this.startColumn = startColumn; @@ -42,19 +44,22 @@ public class Region { return new RegionBuilder(); } - public int getStartLine() { + public Integer getStartLine() { return startLine; } - public int getEndLine() { + @CheckForNull + public Integer getEndLine() { return endLine; } - public int getStartColumn() { + @CheckForNull + public Integer getStartColumn() { return startColumn; } - public int getEndColumn() { + @CheckForNull + public Integer getEndColumn() { return endColumn; } diff --git a/sonar-core/src/main/java/org/sonar/core/sarif/Result.java b/sonar-core/src/main/java/org/sonar/core/sarif/Result.java index 60f980de875..33a9d12618f 100644 --- a/sonar-core/src/main/java/org/sonar/core/sarif/Result.java +++ b/sonar-core/src/main/java/org/sonar/core/sarif/Result.java @@ -37,14 +37,17 @@ public class Result { private final PartialFingerprints partialFingerprints; @SerializedName("codeFlows") private final List<CodeFlow> codeFlows; + @SerializedName("level") + private final String level; private Result(String ruleId, String message, LinkedHashSet<Location> locations, - @Nullable String primaryLocationLineHash, @Nullable List<CodeFlow> codeFlows) { + @Nullable String primaryLocationLineHash, @Nullable List<CodeFlow> codeFlows, @Nullable String level) { this.ruleId = ruleId; this.message = WrappedText.of(message); this.locations = locations; this.partialFingerprints = primaryLocationLineHash == null ? null : new PartialFingerprints(primaryLocationLineHash); this.codeFlows = codeFlows == null ? null : List.copyOf(codeFlows); + this.level = level; } public String getRuleId() { @@ -69,6 +72,10 @@ public class Result { return codeFlows; } + public String getLevel() { + return level; + } + public static ResultBuilder builder() { return new ResultBuilder(); } @@ -79,6 +86,7 @@ public class Result { private LinkedHashSet<Location> locations; private String hash; private List<CodeFlow> codeFlows; + private String level; private ResultBuilder() { } @@ -93,6 +101,11 @@ public class Result { return this; } + public ResultBuilder level(String level) { + this.level = level; + return this; + } + public ResultBuilder locations(Set<Location> locations) { this.locations = new LinkedHashSet<>(locations); return this; @@ -109,7 +122,7 @@ public class Result { } public Result build() { - return new Result(ruleId, message, locations, hash, codeFlows); + return new Result(ruleId, message, locations, hash, codeFlows, level); } } } |