private RuleType type;
private String engineId;
private String ruleId;
+ private String cveId;
private Map<SoftwareQuality, org.sonar.api.issue.impact.Severity> impacts = new EnumMap<>(SoftwareQuality.class);
private CleanCodeAttribute cleanCodeAttribute;
return ruleId;
}
+ public String cveId() {
+ return cveId;
+ }
+
@Override
public Severity severity() {
return this.severity;
return this;
}
+ public NewExternalIssue cveId(String cveId) {
+ this.cveId = cveId;
+ return this;
+ }
+
@Override
public DefaultExternalIssue forRule(RuleKey ruleKey) {
this.engineId = ruleKey.repository();
import org.sonar.api.batch.sensor.issue.Issue.Flow;
import org.sonar.api.batch.sensor.issue.MessageFormatting;
import org.sonar.api.batch.sensor.issue.NewIssue.FlowType;
+import org.sonar.api.batch.sensor.issue.internal.DefaultExternalIssue;
import org.sonar.api.batch.sensor.issue.internal.DefaultIssueFlow;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rules.CleanCodeAttribute;
private static boolean noSonar(DefaultInputComponent inputComponent, Issue issue) {
TextRange textRange = issue.primaryLocation().textRange();
return inputComponent.isFile()
- && textRange != null
- && ((DefaultInputFile) inputComponent).hasNoSonarAt(textRange.start().line())
- && !StringUtils.containsIgnoreCase(issue.ruleKey().rule(), "nosonar");
+ && textRange != null
+ && ((DefaultInputFile) inputComponent).hasNoSonarAt(textRange.start().line())
+ && !StringUtils.containsIgnoreCase(issue.ruleKey().rule(), "nosonar");
}
public void initAndAddExternalIssue(ExternalIssue issue) {
locationBuilder.setComponentRef(componentRef);
TextRange primaryTextRange = issue.primaryLocation().textRange();
- //nullable fields
+ // nullable fields
+ var cveId = ((DefaultExternalIssue) issue).cveId();
+ if (cveId != null) {
+ builder.setCveId(cveId);
+ }
CleanCodeAttribute cleanCodeAttribute = issue.cleanCodeAttribute();
if (cleanCodeAttribute != null) {
builder.setCleanCodeAttribute(cleanCodeAttribute.name());
return readFromReport(ScannerReportReader::readAdHocRules);
}
+ public List<ScannerReport.Cve> cves() {
+ return readFromReport(ScannerReportReader::readCves);
+ }
+
@NotNull
private <G> List<G> readFromReport(InputComponent component, BiFunction<ScannerReportReader, Integer, CloseableIterator<G>> readerMethod) {
int ref = ((DefaultInputComponent) component).scannerId();
repeated MessageFormatting msgFormatting = 9;
repeated Impact impacts = 10;
optional string cleanCodeAttribute = 11;
-
+ optional string cve_id = 12;
}
message AdHocRule {
string cve_id = 1;
string description = 2;
float cvss_score = 3;
- float epss_score = 4;
- float epss_percentile = 5;
+ optional float epss_score = 4;
+ optional float epss_percentile = 5;
int64 published_date = 6;
int64 last_modified_date = 7;
repeated string cwe = 8;