Skip to content
Tutorials Center
My learning

Topics

Lesson 22 of 37 ยท Security Hotspots

OWASP Top 10, CWE and SonarQube Security Reports

See how SonarQube rules map to OWASP Top 10 categories and CWE weaknesses, how to read the security reports, and how to group findings by category with a runnable stand-in.

Security teams rarely ask "how many issues do we have?" They ask "are we exposed to the OWASP Top 10?" or "which CWE weaknesses appear in this release?" SonarQube tags every security rule with the standards it relates to, so findings can be grouped by those standards instead of by rule key.

This lesson explains the tags, how to filter by them, what the security report pages show, and how to build the same grouping yourself. Report availability differs by edition, so check your server; the concepts below are the same everywhere.

Two vocabularies

CWE (Common Weakness Enumeration) is a numbered catalogue of software weakness types. For example CWE-89 is SQL injection, CWE-79 is cross-site scripting, CWE-798 is use of hard-coded credentials, CWE-327 is use of a broken or risky cryptographic algorithm. A rule can reference one or several CWEs.

OWASP Top 10 is a ranked list of the ten most critical web application risk categories. The 2021 edition is: A01 Broken Access Control, A02 Cryptographic Failures, A03 Injection, A04 Insecure Design, A05 Security Misconfiguration, A06 Vulnerable and Outdated Components, A07 Identification and Authentication Failures, A08 Software and Data Integrity Failures, A09 Security Logging and Monitoring Failures, A10 Server-Side Request Forgery. Older editions (2017) use different numbers, and SonarQube can show more than one edition.

CWEs roll up into OWASP categories, which is why a single SQL injection vulnerability appears under both CWE-89 and A03 Injection.

Weakness found CWE OWASP Top 10 2021
SQL built from user input CWE-89 A03 Injection
Hard-coded password CWE-798 A07 Identification and Authentication Failures
MD5 for passwords CWE-327 A02 Cryptographic Failures
Clear-text HTTP CWE-319 A02 Cryptographic Failures
Permissive CORS CWE-346 A05 Security Misconfiguration

Mapping tables are a convenience, not a proof. A rule marked A03 does not find all injection problems, and a clean A03 column does not mean the application is safe. Treat the reports as a way to organise findings, alongside code review, testing and threat modelling.

Filtering by standard

In the Issues page the left sidebar has a Security Category (or Standards) filter. You can pick one OWASP category or a CWE and see only matching vulnerabilities. The Security Hotspots page has a category filter too. The Web API supports the same idea with parameters such as owaspTop10-2021=a3 or cwe=89 on /api/issues/search; check the parameter names against your server's API documentation page (/web_api), since they can change between versions.

Security reports

A project can show a Security Reports page. It lists each OWASP category with the number of vulnerabilities, the number of hotspots (and how many are reviewed), and a security rating per category. The rating of a category uses the same A-to-E scale as the project, but is calculated only from findings in that category. Some editions add regulatory-style reports such as PCI DSS and OWASP ASVS; those are tied to higher editions.

How to read it:

  • A category with vulnerabilities and rating D or E needs action first.
  • A category with only unreviewed hotspots needs a review session, not a code change.
  • An all-A column is a good sign, but only for what static analysis can see.

Stand-in: group findings by standard

SonarQube does this grouping on the server. The block below does the same job on a list of findings, so you can see exactly what "count by OWASP category with a rating" means.

JS Stand-in: findings by OWASP category

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The rating column follows the SonarQube rule of thumb: the worst vulnerability sets the letter (blocker = E, critical = D, major = C, minor = B, none = A). Hotspots never change it.

Stand-in: CWE lookup helper

Teams often paste a CWE number from a pentest report and want to know where SonarQube would have flagged it. This helper keeps a small map between CWE numbers and the rule families that cover them.

JS Stand-in: from CWE number to rule family

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The last line shows an honest outcome: some CWEs have no matching rule for your language. A gap in coverage is a reason to add other tools such as dependency scanning, DAST or manual review.

Using the reports in practice

  1. Pick a standard your organisation already uses (usually OWASP Top 10 and sometimes a CWE Top list).
  2. After each release, open the report and note categories with worse than A.
  3. Sort the Issues list by that category, fix vulnerabilities, then run a hotspot review session for the rest (see Reviewing security hotspots).
  4. Export numbers through the Web API for dashboards (see Web API and automation).

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. A rule that finds SQL built from request input would most likely be tagged with which pair?

    CWE-89 is SQL injection and sits under the OWASP category A03 Injection.
  2. 2. Does an unreviewed hotspot in the A02 category lower the A02 security rating?

    Ratings are calculated from vulnerabilities; hotspots show up as a reviewed percentage.
  3. 3. What does an all-A OWASP report prove?

    Static analysis covers only what its rules can detect, so a clean report is not a safety proof.

Summary

  • CWE numbers weaknesses; OWASP Top 10 groups risk categories; SonarQube tags rules with both.
  • Filter issues and hotspots by category, and use Security Reports for a category view.
  • Category ratings come from vulnerabilities; hotspots appear as a reviewed percentage.
  • Reports are an organising tool, not a guarantee of security.

Next: Code coverage basics