Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report AutoFix Results #773

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/salus/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,17 @@ def to_cyclonedx(config = {})
bugsnag_notify(e.class.to_s + " " + e.message + "\nBuild Info:" + @builds.to_s)
end

def to_auto_fix
auto_fixes = {}
file_names = ["yarn-autofixed.lock", "package-autofixed.json"]
file_names.each do |file_name|
if File.exist?("/home/repo/#{file_name}")
auto_fixes[file_name] = File.read("/home/repo/#{file_name}")
end
end
JSON.pretty_generate(auto_fixes)
end

def publish_report(directive)
# First create the string for the report.
uri = directive['uri']
Expand All @@ -283,6 +294,7 @@ def publish_report(directive)
when 'sarif_diff' then to_sarif_diff
when 'sarif_diff_full' then to_full_sarif_diff
when 'cyclonedx-json' then to_cyclonedx(directive['cyclonedx_options'] || {})
when 'auto_fix' then to_auto_fix
else
raise ExportReportError, "unknown report format #{directive['format']}"
end
Expand Down Expand Up @@ -405,9 +417,13 @@ def report_body(config)
to_full_sarif_diff
when 'cyclonedx-json'
to_cyclonedx(config['cyclonedx_options'] || {})
when 'auto_fix'
to_auto_fix
end

if %w[json sarif sarif_diff sarif_diff_full cyclonedx-json].include?(config['format'])
if %w[json sarif sarif_diff sarif_diff_full cyclonedx-json auto_fix].include?(
config['format']
)
body = JSON.parse(body)
return JSON.pretty_generate(report_body_hash(config, body))
end
Expand Down