-
Notifications
You must be signed in to change notification settings - Fork 67
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
Fixes #38164 - Update on bulk-upload from scap security guide #590
base: master
Are you sure you want to change the base?
Fixes #38164 - Update on bulk-upload from scap security guide #590
Conversation
@@ -48,12 +48,16 @@ def upload_from_files(files_array, from_scap_guide = false) | |||
next | |||
end | |||
|
|||
file = File.open(datastream, 'rb').read | |||
file = File.read(datastream, mode: 'rb') | |||
digest = Digest::SHA2.hexdigest(datastream) |
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.
Should we still keep calculating the digest from the filename?
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.
I've left it just so we don't change behavior for non-standard content files.
For updates, it will be regenerated https://github.com/theforeman/foreman_openscap/blob/master/app/models/concerns/foreman_openscap/scap_file_content.rb#L11 based of file contents. I think we could change it to be generated based on contents right away on the first upload.
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.
I think we could change it to be generated based on contents right away on the first upload.
That would make sense.
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.
Now I'm thinking that it will change behavior for both cases (upload from custom files and scap guide): currently, on first upload it will generate digest from fullpath, stores it and then searches for existing db entry based on title and digest and if an entry is found it does nothing. By changing digest generation we will throw errors like "title already exists" on re-uploads (digests won't match for existing contents) .
Should we then just make it simple for all the cases: generate digest on upload in before_validation
if it doesn't already exist (so we don't generate it twice on re-upload) and make already existing content updatable (as we want with scap guide) if titles match?
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.
Should we then just make it simple for all the cases: generate digest on upload in before_validation if it doesn't already exist (so we don't generate it twice on re-upload) and make already existing content updatable (as we want with scap guide) if titles match?
That sounds like the best approach to me
No description provided.