Skip to content

Misc: Add script creating DCA source suites from MRVA #19232

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tausbn
Copy link
Contributor

@tausbn tausbn commented Apr 7, 2025

The script takes the URL of a MRVA exported Gist and uses it to produce a source suite compatible with DCA.

At present, you have to manually specify the language on the commandline, using the --language parameter.

Also supports --min and --max parameters if you want to limit the sources to ones with a bounded number of alerts.

The script takes the URL of a MRVA exported Gist and uses it to produce
a source suite compatible with DCA.

At present, you have to manually specify the language on the
commandline, using the `--language` parameter.

Also supports `--min` and `--max` parameters if you want to limit the
sources to ones with a bounded number of alerts.
@tausbn tausbn added the no-change-note-required This PR does not need a change note label May 1, 2025
@tausbn tausbn marked this pull request as ready for review May 1, 2025 13:17
@Copilot Copilot AI review requested due to automatic review settings May 1, 2025 13:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a Python script to convert a MRVA-exported GitHub Gist into a DCA-compatible source suite, with support for specifying the analysis language and filtering by alert count.

  • Introduces mrva-to-dca-source-suite.py to clone a MRVA Gist, parse its summary, and generate a YAML source suite
  • Adds command-line arguments --language, --min, and --max
  • Implements parsing for repo alert counts and SHA extraction to populate the suite
Comments suppressed due to low confidence (3)

misc/scripts/mrva-to-dca-source-suite.py:6

  • The import defaultdict is never used in this script. Please remove it to avoid unused imports.
from collections import defaultdict

misc/scripts/mrva-to-dca-source-suite.py:56

  • [nitpick] The variable name d is ambiguous. Consider renaming it to alert_counts or a more descriptive name.
        d = {}

misc/scripts/mrva-to-dca-source-suite.py:108

  • The filtering logic for filtered_alerts (min/max bounds) isn't covered by existing tests; please add unit tests validating boundary conditions.
    filtered_alerts = {


help_text = """
To use this script, pass the URL of a GitHub Gist as an argument. The Gist should contain the
exported MarkDown output of a MRVA run.
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term "MarkDown" should be capitalized as "Markdown" for consistency with common usage.

Suggested change
exported MarkDown output of a MRVA run.
exported Markdown output of a MRVA run.

Copilot uses AI. Check for mistakes.

repo_alerts = get_repo_alert_counts(repo_dir)
repo_nwo_shas = get_repo_nwo_shas(repo_dir)

min_count = args.min if args.min else min(repo_alerts.values())
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using if args.min treats 0 as unset. Use if args.min is not None to correctly handle a --min 0 argument.

Suggested change
min_count = args.min if args.min else min(repo_alerts.values())
min_count = args.min if args.min is not None else min(repo_alerts.values())

Copilot uses AI. Check for mistakes.

repo_nwo_shas = get_repo_nwo_shas(repo_dir)

min_count = args.min if args.min else min(repo_alerts.values())
max_count = args.max if args.max else max(repo_alerts.values())
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using if args.max treats 0 as unset. Use if args.max is not None to correctly handle a --max 0 argument.

Suggested change
max_count = args.max if args.max else max(repo_alerts.values())
max_count = args.max if args.max is not None else max(repo_alerts.values())

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant