Rule ID for security hotspot?

SQ 8.6.0 accessed through web portal using Chrome 88.

On the issues page, the rule popup (e.g., I click on the “Why is this an issue?” link) includes the rule ID (e.g., “java:Sxxxx”).

When I access a security hotspot, how do I get the rule ID for the rule which triggered the hotspot?

Hi @MisterPi ,

You can open dev console, click on Networks tab, click on XHR, then refresh your page. Then click on one of the XHR calls until you find the response.

I think this is the one you want:

<SONARQUBE_HOSTNAME>/api/hotspots/show?hotspot=<insert-hotspot-key>

Then look in the response, look for the rule object and the key key. Example of output:

{
  "key": "AW9mgJw6eFC3pGl94Wrf",
  "component": {
    "key": "com.sonarsource:test-project:src/main/java/com/sonarsource/FourthClass.java",
    "qualifier": "FIL",
    "name": "FourthClass.java",
    "longName": "src/main/java/com/sonarsource/FourthClass.java",
    "path": "src/main/java/com/sonarsource/FourthClass.java"
  },
  "project": {
    "key": "com.sonarsource:test-project",
    "qualifier": "TRK",
    "name": "test-project",
    "longName": "test-project"
  },
  "rule": {
    "key": "java:S4787",
    "name": "rule-name",
    "securityCategory": "others",
    "vulnerabilityProbability": "LOW"
  },
  "status": "TO_REVIEW",
  "line": 10,
  "hash": "a227e508d6646b55a086ee11d63b21e9",
  "message": "message",
  "assignee": "joe",
  "author": "joe",
  "creationDate": "2020-01-02T15:43:10+0100",
  "updateDate": "2020-01-02T15:43:10+0100",
  "changelog": [
    {
      "user": "joe",
      "userName": "Joe",
      "creationDate": "2020-01-02T14:44:55+0100",
      "diffs": [
        {
          "key": "diff-key-0",
          "newValue": "new-value-0",
          "oldValue": "old-value-0"
        }
      ],
      "avatar": "my-avatar",
      "isUserActive": true
    },
    {
      "user": "joe",
      "userName": "Joe",
      "creationDate": "2020-01-02T14:44:55+0100",
      "diffs": [
        {
          "key": "diff-key-1",
          "newValue": "new-value-1",
          "oldValue": "old-value-1"
        }
      ],
      "avatar": "my-avatar",
      "isUserActive": true
    },
    {
      "user": "joe",
      "userName": "Joe",
      "creationDate": "2020-01-02T14:44:55+0100",
      "diffs": [
        {
          "key": "diff-key-2",
          "newValue": "new-value-2",
          "oldValue": "old-value-2"
        }
      ],
      "avatar": "my-avatar",
      "isUserActive": true
    }
  ],
  "comment": [
    {
      "key": "comment-0",
      "login": "Joe",
      "htmlText": "html text 0",
      "markdown": "markdown 0",
      "createdAt": "2020-01-02T14:47:47+0100"
    },
    {
      "key": "comment-1",
      "login": "Joe",
      "htmlText": "html text 1",
      "markdown": "markdown 1",
      "createdAt": "2020-01-02T14:47:47+0100"
    },
    {
      "key": "comment-2",
      "login": "Joe",
      "htmlText": "html text 2",
      "markdown": "markdown 2",
      "createdAt": "2020-01-02T14:47:47+0100"
    }
  ],
  "users": [
    {
      "login": "joe",
      "name": "Joe",
      "active": true
    }
  ],
  "canChangeStatus": true
}

Look in the Web API documentation for more information.

If you prefer the web API to get the hotspot key:

<SONARQUBE_HOSTNAME>/api/hotspots/search?projectKey=<insert-project-key>&p=1&ps=500&status=TO_REVIEW&onlyMine=false&sinceLeakPeriod=false

Joe