How to use a union operator in SonarQube web services?

99 Views Asked by At

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.

2

There are 2 best solutions below

2
On BEST ANSWER

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.

0
On

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