-
Notifications
You must be signed in to change notification settings - Fork 63
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
Propagate userid through to create a scanning job with current userid #244
Propagate userid through to create a scanning job with current userid #244
Conversation
@miq-bot add_label bug |
It is targeted to 5.9.2, so yes. |
babe519
to
4af3509
Compare
@miq-bot add_label gaprindashvili/yes |
@@ -164,7 +164,7 @@ def fetch_oscap_arf | |||
# https://github.com/ManageIQ/manageiq-providers-kubernetes/pull/54/files | |||
image = FactoryGirl.create(:container_image, :ext_management_system => @ems) | |||
User.current_user = FactoryGirl.create(:user, :userid => "bob") | |||
job = @ems.raw_scan_job_create(image.class, image.id) | |||
job = @ems.raw_scan_job_create(image.class, image.id, User.current_user.userid) |
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.
raw_scan_job_create
is a callback that is called when scheduling the scan. It is only called through scan_job_create
and never directly and now with this patch - always with a userid
parameter. That is why I had to add the userid
here.
4af3509
to
595d47b
Compare
Note that |
@nimrodshn can you add reviewer(s) and an assignee to this PR. |
@JPrause I can't add reviewer(s) and an assignee (probably) because I'm not part of manageiq-providers-kubernetes org BUT I am a part of the team maintaining this repo so the tagged people above are aware of this PR 😄 but due to vacation in Israel are unable to take a look... 😢 |
@nimrodshn I'm not a fan of falling back to the admin user since it could bypass policy/rbac checks. What should happen is when the user creates the job we store the userid string instead of calling |
It seems that a miq_schedule already has an associated user and that the user information is not passed along to the container image(unlike host.rb for example that does pass that parameter). A few pointers: https://github.com/ManageIQ/manageiq/blob/master/app/models/mixins/scanning_mixin.rb#L109 |
fixing specs fix failed tests adding userid as param to scan_job_create
595d47b
to
0d11ffc
Compare
Checked commit nimrodshn@0d11ffc with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@cben, @moolitayer @agrare I rewrote this with (a lot of help from @cben 👍 ) it now allows scheduled scan to be associated with |
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 much better @nimrodshn
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.
LGTM
disclaimer: we partially paired on this
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.
LGTM 👍
Let's wait and see what becomes of ManageIQ/manageiq#17264
Core PR has been merged |
I'm just going to merge this :) I think @cben forgot |
Propagate userid through to create a scanning job with current userid (cherry picked from commit c19e5a4) https://bugzilla.redhat.com/show_bug.cgi?id=1566529
Gaprindashvili backport details:
|
Currently when a user creates a scanning job we require
User.current_user
to be some value other than nil. But, when scheduling a scan for some period of time and then logging out / session times outUser.current_user
turnsnil
which causes the scanning job to break.This patch fixes the above behavior to fallback to default usersystem
.Now we propagate
userid
through MiqSchedule which solves this issue.Depends on: ManageIQ/manageiq#17264
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1559459
cc: @cben @zeari