inspec 1.35.1 → 1.36.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -20
- data/README.md +24 -34
- data/docs/resources/file.md.erb +20 -7
- data/docs/resources/nginx_conf.md.erb +122 -0
- data/docs/resources/package.md.erb +1 -1
- data/lib/inspec/dependencies/requirement.rb +12 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/file.rb +6 -0
- data/lib/resources/nginx_conf.rb +106 -0
- data/lib/resources/processes.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e657ef01d81b9cfa453584a6b27a56219faab15
|
4
|
+
data.tar.gz: ec4faacc317379e4dbd095fc45c1a58f76eb7cd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e21aed7d8cce4934e220299434dfc0af90e9bbda871f6026c4db94e61e7d94509bf048cd2961d2127149b34d6ba928e435d9cedb07fd677a73132479a7b9a7e
|
7
|
+
data.tar.gz: cda173a2a0071274fc294dbff1cd69d0ffae1b7bd2b4baa16eac8758609ba31c7ccc5f534f6746da38b523ed51ead932af9444f120a30673a9167f6d41cb33b6
|
data/CHANGELOG.md
CHANGED
@@ -1,39 +1,49 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
<!-- latest_release 1.
|
4
|
-
## [v1.
|
3
|
+
<!-- latest_release 1.35.5 -->
|
4
|
+
## [v1.35.5](https://github.com/chef/inspec/tree/v1.35.5) (2017-09-06)
|
5
5
|
|
6
|
-
####
|
7
|
-
-
|
6
|
+
#### Enhancements
|
7
|
+
- add nginx_conf accessors for http, servers, and locations [#2119](https://github.com/chef/inspec/pull/2119) ([arlimus](https://github.com/arlimus))
|
8
8
|
<!-- latest_release -->
|
9
9
|
|
10
|
-
<!-- release_rollup since=1.
|
11
|
-
### Changes since 1.
|
12
|
-
|
13
|
-
#### Enhancements
|
14
|
-
- port resource: support ss instead of netstat [#2110](https://github.com/chef/inspec/pull/2110) ([adamleff](https://github.com/adamleff)) <!-- 1.34.8 -->
|
15
|
-
- pip resource: support non-default pip locations, such as virtualenvs [#2097](https://github.com/chef/inspec/pull/2097) ([tonybaloney](https://github.com/tonybaloney)) <!-- 1.34.7 -->
|
10
|
+
<!-- release_rollup since=1.35.1 -->
|
11
|
+
### Changes since 1.35.1 release
|
16
12
|
|
17
13
|
#### Bug Fixes
|
18
|
-
-
|
19
|
-
-
|
20
|
-
- auditd_rules resource: fix get_keys error on lines that have no keys [#2103](https://github.com/chef/inspec/pull/2103) ([jburns12](https://github.com/jburns12)) <!-- 1.34.4 -->
|
14
|
+
- Fix alternate path profile chaining [#2121](https://github.com/chef/inspec/pull/2121) ([trevor-vaughan](https://github.com/trevor-vaughan)) <!-- 1.35.4 -->
|
15
|
+
- Modify linux regular expression to handle process names with spaces [#2117](https://github.com/chef/inspec/pull/2117) ([ChadScott](https://github.com/ChadScott)) <!-- 1.35.3 -->
|
21
16
|
|
22
|
-
####
|
23
|
-
-
|
17
|
+
#### Enhancements
|
18
|
+
- add nginx_conf accessors for http, servers, and locations [#2119](https://github.com/chef/inspec/pull/2119) ([arlimus](https://github.com/arlimus)) <!-- 1.35.5 -->
|
19
|
+
- File Resource: add be_setgid, be_setuid, be_sticky matchers [#2104](https://github.com/chef/inspec/pull/2104) ([clintoncwolfe](https://github.com/clintoncwolfe)) <!-- 1.35.2 -->
|
20
|
+
<!-- release_rollup -->
|
21
|
+
|
22
|
+
<!-- latest_stable_release -->
|
23
|
+
## [v1.35.1](https://github.com/chef/inspec/tree/v1.35.1) (2017-08-31)
|
24
24
|
|
25
25
|
#### New Resources
|
26
|
-
-
|
27
|
-
- Add support for XML files [#2107](https://github.com/chef/inspec/pull/2107) ([jonathanmorley](https://github.com/jonathanmorley))
|
28
|
-
-
|
29
|
-
<!-- release_rollup -->
|
26
|
+
- aide_conf resource: test configuration of the AIDE file integrity tool [#2063](https://github.com/chef/inspec/pull/2063) ([jburns12](https://github.com/jburns12))
|
27
|
+
- Add support for XML files [#2107](https://github.com/chef/inspec/pull/2107) ([jonathanmorley](https://github.com/jonathanmorley))
|
28
|
+
- etc_hosts resource: test the contents of the /etc/hosts file [#2065](https://github.com/chef/inspec/pull/2065) ([dromazmj](https://github.com/dromazmj))
|
30
29
|
|
30
|
+
#### Enhancements
|
31
|
+
- pip resource: support non-default pip locations, such as virtualenvs [#2097](https://github.com/chef/inspec/pull/2097) ([tonybaloney](https://github.com/tonybaloney))
|
32
|
+
- port resource: support ss instead of netstat [#2110](https://github.com/chef/inspec/pull/2110) ([adamleff](https://github.com/adamleff))
|
33
|
+
|
34
|
+
#### Bug Fixes
|
35
|
+
- auditd_rules resource: fix get_keys error on lines that have no keys [#2103](https://github.com/chef/inspec/pull/2103) ([jburns12](https://github.com/jburns12))
|
36
|
+
- http resource: prevent repeat calls during a control with multiple tests [#2108](https://github.com/chef/inspec/pull/2108) ([mivok](https://github.com/mivok))
|
37
|
+
- Support mixed-case group entries [#2101](https://github.com/chef/inspec/pull/2101) ([adamleff](https://github.com/adamleff))
|
38
|
+
|
39
|
+
#### Merged Pull Requests
|
40
|
+
- Add sensitive flag to resources to restrict logging output [#2017](https://github.com/chef/inspec/pull/2017) ([arothian](https://github.com/arothian))
|
31
41
|
<!-- latest_stable_release -->
|
42
|
+
|
32
43
|
## [v1.34.1](https://github.com/chef/inspec/tree/v1.34.1) (2017-08-24)
|
33
44
|
|
34
45
|
#### Enhancements
|
35
46
|
- Refine the profile/test summary output of the CLI formatter [#2094](https://github.com/chef/inspec/pull/2094) ([adamleff](https://github.com/adamleff))
|
36
|
-
<!-- latest_stable_release -->
|
37
47
|
|
38
48
|
## [v1.33.12](https://github.com/chef/inspec/tree/v1.33.12) (2017-08-18)
|
39
49
|
|
data/README.md
CHANGED
@@ -339,11 +339,10 @@ The InSpec community and maintainers are very active and helpful. This project b
|
|
339
339
|
|
340
340
|
## Testing InSpec
|
341
341
|
|
342
|
-
We perform `unit
|
342
|
+
We perform `unit` and `integration` tests.
|
343
343
|
|
344
|
-
|
345
|
-
|
346
|
-
* `integration` tests run against VMs via test-kitchen and [kitchen-inspec](https://github.com/chef/kitchen-inspec)
|
344
|
+
- `unit` tests ensure the intended behaviour of the implementation
|
345
|
+
- `integration` tests run against Docker-based VMs via test-kitchen and [kitchen-inspec](https://github.com/chef/kitchen-inspec)
|
347
346
|
|
348
347
|
### Unit tests
|
349
348
|
|
@@ -351,60 +350,51 @@ We perform `unit`, `resource` and `integration` tests.
|
|
351
350
|
bundle exec rake test
|
352
351
|
```
|
353
352
|
|
354
|
-
If you like to run only one test
|
353
|
+
If you like to run only one test file:
|
355
354
|
|
356
355
|
```bash
|
357
|
-
bundle exec
|
356
|
+
bundle exec m test/unit/resources/user_test.rb
|
358
357
|
```
|
359
358
|
|
360
|
-
|
361
|
-
|
362
|
-
Resource tests make sure the backend execution layer behaves as expected. These tests will take a while, as a lot of different operating systems and configurations are being tested.
|
363
|
-
|
364
|
-
You will require:
|
365
|
-
|
366
|
-
* docker
|
367
|
-
|
368
|
-
Run `resource` tests with
|
359
|
+
You may also run a single test within a file by line number:
|
369
360
|
|
370
361
|
```bash
|
371
|
-
bundle exec
|
372
|
-
bundle exec rake test:resources config=test/test-extra.yaml
|
362
|
+
bundle exec m test/unit/resources/user_test.rb -l 123
|
373
363
|
```
|
374
364
|
|
375
365
|
### Integration tests
|
376
366
|
|
377
367
|
These tests download various virtual machines, to ensure InSpec is working as expected across different operating systems.
|
378
368
|
|
379
|
-
|
369
|
+
These tests require the following gems:
|
370
|
+
|
371
|
+
- test-kitchen
|
372
|
+
- kitchen-dokken
|
373
|
+
- kitchen-inspec
|
380
374
|
|
381
|
-
|
382
|
-
* test-kitchen
|
375
|
+
These gems are provided via the `integration` group in the project's Gemfile.
|
383
376
|
|
384
|
-
|
377
|
+
In addition, these test require Docker to be available on your machine or a remote Docker machine configured via the standard Docker environment variables.
|
378
|
+
|
379
|
+
#### Running Integration tests
|
380
|
+
|
381
|
+
List the various test instances available:
|
385
382
|
|
386
383
|
```bash
|
387
|
-
|
384
|
+
bundle exec kitchen list`
|
388
385
|
```
|
389
386
|
|
390
|
-
|
387
|
+
The platforms and test suites are configured in the `.kitchen.yml` file. Once you know which instance you wish to test, test that instance:
|
391
388
|
|
392
389
|
```bash
|
393
|
-
|
394
|
-
export AWS_SECRET_ACCESS_KEY=enteryoursecreykey
|
395
|
-
export AWS_KEYPAIR_NAME=enteryoursshkeyid
|
396
|
-
export EC2_SSH_KEY_PATH=~/.ssh/id_aws.pem
|
397
|
-
KITCHEN_YAML=.kitchen.ec2.yml bundle exec kitchen test
|
390
|
+
bundle exec kitchen test <INSTANCE_NAME>
|
398
391
|
```
|
399
392
|
|
400
|
-
|
393
|
+
You may test all instances in parallel with:
|
401
394
|
|
395
|
+
```bash
|
396
|
+
bundle exec kitchen test -c
|
402
397
|
```
|
403
|
-
transport:
|
404
|
-
ssh_key: /Users/chartmann/aws/aws_chartmann.pem
|
405
|
-
username: ec2-user
|
406
|
-
```
|
407
|
-
|
408
398
|
|
409
399
|
## License
|
410
400
|
|
data/docs/resources/file.md.erb
CHANGED
@@ -125,12 +125,30 @@ a user:
|
|
125
125
|
|
126
126
|
it { should be_readable.by_user('user') }
|
127
127
|
|
128
|
+
### be_setgid
|
129
|
+
|
130
|
+
The `be_setgid` matcher tests if the 'setgid' permission is set on the file or directory. On executable files, this causes the process to be started owned by the group that owns the file, rather than the primary group of the invocating user. This can result in escalation of privilege. On Linux, when setgid is set on directories, setgid causes newly created files and directories to be owned by the group that owns the setgid parent directory; additionally, newly created subdirectories will have the setgid bit set. To use this matcher:
|
131
|
+
|
132
|
+
it { should be_setgid }
|
133
|
+
|
128
134
|
### be_socket
|
129
135
|
|
130
136
|
The `be_socket` matcher tests if the file exists as socket (`.sock`), such as `/var/run/php-fpm.sock`:
|
131
137
|
|
132
138
|
it { should be_socket }
|
133
139
|
|
140
|
+
### be_sticky
|
141
|
+
|
142
|
+
The `be_sticky` matcher tests if the 'sticky bit' permission is set on the directory. On directories, this restricts file deletion to the owner of the file, even if the permission of the parent directory would normally permit deletion by others. This is commonly used on /tmp filesystems. To use this matcher:
|
143
|
+
|
144
|
+
it { should be_sticky }
|
145
|
+
|
146
|
+
### be_setuid
|
147
|
+
|
148
|
+
The `be_setuid` matcher tests if the 'setuid' permission is set on the file. On executable files, this causes the process to be started owned by the user that owns the file, rather than invocating user. This can result in escalation of privilege. To use this matcher:
|
149
|
+
|
150
|
+
it { should be_setuid }
|
151
|
+
|
134
152
|
### be_symlink
|
135
153
|
|
136
154
|
The `be_symlink` matcher tests if the file exists as a symbolic, or soft link that contains an absolute or relative path reference to another file:
|
@@ -213,16 +231,11 @@ The `have_mode` matcher tests if a file has a mode assigned to it:
|
|
213
231
|
|
214
232
|
### link_path
|
215
233
|
|
216
|
-
The `link_path` matcher tests if the file exists at the specified path
|
234
|
+
The `link_path` matcher tests if the file exists at the specified path. If the file is a symlink,
|
235
|
+
InSpec will resolve the symlink and return the ultimate linked file:
|
217
236
|
|
218
237
|
its('link_path') { should eq '/some/path/to/file' }
|
219
238
|
|
220
|
-
### link_target
|
221
|
-
|
222
|
-
The `link_target` matcher tests if a file that is linked to this file exists at the specified path:
|
223
|
-
|
224
|
-
its('link_target') { should eq '/some/path/to/file' }
|
225
|
-
|
226
239
|
### match
|
227
240
|
|
228
241
|
<%= partial "/shared/matcher_match" %>
|
@@ -0,0 +1,122 @@
|
|
1
|
+
---
|
2
|
+
title: About the nginx_conf Resource
|
3
|
+
---
|
4
|
+
|
5
|
+
# nginx_conf
|
6
|
+
|
7
|
+
Use the `nginx_conf` InSpec resource to test configuration data for the NGINX server located at `/etc/nginx/nginx.conf` on Linux and Unix platforms.
|
8
|
+
|
9
|
+
**Stability: Experimental**
|
10
|
+
|
11
|
+
## Syntax
|
12
|
+
|
13
|
+
An `nginx_conf` resource block declares the client NGINX configuration data to be tested:
|
14
|
+
|
15
|
+
describe nginx_conf.params['pid'] do
|
16
|
+
it { should cmp 'logs/nginx.pid' }
|
17
|
+
end
|
18
|
+
|
19
|
+
where
|
20
|
+
|
21
|
+
* `nginx_conf` is the resource to reference your NGINX configuration
|
22
|
+
* `params` accesses all its parameters
|
23
|
+
* `params['pid']` selects the `pid` entry from the global NGINX configuration
|
24
|
+
* `{ should cmp 'logs/nginx.pid' }` tests if the PID is set to `logs/nginx.pid` (via `cmp` matcher)
|
25
|
+
|
26
|
+
|
27
|
+
## Matchers
|
28
|
+
|
29
|
+
This InSpec audit resource has the following matchers:
|
30
|
+
|
31
|
+
### http
|
32
|
+
|
33
|
+
Retrieves all `http` entries in the configuration file.
|
34
|
+
|
35
|
+
nginx_conf.http
|
36
|
+
=> nginx_conf /etc/nginx/nginx.conf, http entries
|
37
|
+
|
38
|
+
It provides further access to all individual entries, servers, and locations.
|
39
|
+
|
40
|
+
nginx_conf.http.entries
|
41
|
+
=> [nginx_conf /etc/nginx/nginx.conf, http entry ...]
|
42
|
+
|
43
|
+
nginx_conf.http.servers
|
44
|
+
=> [nginx_conf /etc/nginx/nginx.conf, server entry ...]
|
45
|
+
|
46
|
+
nginx_conf.http.locations
|
47
|
+
=> [nginx_conf /etc/nginx/nginx.conf, location entry ...]
|
48
|
+
|
49
|
+
You can access each of these from the array and inspect it further (see below).
|
50
|
+
|
51
|
+
### servers
|
52
|
+
|
53
|
+
Retrieve all `servers` entries in the configuration:
|
54
|
+
|
55
|
+
# all servers across all configs aggregated:
|
56
|
+
nginx_conf.servers
|
57
|
+
=> [nginx_conf /etc/nginx/nginx.conf, server entry ...]
|
58
|
+
|
59
|
+
# servers that belong to a specific http entry:
|
60
|
+
nginx_conf.http.entries[0].servers
|
61
|
+
=> [nginx_conf /etc/nginx/nginx.conf, server entry ...]
|
62
|
+
|
63
|
+
Servers provide access to all their locations, parent http entry, and raw parameters:
|
64
|
+
|
65
|
+
server = nginx_conf.servers[0]
|
66
|
+
|
67
|
+
server.locations
|
68
|
+
=> [nginx_conf /etc/nginx/nginx.conf, location entry ...]
|
69
|
+
|
70
|
+
server.parent
|
71
|
+
=> nginx_conf /etc/nginx/nginx.conf, http entry
|
72
|
+
|
73
|
+
server.params
|
74
|
+
=> {"listen"=>[["85"]],
|
75
|
+
"server_name"=>[["domain1.com", "www.domain1.com"]],
|
76
|
+
"root"=>[["html"]],
|
77
|
+
"location"=>[{"_"=>["~", "\\.php$"], "fastcgi_pass"=>[["127.0.0.1:1025"]]}]}
|
78
|
+
|
79
|
+
### locations
|
80
|
+
|
81
|
+
Retrieve all `location` entries in the configuration:
|
82
|
+
|
83
|
+
# all locations across all configs aggregated:
|
84
|
+
nginx_conf.locations
|
85
|
+
=> [nginx_conf /etc/nginx/nginx.conf, location entry ...]
|
86
|
+
|
87
|
+
# locations of a http entry aggregated:
|
88
|
+
nginx_conf.http.entries[0].locations
|
89
|
+
=> [nginx_conf /etc/nginx/nginx.conf, location entry ...]
|
90
|
+
|
91
|
+
# locations of a specific server:
|
92
|
+
nginx_conf.servers[0].locations
|
93
|
+
=> [nginx_conf /etc/nginx/nginx.conf, location entry ...]
|
94
|
+
|
95
|
+
Locations provide access to their parent server entry and raw parameters:
|
96
|
+
|
97
|
+
location = nginx_conf.locations[0]
|
98
|
+
|
99
|
+
location.parent
|
100
|
+
=> nginx_conf /etc/nginx/nginx.conf, server entry
|
101
|
+
|
102
|
+
location.params
|
103
|
+
=> {"_"=>["~", "\\.php$"], "fastcgi_pass"=>[["127.0.0.1:1025"]]}
|
104
|
+
|
105
|
+
## Examples
|
106
|
+
|
107
|
+
The following examples show how to use this InSpec audit resource.
|
108
|
+
|
109
|
+
### Find a specific server
|
110
|
+
|
111
|
+
servers = nginx_conf.servers
|
112
|
+
domain2 = servers.find { |s| s.params['server_name'].flatten.include? 'domain2.com' }
|
113
|
+
describe 'No server serves domain2' do
|
114
|
+
subject { domain2 }
|
115
|
+
it { should be_nil }
|
116
|
+
end
|
117
|
+
|
118
|
+
### Test a raw parameter
|
119
|
+
|
120
|
+
describe nginx_conf.params['worker_processes'].flatten do
|
121
|
+
it { should cmp 5 }
|
122
|
+
end
|
@@ -67,7 +67,7 @@ The `version` matcher tests if the named package version is on the system:
|
|
67
67
|
|
68
68
|
The following examples show how to use this InSpec audit resource.
|
69
69
|
|
70
|
-
### Test if
|
70
|
+
### Test if NGINX version 1.9.5 is installed
|
71
71
|
|
72
72
|
describe package('nginx') do
|
73
73
|
it { should be_installed }
|
@@ -10,7 +10,18 @@ module Inspec
|
|
10
10
|
class Requirement
|
11
11
|
def self.from_metadata(dep, cache, opts)
|
12
12
|
raise 'Cannot load empty dependency.' if dep.nil? || dep.empty?
|
13
|
-
|
13
|
+
|
14
|
+
req_path = opts[:cwd]
|
15
|
+
|
16
|
+
if dep[:path]
|
17
|
+
req_path = File.expand_path(dep[:path], req_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
new(dep[:name],
|
21
|
+
dep[:version],
|
22
|
+
cache,
|
23
|
+
req_path,
|
24
|
+
opts.merge(dep))
|
14
25
|
end
|
15
26
|
|
16
27
|
def self.from_lock_entry(entry, cwd, cache, backend, opts = {})
|
data/lib/inspec/version.rb
CHANGED
data/lib/resources/file.rb
CHANGED
@@ -112,14 +112,20 @@ module Inspec::Resources
|
|
112
112
|
(mode & 04000) > 0
|
113
113
|
end
|
114
114
|
|
115
|
+
alias setuid? suid
|
116
|
+
|
115
117
|
def sgid
|
116
118
|
(mode & 02000) > 0
|
117
119
|
end
|
118
120
|
|
121
|
+
alias setgid? sgid
|
122
|
+
|
119
123
|
def sticky
|
120
124
|
(mode & 01000) > 0
|
121
125
|
end
|
122
126
|
|
127
|
+
alias sticky? sticky
|
128
|
+
|
123
129
|
def to_s
|
124
130
|
"File #{source_path}"
|
125
131
|
end
|
data/lib/resources/nginx_conf.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# author: Christoph Hartmann
|
4
4
|
|
5
5
|
require 'utils/nginx_parser'
|
6
|
+
require 'forwardable'
|
6
7
|
|
7
8
|
# STABILITY: Experimental
|
8
9
|
# This resouce needs a proper interace to the underlying data, which is currently missing.
|
@@ -22,6 +23,8 @@ module Inspec::Resources
|
|
22
23
|
describe nginx_conf('/path/to/my/nginx.conf').params ...
|
23
24
|
"
|
24
25
|
|
26
|
+
extend Forwardable
|
27
|
+
|
25
28
|
attr_reader :contents
|
26
29
|
|
27
30
|
def initialize(conf_path = nil)
|
@@ -37,6 +40,12 @@ module Inspec::Resources
|
|
37
40
|
@params = {}
|
38
41
|
end
|
39
42
|
|
43
|
+
def http
|
44
|
+
NginxConfHttp.new(params['http'], self)
|
45
|
+
end
|
46
|
+
|
47
|
+
def_delegators :http, :servers, :locations
|
48
|
+
|
40
49
|
def to_s
|
41
50
|
"nginx_conf #{@conf_path}"
|
42
51
|
end
|
@@ -92,4 +101,101 @@ module Inspec::Resources
|
|
92
101
|
Hash[data.map { |k, v| [k, resolve_references(v, rel_path)] }]
|
93
102
|
end
|
94
103
|
end
|
104
|
+
|
105
|
+
class NginxConfHttp
|
106
|
+
attr_reader :entries
|
107
|
+
def initialize(params, parent)
|
108
|
+
@parent = parent
|
109
|
+
@entries = (params || []).map { |x| NginxConfHttpEntry.new(x, parent) }
|
110
|
+
end
|
111
|
+
|
112
|
+
def servers
|
113
|
+
@entries.map(&:servers).flatten
|
114
|
+
end
|
115
|
+
|
116
|
+
def locations
|
117
|
+
servers.map(&:locations).flatten
|
118
|
+
end
|
119
|
+
|
120
|
+
def to_s
|
121
|
+
@parent.to_s + ', http entries'
|
122
|
+
end
|
123
|
+
alias inspect to_s
|
124
|
+
end
|
125
|
+
|
126
|
+
class NginxConfHttpEntry
|
127
|
+
attr_reader :params, :parent
|
128
|
+
def initialize(params, parent)
|
129
|
+
@params = params || {}
|
130
|
+
@parent = parent
|
131
|
+
end
|
132
|
+
|
133
|
+
filter = FilterTable.create
|
134
|
+
filter.add_accessor(:where)
|
135
|
+
.add(:servers, field: 'server')
|
136
|
+
.connect(self, :server_table)
|
137
|
+
|
138
|
+
def locations
|
139
|
+
servers.map(&:locations).flatten
|
140
|
+
end
|
141
|
+
|
142
|
+
def to_s
|
143
|
+
@parent.to_s + ', http entry'
|
144
|
+
end
|
145
|
+
alias inspect to_s
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
def server_table
|
150
|
+
@server_table ||= (params['server'] || []).map { |x| { 'server' => NginxConfServer.new(x, self) } }
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
class NginxConfServer
|
155
|
+
attr_reader :params, :parent
|
156
|
+
def initialize(params, parent)
|
157
|
+
@parent = parent
|
158
|
+
@params = params || {}
|
159
|
+
end
|
160
|
+
|
161
|
+
filter = FilterTable.create
|
162
|
+
filter.add_accessor(:where)
|
163
|
+
.add(:locations, field: 'location')
|
164
|
+
.connect(self, :location_table)
|
165
|
+
|
166
|
+
def to_s
|
167
|
+
server = ''
|
168
|
+
name = Array(params['server_name']).flatten.first
|
169
|
+
unless name.nil?
|
170
|
+
server += name
|
171
|
+
listen = Array(params['listen']).flatten.first
|
172
|
+
server += ":#{listen}" unless listen.nil?
|
173
|
+
end
|
174
|
+
|
175
|
+
# go two levels up: 1. to the http entry and 2. to the root nginx conf
|
176
|
+
@parent.parent.to_s + ", server #{server}"
|
177
|
+
end
|
178
|
+
alias inspect to_s
|
179
|
+
|
180
|
+
private
|
181
|
+
|
182
|
+
def location_table
|
183
|
+
@location_table ||= (params['location'] || []).map { |x| { 'location' => NginxConfLocation.new(x, self) } }
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
class NginxConfLocation
|
188
|
+
attr_reader :params, :parent
|
189
|
+
def initialize(params, parent)
|
190
|
+
@parent = parent
|
191
|
+
@params = params || {}
|
192
|
+
end
|
193
|
+
|
194
|
+
def to_s
|
195
|
+
location = Array(params['_']).join(' ')
|
196
|
+
# go three levels up: 1. to the server entry, 2. http entry and 3. to the root nginx conf
|
197
|
+
@parent.parent.parent.to_s + ", location #{location.inspect}"
|
198
|
+
end
|
199
|
+
alias inspect to_s
|
200
|
+
end
|
95
201
|
end
|
data/lib/resources/processes.rb
CHANGED
@@ -81,7 +81,7 @@ module Inspec::Resources
|
|
81
81
|
|
82
82
|
if os.linux?
|
83
83
|
command = 'ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command'
|
84
|
-
regex = /^(
|
84
|
+
regex = /^(.+?)\s+(\d+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+(\w{3} \d{2}|\d{2}:\d{2}:\d{2})\s+([^ ]+)\s+([^ ]+)\s+(.*)$/
|
85
85
|
elsif os.windows?
|
86
86
|
command = '$Proc = Get-Process -IncludeUserName | Where-Object {$_.Path -ne $null } | Select-Object PriorityClass,Id,CPU,PM,VirtualMemorySize,NPM,SessionId,Responding,StartTime,TotalProcessorTime,UserName,Path | ConvertTo-Csv -NoTypeInformation;$Proc.Replace("""","").Replace("`r`n","`n")'
|
87
87
|
# Wanted to use /(?:^|,)([^,]*)/; works on rubular.com not sure why here?
|
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.
|
4
|
+
version: 1.36.1
|
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-
|
11
|
+
date: 2017-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|
@@ -355,6 +355,7 @@ files:
|
|
355
355
|
- docs/resources/mssql_session.md.erb
|
356
356
|
- docs/resources/mysql_conf.md.erb
|
357
357
|
- docs/resources/mysql_session.md.erb
|
358
|
+
- docs/resources/nginx_conf.md.erb
|
358
359
|
- docs/resources/npm.md.erb
|
359
360
|
- docs/resources/ntp_conf.md.erb
|
360
361
|
- docs/resources/oneget.md.erb
|