Actions
Bug #20886
closedMake sure proxy is available for data stream content validations
Difficulty:
Triaged:
No
Description
proxy_url method from DataStreamContent returns nil if proxy is not available. The returned value is then used for calls to proxy when validating scap files, but there is no additional check for nil. I think we should make it raise an exception and handle it appropriately.
Steps to reproduce:
1) Make sure all your openscap proxies are down
2) Try to update scap content using hammer
2017-09-11T10:34:13 f0fc6d8f [app] [I] Started PUT "/api/compliance/scap_contents/15" for ::1 at 2017-09-11 10:34:13 +0000 2017-09-11T10:34:13 f0fc6d8f [app] [I] Processing by Api::V2::Compliance::ScapContentsController#update as JSON 2017-09-11T10:34:13 f0fc6d8f [app] [I] Parameters: {"scap_content"=>{"title"=>"update-scap-loc"}, "title"=>"update-scap-loc", "apiv"=>"v2", "id"=>"15"} 2017-09-11T10:34:13 f0fc6d8f [app] [I] Current user: admin (administrator) 2017-09-11T10:34:13 f0fc6d8f [app] [D] Setting current user thread-local variable to admin 2017-09-11T10:34:13 f0fc6d8f [app] [W] Action failed | NoMethodError: undefined method `+' for nil:NilClass | /home/vagrant/projects/foreman_openscap/app/lib/proxy_api/openscap.rb:4:in `initialize' | /home/vagrant/projects/foreman_openscap/app/models/foreman_openscap/scap_content.rb:47:in `new' | /home/vagrant/projects/foreman_openscap/app/models/foreman_openscap/scap_content.rb:47:in `fetch_profiles' | /home/vagrant/projects/foreman_openscap/app/models/concerns/foreman_openscap/data_stream_content.rb:38:in `create_profiles' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.9/lib/active_support/callbacks.rb:432:in `block in make_lambda' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.9/lib/active_support/callbacks.rb:228:in `call' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.9/lib/active_support/callbacks.rb:228:in `block in halting_and_conditional' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.9/lib/active_support/callbacks.rb:506:in `call' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.9/lib/active_support/callbacks.rb:506:in `block in call' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.9/lib/active_support/callbacks.rb:506:in `each' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.9/lib/active_support/callbacks.rb:506:in `call' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.9/lib/active_support/callbacks.rb:92:in `__run_callbacks__' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.9/lib/active_support/callbacks.rb:778:in `_run_save_callbacks' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/callbacks.rb:302:in `create_or_update' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/persistence.rb:120:in `save' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/bullet-5.6.1/lib/bullet/active_record42.rb:47:in `save_with_bullet' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/validations.rb:37:in `save' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/attribute_methods/dirty.rb:21:in `save' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/transactions.rb:286:in `block (2 levels) in save' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/transactions.rb:220:in `transaction' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/transactions.rb:348:in `with_transaction_returning_status' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/transactions.rb:286:in `block in save' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/transactions.rb:301:in `rollback_active_record_state!' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/transactions.rb:285:in `save' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/persistence.rb:252:in `block in update' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/transactions.rb:220:in `transaction' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/transactions.rb:348:in `with_transaction_returning_status' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.9/lib/active_record/persistence.rb:250:in `update' | /home/vagrant/projects/foreman_openscap/app/controllers/api/v2/compliance/scap_contents_controller.rb:58:in `update' | /home/vagrant/.rvm/gems/ruby-2.2.4/gems/actionpack-4.2.9/lib/action_controller/metal/implicit_render.rb:4:in
Actions