Bug 1372575 - foreman_scap_client with invalid policy id raise error "undefined method `[]' for nil:NilClass"
Summary: foreman_scap_client with invalid policy id raise error "undefined method `[]'...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: SCAP Plugin
Version: 6.2.0
Hardware: All
OS: All
low
low vote
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Nikhil Kathole
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-02 06:10 UTC by Ranjan Kumar
Modified: 2019-09-26 15:40 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 16:51:07 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 16402 0 Normal Closed foreman_scap_client with invalid policy id raise error "undefined method `[]' for nil:NilClass" 2020-11-16 12:51:53 UTC

Description Ranjan Kumar 2016-09-02 06:10:49 UTC
Description of problem: foreman_scap_client with invalid policy id raise an exception.
  
#foreman_scap_client 1  <-- invalid id
/usr/share/gems/gems/foreman_scap_client-0.1.2/lib/foreman_scap_client/client.rb:129:in `ensure_scan_file': undefined method `[]' for nil:NilClass (NoMethodError)
	from /usr/share/gems/gems/foreman_scap_client-0.1.2/lib/foreman_scap_client/client.rb:15:in `run'
	from /usr/share/gems/gems/foreman_scap_client-0.1.2/bin/foreman_scap_client:10:in `<top (required)>'
	from /usr/bin/foreman_scap_client:23:in `load'
	from /usr/bin/foreman_scap_client:23:in `<main>'


Version-Release number of selected component (if applicable): Satellite 6.2

Comment 2 Bryan Kearney 2016-09-06 10:19:07 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/16402 has been resolved.

Comment 4 Nikhil Kathole 2017-08-24 11:26:39 UTC
VERIFIED

Version Tested:
Satellite-6.3 Snap 12

Steps:

1. Applied policy on host
2. On host, run foreman_scap_client <invalid_id>

cat /etc/foreman_scap_client/config.yaml
>>>
# DO NOT EDIT THIS FILE MANUALLY
# IT IS MANAGED BY PUPPET

# Foreman proxy to which reports should be uploaded
:server: ''
:port: 9090

## SSL specific options ##
# Client CA file.
# It could be Puppet CA certificate (e.g., '/var/lib/puppet/ssl/certs/ca.pem')
# Or (recommended for client reporting to Katello) subscription manager CA file, (e.g., '/etc/rhsm/ca/katello-server-ca.pem')
:ca_file: '/etc/rhsm/ca/katello-server-ca.pem'
# Client host certificate.
# It could be Puppet agent host certificate (e.g., '/var/lib/puppet/ssl/certs/myhost.example.com.pem')
# Or (recommended for client reporting to Katello) consumer certificate (e.g., '/etc/pki/consumer/cert.pem')
:host_certificate: '/etc/pki/consumer/cert.pem'
# Client private key
# It could be Puppet agent private key (e.g., '/var/lib/puppet/ssl/private_keys/myhost.example.com.pem')
# Or (recommended for client reporting to Katello) consumer private key (e.g., '/etc/pki/consumer/key.pem')
:host_private_key: '/etc/pki/consumer/key.pem'

# policy (key is id as in Foreman)

1:
  :profile: 'xccdf_org.ssgproject.content_profile_common'
  :content_path: '/var/lib/openscap/content/96c2a9d5278d5da905221bbb2dc61d0ace7ee3d97f021fccac994d26296d986d.xml'
  # Download path
  # A path to download SCAP content from proxy
  :download_path: '/compliance/policies/1/content/96c2a9d5278d5da905221bbb2dc61d0ace7ee3d97f021fccac994d26296d986d'
  :tailoring_path: ''
  :tailoring_download_path: ''


foreman_scap_client 3
>>>
Policy id 3 not found.


Successfully shows the error as policy id not found.

Comment 5 Satellite Program 2018-02-21 16:51:07 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.
> 
> For information on the advisory, and where to find the updated files, follow the link below.
> 
> If the solution does not work for you, open a new bug report.
> 
> https://access.redhat.com/errata/RHSA-2018:0336


Note You need to log in before you can comment on or make changes to this bug.