sonarqubesonarqube-api

How to use a union operator in SonarQube web services?


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.


Solution

  • 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.