Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaostrom-cb committed May 17, 2023
1 parent 9f53e8d commit 4ddcc7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/salus/scanners/brakeman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def merged_ignore_file_contents

def ignore_list
return [] unless user_supplied_ignore?
# ADDED THIS LINE UNTIL PUBLIC SALUS HAS IT

return [] unless File.exist?(@config['ignore'])
data = JSON.parse(File.read(@config['ignore']))
return [] unless data.key?('ignored_warnings')
Expand Down
10 changes: 5 additions & 5 deletions lib/sarif/base_sarif.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def uri_info
def build_result(parsed_issue)
result = {
"ruleId": parsed_issue[:id],
"ruleIndex": @mapped_rules[parsed_issue[:id]], # this is wrong
"ruleIndex": @mapped_rules[parsed_issue[:id]],
"level": sarif_level(parsed_issue[:level]),
"message": {
"text": parsed_issue[:details]
Expand Down Expand Up @@ -116,7 +116,6 @@ def build_result(parsed_issue)
def build_rule(parsed_issue)
# only include one entry per rule id
if !@mapped_rules.include?(parsed_issue[:id])
# puts "mapped rules #{@mapped_rules.keys} do not include #{parsed_issue[:id]}"
rule = {
"id": parsed_issue[:id],
"name": parsed_issue[:name],
Expand All @@ -130,7 +129,6 @@ def build_rule(parsed_issue)
"markdown": "[More info](#{parsed_issue[:help_url]})."
}
}
# puts "Setting @mapped_rules[#{parsed_issue[:id]}] to @rule_index (#{@rule_index}) vs #{@mapped_rules.size}"
@mapped_rules[parsed_issue[:id]] = @rule_index
@rule_index += 1
rule[:fullDescription][:text] = "errors reported by scanner" if rule[:id] == SCANNER_ERROR
Expand All @@ -155,7 +153,6 @@ def build_runs_object(supported)

rule = build_rule(parsed_issue)
rules << rule if rule

result = build_result(parsed_issue)

# Add suppresion object for suppressed results
Expand All @@ -173,12 +170,15 @@ def build_runs_object(supported)
# Salus::ScanReport
invocation = build_invocations(@scan_report, supported)
runs_object = {
"tool" => build_tool(rules: rules.deep_sort),
"tool" => build_tool(rules: rules.deep_sort), # we deep sort here as
# our SARIF needs to be deep sorted for easier comparisions
"conversion" => build_conversion,
"results" => results,
"invocations" => [invocation],
"originalUriBaseIds" => uri_info
}
# Ensure our ruleIndex values are correct after the
# prior deep sorting
remap_rule_ids(runs_object)
end

Expand Down

0 comments on commit 4ddcc7a

Please sign in to comment.