inspec 1.45.9 → 1.45.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +54 -32
  3. data/CHANGELOG.md +29 -21
  4. data/Gemfile +1 -1
  5. data/docs/resources/ini.md.erb +14 -1
  6. data/docs/shell.md +1 -1
  7. data/inspec.gemspec +2 -2
  8. data/lib/bundles/inspec-artifact/cli.rb +3 -8
  9. data/lib/bundles/inspec-compliance/configuration.rb +5 -5
  10. data/lib/bundles/inspec-compliance/http.rb +2 -5
  11. data/lib/bundles/inspec-compliance/target.rb +6 -6
  12. data/lib/bundles/inspec-compliance/test/integration/default/cli.rb +1 -1
  13. data/lib/bundles/inspec-habitat/profile.rb +68 -74
  14. data/lib/bundles/inspec-supermarket/api.rb +7 -7
  15. data/lib/bundles/inspec-supermarket/cli.rb +1 -1
  16. data/lib/fetchers/git.rb +3 -8
  17. data/lib/fetchers/local.rb +7 -13
  18. data/lib/fetchers/url.rb +1 -1
  19. data/lib/inspec/backend.rb +0 -1
  20. data/lib/inspec/base_cli.rb +1 -1
  21. data/lib/inspec/cached_fetcher.rb +11 -12
  22. data/lib/inspec/cli.rb +0 -1
  23. data/lib/inspec/control_eval_context.rb +2 -2
  24. data/lib/inspec/dependencies/lockfile.rb +13 -15
  25. data/lib/inspec/dependencies/requirement.rb +1 -1
  26. data/lib/inspec/dependencies/resolver.rb +3 -5
  27. data/lib/inspec/dsl.rb +5 -5
  28. data/lib/inspec/dsl_shared.rb +1 -1
  29. data/lib/inspec/env_printer.rb +26 -26
  30. data/lib/inspec/metadata.rb +11 -10
  31. data/lib/inspec/objects/or_test.rb +4 -2
  32. data/lib/inspec/objects/test.rb +1 -1
  33. data/lib/inspec/profile.rb +2 -2
  34. data/lib/inspec/resource.rb +1 -3
  35. data/lib/inspec/rspec_json_formatter.rb +6 -8
  36. data/lib/inspec/shell.rb +51 -52
  37. data/lib/inspec/version.rb +1 -1
  38. data/lib/matchers/matchers.rb +1 -2
  39. data/lib/resources/audit_policy.rb +2 -2
  40. data/lib/resources/auditd.rb +6 -3
  41. data/lib/resources/dh_params.rb +1 -2
  42. data/lib/resources/docker.rb +2 -2
  43. data/lib/resources/docker_container.rb +4 -4
  44. data/lib/resources/elasticsearch.rb +2 -6
  45. data/lib/resources/etc_group.rb +2 -4
  46. data/lib/resources/groups.rb +14 -14
  47. data/lib/resources/host.rb +2 -3
  48. data/lib/resources/packages.rb +1 -1
  49. data/lib/resources/port.rb +1 -1
  50. data/lib/resources/postgres.rb +6 -6
  51. data/lib/resources/powershell.rb +1 -1
  52. data/lib/resources/service.rb +4 -5
  53. data/lib/resources/users.rb +58 -58
  54. data/lib/resources/vbscript.rb +10 -10
  55. data/lib/resources/virtualization.rb +3 -4
  56. data/lib/resources/x509_certificate.rb +1 -1
  57. data/lib/resources/yum.rb +1 -1
  58. data/lib/source_readers/inspec.rb +2 -1
  59. data/lib/utils/command_wrapper.rb +3 -8
  60. data/lib/utils/filter.rb +1 -1
  61. data/lib/utils/json_log.rb +2 -1
  62. data/lib/utils/latest_version.rb +5 -4
  63. data/lib/utils/object_traversal.rb +1 -1
  64. data/lib/utils/parser.rb +2 -2
  65. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a9abff18ab1cdd996b01299cb2c0e0ab2bdbaab
