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

`--check` gives `'SarifFileSet' object has no attribute 'get_result_count_by_severity'` #77

Closed danielszot closed 1 week ago

danielszot commented 1 week ago

Seems there is regression in check command because of recent Python API change. See:

root@76bdb3291e3f:/# python3 --version
Python 3.8.10
root@76bdb3291e3f:/# sarif --version
SARIF tools v3.0.3
root@76bdb3291e3f:/# sarif --check error summary /root/2024-11-12T15\:03\:16.3207055+00\:00_vs_2024-11-12T15\:03\:38.5907415+00\:00_summary.Sarif

error: 0

warning: 2
 - SetGid: 1
 - SetUid: 1

note: 552
 - Default Level: 552
Traceback (most recent call last):
  File "/usr/local/bin/sarif", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/sarif/cmdline/main.py", line 61, in main
    exitcode = args.func(args)
  File "/usr/local/lib/python3.8/dist-packages/sarif/cmdline/main.py", line 402, in _summary_command
    return _check(input_files, args.check)
  File "/usr/local/lib/python3.8/dist-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'

The same command works fine on sarif-tools 2.0.0.

balgillo commented 1 week ago

Thanks for raising. This is fixed in the main branch but it doesn't look like the fix is in the latest release.

L230 in main.py in main branch is good: ret += input_files.get_report().get_issue_count_for_severity(severity)

L229 in main.py in 3.0.3 is bad (and 3.0.2 is broken too) counts = input_files.get_result_count_by_severity()

Tagging @debonte , possible to make a new release?

debonte commented 1 week ago

Yes, this is a duplicate of https://github.com/microsoft/sarif-tools/issues/73 which is already fixed. I'll ship a new release today.

debonte commented 1 week ago

@danielszot, I just shipped 3.0.4 with the fix for this issue.