microsoft / sarif-tools

A set of Python command line tools for working with SARIF files produced by code analysis tools
MIT License
91 stars 21 forks source link

Crash when using `--check` #73

Closed debonte closed 1 month ago

debonte commented 1 month ago

Regression in v3.0.0+

Repro Steps

  1. Create foo.sarif containing the JSON content below.
  2. sarif --check note info foo.sarif -- but any command (except diff) on any valid SARIF file will repro this.

Actual

c:\issues\sarif-tools\73\foo.sarif
  214 bytes (1 KiB)
  modified: 2024-10-02 18:48:19.718669, accessed: 2024-10-02 18:51:06.802777, ctime: 2024-10-02 18:36:17.301405
  1 run
    Tool: Tool
    1 result

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\test\SarifToolsTests\.venv\Scripts\sarif.exe\__main__.py", line 7, in <module>
  File "C:\test\SarifToolsTests\.venv\Lib\site-packages\sarif\cmdline\main.py", line 61, in main
    exitcode = args.func(args)
               ^^^^^^^^^^^^^^^
  File "C:\test\SarifToolsTests\.venv\Lib\site-packages\sarif\cmdline\main.py", line 381, in _info_command
    return _check(input_files, args.check)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\test\SarifToolsTests\.venv\Lib\site-packages\sarif\cmdline\main.py", line 229, in _check
    counts = input_files.get_result_count_by_severity()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SarifFileSet' object has no attribute 'get_result_count_by_severity'

Expected

This is what v2.0.0 outputs:

c:\issues\sarif-tools\73\foo.sarif
  214 bytes (1 KiB)
  modified: 2024-10-02 18:48:19.718669, accessed: 2024-10-02 18:48:24.475017, ctime: 2024-10-02 18:36:17.301405
  1 run
    Tool: Tool
    1 result

Check: exiting with return code 1 due to issues at or above note severity
{
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "Tool"
        }
      },
      "results": [
        {
          "level": "error",
          "ruleId": "rule"
        }
      ]
    }
  ]
}