4
- data.tar.gz: 24deaa54689c34fd8f7813e10828a74d54583e79
3
+ metadata.gz: 942384b7fafcd0d8318201eec37d4a08556d3080
4
+ data.tar.gz: 8823e1de51315eec835891df623ea55f6dca3059
5
5
  SHA512:
6
- metadata.gz: c70d6d686d8bc62602837812f291a1bb1b05805cad90bf2fe22d168809cd3d427ff31ac4f57d5471be5f334c8daae22fab0e9a646e311c9152b88c9f09fe4d06
7
- data.tar.gz: 48c1b044e2d6082bfe89d1babe2df372625f7a970468882c10180b855da5625eeec81eab3c4096abbe1690cf78def4f1b4960ea871a8c1ef9da69eee3c5c3c73
6
+ metadata.gz: 8fa3b0ea4482dc3f5562610a64fb6b878e97c6ad6b614564f7f6a2742d66ead3620c770ec379347373ed5e0182557d4c80100d219cef7d77c70ff87cdaaa89e6
7
+ data.tar.gz: 0c82db93fca88e51f51d936aaa792e124ba3826033963918e0bb8faca4b3a18bcaad3f64d3773db8ecfc62df22962e8c58ffa6055aad875e8563888c6a74322e
data/.rubocop.yml CHANGED
@@ -8,30 +8,72 @@ AllCops:
8
8
  - 'examples/**/*'
9
9
  - 'vendor/**/*'
10
10
  - 'lib/bundles/inspec-init/templates/**/*'
11
- Documentation:
12
- Enabled: false
11
+ - 'www/tutorial/**/*'
13
12
  AlignParameters:
14
13
  Enabled: true
15
- Encoding:
16
- Enabled: true
14
+ BlockDelimiters:
15
+ Enabled: false
16
+ Documentation:
17
+ Enabled: false
18
+ EmptyLinesAroundBlockBody:
19
+ Enabled: false
17
20
  FrozenStringLiteralComment:
18
21
  Enabled: false
19
22
  HashSyntax:
20
23
  Enabled: true
21
24
  LineLength:
22
25
  Enabled: false
23
- EmptyLinesAroundBlockBody:
26
+ Layout/AlignHash:
27
+ Enabled: false
28
+ Layout/EmptyLineAfterMagicComment:
29
+ Enabled: false
30
+ Layout/EndOfLine:
31
+ Enabled: true
32
+ EnforcedStyle: lf
33
+ Layout/SpaceAroundOperators:
24
34
  Enabled: false
25
35
  MethodLength:
26
36
  Max: 40
27
- NumericLiterals:
28
- MinDigits: 10
37
+ Metrics/AbcSize:
38
+ Max: 33
39
+ Metrics/BlockLength:
40
+ Max: 50
29
41
  Metrics/CyclomaticComplexity:
30
42
  Max: 10
31
43
  Metrics/PerceivedComplexity:
32
44
  Max: 11
33
- Metrics/AbcSize:
34
- Max: 33
45
+ NumericLiterals:
46
+ MinDigits: 10
47
+ Security/YAMLLoad:
48
+ Enabled: false
49
+ Style/AndOr:
50
+ Enabled: false
51
+ Style/BracesAroundHashParameters:
52
+ Enabled: false
53
+ Style/ClassAndModuleChildren:
54
+ Enabled: false
55
+ Style/ConditionalAssignment:
56
+ Enabled: false
57
+ Style/EmptyMethod:
58
+ Enabled: false
59
+ Style/Encoding:
60
+ Enabled: false
61
+ Style/FileName:
62
+ Enabled: false
63
+ Style/IfUnlessModifier:
64
+ Enabled: false
65
+ Style/MethodMissing:
66
+ Enabled: false
67
+ Style/MultilineIfModifier:
68
+ Enabled: false
69
+ Style/NegatedIf:
70
+ Enabled: false
71
+ Style/Not:
72
+ Enabled: false
73
+ Style/NumericLiteralPrefix:
74
+ Enabled: false
75
+ Style/NumericPredicate:
76
+ Enabled: false
35
77
  Style/PercentLiteralDelimiters:
