foreman_rh_cloud 12.1.0 → 12.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -4
  3. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +26 -22
  4. data/app/services/foreman_rh_cloud/cloud_request.rb +9 -3
  5. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +0 -2
  6. data/app/views/api/v2/hosts/insights/single.rabl +5 -0
  7. data/config/package-lock.json.plugin +4137 -3036
  8. data/config/routes.rb +1 -0
  9. data/lib/foreman_rh_cloud/engine.rb +11 -4
  10. data/lib/foreman_rh_cloud/version.rb +1 -1
  11. data/lib/insights_vulnerability.rb +2 -0
  12. data/package.json +1 -1
  13. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +35 -2
  14. data/webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.js +17 -0
  15. data/webpack/CVEsHostDetailsTab/__tests__/CVEsHostDetailsTab.test.js +18 -0
  16. data/webpack/CVEsHostDetailsTab/index.js +3 -0
  17. data/webpack/ForemanInventoryUpload/Components/InventorySettings/MinimalInventoryDropdown.js +1 -1
  18. data/webpack/ForemanRhCloudFills.js +11 -1
  19. data/webpack/ForemanRhCloudHelpers.js +3 -0
  20. data/webpack/ForemanRhCloudPages.js +7 -0
  21. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsLabel.js +40 -0
  22. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsSection.js +30 -0
  23. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsSection.scss +25 -0
  24. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +4 -6
  25. data/webpack/InsightsVulnerability/InsightsVulnerability.js +13 -0
  26. data/webpack/InsightsVulnerability/InsightsVulnerability.test.js +18 -0
  27. data/webpack/__tests__/ForemanRhCloudHelpers.test.js +30 -1
  28. data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +10 -0
  29. metadata +11 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc6fa218e9a87166dd1b6ea44dc00f52dc4a0ee28edaa6363bfd74fd0e93c17c
4
- data.tar.gz: 80d9b1dcfa4a2e1589d2273b895360d237e84101d0e2a216a18ffc0d9259e14d
3
+ metadata.gz: ca9c35b5c31e2f8d00889ae5c4f57a3245e038f2ff106e708c9f45909e1340d2
4
+ data.tar.gz: 7b151bcccb350ff1cb748aeca126656d8e7e2712e7878ea0522b7db719c6594f
5
5
  SHA512:
