@@ -65,6 +65,7 @@ public class SearchRequest { | |||
private List<String> types; | |||
private List<String> owaspTop10; | |||
private List<String> sansTop25; | |||
private List<String> sonarsourceSecurity; | |||
private List<String> cwe; | |||
@CheckForNull | |||
@@ -425,6 +426,16 @@ public class SearchRequest { | |||
return this; | |||
} | |||
@CheckForNull | |||
public List<String> getSonarsourceSecurity() { | |||
return sonarsourceSecurity; | |||
} | |||
public SearchRequest setSonarsourceSecurity(@Nullable List<String> sonarsourceSecurity) { | |||
this.sonarsourceSecurity = sonarsourceSecurity; | |||
return this; | |||
} | |||
@CheckForNull | |||
public List<String> getComponentRootUuids() { | |||
return componentRootUuids; |
@@ -117,6 +117,7 @@ import static org.sonar.server.issue.index.IssueIndex.Facet.RESOLUTIONS; | |||
import static org.sonar.server.issue.index.IssueIndex.Facet.RULES; | |||
import static org.sonar.server.issue.index.IssueIndex.Facet.SANS_TOP_25; | |||
import static org.sonar.server.issue.index.IssueIndex.Facet.SEVERITIES; | |||
import static org.sonar.server.issue.index.IssueIndex.Facet.SONARSOURCE_SECURITY; | |||
import static org.sonar.server.issue.index.IssueIndex.Facet.STATUSES; | |||
import static org.sonar.server.issue.index.IssueIndex.Facet.TAGS; | |||
import static org.sonar.server.issue.index.IssueIndex.Facet.TYPES; | |||
@@ -170,6 +171,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RESOLUTIONS | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RULES; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SANS_TOP_25; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SEVERITIES; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SONARSOURCE_SECURITY; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_STATUSES; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TAGS; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TYPES; | |||
@@ -206,7 +208,8 @@ public class IssueIndex { | |||
OWASP_TOP_10(PARAM_OWASP_TOP_10, FIELD_ISSUE_OWASP_TOP_10, DEFAULT_FACET_SIZE), | |||
SANS_TOP_25(PARAM_SANS_TOP_25, FIELD_ISSUE_SANS_TOP_25, DEFAULT_FACET_SIZE), | |||
CWE(PARAM_CWE, FIELD_ISSUE_CWE, DEFAULT_FACET_SIZE), | |||
CREATED_AT(PARAM_CREATED_AT, FIELD_ISSUE_FUNC_CREATED_AT, DEFAULT_FACET_SIZE); | |||
CREATED_AT(PARAM_CREATED_AT, FIELD_ISSUE_FUNC_CREATED_AT, DEFAULT_FACET_SIZE), | |||
SONARSOURCE_SECURITY(PARAM_SONARSOURCE_SECURITY, FIELD_ISSUE_SONARSOURCE_SECURITY, DEFAULT_FACET_SIZE); | |||
private final String name; | |||
private final String fieldName; | |||
@@ -365,6 +368,7 @@ public class IssueIndex { | |||
filters.put(FIELD_ISSUE_SANS_TOP_25, createTermsFilter(FIELD_ISSUE_SANS_TOP_25, query.sansTop25())); | |||
filters.put(FIELD_ISSUE_CWE, createTermsFilter(FIELD_ISSUE_CWE, query.cwe())); | |||
addSeverityFilter(query, filters); | |||
filters.put(FIELD_ISSUE_SONARSOURCE_SECURITY, createTermsFilter(FIELD_ISSUE_SONARSOURCE_SECURITY, query.sonarsourceSecurity())); | |||
addComponentRelatedFilters(query, filters); | |||
addDatesFilter(filters, query); | |||
@@ -612,6 +616,7 @@ public class IssueIndex { | |||
if (options.getFacets().contains(PARAM_SEVERITIES)) { | |||
esSearch.addAggregation(createSeverityFacet(query, filters, esQuery)); | |||
} | |||
addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch, SONARSOURCE_SECURITY, query.sonarsourceSecurity().toArray()); | |||
if (options.getFacets().contains(PARAM_RESOLUTIONS)) { | |||
esSearch.addAggregation(createResolutionFacet(query, filters, esQuery)); | |||
} |
@@ -77,6 +77,7 @@ public class IssueQuery { | |||
private final Collection<String> owaspTop10; | |||
private final Collection<String> sansTop25; | |||
private final Collection<String> cwe; | |||
private final Collection<String> sonarsourceSecurity; | |||
private final Map<String, PeriodStart> createdAfterByProjectUuids; | |||
private final Boolean onComponentOnly; | |||
private final Boolean assigned; | |||
@@ -112,6 +113,7 @@ public class IssueQuery { | |||
this.owaspTop10 = defaultCollection(builder.owaspTop10); | |||
this.sansTop25 = defaultCollection(builder.sansTop25); | |||
this.cwe = defaultCollection(builder.cwe); | |||
this.sonarsourceSecurity = defaultCollection(builder.sonarsourceSecurity); | |||
this.createdAfterByProjectUuids = defaultMap(builder.createdAfterByProjectUuids); | |||
this.onComponentOnly = builder.onComponentOnly; | |||
this.assigned = builder.assigned; | |||
@@ -207,6 +209,10 @@ public class IssueQuery { | |||
return cwe; | |||
} | |||
public Collection<String> sonarsourceSecurity() { | |||
return sonarsourceSecurity; | |||
} | |||
public Map<String, PeriodStart> createdAfterByProjectUuids() { | |||
return createdAfterByProjectUuids; | |||
} | |||
@@ -299,6 +305,7 @@ public class IssueQuery { | |||
private Collection<String> owaspTop10; | |||
private Collection<String> sansTop25; | |||
private Collection<String> cwe; | |||
private Collection<String> sonarsourceSecurity; | |||
private Map<String, PeriodStart> createdAfterByProjectUuids; | |||
private Boolean onComponentOnly = false; | |||
private Boolean assigned = null; | |||
@@ -417,6 +424,11 @@ public class IssueQuery { | |||
return this; | |||
} | |||
public Builder sonarsourceSecurity(@Nullable Collection<String> sonarsourceSecurity) { | |||
this.sonarsourceSecurity = sonarsourceSecurity; | |||
return this; | |||
} | |||
public Builder createdAfterByProjectUuids(@Nullable Map<String, PeriodStart> createdAfterByProjectUuids) { | |||
this.createdAfterByProjectUuids = createdAfterByProjectUuids; | |||
return this; |
@@ -109,6 +109,7 @@ public class IssueQueryFactory { | |||
.owaspTop10(request.getOwaspTop10()) | |||
.sansTop25(request.getSansTop25()) | |||
.cwe(request.getCwe()) | |||
.sonarsourceSecurity(request.getSonarsourceSecurity()) | |||
.assigned(request.getAssigned()) | |||
.createdAt(parseDateOrDateTime(request.getCreatedAt())) | |||
.createdBefore(parseEndingDateOrDateTime(request.getCreatedBefore())) |
@@ -79,6 +79,7 @@ import static org.sonar.server.issue.index.IssueQueryFactory.UNKNOWN; | |||
import static org.sonar.server.issue.index.SecurityStandardHelper.SANS_TOP_25_INSECURE_INTERACTION; | |||
import static org.sonar.server.issue.index.SecurityStandardHelper.SANS_TOP_25_POROUS_DEFENSES; | |||
import static org.sonar.server.issue.index.SecurityStandardHelper.SANS_TOP_25_RISKY_RESOURCE; | |||
import static org.sonar.server.issue.index.SecurityStandardHelper.SONARSOURCE_CWE_MAPPING; | |||
import static org.sonar.server.issue.index.SecurityStandardHelper.UNKNOWN_STANDARD; | |||
import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
@@ -119,6 +120,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RULES; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SANS_TOP_25; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SEVERITIES; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SINCE_LEAK_PERIOD; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SONARSOURCE_SECURITY; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_STATUSES; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TAGS; | |||
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TYPES; | |||
@@ -146,7 +148,8 @@ public class SearchAction implements IssuesWsAction, Startable { | |||
PARAM_OWASP_TOP_10, | |||
PARAM_SANS_TOP_25, | |||
PARAM_CWE, | |||
PARAM_CREATED_AT); | |||
PARAM_CREATED_AT, | |||
PARAM_SONARSOURCE_SECURITY); | |||
private static final String INTERNAL_PARAMETER_DISCLAIMER = "This parameter is mostly used by the Issues page, please prefer usage of the componentKeys parameter. "; | |||
private static final Set<String> FACETS_REQUIRING_PROJECT_OR_ORGANIZATION = newHashSet(PARAM_MODULE_UUIDS, PARAM_FILE_UUIDS, PARAM_DIRECTORIES); | |||
@@ -257,6 +260,10 @@ public class SearchAction implements IssuesWsAction, Startable { | |||
action.createParam(PARAM_CWE) | |||
.setDescription("Comma-separated list of CWE identifiers. Use '" + UNKNOWN_STANDARD + "' to select issues not associated to any CWE.") | |||
.setExampleValue("12,125," + UNKNOWN_STANDARD); | |||
action.createParam(PARAM_SONARSOURCE_SECURITY) | |||
.setDescription("Comma-separated list of SonarSource security categories.") | |||
.setSince("7.8") | |||
.setPossibleValues(SONARSOURCE_CWE_MAPPING.keySet()); | |||
action.createParam(DEPRECATED_PARAM_AUTHORS) | |||
.setDeprecatedSince("7.7") | |||
.setDescription("This parameter is deprecated, please use '%s' instead", PARAM_AUTHOR) | |||
@@ -468,6 +475,7 @@ public class SearchAction implements IssuesWsAction, Startable { | |||
addMandatoryValuesToFacet(facets, PARAM_OWASP_TOP_10, request.getOwaspTop10()); | |||
addMandatoryValuesToFacet(facets, PARAM_SANS_TOP_25, request.getSansTop25()); | |||
addMandatoryValuesToFacet(facets, PARAM_CWE, request.getCwe()); | |||
addMandatoryValuesToFacet(facets, PARAM_SONARSOURCE_SECURITY, request.getSonarsourceSecurity()); | |||
} | |||
private static void addMandatoryValuesToFacet(Facets facets, String facetName, @Nullable Iterable<String> mandatoryValues) { | |||
@@ -542,7 +550,8 @@ public class SearchAction implements IssuesWsAction, Startable { | |||
.setTypes(request.paramAsStrings(PARAM_TYPES)) | |||
.setOwaspTop10(request.paramAsStrings(PARAM_OWASP_TOP_10)) | |||
.setSansTop25(request.paramAsStrings(PARAM_SANS_TOP_25)) | |||
.setCwe(request.paramAsStrings(PARAM_CWE)); | |||
.setCwe(request.paramAsStrings(PARAM_CWE)) | |||
.setSonarsourceSecurity(request.paramAsStrings(PARAM_SONARSOURCE_SECURITY)); | |||
} | |||
private List<String> getLogins(DbSession dbSession, @Nullable List<String> assigneeLogins) { |
@@ -906,7 +906,7 @@ public class SearchActionTest { | |||
"pullRequest", "organization", | |||
"createdAfter", "createdAt", "createdBefore", "createdInLast", "directories", "facetMode", "facets", "fileUuids", "issues", "languages", "moduleUuids", "onComponentOnly", | |||
"p", "projects", "ps", "resolutions", "resolved", "rules", "s", "severities", "sinceLeakPeriod", | |||
"statuses", "tags", "types", "owaspTop10", "sansTop25", "cwe"); | |||
"statuses", "tags", "types", "owaspTop10", "sansTop25", "cwe", "sonarsourceSecurity"); | |||
assertThat(def.param("organization")) | |||
.matches(WebService.Param::isInternal) |