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

Adding ContainerImage subclasses #15386

Merged
Merged
Show file tree
Hide file tree
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
14 changes: 0 additions & 14 deletions app/models/container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,6 @@ def has_compliance_policies?
!plist.blank?
end

def annotate_deny_execution(causing_policy)
# TODO: support sti and replace check with inplementing only for OpenShift providers
unless ext_management_system.kind_of?(ManageIQ::Providers::Openshift::ContainerManagerMixin)
_log.error("#{__method__} only applicable for OpenShift Providers")
return
end
ext_management_system.annotate(
"image",
digest,
"security.manageiq.org/failed-policy" => causing_policy,
"images.openshift.io/deny-execution" => "true"
)
end

def openscap_failed_rules_summary
openscap_rule_results.where(:result => "fail").group(:severity).count.symbolize_keys
end
Expand Down
1 change: 1 addition & 0 deletions app/models/ems_refresh/save_inventory_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def save_container_images_inventory(ems, hashes, target = nil)

hashes.each do |h|
h[:container_image_registry_id] = h[:container_image_registry][:id] unless h[:container_image_registry].nil?
h[:type] ||= 'ContainerImage'
end

save_inventory_multi(ems.container_images, hashes, deletes, [:image_ref, :container_image_registry_id],
Expand Down
7 changes: 1 addition & 6 deletions app/models/miq_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -737,12 +737,7 @@ def action_container_image_annotate_deny_execution(action, rec, inputs)
return
end

unless rec.try(:ext_management_system).kind_of?(ManageIQ::Providers::Openshift::ContainerManagerMixin)
MiqPolicy.logger.error("#{error_prefix} only applicable for OpenShift Providers")
return
end

unless rec.digest.present?
unless rec.respond_to?(:annotate_deny_execution)
MiqPolicy.logger.error("#{error_prefix} ContainerImage is not linked with an OpenShift image")
return
end
Expand Down
11 changes: 11 additions & 0 deletions spec/models/miq_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,17 @@
end
end

context "#action_container_image_annotate_deny_execution" do
let(:container_image) { FactoryGirl.create(:container_image) }
let(:event) { FactoryGirl.create(:miq_event_definition, :name => "whatever") }
let(:action) { FactoryGirl.create(:miq_action, :name => "container_image_annotate_deny_execution") }

it "will not annotate if the method is unavailable" do
expect(MiqQueue).to receive(:put).exactly(0).times
action.action_container_image_annotate_deny_execution(action, container_image, :event => event)
end
end

context '.create_default_actions' do
context 'seeding default actions from a file with 3 csv rows and some comments' do
before do
Expand Down