6
- metadata.gz: 4e76e623f5509cd2bedab0fcd8abf926d7380eee120d1c73fc7f3be32ec9fe97cfc3948f56e93436ac21431ec8a5f85b4f8f349d1fe5df05bcad9d4e043eb332
7
- data.tar.gz: d6f0d6140787ba18bc69bcf4de2161795a4404530fd24bd4502c352d1e87e1d13bd447049b220901edc48f0fbb9fde78ce73b737dea5435fc841d70f6c1a38bf
6
+ metadata.gz: ec35e323ea4ff1e5af20ee9a6185c83f5cf43e011a1f4879d696050381265c474cbf2b1435f72f53e43c785c797f5de013513f7efbf49e19fd87b9d2c58fe279
7
+ data.tar.gz: 109928813b8f2e70ee7107d44470e04fff2fad1e9fd356f2b15f7f57092bb06c003277de931c5d5dfa84a4a379de36e4e14fd7ea2898b3070d310c4c7311e5c0
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
+ [![Ruby tests](https://github.com/theforeman/foreman_rh_cloud/actions/workflows/ruby_tests.yml/badge.svg)](https://github.com/theforeman/foreman_rh_cloud/actions/workflows/ruby_tests.yml)
2
+ [![JS](https://github.com/theforeman/foreman_rh_cloud/actions/workflows/js_tests.yml/badge.svg)](https://github.com/theforeman/foreman_rh_cloud/actions/workflows/js_tests.yml)
3
+
1
4
  # ForemanRhCloud
2
5
 
3
- *Introdction here*
6
+ *Introduction here*
4
7
 
5
8
  ## Installation
6
9
 
@@ -15,7 +18,7 @@ for how to install Foreman plugins
15
18
 
16
19
  #### Inventory upload
17
20
 
18
- In UI: Configure -> Inventory Upload -> Generate and upload report
21
+ In UI: Insights -> Inventory Upload -> select the organization -> Generate and upload report
19
22
 
20
23
  From command-line:
21
24
 
@@ -38,7 +41,7 @@ From command-line:
38
41
 
39
42
  #### Fetch hosts remediation data
40
43
 
41
- In UI: Configure -> Insights -> Sync now
44
+ In UI: Insights -> Recommendations -> Sync recommendations (under the vertical ellipsis)
42
45
 
43
46
  From command-line:
44
47
 
@@ -46,7 +49,7 @@ From command-line:
46
49
 
47
50
  #### Synchronize inventory status
48
51
 
49
- In UI: Configure -> Inventory Upload -> Sync all inventory status
52
+ In UI: Insights -> Inventory Upload -> Sync all inventory status
50
53
 
51
54
  From command-line:
52
55
 
@@ -18,35 +18,39 @@ module InsightsCloud::Api
18
18
  certs = candlepin_id_cert @organization
19
19
  begin
20
20
  @cloud_response = ::ForemanRhCloud::CloudRequestForwarder.new.forward_request(request, controller_name, @branch_id, certs)
21
- rescue RestClient::Exception => e
22
- logger.info("Forwarding request failed with exception: #{e}")
23
- return render json: { error: e }, status: :bad_gateway
24
- rescue RestClient::Timeout => e
25
- logger.info("Forwarding request failed with timeout: #{e}")
26
- return render json: { error: e }, status: :gateway_timeout
27
- end
28
-
29
- return render json: { message: @cloud_response.to_s }, status: :gateway_timeout if @cloud_response.is_a?(RestClient::Exceptions::OpenTimeout)
21
+ rescue RestClient::Exceptions::Timeout => e
22
+ response_obj = e.response.presence || e.exception
23
+ return render json: { message: response_obj.to_s, error: response_obj.to_s }, status: :gateway_timeout
24
+ rescue RestClient::Unauthorized => e
25
+ logger.warn("Forwarding request auth error: #{e}")
26
+ message = 'Authentication to the Insights Service failed.'
27
+ return render json: { message: message, error: message }, status: :unauthorized
28
+ rescue RestClient::NotModified => e
29
+ logger.info("Forwarding request not modified: #{e}")
30
+ message = 'Cloud request not modified'
31
+ return render json: { message: message, error: message }, status: :not_modified
32
+ rescue RestClient::ExceptionWithResponse => e
33
+ response_obj = e.response.presence || e.exception
34
+ code = response_obj.try(:code) || response_obj.try(:http_code) || 500
35
+ message = 'Cloud request failed'
30
36
 
31
- if @cloud_response.code == 401
32
37
  return render json: {
33
- :message => 'Authentication to the Insights Service failed.',
38
+ :message => message,
39
+ :error => response_obj.to_s,
34
40
  :headers => {},
35
- }, status: :bad_gateway
36
- end
37
-
38
- if @cloud_response.code >= 300
39
- return render json: {
40
- :message => 'Cloud request failed',
41
- :headers => {},
42
- :response => @cloud_response,
43
- }, status: @cloud_response.code
41
+ :response => response_obj,
42
+ }, status: code
43
+ rescue StandardError => e
44
+ # Catch any other exceptions here, such as Errno::ECONNREFUSED
45
+ logger.warn("Cloud request failed with exception: #{e}")
46
+ return render json: { error: e.to_s }, status: :bad_gateway
44
47
  end
45
48
 
46
49
  # Append redhat-specific headers
47
50
  @cloud_response.headers.each do |key, value|
48
51
  assign_header(response, @cloud_response, key, false) if key.to_s.start_with?('x_rh_')
49
52
  end
53
+
50
54
  # Append general headers
51
55
  assign_header(response, @cloud_response, :x_resource_count, true)
52
56
  headers[Rack::ETAG] = @cloud_response.headers[:etag]
@@ -56,8 +60,8 @@ module InsightsCloud::Api
56
60
  # content type
57
61
  send_data @cloud_response, disposition: @cloud_response.headers[:content_disposition], type: @cloud_response.headers[:content_type]
58
62
  elsif @cloud_response.headers[:content_type] =~ /zip/
59
- # if there is no Content-Disposition, but the content type is binary according the content type,
60
- # forward the request as binry too
63
+ # If there is no Content-Disposition, but the content type is binary according to Content-Type, send the raw data
64
+ # with proper content type
61
65
  send_data @cloud_response, type: @cloud_response.headers[:content_type]
62
66
  else
63
67
  render json: @cloud_response, status: @cloud_response.code
@@ -17,9 +17,15 @@ module ForemanRhCloud
17
17
  logger.debug("Response headers for request url #{final_params[:url]} are: #{response.headers}")
18
18
 
19
19
  response
20
- rescue RestClient::Exception => ex
21
- logger.debug("Failed response with code #{ex.http_code} headers for request url #{final_params[:url]} are: #{ex.http_headers} and body: #{ex.http_body}")
22
- raise ex
20
+ rescue RestClient::Exceptions::Timeout => ex
21
+ logger.debug("Timeout exception raised for request url #{final_params[:url]}: #{ex}")
22
+ raise
23
+ rescue RestClient::ExceptionWithResponse => ex
24
+ logger.debug("Response headers for request url #{final_params[:url]} with status code #{ex.http_code} are: #{ex.http_headers} and body: #{ex.http_body}")
25
+ raise
26
+ rescue StandardError => ex
27
+ logger.debug("Exception raised for request url #{final_params[:url]}: #{ex}")
28
+ raise
23
29
  end
24
30
  end
25
31
  end
@@ -17,8 +17,6 @@ module ForemanRhCloud
17
17
  logger.debug("Sending request to: #{request_opts[:url]}")
18
18
 
19
19
  execute_cloud_request(request_opts)
20
- rescue RestClient::ExceptionWithResponse => error_response
21
- error_response.response.presence || error_response.exception
22
20
  end
23
21
 
24
22
  def prepare_request_opts(original_request, forward_payload, forward_params, certs)
@@ -0,0 +1,5 @@
1
+ node :vulnerability do
2
+ {
3
+ enabled: ForemanRhCloud.with_local_advisor_engine?,
4
+ }
5
+ end