Merge pull request #248 from troyready/rhelpkgvers

EL package resource improvements: catch missing newlines & add release info
This commit is contained in:
Christoph Hartmann 2015-12-11 23:11:50 +01:00
commit 22f2a34ce8
3 changed files with 18 additions and 6 deletions

View file

@ -2,7 +2,7 @@
InSpec DSL
=====================================================
|inspec| is a run-time framework and rule language used to specify compliance, securuty, and policy requirements. It includes a collection of resources that help you write auditing controls quickly and easily. The syntax used by both open source and |chef compliance| auditing is the same. The open source |inspec resource| framework is compatible with |chef compliance|.
|inspec| is a run-time framework and rule language used to specify compliance, security, and policy requirements. It includes a collection of resources that help you write auditing controls quickly and easily. The syntax used by both open source and |chef compliance| auditing is the same. The open source |inspec resource| framework is compatible with |chef compliance|.
The InSpec DSL is a Ruby DSL for writing audit controls, which includes audit resources that you can invoke.

View file

@ -105,10 +105,22 @@ class Rpm < PkgManagement
assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
multiple_values: false,
).params
# On some (all?) systems, the linebreak before the vendor line is missing
if params['Version'] =~ /\s*Vendor:/
v = params['Version'].split(' ')[0]
else
v = params['Version']
end
# On some (all?) systems, the linebreak before the build line is missing
if params['Release'] =~ /\s*Build Date:/
r = params['Release'].split(' ')[0]
else
r = params['Release']
end
{
name: params['Name'],
installed: true,
version: params['Version'],
version: "#{v}-#{r}",
type: 'rpm',
}
end

View file

@ -27,18 +27,18 @@ describe 'Inspec::Resources::Package' do
# centos
it 'verify centos package parsing' do
resource = MockLoader.new(:centos7).load_resource('package', 'curl')
pkg = { name: 'curl', installed: true, version: '7.29.0', type: 'rpm' }
pkg = { name: 'curl', installed: true, version: '7.29.0-19.el7', type: 'rpm' }
_(resource.installed?).must_equal true
_(resource.version).must_equal '7.29.0'
_(resource.version).must_equal '7.29.0-19.el7'
_(resource.info).must_equal pkg
end
# wrlinux
it 'verify wrlinux package parsing' do
resource = MockLoader.new(:wrlinux).load_resource('package', 'curl')
pkg = { name: 'curl', installed: true, version: '7.29.0', type: 'rpm' }
pkg = { name: 'curl', installed: true, version: '7.29.0-19.el7', type: 'rpm' }
_(resource.installed?).must_equal true
_(resource.version).must_equal '7.29.0'
_(resource.version).must_equal '7.29.0-19.el7'
_(resource.info).must_equal pkg
end