Class: ForemanOpenscap::ScapContent

Inherits:
ApplicationRecord
  • Object
show all
Includes:
Authorizable, DataStreamContent, ScapFileContent, Taxonomix
Defined in:
app/models/foreman_openscap/scap_content.rb

Instance Method Summary collapse

Methods included from ScapFileContent

#digest

Methods included from DataStreamContent

#create_or_update_profile, #create_profiles, #proxy_url

Instance Method Details

#as_json(*args) ⇒ Object



43
44
45
46
# File 'app/models/foreman_openscap/scap_content.rb', line 43

def as_json(*args)
  hash = super
  hash["scap_file"] = scap_file.to_s.encode('utf-8', :invalid => :replace, :undef => :replace, :replace => '_')
end

#fetch_profilesObject



48
49
50
51
52
# File 'app/models/foreman_openscap/scap_content.rb', line 48

def fetch_profiles
  api = ProxyAPI::Openscap.new(:url => proxy_url)
  profiles = api.fetch_policies_for_scap_content(scap_file)
  profiles
end

#to_labelObject



39
40
41
# File 'app/models/foreman_openscap/scap_content.rb', line 39

def to_label
  title
end

#used_location_idsObject



25
26
27
28
29
30
# File 'app/models/foreman_openscap/scap_content.rb', line 25

def used_location_ids
  Location.joins(:taxable_taxonomies).where(
    'taxable_taxonomies.taxable_type' => 'ForemanOpenscap::ScapContent',
    'taxable_taxonomies.taxable_id' => id
  ).pluck("#{Location.arel_table.name}.id")
end

#used_organization_idsObject



32
33
34
35
36
37
# File 'app/models/foreman_openscap/scap_content.rb', line 32

def used_organization_ids
  Organization.joins(:taxable_taxonomies).where(
    'taxable_taxonomies.taxable_type' => 'ForemanOpenscap::ScapContent',
    'taxable_taxonomies.taxable_id' => id
  ).pluck("#{Location.arel_table.name}.id")
end