Skip to content

Instantly share code, notes, and snippets.

View dLobatog's full-sized avatar
🤗

Daniel Lobato García dLobatog

🤗
View GitHub Profile
Time since start: 150s. Press Ctrl+C to stop.
Summary of profiling data so far:
% self % total name
43.83 99.71 <c function> - unknown
2.14 44.12 continue_field - /home/dlobatog/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/graphql-1.9.7/lib/graphql/execution/interpreter/runtime.rb
2.02 2.38 continue_value - /home/dlobatog/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/graphql-1.9.7/lib/graphql/execution/interpreter/runtime.rb
2.00 33.32 block in evaluate_selections - /home/dlobatog/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/graphql-1.9.7/lib/graphql/execution/interpreter/runtime.rb
1.93 63.26 resolve - /home/dlobatog/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/graphql-1.9.7/lib/graphql/execution/interpreter/resolve.rb
1.69 3.14 write_in_response - /home/dlobatog/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/graphql-1.9.7/lib/graphql/execution/interpreter/runtime.rb
task fix_xccdf_reports: :environment do
start_time = Time.now.utc
puts "Starting fix_xccdf_reports job at #{start_time}"
xccdf_profiles = Profile.reject{ |profile| profile.ref_id.match?(/xccdf_org.ssgproject.content_profile_.*/) }
xccdf_profiles.map { |profile| profile.update(name: "xccdf_org.ssgproject.content_profile_#{profile.ref_id}") }
# At this point, some of the profiles will still have the same broken ref_id as other profiles in the same
# account might have it.
xccdf_profiles = Profile.reject{ |profile| profile.ref_id.match?(/xccdf_org.ssgproject.content_profile_.*/) }
[35] pry(main)> parser.save_rule_references
RuleReference Load (0.5ms) SELECT "rule_references".* FROM "rule_references" WHERE "rule_references"."href" = $1 AND "rule_references"."label" = $2 ORDER BY "rule_references"."label" ASC LIMIT $3 [["href", "https://www.niap-ccevs.org/Profile/PP.cfm"], ["label", "FAU_GEN.1.1.c"], ["LIMIT", 1]]
RuleReference Load (0.8ms) SELECT "rule_references".* FROM "rule_references" WHERE "rule_references"."href" = $1 AND "rule_references"."label" = $2 ORDER BY "rule_references"."label" ASC LIMIT $3 [["href", "https://www.niap-ccevs.org/Profile/PP.cfm"], ["label", "FAU_GEN.1.1.c"], ["LIMIT", 1]]
RuleReference Load (0.4ms) SELECT "rule_references".* FROM "rule_references" WHERE "rule_references"."href" = $1 AND "rule_references"."label" = $2 ORDER BY "rule_references"."label" ASC LIMIT $3 [["href", "https://www.niap-ccevs.org/Profile/PP.cfm"], ["label", "FAU_GEN.1.1.c"], ["LIMIT", 1]]
RuleReference Load (0.3ms) SELECT "rule_references".* FROM "rule_references" W
def connection
faraday = Faraday.new do |f|
f.response :raise_error
f.adapter Faraday.default_adapter # this must be the last middleware
f.ssl[:verify] = false
end
faraday.basic_auth 'insights-qa', 'redhat'
faraday
end
Host.find_each(100).map do |host|
inventory_host = HostInventoryAPI.new(
host,
host.account,
Settings.host_inventory_url,
host.account.b64identity
).host_already_in_inventory
if inventory_host
old_id = host.id
host.update(id: inventory_host.id)
irb(main):033:0> host = parser.save_host
=> #<Host id: "747db4fd-8221-40f2-bb7c-776fc4671cbb", name: "5.example.com", created_at: nil, updated_at: nil, account_id: "bbc76fb9-de55-490b-903d-ec39d22bf0c7">
irb(main):034:0> host.valid?
=> false
irb(main):035:0> host.errors
=> #<ActiveModel::Errors:0x000000000a5aac30 @base=#<Host id: "747db4fd-8221-40f2-bb7c-776fc4671cbb", name: "5.example.com", created_at: nil, updated_at: nil, account_id: "bbc76fb9-de55-490b-903d-ec39d22bf0c7">, @messages={:profiles=>["is invalid"]}, @details={:profiles=>[{:error=>:invalid}]}>
irb(main):036:0> host.profiles
=> #<ActiveRecord::Associations::CollectionProxy [#<Profile id: "aaf30659-f12b-46c4-8c1e-589dbab528d9", name: "PCI-DSS v3 Control Baseline for Red Hat Enterprise...", ref_id: "xccdf_org.ssgproject.content_profile_pci-dss", policy_id: nil, created_at: "2019-07-09 08:32:34", updated_at: "2019-07-09 08:32:34", description: "This guide presents a catalog of security-relevant...", account_id: "bbc76fb9-de55-490b-903d-ec39d22bf0c
INSERT INTO "rule_references" ("id","href","label") VALUES
('ce7ea772-be9d-4cb4-923b-c901ef18bd7b','http://www.ssi.gouv.fr/administration/bonnes-pratiques/','NT28(R46)'),
('d755a306-cffb-4d90-8339-c43cd2756302','http://www.ssi.gouv.fr/administration/bonnes-pratiques/','NT28(R5)'),
(NULL,'','5.1.1'),
('42af46af-47ed-4f11-8c5e-c2640a05798a','http://iase.disa.mil/stigs/cci/Pages/index.aspx','CCI-001311'),
('860a1562-c21b-4144-9a60-7f69e2e54c84','http://iase.disa.mil/stigs/cci/Pages/index.aspx','CCI-001312'),
('5fadc8fb-377c-4a07-8f38-d8e04b04e0aa','http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-53r4.pdf','AU-9(2)'),
('ce7ea772-be9d-4cb4-923b-c901ef18bd7b','http://www.ssi.gouv.fr/administration/bonnes-pratiques/','NT28(R46)'),
('d755a306-cffb-4d90-8339-c43cd2756302','http://www.ssi.gouv.fr/administration/bonnes-pratiques/','NT28(R5)'),
(NULL,'','5.1.2'),
dlobatog  lenovolobato  ⋯  workspace  insights  iqe_venv  ENV_FOR_DYNACONF=ci DYNACONF_COMPLIANCE={reliability_test="{num_uploads=3,concurrency_limit=35}"} iqe tests plugin compliance -s -k test_compliance_reliability_async
Plugin path: /home/dlobatog/workspace/insights/iqe_venv/lib/python3.6/site-packages/iqe_compliance
============================================================================================================================= test session starts ==============================================================================================================================
platform linux -- Python 3.6.1, pytest-4.4.1, py-1.8.0, pluggy-0.9.0 -- /home/dlobatog/workspace/insights/iqe_venv/bin/python3.6
cachedir: .pytest_cache
metadata: {'Python': '3.6.1', 'Platform': 'Linux-5.1.15-300.fc30.x86_64-x86_64-with-fedora-30-Thirty', 'Packages': {'pytest': '4.4.1', 'py': '1.8.0', 'pluggy': '0.9.0'}, 'Plugins': {'report-parameters': '0.2', 'polarion-collect': '0.13', 'metadata': '1.8.0', 'html':
# frozen_string_literal: true
require 'prometheus_exporter/client'
RuleType = GraphQL::ObjectType.define do
name 'Rule'
description 'A Rule registered in Insights Compliance'
field :id, !types.ID
field :title, !types.String
{
"data": {
"allSystems": [
{
"id": "1a8e87ad-8b46-442c-9c6c-6516d333edbd",
"name": "99.example.com",
"profile_names": "PCI-DSS v3 Control Baseline for Red Hat Enterprise Linux 7",
"rules_passed": 971,
"rules_failed": 56,
"last_scanned": "2019-03-06T06:20:13Z",