inspec 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 716b0f2740402869ee9542519dff597bef2c6239
4
- data.tar.gz: 304547b882202c6a9748148987a8a859efe14752
3
+ metadata.gz: d2e2aeebe40a757983d190ca0921c507e1158c33
4
+ data.tar.gz: 99aad400d64fd3da51392aaa752cbbb2a2647a6b
5
5
  SHA512:
6
- metadata.gz: 2796299fda33d2ad2251e0627c7ecc7ee8e54d2c91e79dc9e03a6c8a1a924fa5105ef77d045a48cbfcc84f0c830187c69f7da6586cf83abce74319eef21a4c5d
7
- data.tar.gz: 26174779c09a85bcb8dfbb2d3026113b80e27158ae8d7ad021a7e9b8155b845ab47389c8813808d7ee5bab02c5ad35ae27a41f2c933833f34ad6204c5a5fe508
6
+ metadata.gz: 538a625e9eb9019e46b72095139215548f2f5aa96bb4cfba9e54ac0c4ad64375a4be36f0d15d099b9dde0cb0c8e34f6bc2894dff712adbdffe68d5ffb57c5e7b
7
+ data.tar.gz: 75fa86184262907ea53bff79ba9c708671970c7825ee33e966b88feb2739c7ed0c38b189a13394edd1e6e2a70060853f3e8e2ced4488f0d888cf011ccce0aa7e
data/CHANGELOG.md CHANGED
@@ -1,32 +1,48 @@
1
1
  # Change Log
2
2
 
