Class: Api::V2::Compliance::ArfReportsController

Inherits:
V2::BaseController
  • Object
show all
Includes:
Api::Version2, Foreman::Controller::SmartProxyAuth
Defined in:
app/controllers/api/v2/compliance/arf_reports_controller.rb

Instance Method Summary collapse

Instance Method Details

#check_content_type ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/api/v2/compliance/arf_reports_controller.rb', line 37

def check_content_type
  # Well, this is unfortunate. Parent class asserts that content-type is
  # application/json. While we want to have content-type text/xml. We
  # also need the content-encoding to equal with x-bzip2. However, when
  # the framework sees text/xml, it will rewrite it to application/xml.
  # What's worse, a framework will try to parse body as an utf8 string,
  # no matter what content-encoding says. Let's pass content-type arf-bzip2
  # and move forward.
  super unless
    request.content_type.end_with? 'arf-bzip2' and
    request.env['HTTP_CONTENT_ENCODING'] == 'x-bzip2'
end

#create ⇒ Object



29
30
31
32
33
34
35
# File 'app/controllers/api/v2/compliance/arf_reports_controller.rb', line 29

def create
  asset = ForemanOpenscap::Helper::get_asset(params[:cname])
  arf_bzip2 = request.body.read
  arf_bzip2_size = request.body.size
  Scaptimony::ArfReportsHelper.create_arf(asset, params, arf_bzip2, arf_bzip2_size)
  render :json => { :result => :OK, :received => arf_bzip2_size }
end