Skip to content

Commit

Permalink
Merge pull request #9623 from zakiva/failed_rules_summary
Browse files Browse the repository at this point in the history
Add OpenSCAP failed rules summary
  • Loading branch information
martinpovolny authored Jul 11, 2016
2 parents b791d80 + 1c0ce86 commit 3f4cf7f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/helpers/container_image_helper/textual_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def textual_group_smart_management
items.collect { |m| send("textual_#{m}") }.flatten.compact
end

def textual_openscap_failed_rules
%i(openscap_failed_rules_low openscap_failed_rules_medium openscap_failed_rules_high)
end

#
# Items
#
Expand Down Expand Up @@ -73,5 +77,24 @@ def textual_compliance_history
end
h
end

def failed_rules_summary
@failed_rules_summary ||= @record.openscap_failed_rules_summary
end

def textual_openscap_failed_rules_low
low = failed_rules_summary[:Low]
{:label => _("Low"), :value => low} if low
end

def textual_openscap_failed_rules_medium
medium = failed_rules_summary[:Medium]
{:label => _("Medium"), :value => medium} if medium
end

def textual_openscap_failed_rules_high
high = failed_rules_summary[:High]
{:label => _("High"), :value => high} if high
end
end
end
4 changes: 4 additions & 0 deletions app/models/container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,9 @@ def annotate_deny_execution(causing_policy)
)
end

def openscap_failed_rules_summary
openscap_rule_results.where(:result => "fail").group(:severity).count.symbolize_keys
end

alias_method :perform_metadata_sync, :sync_stashed_metadata
end
2 changes: 2 additions & 0 deletions app/views/container_image/_main.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
:items => textual_group_smart_management}
= render :partial => "shared/summary/textual", :locals => {:title => _("Configuration"),
:items => textual_group_configuration}
= render :partial => "shared/summary/textual", :locals => {:title => _("OpenSCAP Failed Rules Summary"),
:items => textual_openscap_failed_rules}

0 comments on commit 3f4cf7f

Please sign in to comment.