diff --git a/docs/dsl_inspec.rst b/docs/dsl_inspec.rst index 773914606..fb4d4f518 100644 --- a/docs/dsl_inspec.rst +++ b/docs/dsl_inspec.rst @@ -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. diff --git a/lib/resources/package.rb b/lib/resources/package.rb index 108f6845c..93a36e449 100644 --- a/lib/resources/package.rb +++ b/lib/resources/package.rb @@ -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 diff --git a/test/unit/resources/package_test.rb b/test/unit/resources/package_test.rb index dc4769cb2..27edf93e7 100644 --- a/test/unit/resources/package_test.rb +++ b/test/unit/resources/package_test.rb @@ -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