-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Append rule help text/markdown in alert view for CodeQL SARIF files #305
Append rule help text/markdown in alert view for CodeQL SARIF files #305
Comments
Hey @cwong-scw. I think one way you could achieve this would be to publish an action to GitHub's Marketplace that would perform "post-processing" of a SARIF file, before the SARIF gets uploaded to GitHub. You could use this "post-processing" step to attach additional rule help. E.g. imagine a workflow like this, note the name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 0 * * 0'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'csharp', 'java', 'javascript' ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
with:
upload: false
- name: Perform post-processing of CodeQL Analysis
uses: cwong-scw/post-process-sarif@v1
with:
sarif_file: '../results'
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: '../results'
|
Hi @swinton! Thanks for the response! We have actually taken this exact approach to supplement the SARIF file prior to upload. However, the last time that I checked it, the problem we hit was that the help text in the processed SARIF file seemed to be ignored in the upload processing, and the CodeQL .qhelp file content was used instead. This meant that any additional help contents added to the SARIF file were not shown in the code scanning alerts once uploaded. Our request here, which I can understand might be fairly low priority, is for a way to append any help text present in the SARIF rule to the main .qhelp file content generated by CodeQL during the upload processing. This would keep the valuable remediation advice from CodeQL while still allowing this to be supplemented by other tools. Do you think something like this would be possible? |
Can you please help me understand what you mean by the main .qhelp file? I'm not sure what this is referring to, and I see no mention of
You should be able to provide additional content in |
Yep no problem! Just to clarify, the .qhelp files are used by CodeQL only and are not part of the SARIF spec. Sorry for the confusion. If we use a workflow such as the example above that contains the
For example, if the post-processed rule is something like this: {
"id": "js/code-injection",
"name": "js/code-injection",
"shortDescription": {
"text": "Code injection"
},
"fullDescription": {
"text": "Interpreting unsanitized user input as code allows a malicious user arbitrary code execution."
},
"defaultConfiguration": {
"level": "error"
},
"properties": {
"tags": [
"security",
"external/cwe/cwe-094",
"external/cwe/cwe-079",
"external/cwe/cwe-116"
],
"kind": "path-problem",
"precision": "high",
"name": "Code injection",
"description": "Interpreting unsanitized user input as code allows a malicious user arbitrary\n code execution.",
"id": "js/code-injection",
"problem.severity": "error"
},
"help": {
"text": "Some help text here",
"markdown": "Some help text here"
}
} When uploaded, "Some help text here" is not shown in the code scanning alert. Instead, the help text section seems to be populated from the .qhelp file corresponding to the .ql file (e.g. https://github.com/github/codeql/blob/main/javascript/ql/src/Security/CWE-094/CodeInjection.qhelp). In the header of the help text section there is a Query field in addition to the regular Tool and Rule ID fields, with a View Source link to the corresponding .ql file (e.g. https://github.com/github/codeql/blob/main/javascript/ql/src/Security/CWE-094/CodeInjection.ql). An example of this occurring: https://github.com/cwong-scw/action-playground/security/code-scanning/225 My guess is that CodeQL rules are processed in a special manner and make use of the more expressive .qhelp templating to generate the markdown that is displayed in the help text section of code scanning alerts. I am wondering if it would be possible to append the |
@cwong-scw: unfortunately, security/code-scanning/ urls tend to be private to people w/ write access to the repository. I'm very interested in this because I'd love to generate |
In the SARIF files produced by CodeQL, the rule help text/markdown is ignored in favour of the corresponding .qhelp file content when displayed in code scanning alerts. Would it be possible to have the rule help text/markdown appended to the end of the markdown generated from the .qhelp file? This would allow any SARIF file pre-processors to enrich the displayed help text with additional material such as additional analysis results, contextual training resources, vulnerability risk ratings, etc.
The text was updated successfully, but these errors were encountered: