A terminal-first approach to CodeQL multi-repo variant analysis
Project description
mrva
mrva is a terminal-first approach to CodeQL multi-repo variant analysis. You can download existing CodeQL databases from the GitHub API, run variant analyses, and view results all from your local machine. This tool was inspired by the VSCode CodeQL extension, but instead runs as a standalone CLI tool.
Table of contents:
Installing
Currently mrva must be installed from the git source. If/when it is open sourced we will upload it to PyPI.
To install:
$ git clone https://github.com/trailofbits/mrva.git
$ python -m pip install mrva/
$ mrva -h
Using
mrva has the following command tree:
mrvadownloadtoporgrepoqueryfrom-file
analyzepprintprint-ast(experimental)
Using mrva generally requires three steps:
- Downloading existing CodeQL databases from the GitHub API
- Running CodeQL variant analyses against these databases
- Viewing the results
First, ensure you have a codeql binary in your $PATH (releases here).
Next, create a directory to store mrva data:
$ mkdir dbs/
This directory will eventually contain CodeQL databases, tool configuration, SARIF results, and other information mrva needs to operate.
Use the mrva download command to download CodeQL databases:
$ mrva download --token $GITHUB_TOKEN --language ruby dbs/ top --limit 100
[!NOTE]
downloadwill automatically use the$GITHUB_TOKENenvironment variable if it's available.
This command will download CodeQL databases of the top 100 GitHub Ruby projects (by star count). You can download other databases by specifying a different --language, or using a different download strategy like download org or download repo.
Use the mrva analyze command to analyze the downloaded databases:
$ mrva analyze dbs/ /path/to/queries -- --rerun --threads=0
Any flags included after -- are passed directly to the CodeQL binary.
[!NOTE]
mrvarecommends using the--threadsflag to process multiple queries within a single CodeQL analysis instead of parallelizing multiple CodeQL analyses. This prevents contention betweenmrvaand CodeQL.
Use the mrva pprint command to view analysis results:
$ mrva pprint dbs/
You can also use the pprint command to print raw CodeQL SARIF results:
$ codeql database analyze \
--format sarif-latest \
--sarif-add-file-contents \
--output output.sarif \
-- db/ query.ql
$ mrva pprint output.sarif
Many of these commands take additional flags to modify their functionality. For example, analyze and pprint take --select and --ignore flags to filter repositories. Use the --help flag to explore all functionality provided by a given command.
Developing
mrva uses poetry for dependency and configuration management.
Before proceeding, install project dependencies with the following command:
$ poetry install --with dev
[!NOTE] When running
mrva analyzein the Poetry environment you may need to pass--topoetry runlikepoetry run -- mrva analyze. This prevents Poetry from getting confused about which arguments are its arguments,mrva's arguments, andcodeql's arguments.
Linting
Lint all project files with the following command:
$ poetry run pre-commit run --all-files
Testing
Run Python tests with the following command:
$ poetry run pytest --cov
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mrva-0.5.0.tar.gz.
File metadata
- Download URL: mrva-0.5.0.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
216b147141409349541c33253e3fb0b2c38d50853e5dcabdccd795789e61f548
|
|
| MD5 |
482bc1d34e4ab4d8a8485200e6a16c3a
|
|
| BLAKE2b-256 |
efd6b84196d9d475904cda1d5e237c97840e49d2ff15ee23310ea6537044d243
|
Provenance
The following attestation bundles were made for mrva-0.5.0.tar.gz:
Publisher:
release.yml on trailofbits/mrva
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mrva-0.5.0.tar.gz -
Subject digest:
216b147141409349541c33253e3fb0b2c38d50853e5dcabdccd795789e61f548 - Sigstore transparency entry: 757883012
- Sigstore integration time:
-
Permalink:
trailofbits/mrva@d14997158d24da8ecda06f7e1b3eca93c8dc2784 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/trailofbits
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d14997158d24da8ecda06f7e1b3eca93c8dc2784 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mrva-0.5.0-py3-none-any.whl.
File metadata
- Download URL: mrva-0.5.0-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ace0878cfebae97c6783eb0200f0cee723696c1d075f0194cf1a88bad5c70a22
|
|
| MD5 |
85442a6df71c2557c196a8154c9dc708
|
|
| BLAKE2b-256 |
367762dda67167b57e39fce4d2ae0ba279dcc128bbf8cd9520ca89e7e4b7893b
|
Provenance
The following attestation bundles were made for mrva-0.5.0-py3-none-any.whl:
Publisher:
release.yml on trailofbits/mrva
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mrva-0.5.0-py3-none-any.whl -
Subject digest:
ace0878cfebae97c6783eb0200f0cee723696c1d075f0194cf1a88bad5c70a22 - Sigstore transparency entry: 757883019
- Sigstore integration time:
-
Permalink:
trailofbits/mrva@d14997158d24da8ecda06f7e1b3eca93c8dc2784 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/trailofbits
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d14997158d24da8ecda06f7e1b3eca93c8dc2784 -
Trigger Event:
push
-
Statement type: