-
Notifications
You must be signed in to change notification settings - Fork 900
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
Add MiqAction to annotate container images as non secure at openshift #7536
Conversation
@miq-bot add_label wip, providers/containers, control |
@@ -59,5 +59,9 @@ def perform_metadata_scan(ost) | |||
scan_via_miq_vm(miq_cnt_group, ost) | |||
end | |||
|
|||
def prevent_from_starting | |||
ext_management_system.annotate(self, {"manageiq.org/security" => "fail"}) # TODO: handle non openshift providers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smarterclayton @deads2k This is the patch the annotates non secure images.
- Which label should we set here?
- Any other actions needed to prevent containers based on the image from starting on a master openshift deployed using openshift-ansible (I would like to test)
cc @simon3z
608cabc
to
f607ddf
Compare
We probably need to sort out whether others would set this annotation (a There are descriptive annotations "this is true for this object" (such as " What information do you have at this current time around the image and its On Sun, Mar 27, 2016 at 1:02 PM, ManageIQ Bot [email protected]
|
I agree. I'd like to have a human-readable string annotation for us to display along with the denial. I suspect that the marking process will have better information than we'll have. |
This action is ad hock and can be executed in response to which ever condition/s the user chooses. Said condition might be OpenSCAP vulnerabilities detected OR it might be something entirely different e.g image name is X. I think the best we can do here is to name the failed ManageIQ policy, So: "security.manageiq.org/failed-policies" = [] The deny-execution satisfy my immediate goal. Going forward I'm pretty sure I could define a parameterized action that will allow the user to select his annotations (and examples for those could be provided out of the box) |
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
f607ddf
to
b9eac70
Compare
@smarterclayton @deads2k Please review used annotations |
b9eac70
to
3839459
Compare
"image", | ||
self, | ||
"security.manageiq.org/failed-policy" => causing_policy, | ||
"images.openshift.io/deny-execution" => "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me.
@miq-bot add_label darga/yes |
@simon3z I should have discovered this sooner but I don't think I can tag with our current inventory. These are the openshift names I need to know in order to tag: [root@oshift01 ~]# oc get images
NAME DOCKER REF
sha256:20098eb056620c0ceade04b4bec642fb89c8f3361e89e6ff4729b273f2c799ed openshift/ruby-20-centos7@sha256:20098eb056620c0ceade04b4bec642fb89c8f3361e89e6ff4729b273f2c799ed
sha256:592872229633f5b906301b1880aeb45272ef83a838794a9c2e53ce07b2a5f3f0 172.30.107.74:5000/test/origin-ruby-sample@sha256:592872229633f5b906301b1880aeb45272ef83a838794a9c2e53ce07b2a5f3f0
sha256:78380eec5f83213b7ef0c0d37a5f285ebb7632ca2c7390b9bd6c07625019cf7e 172.30.107.74:5000/test/origin-ruby-sample@sha256:78380eec5f83213b7ef0c0d37a5f285ebb7632ca2c7390b9bd6c07625019cf7e
sha256:af4c1abc8797bc2df3bfdc92b3ae5fd01984fd4590ffd4899520777f9de2d674 172.30.107.74:5000/test/origin-ruby-sample@sha256:af4c1abc8797bc2df3bfdc92b3ae5fd01984fd4590ffd4899520777f9de2d674
sha256:f334f35cdafe80368b83b53144e2f9a028b2f1170b25f612ce2ad7de890abcba centos/ruby-22-centos7@sha256:f334f35cdafe80368b83b53144e2f9a028b2f1170b25f612ce2ad7de890abcba This is the information we look at to create our ManageIQ image inventory: [root@oshift01 ~]# oc describe pod docker-registry-1-a8bhm|grep -i image
Image(s): openshift/origin-docker-registry:v1.0.8
Image: openshift/origin-docker-registry:v1.0.8
Image ID: docker://3629a651e6c11d7435937bdf41da11cf87863c03f2587fa788cf5cbfe8a11b9a fyi @zeari thoughts? |
3839459
to
6669cad
Compare
Added handling for images with no digest and usual testing for entity type. Tested: ContainerImage.find(8).prevent_from_starting("has openscap failures") Annotations returned by Openshift: "annotations": { Another common use case would lead to a guid name (policies can have a descriptive name or a guid name) @simon3z Please review |
ping @simon3z |
return | ||
end | ||
|
||
if inputs[:synchronous] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@moolitayer @Fryguy @gmcculloug @blomquisg can anyone (after this patch) take the refactoring of the repeating:
if inputs[:synchronous]
log_do_something
do_something
else
log_queuing_do_something
queue(do_something)
end
It seems pretty common in this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I'll give it a try @simon3z
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@moolitayer: few minor naming changes. |
ae4c0ec
to
21ee2a0
Compare
end | ||
|
||
if inputs[:synchronous] | ||
MiqPolicy.logger.info("MIQ(#{__method__}): Now executing [#{action.description}] for event "\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmcculloug Noticed it's Now executing
or Queueing
in most calls
Looks good @moolitayer. I had minor comments. Once they're fixed and @simon3z gives the 👍 , I'm good with this. Note, I don't think we have an out of box deny/stop a vm thing but it seems like they'd have similar mechanics. |
21ee2a0
to
8c69985
Compare
Address comment |
@simon3z please reivew |
return | ||
end | ||
|
||
unless rec.try(:ext_management_system).kind_of?(ManageIQ::Providers::Openshift::ContainerManagerMixin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like something that should be refactored in the future. We need to be able to define actions and action handler methods for each manager type and provider.
/cc @durandom
LGTM 👍 cc @blomquisg @jrafanie @chessbyte |
@@ -82,5 +82,14 @@ def has_compliance_policies? | |||
!plist.blank? | |||
end | |||
|
|||
def annotate_deny_execution(causing_policy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this error message, this call is only available for OpenShift images. This should really be implemented on an OpenShift implementation of ContainerImage
.
But, since ContainerImage
does not yet support STI, add an error handler here in case someone calls this method directly. Stopping calls via MiqAction
seems insufficient to protect this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, since ContainerImage does not yet support STI, add an error handler here in case someone calls this method directly. Stopping calls via MiqAction seems insufficient to protect this method.
@moolitayer can you take care of that? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
8c69985
to
97d50db
Compare
Checked commit moolitayer@97d50db with ruby 2.2.3, rubocop 0.37.2, and haml-lint 0.16.1 app/models/miq_action.rb
|
Add MiqAction to annotate container images as non secure at openshift (cherry picked from commit 3b300aa)
Based on:
The metadata created by the MiqAction is meant to be used by Openshift to prevent tagged images from running.