Bug 1474175 - Unable to upload the SCAP content file via API with Location and Organization params.
Summary: Unable to upload the SCAP content file via API with Location and Organization...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: SCAP Plugin
Version: 6.2.10
Hardware: All
OS: Linux
medium
medium
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-24 04:52 UTC by Deepannagaraj Nagarathinam
Modified: 2020-09-10 11:00 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-03 06:32:45 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Upload scap content script (522 bytes, application/x-shellscript)
2017-07-31 07:23 UTC, Ondřej Pražák
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3135671 0 None None None 2017-08-02 06:25:22 UTC

Description Deepannagaraj Nagarathinam 2017-07-24 04:52:33 UTC
Description of problem:

- When trying to upload the SCAP content files to the Satellite server with the Location ID and Organization ID mentioned in the API Call, it fails to upload the Content file to the Satellite server.

Version-Release number of selected component (if applicable):

- Red Hat Satellite v6

How reproducible:

- Always

Steps to Reproduce:

1. Configure the Satellite server with OpenSCAP.

2. Try to upload the SCAP Content file with the location_ids and organization_ids mentioned in the API Call.

Actual results:

- API Call completes successfully, but the Content file is not uploaded to the Satellite server.

Expected results:

- The content file should be uploaded to the Satellite server.

Additional info:

- API Call works fine when the location_ids and organization_ids are not mentioned in the call.

- Able to see the below error at the starting, while running the API Call.