36
78
  PreferredDelimiters:
37
79
  '%': '{}'
@@ -43,33 +85,13 @@ Style/PercentLiteralDelimiters:
43
85
  '%w': '{}'
44
86
  '%W': ()
45
87
  '%x': ()
46
- Style/AlignHash:
47
- Enabled: false
48
88
  Style/PredicateName:
49
89
  Enabled: false
50
- Style/ClassAndModuleChildren:
51
- Enabled: false
52
- Style/ConditionalAssignment:
53
- Enabled: false
54
- Style/BracesAroundHashParameters:
90
+ Style/SymbolArray:
55
91
  Enabled: false
56
- Style/AndOr:
57
- Enabled: false
58
- Style/Not:
59
- Enabled: false
60
- Style/FileName:
61
- Enabled: false
62
- Style/TrailingCommaInLiteral:
63
- EnforcedStyleForMultiline: comma
64
92
  Style/TrailingCommaInArguments:
65
93
  EnforcedStyleForMultiline: comma
66
- Style/NegatedIf:
67
- Enabled: false
94
+ Style/TrailingCommaInLiteral:
95
+ EnforcedStyleForMultiline: comma
68
96
  Style/UnlessElse:
69
97
  Enabled: false
70
- BlockDelimiters:
71
- Enabled: false
72
- Style/SpaceAroundOperators:
73
- Enabled: false
74
- Style/IfUnlessModifier:
75
- Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,34 +1,43 @@
1
1
  # Change Log
2
2
  <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ -->
3
- <!-- latest_release 1.45.9 -->
4
- ## [v1.45.9](https://github.com/chef/inspec/tree/v1.45.9) (2017-11-16)
3
+ <!-- latest_release 1.45.13 -->
4
+ ## [v1.45.13](https://github.com/chef/inspec/tree/v1.45.13) (2017-11-21)
5
5
 
