Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Lobato García dLobatog

View GitHub Profile
View gist:63c78829af1dff782802144522a2c695
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
View gist:53225294303b2676ed99cc21dbc2b022
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_.*/) }
View gist:2f382f1cd9adfed7581cda530b6defd7
[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
View gist:9d18276de2e47761988b9824fd058054
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
View gist:0ea95043431c0c38e223bbfb1cdfb860
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)
View gist:fb1bc3109e171af52d997233823f51c1
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
View gist:0ccbed354b93bb6f5ffabf2aa739cdb3
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'),
View gist:2545d6aa0156a80cb9127e5d2be18662
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':
View gist:14a39caca58bee912ceb7d521cb86915
# 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
View gist:e270c634c644dc3cf0f3b1c844c59ce4
{
"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",
You can’t perform that action at this time.