~~~~~~
# bash scap_upload test ssg-rhel7-ds.xml 
Uploading 'ssg-rhel7-ds.xml' file with title name 'test'...
{"status":400,"error":"There was a problem in the JSON you submitted: 795: unexpected token at '{  \"scap_content\": {    \"title\": \"test\",    \"scap_file\":
--- snipped ---
~~~~~~

==> /var/log/foreman/production.log <==

-> With API,

~~~~~~
2017-07-24 00:43:02 [app] [I] Started POST "/api/v2/compliance/scap_contents" for 127.0.0.1 at 2017-07-24 00:43:02 -0400
2017-07-24 00:43:02 [app] [D] Error occurred while parsing request parameters.
 | Contents:
 | 
 | {  "scap_content": {    "title": "test",    "location_ids"=>["2"],     "organization_ids"=>["1"]    "scap_file":

--- snipped ---

2017-07-24 00:43:03 [app] [I] Started HEAD "/" for 127.0.0.1 at 2017-07-24 00:43:03 -0400
2017-07-24 00:43:03 [app] [I] Processing by DashboardController#index as HTML
2017-07-24 00:43:03 [app] [I] Redirected to https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com/users/login
2017-07-24 00:43:03 [app] [I] Filter chain halted as :require_login rendered or redirected
2017-07-24 00:43:03 [app] [I] Completed 302 Found in 20ms (ActiveRecord: 8.4ms)
~~~~~~

-> From WebUI,

~~~~~~
2017-07-24 00:48:08 [app] [I] Started POST "/compliance/scap_contents" for 10.76.0.80 at 2017-07-24 00:48:08 -0400
2017-07-24 00:48:08 [app] [I] Processing by ScapContentsController#create as */*
2017-07-24 00:48:08 [app] [I]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"LsLSRlO7QKRg1h5z+OncmznBa6wJPZalqxKeP752xdI=", "scap_content"=>{"title"=>"scap", "scap_file"=>#<ActionDispatch::Http::UploadedFile:0x007fb253ac0d20 @tempfile=#<Tempfile:/tmp/RackMultipart20170724-31221-uust5f>, @original_filename="ssg-rhel7-ds.xml", @content_type="text/xml", @headers="Content-Disposition: form-data; name=\"scap_content[scap_file]\"; filename=\"ssg-rhel7-ds.xml\"\r\nContent-Type: text/xml\r\n">, "location_ids"=>["", "2"], "organization_ids"=>["", "1"]}}
2017-07-24 00:48:08 [app] [D] Setting current user thread-local variable to admin
2017-07-24 00:48:08 [app] [D] Setting current organization thread-local variable to none
2017-07-24 00:48:08 [app] [D] Setting current location thread-local variable to none
2017-07-24 00:48:08 [app] [D] RestClient.get "https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com:9090/features", "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate"
 | 
2017-07-24 00:48:08 [app] [D] # => 200 OK | application/json 67 bytes
 | 
2017-07-24 00:48:08 [app] [D] RestClient.get "https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com:9090/version", "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate"
 | 
2017-07-24 00:48:08 [app] [D] # => 200 OK | application/json 164 bytes
 | 
2017-07-24 00:48:08 [app] [D] RestClient.post "https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com:9090/compliance/scap_content/validator", 4985633 byte(s) length, "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"4985633", "Content-Type"=>"application/xml"
 | 
2017-07-24 00:48:09 [app] [D] # => 200 OK | text/html 13 bytes
 | 
2017-07-24 00:48:09 [app] [D] RestClient.post "https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com:9090/compliance/scap_content/policies", 4985633 byte(s) length, "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"4985633", "Content-Type"=>"application/xml"
 | 
2017-07-24 00:48:10 [app] [D] # => 200 OK | text/html 1205 bytes
 | 
2017-07-24 00:48:10 [app] [D] RestClient.post "https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com:9090/compliance/scap_content/policies", 4985633 byte(s) length, "Accept"=>"application/json", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"4985633", "Content-Type"=>"application/xml"
 | 
2017-07-24 00:48:10 [app] [D] # => 200 OK | text/html 1205 bytes
 | 
2017-07-24 00:48:10 [app] [I] Redirected to https://rhel7u3-sat62-1.gsslab.rdu2.redhat.com/compliance/scap_contents
2017-07-24 00:48:10 [app] [I] Completed 302 Found in 2356ms (ActiveRecord: 121.5ms)
2017-07-24 00:48:11 [app] [I] Started GET "/compliance/scap_contents" for 10.76.0.80 at 2017-07-24 00:48:11 -0400
2017-07-24 00:48:11 [app] [I] Processing by ScapContentsController#index as */*
2017-07-24 00:48:11 [app] [D] Setting current user thread-local variable to admin
2017-07-24 00:48:11 [app] [D] Setting current organization thread-local variable to none
2017-07-24 00:48:11 [app] [D] Setting current location thread-local variable to none
2017-07-24 00:48:11 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-0.5.3.18/app/views/scap_contents/_list.html.erb (653.2ms)
2017-07-24 00:48:11 [app] [I]   Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-0.5.3.18/app/views/scap_contents/index.html.erb within layouts/application (706.8ms)
2017-07-24 00:48:11 [app] [I]   Rendered common/_searchbar.html.erb (5.3ms)
2017-07-24 00:48:11 [app] [I]   Rendered layouts/_application_content.html.erb (7.8ms)
2017-07-24 00:48:11 [app] [D] Deface: 1 overrides found for 'layouts/base'
2017-07-24 00:48:11 [app] [D] Deface: 'theme_resources' matched 1 times with 'head'
2017-07-24 00:48:11 [app] [I] Deface: [WARNING] No :original defined for 'theme_resources', you should change its definition to include:
 |  :original => '9f26415985aeb5438b8efcaf9078980451df5ff7' 
2017-07-24 00:48:11 [app] [D] Deface: 2 overrides found for 'home/_topbar'
2017-07-24 00:48:11 [app] [D] Deface: 'remove foreman name from topbar' matched 1 times with 'erb[loud]:contains('link_to')'
2017-07-24 00:48:11 [app] [I] Deface: [WARNING] No :original defined for 'remove foreman name from topbar', you should change its definition to include:
 |  :original => '6f86bcbd36e017373b168cc34f62c6deb016bb55' 
2017-07-24 00:48:11 [app] [D] Deface: 'add link to home' matched 1 times with 'erb[loud]:contains('image_tag')'
2017-07-24 00:48:11 [app] [I] Deface: [WARNING] No :original defined for 'add link to home', you should change its definition to include:
 |  :original => '7c247aee58a81a4e49096e83b6a14b07ec780462' 
2017-07-24 00:48:11 [app] [I]   Rendered home/_submenu.html.erb (2.4ms)
2017-07-24 00:48:11 [app] [I]   Rendered home/_user_dropdown.html.erb (4.6ms)
2017-07-24 00:48:11 [app] [I] Read fragment views/tabs_and_title_records-3 (0.1ms)
2017-07-24 00:48:11 [app] [I]   Rendered home/_topbar.html.erb (12.4ms)
2017-07-24 00:48:11 [app] [I]   Rendered layouts/base.html.erb (23.1ms)
2017-07-24 00:48:11 [app] [I] Completed 200 OK in 812ms (Views: 530.5ms | ActiveRecord: 266.7ms)
~~~~~~

Comment 1 Ondřej Pražák 2017-07-31 07:23:51 UTC
Created attachment 1306816 [details]
Upload scap content script

Comment 2 Ondřej Pražák 2017-07-31 08:30:21 UTC
The 400 error message suggests posting a malformed JSON, which is the reason why scap content is not created. I am afraid the script in the attached customer case is the culprit. Notice there are missing commas in version posted on Jul 12, when location_ids and organization_ids were added. I modified the script and was able to upload the scap content, the updated script version is attached here. Could you find out if the updated version works for the customer?

Comment 3 Deepannagaraj Nagarathinam 2017-08-01 02:34:41 UTC
Hi Ondřej,

Thank you. I have tried the script in my test Satellite and it worked fine.

I hope it will work for the customer too. I will update the BZ once I hear back from customer.

Deepannagaraj N.

Comment 4 Deepannagaraj Nagarathinam 2017-08-02 05:14:11 UTC
Hi Ondřej,

Customer has confirmed that the corrected --new-- script works fine. Thank you so much for your help and sorry for the silly mistake.

I think we are good to close this BZ as NOTABUG.

Deepannagaraj N.

Comment 5 Ondřej Pražák 2017-08-03 06:32:45 UTC
Thank you, closing as per comment #4.


Note You need to log in before you can comment on or make changes to this bug.