6
- #### Enhancements
7
- - http resource: Add basic param handling to remote HTTP worker [#2286](https://github.com/chef/inspec/pull/2286) ([schisamo](https://github.com/schisamo))
6
+ #### Merged Pull Requests
7
+ - Bump train to 0.29.2 [#2327](https://github.com/chef/inspec/pull/2327) ([adamleff](https://github.com/adamleff))
8
8
  <!-- latest_release -->
9
9
 
10
- <!-- release_rollup since=1.44.8 -->
11
- ### Changes since 1.44.8 release
12
-
13
- #### Enhancements
14
- - http resource: Add basic param handling to remote HTTP worker [#2286](https://github.com/chef/inspec/pull/2286) ([schisamo](https://github.com/schisamo)) <!-- 1.45.9 -->
15
- - Correctly format skip exceptions in formatters [#2307](https://github.com/chef/inspec/pull/2307) ([adamleff](https://github.com/adamleff)) <!-- 1.45.4 -->
10
+ <!-- release_rollup since=1.45.9 -->
11
+ ### Changes since 1.45.9 release
16
12
 
17
13
  #### Merged Pull Requests
18
- - Update Rubocop to TargetRubyVersion 2.3 [#2311](https://github.com/chef/inspec/pull/2311) ([adamleff](https://github.com/adamleff)) <!-- 1.45.8 -->
19
- - Require Ruby 2.3 and later [#2293](https://github.com/chef/inspec/pull/2293) ([adamleff](https://github.com/adamleff)) <!-- 1.45.7 -->
20
- - Fix gid filtering for etc_group resource [#2297](https://github.com/chef/inspec/pull/2297) ([eramoto](https://github.com/eramoto)) <!-- 1.45.3 -->
21
- - Habitat build works for all versions, eliminates rake [#2301](https://github.com/chef/inspec/pull/2301) ([adamleff](https://github.com/adamleff)) <!-- 1.45.2 -->
22
- - Bumping train to 0.29.1 [#2306](https://github.com/chef/inspec/pull/2306) ([adamleff](https://github.com/adamleff)) <!-- 1.45.0 -->
14
+ - Bump train to 0.29.2 [#2327](https://github.com/chef/inspec/pull/2327) ([adamleff](https://github.com/adamleff)) <!-- 1.45.13 -->
15
+ - Bump Rubocop to 0.49.1 [#2323](https://github.com/chef/inspec/pull/2323) ([adamleff](https://github.com/adamleff)) <!-- 1.45.12 -->
16
+ - Remove bundler install during Appveyor tests [#2322](https://github.com/chef/inspec/pull/2322) ([adamleff](https://github.com/adamleff)) <!-- 1.45.11 -->
17
+ - Remove debug message from unit test [#2313](https://github.com/chef/inspec/pull/2313) ([eramoto](https://github.com/eramoto)) <!-- 1.45.10 -->
18
+ <!-- release_rollup -->
19
+
20
+ <!-- latest_stable_release -->
21
+ ## [v1.45.9](https://github.com/chef/inspec/tree/v1.45.9) (2017-11-16)
22
+
23
+ #### Enhancements
24
+ - Correctly format skip exceptions in formatters [#2307](https://github.com/chef/inspec/pull/2307) ([adamleff](https://github.com/adamleff))
25
+ - http resource: Add basic param handling to remote HTTP worker [#2286](https://github.com/chef/inspec/pull/2286) ([schisamo](https://github.com/schisamo))
23
26
 
24
27
  #### Bug Fixes
25
- - xinetd_conf resource: fix false positives when config file or directory doesn&#39;t exist [#2302](https://github.com/chef/inspec/pull/2302) ([eramoto](https://github.com/eramoto)) <!-- 1.45.6 -->
26
- - oracledb_session resource: fix credential passing to sql/sqlplus [#2308](https://github.com/chef/inspec/pull/2308) ([bratdim](https://github.com/bratdim)) <!-- 1.45.5 -->
27
- - Fix classname in JUnit formatter [#2283](https://github.com/chef/inspec/pull/2283) ([adamleff](https://github.com/adamleff)) <!-- 1.45.1 -->
28
- - port resource: handle ss output from older iproute package [#2305](https://github.com/chef/inspec/pull/2305) ([Wing924](https://github.com/Wing924)) <!-- 1.44.9 -->
29
- <!-- release_rollup -->
28
+ - port resource: handle ss output from older iproute package [#2305](https://github.com/chef/inspec/pull/2305) ([Wing924](https://github.com/Wing924))
29
+ - Fix classname in JUnit formatter [#2283](https://github.com/chef/inspec/pull/2283) ([adamleff](https://github.com/adamleff))
30
+ - oracledb_session resource: fix credential passing to sql/sqlplus [#2308](https://github.com/chef/inspec/pull/2308) ([bratdim](https://github.com/bratdim))
31
+ - xinetd_conf resource: fix false positives when config file or directory doesn&#39;t exist [#2302](https://github.com/chef/inspec/pull/2302) ([eramoto](https://github.com/eramoto))
30
32
 
33
+ #### Merged Pull Requests
34
+ - Bumping train to 0.29.1 [#2306](https://github.com/chef/inspec/pull/2306) ([adamleff](https://github.com/adamleff))
35
+ - Habitat build works for all versions, eliminates rake [#2301](https://github.com/chef/inspec/pull/2301) ([adamleff](https://github.com/adamleff))
36
+ - Fix gid filtering for etc_group resource [#2297](https://github.com/chef/inspec/pull/2297) ([eramoto](https://github.com/eramoto))
37
+ - Require Ruby 2.3 and later [#2293](https://github.com/chef/inspec/pull/2293) ([adamleff](https://github.com/adamleff))
38
+ - Update Rubocop to TargetRubyVersion 2.3 [#2311](https://github.com/chef/inspec/pull/2311) ([adamleff](https://github.com/adamleff))
31
39
  <!-- latest_stable_release -->
40
+
32
41
  ## [v1.44.8](https://github.com/chef/inspec/tree/v1.44.8) (2017-11-09)
33
42
 
34
43
  #### Enhancements
@@ -47,7 +56,6 @@
47
56
  - Switch to tomlrb for TOML parsing [#2295](https://github.com/chef/inspec/pull/2295) ([adamleff](https://github.com/adamleff))
48
57
  - Use Ruby 2.4.2 in the Omnibus InSpec packages [#2294](https://github.com/chef/inspec/pull/2294) ([adamleff](https://github.com/adamleff))
49
58
  - Eliminate deprecation warnings on resource skipped messages [#2296](https://github.com/chef/inspec/pull/2296) ([adamleff](https://github.com/adamleff))
50
- <!-- latest_stable_release -->
51
59
 
52
60
  ## [v1.43.8](https://github.com/chef/inspec/tree/v1.43.8) (2017-11-02)
53
61
 
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ group :test do
13
13
  gem 'bundler', '~> 1.5'
14
14
  gem 'minitest', '~> 5.5'
15
15
  gem 'rake', '~> 10'
16
- gem 'rubocop', '= 0.39.0'
16
+ gem 'rubocop', '= 0.49.1'
17
17
  gem 'simplecov', '~> 0.10'
18
18
  gem 'concurrent-ruby', '~> 0.9'
19
19
  gem 'mocha', '~> 1.1'
@@ -18,7 +18,7 @@ An `ini` resource block declares the configuration settings to be tested:
18
18
 
19
19
  where
20
20
 
21
- * `'setting_name'` is a synchronization setting defined in the INI file
21
+ * `'setting_name'` is a setting key defined in the INI file
22
22
  * `('path')` is the path to the INI file
23
23
  * `{ should eq 'value' }` is the value that is expected
24
24
 
@@ -29,6 +29,19 @@ For example:
29
29
  its('server') { should eq '192.0.2.62' }
30
30
  end
31
31
 
32
+ Settings inside of sections, such as the following:
33
+
34
+ [section_name]
35
+ setting_name = 123
36
+
37
+ ... can be retrieved by prefixing the setting_name with the section.
38
+
39
+ its('section_name.setting_name') { should cmp 123 }
40
+
41
+ In the event a section or setting name has a period in it, the alternate syntax can be used:
42
+
43
+ its(['section.with.a.dot.in.it', 'setting.name.with.dots']) { should cmp 'lotsadots' }
44
+
32
45
  <br>
33
46
 
34
47
  ## Examples
data/docs/shell.md CHANGED
@@ -29,7 +29,7 @@ InSpec), you can use the `-t` flag. We support connecting using ssh,
29
29
  WinRm and docker. If no target is provided, we implicitly support the
30
30
  "local" target - i.e. tests running on the current machine running
31
31
  InSpec. For an ssh connection, use `-i` for specifying ssh key files,
32
- and the `--sudo*` commands for requesting a privelege escalation after
32
+ and the `--sudo*` commands for requesting a privilege escalation after
33
33
  logging in. For a WinRM connection, use `--path` to change the login
34
34
  path, `--ssl` to use SSL for transport layer encryption.
35
35
 
data/inspec.gemspec CHANGED
@@ -20,13 +20,13 @@ Gem::Specification.new do |spec|
20
20
  '{bin,docs,examples,lib}/**/*', File::FNM_DOTMATCH
21
21
  ).reject { |f| File.directory?(f) }
22
22
 
23
- spec.executables = %w{ inspec }
23
+ spec.executables = %w{inspec}
24
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
25
  spec.require_paths = ['lib']
26
26
 
27
27
  spec.required_ruby_version = '>= 2.3'
28
28
 
29
- spec.add_dependency 'train', '~> 0.29', '>= 0.29.1'
29
+ spec.add_dependency 'train', '~> 0.29', '>= 0.29.2'
30
30
  spec.add_dependency 'thor', '~> 0.19'
31
31
  spec.add_dependency 'json', '>= 1.8', '< 3.0'
32
32
  spec.add_dependency 'rainbow', '~> 2'
@@ -211,17 +211,12 @@ module Artifact
211
211
  def valid_header?(file_alg, file_version, file_keyname)
212
212
  public_keyfile = "#{file_keyname}.pem.pub"
213
213
  puts "Looking for #{public_keyfile} to verify artifact"
214
- if not File.exist? public_keyfile
214
+ if !File.exist? public_keyfile
215
215
  raise "Can't find #{public_keyfile}"
216
216
  end
217
217
 
218
- if not VALID_PROFILE_DIGESTS.member? file_alg
219
- raise 'Invalid artifact digest algorithm detected'
220
- end
221
-
222
- if not VALID_PROFILE_VERSIONS.member? file_version
223
- raise 'Invalid artifact version detected'
224
- end
218
+ raise 'Invalid artifact digest algorithm detected' if !VALID_PROFILE_DIGESTS.member?(file_alg)
219
+ raise 'Invalid artifact version detected' if !VALID_PROFILE_VERSIONS.member?(file_version)
225
220
  end
226
221
 
227
222
  def verify(file_to_verifiy, &content_block)
@@ -79,11 +79,11 @@ module Compliance
79
79
 
80
80
  # exit 1 if the version of compliance that we're working with doesn't support odic
81
81
  def legacy_check!(feature)
82
- if !supported?(feature)
83
- puts "This feature (#{feature}) is not available for legacy installations."
84
- puts 'Please upgrade to a recent version of Chef Compliance.'
85
- exit 1
86
- end
82
+ return if supported?(feature)
83
+
84
+ puts "This feature (#{feature}) is not available for legacy installations."
85
+ puts 'Please upgrade to a recent version of Chef Compliance.'
86
+ exit 1
87
87
  end
88
88
 
89
89
  private
@@ -12,10 +12,8 @@ module Compliance
12
12
  def self.get(url, headers = nil, insecure)
13
13
  uri = _parse_url(url)
14
14
  req = Net::HTTP::Get.new(uri.path)
15
- if !headers.nil?
16
- headers.each do |key, value|
17
- req.add_field(key, value)
18
- end
15
+ headers&.each do |key, value|
16
+ req.add_field(key, value)
19
17
  end
20
18
  send_request(uri, req, insecure)
21
19
  end
@@ -72,7 +70,6 @@ module Compliance
72
70
  http.request(req)
73
71
  }
74
72
  res
75
-
76
73
  rescue OpenSSL::SSL::SSLError => e
77
74
  raise e unless e.message.include? 'certificate verify failed'
78
75
 
@@ -37,15 +37,15 @@ module Compliance
37
37
  server = 'compliance'
38
38
  msg = "inspec compliance login https://your_compliance_server --user admin --insecure --token 'PASTE TOKEN HERE' "
39
39
  end
40
- raise Inspec::FetcherFailure, <<EOF
40
+ raise Inspec::FetcherFailure, <<~EOF
41
41
 
42
- Cannot fetch #{uri} because your #{server} token has not been
43
- configured.
42
+ Cannot fetch #{uri} because your #{server} token has not been
43
+ configured.
44
44
 
45
- Please login using
45
+ Please login using
46
46
 
47
- #{msg}
48
- EOF
47
+ #{msg}
48
+ EOF
49
49
  end
50
50
 
51
51
  # verifies that the target e.g base/ssh exists
@@ -13,7 +13,7 @@ puts "Run test as #{user} in path #{pwd}"
13
13
  access_token = ENV['COMPLIANCE_ACCESSTOKEN']
14
14
  refresh_token = ENV['COMPLIANCE_REFRESHTOKEN']
15
15
 
16
- %w{refresh_token access_token}.each do |type|
16
+ %w{refresh_token access_token}.each do |type| # rubocop:disable Metrics/BlockLength
17
17
  case type
18
18
  when 'access_token'
19
19
  token_options = "--token '#{access_token}'"
@@ -136,27 +136,21 @@ module Habitat
136
136
  Habitat::Log.info('Checking to see if Habitat is installed...')
137
137
  cmd = Mixlib::ShellOut.new('hab --version')
138
138
  cmd.run_command
139
- if cmd.error?
140
- exit_with_error('Unable to run Habitat commands.', cmd.stderr)
141
- end
139
+ exit_with_error('Unable to run Habitat commands.', cmd.stderr) if cmd.error?
142
140
  end
143
141
 
144
142
  def validate_habitat_origin
145
- if habitat_origin.nil?
146
- exit_with_error(
147
- 'Unable to determine Habitat origin name.',
148
- 'Run `hab setup` or set the HAB_ORIGIN environment variable.',
149
- )
150
- end
143
+ exit_with_error(
144
+ 'Unable to determine Habitat origin name.',
145
+ 'Run `hab setup` or set the HAB_ORIGIN environment variable.',
146
+ ) if habitat_origin.nil?
151
147
  end
152
148
 
153
149
  def validate_habitat_auth_token
154
- if habitat_auth_token.nil?
155
- exit_with_error(
156
- 'Unable to determine Habitat auth token for publishing.',
157
- 'Run `hab setup` or set the HAB_AUTH_TOKEN environment variable.',
158
- )
159
- end
150
+ exit_with_error(
151
+ 'Unable to determine Habitat auth token for publishing.',
152
+ 'Run `hab setup` or set the HAB_AUTH_TOKEN environment variable.',
153
+ ) if habitat_auth_token.nil?
160
154
  end
161
155
 
162
156
  def validate_output_dir
@@ -318,78 +312,78 @@ module Habitat
318
312
  end
319
313
 
320
314
  def plan_contents
321
- plan = <<-EOL
322
- pkg_name=#{package_name}
323
- pkg_version=#{profile.version}
324
- pkg_origin=#{habitat_origin}
325
- pkg_deps=(chef/inspec core/ruby core/hab)
326
- pkg_svc_user=root
327
- EOL
315
+ plan = <<~EOL
316
+ pkg_name=#{package_name}
317
+ pkg_version=#{profile.version}
318
+ pkg_origin=#{habitat_origin}
319
+ pkg_deps=(chef/inspec core/ruby core/hab)
320
+ pkg_svc_user=root
321
+ EOL
328
322
 
329
323
  plan += "pkg_license='#{profile.metadata.params[:license]}'\n\n" if profile.metadata.params[:license]
330
324
 
331
- plan += <<-EOL
325
+ plan += <<~EOL
332
326
 
333
- do_build() {
334
- cp -vr $PLAN_CONTEXT/../* $HAB_CACHE_SRC_PATH/$pkg_dirname
335
- }
327
+ do_build() {
328
+ cp -vr $PLAN_CONTEXT/../* $HAB_CACHE_SRC_PATH/$pkg_dirname
329
+ }
336
330
 
337
- do_install() {
338
- local profile_contents
339
- local excludes
340
- profile_contents=($(ls))
341
- excludes=(habitat results *.hart)
331
+ do_install() {
332
+ local profile_contents
333
+ local excludes
334
+ profile_contents=($(ls))
335
+ excludes=(habitat results *.hart)
342
336
 
343
- for item in ${excludes[@]}; do
344
- profile_contents=(${profile_contents[@]/$item/})
345
- done
337
+ for item in ${excludes[@]}; do
338
+ profile_contents=(${profile_contents[@]/$item/})
339
+ done
346
340
 
347
- mkdir ${pkg_prefix}/dist
348
- cp -r ${profile_contents[@]} ${pkg_prefix}/dist/
349
- }
341
+ mkdir ${pkg_prefix}/dist
342
+ cp -r ${profile_contents[@]} ${pkg_prefix}/dist/
343
+ }
350
344
  EOL
351
345
 
352
346
  plan
353
347
  end
354
348
 
355
349
  def run_hook_contents
356
- <<-EOL
357
- #!/bin/sh
358
-
359
- # redirect stderr to stdout
360
- # ultimately, we'd like to log this somewhere useful, but due to
361
- # https://github.com/habitat-sh/habitat/issues/2395, we need to
362
- # avoid doing that for now.
363
- exec 2>&1
364
-
365
- # InSpec will try to create a .cache directory in the user's home directory
366
- # so this needs to be someplace writeable by the hab user
367
- export HOME={{pkg.svc_var_path}}
368
-
369
- PROFILE_IDENT="{{pkg.origin}}/{{pkg.name}}"
370
- RESULTS_DIR="{{pkg.svc_var_path}}/inspec_results"
371
- RESULTS_FILE="${RESULTS_DIR}/{{pkg.name}}.json"
372
-
373
- # Create a directory for inspec formatter output
374
- mkdir -p {{pkg.svc_var_path}}/inspec_results
375
-
376
- while true; do
377
- echo "Executing InSpec for ${PROFILE_IDENT}"
378
- inspec exec {{pkg.path}}/dist --format=json > ${RESULTS_FILE}
379
-
380
- if [ $? -eq 0 ]; then
381
- echo "InSpec run completed successfully."
382
- else
383
- echo "InSpec run did not complete successfully. If you do not see any errors above,"
384
- echo "control failures were detected. Check the InSpec results here for details:"
385
- echo ${RESULTS_FILE}
386
- echo "Otherwise, troubleshoot any errors shown above."
387
- fi
388
-
389
- source {{pkg.svc_config_path}}/settings.sh
390
- echo "sleeping for ${SLEEP_TIME} seconds"
391
- sleep ${SLEEP_TIME}
392
- done
350
+ <<~EOL
351
+ #!/bin/sh
352
+
353
+ # redirect stderr to stdout
354
+ # ultimately, we'd like to log this somewhere useful, but due to
355
+ # https://github.com/habitat-sh/habitat/issues/2395, we need to
356
+ # avoid doing that for now.
357
+ exec 2>&1
358
+
359
+ # InSpec will try to create a .cache directory in the user's home directory
360
+ # so this needs to be someplace writeable by the hab user
361
+ export HOME={{pkg.svc_var_path}}
362
+
363
+ PROFILE_IDENT="{{pkg.origin}}/{{pkg.name}}"
364
+ RESULTS_DIR="{{pkg.svc_var_path}}/inspec_results"
365
+ RESULTS_FILE="${RESULTS_DIR}/{{pkg.name}}.json"
366
+
367
+ # Create a directory for inspec formatter output
368
+ mkdir -p {{pkg.svc_var_path}}/inspec_results
369
+
370
+ while true; do
371
+ echo "Executing InSpec for ${PROFILE_IDENT}"
372
+ inspec exec {{pkg.path}}/dist --format=json > ${RESULTS_FILE}
373
+
374
+ if [ $? -eq 0 ]; then
375
+ echo "InSpec run completed successfully."
376
+ else
377
+ echo "InSpec run did not complete successfully. If you do not see any errors above,"
378
+ echo "control failures were detected. Check the InSpec results here for details:"
379
+ echo ${RESULTS_FILE}
380
+ echo "Otherwise, troubleshoot any errors shown above."
381
+ fi
382
+
383
+ source {{pkg.svc_config_path}}/settings.sh
384
+ echo "sleeping for ${SLEEP_TIME} seconds"
385
+ sleep ${SLEEP_TIME}
386
+ done
393
387
  EOL
394
388
  end
395
389
  end