diff --git a/lib/brakeman/report/report_sarif.rb b/lib/brakeman/report/report_sarif.rb index 905087742..7f3545f3a 100644 --- a/lib/brakeman/report/report_sarif.rb +++ b/lib/brakeman/report/report_sarif.rb @@ -19,7 +19,6 @@ def runs :rules => rules, }, }, - :artifacts => artifacts, :results => results, }, ] @@ -50,17 +49,6 @@ def rules end end - def artifacts - @artifacts ||= unique_locations.map do |location| - { - :location => { - :uri => location, - :uriBaseId => '%SRCROOT%', - } - } - end - end - def results @results ||= all_warnings.map do |warning| rule_id = render_id warning @@ -76,7 +64,6 @@ def results :artifactLocation => { :uri => warning.file.relative, :uriBaseId => '%SRCROOT%', - :index => unique_locations.index { |l| l == warning.file.relative }, }, :region => { :startLine => warning.line.is_a?(Integer) ? warning.line : 1, @@ -103,10 +90,6 @@ def unique_warnings @unique_warnings ||= all_warnings.uniq { |w| w.warning_code } end - def unique_locations - @unique_locations ||= all_warnings.map { |w| w.file.relative }.uniq - end - def render_id warning # Include alpha prefix to provide 'compiler error' appearance "BRAKE#{'%04d' % warning.warning_code}" # 46 becomes BRAKE0046, for example diff --git a/test/tests/sarif_output.rb b/test/tests/sarif_output.rb index 656a5016d..267ef6564 100644 --- a/test/tests/sarif_output.rb +++ b/test/tests/sarif_output.rb @@ -16,8 +16,8 @@ def test_runs_shape assert runs = @@sarif['runs'] assert_equal 1, runs.length - # The single run contains tool, artifacts, and results - assert_equal runs[0].keys, ['tool', 'artifacts', 'results'] + # The single run contains tool, and results + assert_equal runs[0].keys, ['tool', 'results'] # The single run contains a single tool assert_equal 1, runs[0]['tool'].length @@ -67,15 +67,6 @@ def test_rules_shape assert_equal rules.length, rules.map{ |rule| rule['id'] }.uniq.length end - def test_artifacts_shape - assert artifacts = @@sarif.dig('runs', 0, 'artifacts') - artifacts.each do |artifact| - assert artifact['location']['uri'] - assert artifact['location']['uriBaseId'] - assert_equal artifact['location']['uriBaseId'], '%SRCROOT%' - end - end - def test_results_shape assert results = @@sarif.dig('runs', 0, 'results') results.each do |result| @@ -97,10 +88,6 @@ def test_results_shape # Each location has a physical location, ... assert location['physicalLocation'] - # Each location maps onto an artifact - assert artifact = location['physicalLocation']['artifactLocation'] - assert_equal artifact['uri'], @@sarif.dig('runs', 0, 'artifacts', artifact['index'], 'location', 'uri') - # Each location has a region assert location['physicalLocation']['region']['startLine'] end