Skip to content

Commit

Permalink
Remove artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
swinton committed Aug 24, 2020
1 parent 9fa80eb commit c981d1c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
17 changes: 0 additions & 17 deletions lib/brakeman/report/report_sarif.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def runs
:rules => rules,
},
},
:artifacts => artifacts,
:results => results,
},
]
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand Down
17 changes: 2 additions & 15 deletions test/tests/sarif_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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|
Expand All @@ -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
Expand Down

0 comments on commit c981d1c

Please sign in to comment.