2

I would like to select from all the issues I have all the blocking issues and all the vulnerability issues, which are Blocker, Critical or Major. How can I do that in one request for SonarQube 6.4? If I do

http://localhost:9000/api/issues/search
severities=BLOCKER,CRITICAL,MAJOR&type=vulnerability&additionalFields=comments

I will have the vulnerability issues only.

And if I do two requests, one for blocker issues and one for the vulnerabilities, I will have blocking vulnerabilities which are redundant.

slartidan
  • 20,403
  • 15
  • 83
  • 131
Samorix
  • 307
  • 4
  • 17

2 Answers2

3

api/issues/search does not allow to combine filters. It will "AND" all conditions together.

I assumed that you are asking about how to query for these issues:

           CODE_SMELL | BUG | VULNERABILITY
BLOCKER  | YES        | YES | YES
CRITICAL | no         | no  | YES
MAJOR    | no         | no  | YES
MINOR    | no         | no  | YES
INFO     | no         | no  | YES

So I suggest:

(for to get all BLOCKER issues of CODE_SMELL and BUG)

           CODE_SMELL | BUG | VULNERABILITY
BLOCKER  | YES        | YES | no
CRITICAL | no         | no  | no 
MAJOR    | no         | no  | no 
MINOR    | no         | no  | no
INFO     | no         | no  | no

(for to get all issues of VULNERABILITY)

           CODE_SMELL | BUG | VULNERABILITY
BLOCKER  | no         | no  | YES
CRITICAL | no         | no  | YES
MAJOR    | no         | no  | YES
MINOR    | no         | no  | YES
INFO     | no         | no  | YES

So you will not have duplicated issues, but have to do two requests.

janos
  • 120,954
  • 29
  • 226
  • 236
slartidan
  • 20,403
  • 15
  • 83
  • 131
  • I think he's looking for [this](https://gist.github.com/janos-ss/62bef28931d2393ab9f246d78aaae6ce#file-answer1). Your logic will still work, with minor adjustments to the two queries – janos Jul 18 '17 at 13:38
  • Perfect! Thank you so much, exactly what I needed, though I thought combining in a single request was possible. Ps @janos, it's a she :p – Samorix Jul 18 '17 at 15:44
0

There are three types of issues

  • BUG
  • CODE_SMELL
  • VULNERABILITY

All of this issues types can have any severity set. So, if you want all issues (of any type) with Blocker, Critical and Major severity there should be this params in your request.

severities=BLOCKER,CRITICAL,MAJOR&types=CODE_SMELL,BUG,VULNERABILITY&additionalFields=comments

Josef Prochazka
  • 1,273
  • 2
  • 9
  • 28