r/StackoverReddit • • Jun 11 '24

Question How do I interpret GitHub CodeQL CLI results?

It's my first time trying out CodeQL. I've setup a few Python scripts for analysis via the CLI. I ran the create database command and analyze command with a queries that look for the top 25 CWEs by MITRE, and specified that the results should be a CSV file. My issue is interpreting the results. The severity levels I got are only {'error', 'warning'}. I expected {'critical', 'high', 'medium', 'low'}. I read https://github.blog/changelog/2021-07-19-codeql-code-scanning-new-severity-levels-for-security-alerts/ and https://docs.github.com/en/code-security/code-scanning/managing-code-scanning-alerts/about-code-scanning-alerts but I'm still not clear on what these results mean. Are 'error' and 'warning' necessarily about security here? I am only interested in security vulnerabilities and I only used queries that look specifically for CWEs. My assumption based on what I read is that error = {critical and high} and warning = {medium and low} and note = none.

2 Upvotes

2 comments sorted by

1

u/chrisrko Moderator Jun 12 '24

Interpreting GitHub CodeQL CLI results can be a bit confusing, especially when trying to map severity levels to the security vulnerability context. Let's break down your situation. :)

Understanding Severity Levels in CodeQL CLI

The severity levels you're seeing (error, warning, note) are specific to CodeQL and do not directly map to the more detailed severity levels (critical, high, medium, low) used in some other contexts, such as the GitHub Code Scanning alerts. Here's a basic mapping of how CodeQL CLI results can be interpreted:

  1. Error: Indicates issues that are generally considered more severe and should be addressed promptly. These may correspond to critical or high severity in the context of security vulnerabilities.
  2. Warning: Represents issues that are less severe but still important to address. These can correspond to medium or low severity in security contexts.
  3. Note: These are usually informational and might not correspond to direct security vulnerabilities.

Mapping CodeQL Results to Security Context

Given your specific interest in security vulnerabilities and your use of queries focusing on the top 25 CWEs by MITRE, it's important to correctly interpret the severity of the findings:

  • Error: Likely corresponds to critical and high severity vulnerabilities.
  • Warning: Likely corresponds to medium and low severity vulnerabilities.
  • Note: Typically informational and may not correspond to security vulnerabilities directly.

Practical Steps to Interpret Your Results

  1. Review the Queries: Ensure the queries you ran are specifically designed to detect security issues. CodeQL has a repository of security-focused queries, and it's important to use those to get relevant results.
  2. Check Documentation: Refer to the CodeQL documentation or the specific queries' documentation to understand what each result implies. This will give you a better idea of the severity and nature of each finding.
  3. Severity Levels in Context: If you want to align the results with the critical, high, medium, low severity levels, consider this general guideline:

    • Error: Treat these as critical or high.
    • Warning: Treat these as medium or low.
    • Note: Typically not mapped to a severity level in the security context.

Further Clarification

If the above mapping doesn't provide enough clarity, you can also:

  • Use the CodeQL Dashboard: If you have access to the GitHub Advanced Security dashboard, it provides a more detailed and refined view of the results, including the critical, high, medium, low severity levels directly.
  • Custom Analysis: Consider writing custom scripts or using additional tools to parse the CSV results and categorize them based on the severity mappings that fit your security context.

1

u/chrisrko Moderator Aug 08 '24

INFO!!! We are moving to r/stackoverflow !!!!

We want everybody to please be aware that all future posts and updates from us will from now on be on r/stackoverflow

We made an appeal to gain ownershift of r/stackoverflow because it has been abandoned, and it got granted!!

So please migrate with us to our new subreddit r/stackoverflow ;)