3
- ## [1.12.0](https://github.com/chef/inspec/tree/1.12.0) (2017-02-03)
4
- [Full Changelog](https://github.com/chef/inspec/compare/v1.11.0...1.12.0)
3
+ ## [1.13.0](https://github.com/chef/inspec/tree/1.13.0) (2017-02-07)
4
+ [Full Changelog](https://github.com/chef/inspec/compare/v1.12.0...1.13.0)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - add "packages" resource [\#1458](https://github.com/chef/inspec/pull/1458) ([jtimberman](https://github.com/jtimberman))
9
+ - Provide a way to force it vs its for any argument [\#1457](https://github.com/chef/inspec/pull/1457) ([alexpop](https://github.com/alexpop))
5
10
 
6
11
  **Closed issues:**
7
12
 
8
- - `skip` parameter ignored inside `describe` block [\#1450](https://github.com/chef/inspec/issues/1450)
13
+ - Ignore me [\#1464](https://github.com/chef/inspec/issues/1464)
14
+ - redirect URL downloads.inspec.io to https://downloads.chef.io/inspec [\#1462](https://github.com/chef/inspec/issues/1462)
9
15
 
10
- **Merged pull requests:**
16
+ ## [v1.12.0](https://github.com/chef/inspec/tree/v1.12.0) (2017-02-03)
17
+ [Full Changelog](https://github.com/chef/inspec/compare/v1.11.0...v1.12.0)
18
+
19
+ **Implemented enhancements:**
11
20
 
12
21
  - Allow setting of the tests array [\#1455](https://github.com/chef/inspec/pull/1455) ([alexpop](https://github.com/alexpop))
13
22
  - switch to faraday as http backend [\#1452](https://github.com/chef/inspec/pull/1452) ([chris-rock](https://github.com/chris-rock))
14
23
  - Add FilterTable support to processes resource [\#1451](https://github.com/chef/inspec/pull/1451) ([alexpop](https://github.com/alexpop))
15
24
 
25
+ **Closed issues:**
26
+
27
+ - `skip` parameter ignored inside `describe` block [\#1450](https://github.com/chef/inspec/issues/1450)
28
+
16
29
  ## [v1.11.0](https://github.com/chef/inspec/tree/v1.11.0) (2017-02-01)
17
30
  [Full Changelog](https://github.com/chef/inspec/compare/v1.10.0...v1.11.0)
18
31
 
19
32
  **Implemented enhancements:**
20
33
 
21
34
  - HTTP request resource [\#336](https://github.com/chef/inspec/issues/336)
35
+ - derive xinetd protocol from socket\_type when not defined in the config file [\#1448](https://github.com/chef/inspec/pull/1448) ([alexpop](https://github.com/alexpop))
36
+ - Add negate! support for describe.one object [\#1442](https://github.com/chef/inspec/pull/1442) ([alexpop](https://github.com/alexpop))
37
+ - Version method for kernel\_module [\#1435](https://github.com/chef/inspec/pull/1435) ([postgred](https://github.com/postgred))
22
38
 
23
- **Merged pull requests:**
39
+ **Fixed bugs:**
24
40
 
25
- - derive xinetd protocol from socket\_type when not defined in the config file [\#1448](https://github.com/chef/inspec/pull/1448) ([alexpop](https://github.com/alexpop))
26
41
  - Fix xinetd parsing of services from the same file. Expose resource.protocols [\#1444](https://github.com/chef/inspec/pull/1444) ([alexpop](https://github.com/alexpop))
27
- - Add negate! support for describe.one object [\#1442](https://github.com/chef/inspec/pull/1442) ([alexpop](https://github.com/alexpop))
42
+
43
+ **Merged pull requests:**
44
+
28
45
  - Make minor grammar/style changes to `inspec.io` [\#1441](https://github.com/chef/inspec/pull/1441) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
29
- - Version method for kernel\_module [\#1435](https://github.com/chef/inspec/pull/1435) ([postgred](https://github.com/postgred))
30
46
 
31
47
  ## [v1.10.0](https://github.com/chef/inspec/tree/v1.10.0) (2017-01-26)
32
48
  [Full Changelog](https://github.com/chef/inspec/compare/v1.9.0...v1.10.0)
@@ -53,7 +53,7 @@ module Inspec
53
53
  # this will go in its()
54
54
  xres = last_call
55
55
  else
56
- res += '.' + ruby_qualifier(last)
56
+ res += '.' + ruby_qualifier(last) unless last_call.empty?
57
57
  end
58
58
  end
59
59
 
@@ -107,6 +107,7 @@ require 'resources/oneget'
107
107
  require 'resources/os'
108
108
  require 'resources/os_env'
109
109
  require 'resources/package'
110
+ require 'resources/packages'
110
111
  require 'resources/parse_config'
111
112
  require 'resources/passwd'
112
113
  require 'resources/pip'
@@ -4,5 +4,5 @@
4
4
  # author: Christoph Hartmann
5
5
 
6
6
  module Inspec
7
- VERSION = '1.12.0'.freeze
7
+ VERSION = '1.13.0'.freeze
8
8
  end
@@ -0,0 +1,86 @@
1
+ # encoding: utf-8
2
+ # copyright: 2017, Chef Software, Inc. <legal@chef.io>
3
+ # author: Joshua Timberman
4
+ # author: Alex Pop
5
+ # license: All rights reserved
6
+
7
+ require 'utils/filter'
8
+
9
+ module Inspec::Resources
10
+ class Packages < Inspec.resource(1)
11
+ name 'packages'
12
+ desc 'Use the packages InSpec audit resource to test properties for multiple packages installed on the system'
13
+ example "
14
+ describe packages(/xserver-xorg.*/) do
15
+ its('entries') { should be_empty }
16
+ end
17
+ describe packages('vim').entries.length do
18
+ it { should be > 1 }
19
+ end
20
+ describe packages(/vi.+/).where { status != 'installed' } do
21
+ its('statuses') { should be_empty }
22
+ end
23
+ "
24
+
25
+ def initialize(pattern)
26
+ @pattern = pattern_regexp(pattern)
27
+ all_pkgs = package_list
28
+ @list = all_pkgs.find_all do |hm|
29
+ hm[:name] =~ pattern_regexp(pattern)
30
+ end
31
+ end
32
+
33
+ def to_s
34
+ "Packages #{@pattern.class == String ? @pattern : @pattern.inspect}"
35
+ end
36
+
37
+ filter = FilterTable.create
38
+ filter.add_accessor(:where)
39
+ .add_accessor(:entries)
40
+ .add(:statuses, field: 'status', style: :simple)
41
+ .add(:names, field: 'name')
42
+ .add(:versions, field: 'version')
43
+ .connect(self, :filtered_packages)
44
+
45
+ private
46
+
47
+ def pattern_regexp(p)
48
+ if p.class == String
49
+ Regexp.new(Regexp.escape(p))
50
+ elsif p.class == Regexp
51
+ p
52
+ else
53
+ fail 'invalid name argument to packages resource, please use a "string" or /regexp/'
54
+ end
55
+ end
56
+
57
+ def filtered_packages
58
+ @list
59
+ end
60
+
61
+ def package_list
62
+ os = inspec.os
63
+
64
+ if os.debian?
65
+ command = "dpkg-query -W -f='${db:Status-Abbrev} ${Package} ${Version}\\n'"
66
+ else
67
+ fail "packages resource is not yet supported on #{os.name}"
68
+ end
69
+ build_package_list(command)
70
+ end
71
+
72
+ Package = Struct.new(:status, :name, :version)
73
+
74
+ def build_package_list(command)
75
+ cmd = inspec.command(command)
76
+ all = cmd.stdout.split("\n")[1..-1]
77
+ return [] if all.nil?
78
+ all.map do |m|
79
+ a = m.split
80
+ a[0] = 'installed' if a[0] =~ /^.i/
81
+ a[2] = a[2].split(':').last
82
+ Package.new(*a)
83
+ end
84
+ end
85
+ end
86
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2017-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train
@@ -510,6 +510,7 @@ files:
510
510
  - lib/resources/os.rb
511
511
  - lib/resources/os_env.rb
512
512
  - lib/resources/package.rb
513
+ - lib/resources/packages.rb
513
514
  - lib/resources/parse_config.rb
514
515
  - lib/resources/passwd.rb
515
516
  - lib/resources/pip.rb