Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Github Action that run a CodeQL security scan and generate a markdown report

License

NotificationsYou must be signed in to change notification settings

Vedza/codeql-security-report

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This action will run CodeQL rules on files in$GITHUB_WORKSPACE and checks for security issues. A markdown report is generated with the results and available in$CODEQL_MD

Usage

Here is an action that will run on every pull request, scan all the files and post the result in a comment:

name:CodeQL Security Scanon:[pull_request]jobs:build:runs-on:ubuntu-latestenv:LANGUAGE:javascriptsteps:      -uses:actions/checkout@v2      -name:Run CodeQL scanuses:themenu/codeql-security-report@master      -name:Comment PRuses:thollander/actions-comment-pull-request@masterwith:message:|           ${{ env.CODEQL_MD }}GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }}

Here is an action that will run on every pull request, scan only the files edited in the PR and post the result in a comment:

name:CodeQL Security Scanon:[pull_request]jobs:build:runs-on:ubuntu-latestenv:LANGUAGE:javascriptsteps:      -uses:actions/checkout@v2            -name:Get changed filesid:changed-filesuses:tj-actions/changed-files@v13.1              -name:Delete unedited filesid:deletecontinue-on-error:truerun:|          for file in ${{ steps.changed-files.outputs.all_changed_and_modified_files }}; do            edited="$edited ! -name ${file##*/}"          done          edited="${edited:1}"          find $GITHUB_WORKSPACE $edited -type f -exec rm -f {} +          ls -R $GITHUB_WORKSPACE          if [[ "$edited" == *".js"* ]]; then            exit 0          fi          exit 1      -name:Run CodeQL scanif:steps.delete.outcome == 'success'uses:vedza/codeql-security-report@master      -name:Comment PRif:steps.delete.outcome == 'success'uses:thollander/actions-comment-pull-request@mainwith:message:|           ${{ env.CODEQL_MD }}GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }}

Docker image issue

The docker image of this action is based onmcr.microsoft.com/cstsectools/codeql-container. But because of some issue, I had to build my own imagevedza/codeql-github-action, which use the same Dockerfile asmcr.microsoft.com/cstsectools/codeql-container.

So when the base image is updated, we will need to update the docker image to use the latest microsoft image.

Use as Github Action or as CodeQL container

Our image run our script that scan and generate the markdown report only if no$CODEQL_CLI_ARGS is passed in env.

So you can still use this image the same way asmcr.microsoft.com/cstsectools/codeql-container to run CodeQL queries if you want.

Ignore files or vulnerabilities

If you want to skip test on some files or vulnerabilities, you can add path and/or vulnerabilityid in a.sastignore file in the root of your project.

Security Report

The security report is available in$CODEQL_MD as markdown.It contains security issues split by priority, and issues in each priority level are sorted by score.You can click on the file URL to see the exact piece of code causing the security issue.

Here is an example of what the markdown report look like forNodeGoat:

NodeGoat

Security issues

High Priority

Uncontrolled data used in network request

Score:9.1Definition:Sending network requests with user-controlled data allows for request forgery attacks.ID:js/request-forgery

TitleFilePrecision
The URL of this request depends on a user-provided valueexample/NodeGoat/app/routes/research.jsMedium
Log injection

Score:7.8Definition:Building log entries from user-controlled sources is vulnerable to insertion of forged log entries by a malicious user.ID:js/log-injection

TitleFilePrecision
User-provided value flows to log entryexample/NodeGoat/app/routes/session.jsMedium
Inefficient regular expression

Score:7.5Definition:A regular expression that requires exponential time to match certain inputs can be a performance bottleneck, and may be vulnerable to denial-of-service attacks.ID:js/redos

TitleFilePrecision
This part of the regular expression may cause exponential backtracking on strings containing many repetitions of '0'example/NodeGoat/app/routes/profile.jsHigh
Polynomial regular expression used on uncontrolled data

Score:7.5Definition:A regular expression that can require polynomial time to match may be vulnerable to denial-of-service attacks.ID:js/polynomial-redos

TitleFilePrecision
This regular expression that depends on a user-provided value may run slow on strings with many repetitions of '0'example/NodeGoat/app/routes/profile.jsHigh
Uncontrolled data used in path expression

Score:7.5Definition:Accessing paths influenced by users can allow an attacker to access unexpected resources.ID:js/path-injection

TitleFilePrecision
This path depends on a user-provided valueexample/NodeGoat/app/routes/index.jsHigh

Medium Priority

Code injection

Score:6.1Definition:Interpreting unsanitized user input as code allows a malicious user arbitrary code execution.ID:js/code-injection

TitleFilePrecision
User-provided value flows to here and is interpreted as codeexample/NodeGoat/app/data/allocations-dao.jsHigh
User-provided value flows to here and is interpreted as codeexample/NodeGoat/app/routes/contributions.jsHigh
User-provided value flows to here and is interpreted as codeexample/NodeGoat/app/routes/contributions.jsHigh
User-provided value flows to here and is interpreted as codeexample/NodeGoat/app/routes/contributions.jsHigh
Server-side URL redirect

Score:6.1Definition:Server-side URL redirection based on unvalidated user input may cause redirection to malicious web sites.ID:js/server-side-unvalidated-url-redirection

TitleFilePrecision
Untrusted URL redirection due to user-provided valueexample/NodeGoat/app/routes/index.jsHigh
DOM text reinterpreted as HTML

Score:6.1Definition:Reinterpreting text from the DOM as HTML can lead to a cross-site scripting vulnerability.ID:js/xss-through-dom

TitleFilePrecision
DOM text is reinterpreted as HTML without escaping meta-charactersexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
DOM text is reinterpreted as HTML without escaping meta-charactersexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
DOM text is reinterpreted as HTML without escaping meta-charactersexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
DOM text is reinterpreted as HTML without escaping meta-charactersexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
DOM text is reinterpreted as HTML without escaping meta-charactersexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
DOM text is reinterpreted as HTML without escaping meta-charactersexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
DOM text is reinterpreted as HTML without escaping meta-charactersexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
DOM text is reinterpreted as HTML without escaping meta-charactersexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
Unsafe jQuery plugin

Score:6.1Definition:A jQuery plugin that unintentionally constructs HTML from some of its options may be unsafe to use for clients.ID:js/unsafe-jquery-plugin

TitleFilePrecision
Potential XSS vulnerability in the '$fntooltip' pluginexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
Potential XSS vulnerability in the '$fncollapse' pluginexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
Potential XSS vulnerability in the '$fnscrollspy' pluginexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh
Potential XSS vulnerability in the '$fnscrollspy' pluginexample/NodeGoat/app/assets/vendor/bootstrap/bootstrap.jsHigh

About

Github Action that run a CodeQL security scan and generate a markdown report

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp