puppet-syntax 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +7 -24
- data/CHANGELOG +6 -0
- data/lib/puppet-syntax.rb +3 -3
- data/lib/puppet-syntax/hiera.rb +50 -0
- data/lib/puppet-syntax/tasks/puppet-syntax.rb +4 -2
- data/lib/puppet-syntax/version.rb +1 -1
- data/spec/fixtures/hiera/hiera_bad.eyaml +24 -0
- data/spec/puppet-syntax/hiera_spec.rb +17 -0
- data/spec/puppet-syntax/manifests_spec.rb +2 -2
- data/spec/puppet-syntax/tasks/puppet-syntax_spec.rb +0 -17
- data/spec/puppet-syntax/templates_spec.rb +1 -1
- data/spec/puppet-syntax_spec.rb +2 -2
- metadata +5 -5
- data/appveyor.yml +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5881bcc80736f1d0fa83276ba62c306e827839e94e6d6b124a5212b11430af15
|
4
|
+
data.tar.gz: 6140b85f3ae60a823157c763369ee81a5cf7bd3d06a2e8f6400aabc8240ca0e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b545df2d01645001047e3dac3ad30d9c11a9003f0f8ea5011b519305cafb17a0cffdd8cd646500ab515bc79cbd876148763c24e3aa894a5ff500c35e5a07c9f
|
7
|
+
data.tar.gz: 97ca7f5db0a74bb98fa3447cb60660601d7455e6d8322d872208a402393684aba8060a86183e5fa857d4fcf2379487a5ecb08234ae50dd470654ad3017dcf5d7
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -5,32 +5,15 @@ before_install: gem install bundler
|
|
5
5
|
install: bundle install --jobs 4 --retry 2 --without development
|
6
6
|
script: bundle exec rake
|
7
7
|
rvm:
|
8
|
-
-
|
9
|
-
- 2.1
|
10
|
-
- 2.2.6
|
11
|
-
- 2.3.3
|
12
|
-
- 2.4.0
|
8
|
+
- 2.4.4
|
9
|
+
- 2.5.1
|
13
10
|
env:
|
14
|
-
- PUPPET_VERSION="~>
|
15
|
-
- PUPPET_VERSION="~>
|
16
|
-
- PUPPET_VERSION="~>
|
11
|
+
- PUPPET_VERSION="~> 5.5.10"
|
12
|
+
- PUPPET_VERSION="~> 6.1.0"
|
13
|
+
- PUPPET_VERSION="~> 6.2.0"
|
17
14
|
- PUPPET_VERSION=">= 0"
|
18
15
|
- PUPPET_VERSION="git://github.com/puppetlabs/puppet.git#master"
|
19
16
|
matrix:
|
20
|
-
exclude:
|
21
|
-
- env: PUPPET_VERSION="~> 3.8.7"
|
22
|
-
rvm: 2.2.6
|
23
|
-
- env: PUPPET_VERSION="~> 3.8.7"
|
24
|
-
rvm: 2.3.3
|
25
|
-
- env: PUPPET_VERSION="~> 3.8.7"
|
26
|
-
rvm: 2.4.0
|
27
|
-
# 4.9 with Ruby 1.9.3 issues deprecation warnings
|
28
|
-
- env: PUPPET_VERSION="~> 4.9.0"
|
29
|
-
rvm: 1.9.3
|
30
|
-
- env: PUPPET_VERSION=">= 0"
|
31
|
-
rvm: 1.9.3
|
32
|
-
- env: PUPPET_VERSION="git://github.com/puppetlabs/puppet.git#master"
|
33
|
-
rvm: 1.9.3
|
34
17
|
allow_failures:
|
35
18
|
- env: PUPPET_VERSION=">= 0"
|
36
19
|
- env: PUPPET_VERSION="git://github.com/puppetlabs/puppet.git#master"
|
@@ -40,8 +23,8 @@ deploy:
|
|
40
23
|
secure: "kwxryZZ/t9EkWuYxhz3G1v+U3ZK4WdsiN0UFHDjijnAGPxqe/n+oBcNA8hOiNhjZeTFo8bADEZkL7JtdKQo9RvgStipyaS5gDHB/C1c4LOBWv4Tga21NNCAuBcE2CDtAH3+TzrZV5vv2+SpOrhKZpzZoAoR6PR1MWVWMUie/rE0="
|
41
24
|
gem: puppet-syntax
|
42
25
|
on:
|
43
|
-
rvm: 2.
|
44
|
-
condition: '"$PUPPET_VERSION" = "~>
|
26
|
+
rvm: 2.5.1
|
27
|
+
condition: '"$PUPPET_VERSION" = "~> 5.5.10"'
|
45
28
|
tags: true
|
46
29
|
all_branches: true
|
47
30
|
repo: voxpupuli/puppet-syntax
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
2019-02-02 Release 2.4.2
|
2
|
+
- Search manifests in manifests directory
|
3
|
+
- Allow .yml as an extension for YAML files.
|
4
|
+
- Ensure the pkg directory is always excluded
|
5
|
+
- Check consistency of ENC blobs in eyaml data
|
6
|
+
|
1
7
|
2017-06-29 Release 2.4.1
|
2
8
|
- Fix to ensure namespace scope is inherited.
|
3
9
|
- Cleanly exits when syntax warnings/errors are found instead of failing.
|
data/lib/puppet-syntax.rb
CHANGED
@@ -8,9 +8,9 @@ module PuppetSyntax
|
|
8
8
|
@exclude_paths = []
|
9
9
|
@future_parser = false
|
10
10
|
@hieradata_paths = [
|
11
|
-
"**/data/**/*.*yaml",
|
12
|
-
"hieradata/**/*.*yaml",
|
13
|
-
"hiera*.*yaml"
|
11
|
+
"**/data/**/*.*{yaml,yml}",
|
12
|
+
"hieradata/**/*.*{yaml,yml}",
|
13
|
+
"hiera*.*{yaml,yml}"
|
14
14
|
]
|
15
15
|
@fail_on_deprecation_notices = true
|
16
16
|
@app_management = Puppet.version.to_i >= 5 ? true : false
|
data/lib/puppet-syntax/hiera.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'base64'
|
2
3
|
|
3
4
|
module PuppetSyntax
|
4
5
|
class Hiera
|
@@ -20,6 +21,53 @@ module PuppetSyntax
|
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
24
|
+
# Recurse through complex data structures. Return on first error.
|
25
|
+
def check_eyaml_data(name, val)
|
26
|
+
error = nil
|
27
|
+
if val.is_a? String
|
28
|
+
err = check_eyaml_blob(val)
|
29
|
+
error = "Key #{name} #{err}" if err
|
30
|
+
elsif val.is_a? Array
|
31
|
+
val.each_with_index do |v, idx|
|
32
|
+
error = check_eyaml_data("#{name}[#{idx}]", v)
|
33
|
+
break if error
|
34
|
+
end
|
35
|
+
elsif val.is_a? Hash
|
36
|
+
val.each do |k,v|
|
37
|
+
error = check_eyaml_data("#{name}['#{k}']", v)
|
38
|
+
break if error
|
39
|
+
end
|
40
|
+
end
|
41
|
+
error
|
42
|
+
end
|
43
|
+
|
44
|
+
def check_eyaml_blob(val)
|
45
|
+
return unless val =~ /^ENC\[/
|
46
|
+
|
47
|
+
val.sub!('ENC[', '')
|
48
|
+
val.gsub!(/\s+/, '')
|
49
|
+
if val !~ /\]$/
|
50
|
+
return "has unterminated eyaml value"
|
51
|
+
else
|
52
|
+
val.sub!(/\]$/, '')
|
53
|
+
method, base64 = val.split(/,/)
|
54
|
+
if base64 == nil
|
55
|
+
base64 = method
|
56
|
+
method = 'PKCS7'
|
57
|
+
end
|
58
|
+
|
59
|
+
return "has unknown eyaml method #{method}" unless ['PKCS7','GPG'].include? method
|
60
|
+
return "has unpadded or truncated base64 data" unless base64.length % 4 == 0
|
61
|
+
|
62
|
+
# Base64#decode64 will silently ignore characters outside the alphabet,
|
63
|
+
# so we check resulting length of binary data instead
|
64
|
+
pad_length = base64.gsub(/[^=]/, '').length
|
65
|
+
if Base64.decode64(base64).length != base64.length * 3/4 - pad_length
|
66
|
+
return "has corrupt base64 data"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
23
71
|
def check(filelist)
|
24
72
|
raise "Expected an array of files" unless filelist.is_a?(Array)
|
25
73
|
|
@@ -38,6 +86,8 @@ module PuppetSyntax
|
|
38
86
|
key_msg = check_hiera_key(k)
|
39
87
|
errors << "WARNING: #{hiera_file}: Key :#{k}: #{key_msg}" if key_msg
|
40
88
|
end
|
89
|
+
eyaml_msg = check_eyaml_data(k, v)
|
90
|
+
errors << "WARNING: #{hiera_file}: #{eyaml_msg}" if eyaml_msg
|
41
91
|
end
|
42
92
|
end
|
43
93
|
end
|
@@ -5,13 +5,15 @@ require 'rake/tasklib'
|
|
5
5
|
module PuppetSyntax
|
6
6
|
class RakeTask < ::Rake::TaskLib
|
7
7
|
def filelist(paths)
|
8
|
+
excludes = PuppetSyntax.exclude_paths
|
9
|
+
excludes.push('pkg/**/*')
|
8
10
|
files = FileList[paths]
|
9
11
|
files.reject! { |f| File.directory?(f) }
|
10
|
-
files.exclude(*
|
12
|
+
files.exclude(*excludes)
|
11
13
|
end
|
12
14
|
|
13
15
|
def filelist_manifests
|
14
|
-
filelist("
|
16
|
+
filelist("**/manifests/**/*.pp")
|
15
17
|
end
|
16
18
|
|
17
19
|
def filelist_templates
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
acme::warning1: ENC[unknown-method,aGVsbG8sIHdvcmxk]
|
3
|
+
acme::warning2: ENC[PKCS7,aGVsbG8sIHdvcmxk
|
4
|
+
acme::warning3: ENC[PKCS7,aGVsbG8sIHdvcmxk==]
|
5
|
+
acme::warning4: ENC[PKCS7,aGVs!!!!bG8sIHdvcmxk]
|
6
|
+
acme::warning5:
|
7
|
+
key1: foo
|
8
|
+
key2: ENC[PKCS7,aGVs!!!!bG8sIHdvcmxk]
|
9
|
+
acme::warning6:
|
10
|
+
hash_key:
|
11
|
+
- element1
|
12
|
+
- >
|
13
|
+
ENC[PKCS7,
|
14
|
+
aGVsbG8sIHdvcmxk
|
15
|
+
]
|
16
|
+
- >
|
17
|
+
ENC[PKCS7,
|
18
|
+
aGVs!!!!bG8sIHdvcmxk
|
19
|
+
]
|
20
|
+
acme::good1: >
|
21
|
+
ENC[PKCS7,
|
22
|
+
aGVsbG8sIHdvcmxk]
|
23
|
+
acme::good2: ENC[GPG,aGVsbG8sIHdvcmxkIQ==]
|
24
|
+
acme::good3: ENC[GPG,aGVsbG8sIHdvcmxkISE=]
|
@@ -43,6 +43,23 @@ describe PuppetSyntax::Hiera do
|
|
43
43
|
expect(res[4]).to match('Key :picky::warning5: Puppet automatic lookup will not look up symbols')
|
44
44
|
end
|
45
45
|
|
46
|
+
it "should return warnings for bad eyaml values" do
|
47
|
+
hiera_yaml = 'hiera_bad.eyaml'
|
48
|
+
examples = 6
|
49
|
+
files = fixture_hiera(hiera_yaml)
|
50
|
+
res = subject.check(files)
|
51
|
+
(1..examples).each do |n|
|
52
|
+
expect(res).to include(/::warning#{n}/)
|
53
|
+
end
|
54
|
+
expect(res.size).to be == examples
|
55
|
+
expect(res[0]).to match('Key acme::warning1 has unknown eyaml method unknown-method')
|
56
|
+
expect(res[1]).to match('Key acme::warning2 has unterminated eyaml value')
|
57
|
+
expect(res[2]).to match('Key acme::warning3 has unpadded or truncated base64 data')
|
58
|
+
expect(res[3]).to match('Key acme::warning4 has corrupt base64 data')
|
59
|
+
expect(res[4]).to match('Key acme::warning5\[\'key2\'\] has corrupt base64 data')
|
60
|
+
expect(res[5]).to match('Key acme::warning6\[\'hash_key\'\]\[2\] has corrupt base64 data')
|
61
|
+
end
|
62
|
+
|
46
63
|
it "should handle empty files" do
|
47
64
|
hiera_yaml = 'hiera_key_empty.yaml'
|
48
65
|
files = fixture_hiera(hiera_yaml)
|
@@ -74,8 +74,8 @@ describe PuppetSyntax::Manifests do
|
|
74
74
|
expect(has_errors).to eq(true)
|
75
75
|
if Puppet.version.to_i >= 4
|
76
76
|
expect(output.size).to eq(5)
|
77
|
-
expect(output[0]).to match(/This Name has no effect. A Host Class Definition can not end with a value-producing expression without other effect
|
78
|
-
expect(output[1]).to match(/This Name has no effect. A value
|
77
|
+
expect(output[0]).to match(/This Name has no effect. A Host Class Definition can not end with a value-producing expression without other effect \(file: \S*\/fail_error.pp, line: 2, column: 32\)$/)
|
78
|
+
expect(output[1]).to match(/This Name has no effect. A value was produced and then forgotten \(one or more preceding expressions may have the wrong form\) \(file: \S*\/fail_error.pp, line: 2, column: 3\)$/)
|
79
79
|
expect(output[2]).to match('2 errors. Giving up')
|
80
80
|
expect(output[3]).to match(/Unrecogni(s|z)ed escape sequence '\\\['/)
|
81
81
|
expect(output[4]).to match(/Unrecogni(s|z)ed escape sequence '\\\]'/)
|
@@ -35,21 +35,4 @@ describe 'PuppetSyntax rake tasks' do
|
|
35
35
|
expect(list).to include(known_eyaml_subdir)
|
36
36
|
expect(list.count).to eq 4
|
37
37
|
end
|
38
|
-
|
39
|
-
it 'should check manifests relative to Rakefile' do
|
40
|
-
if RSpec::Version::STRING < '3'
|
41
|
-
pending
|
42
|
-
else
|
43
|
-
skip('needs to be done')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should check templates relative to Rakefile' do
|
48
|
-
if RSpec::Version::STRING < '3'
|
49
|
-
pending
|
50
|
-
else
|
51
|
-
skip('needs to be done')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
38
|
end
|
@@ -117,7 +117,7 @@ describe PuppetSyntax::Templates do
|
|
117
117
|
|
118
118
|
expect(res.size).to eq(2)
|
119
119
|
expect(res[0]).to match(/This Type-Name has no effect/)
|
120
|
-
expect(res[1]).to match(/Syntax error at '}'
|
120
|
+
expect(res[1]).to match(/Syntax error at '}' \(file: \S*\/fail_error_also.epp, line: 2, column: 4\)/)
|
121
121
|
end
|
122
122
|
|
123
123
|
context "when the 'epp_only' options is set" do
|
data/spec/puppet-syntax_spec.rb
CHANGED
@@ -6,8 +6,8 @@ describe PuppetSyntax do
|
|
6
6
|
PuppetSyntax.app_management = false if Puppet.version.to_i < 5
|
7
7
|
end
|
8
8
|
|
9
|
-
it 'should default exclude_paths to
|
10
|
-
expect(PuppetSyntax.exclude_paths).to
|
9
|
+
it 'should default exclude_paths to include the pkg directory' do
|
10
|
+
expect(PuppetSyntax.exclude_paths).to include('pkg/**/*')
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should support setting exclude_paths' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-syntax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vox Pupuli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,7 +80,6 @@ files:
|
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
82
82
|
- Rakefile
|
83
|
-
- appveyor.yml
|
84
83
|
- jenkins.sh
|
85
84
|
- lib/puppet-syntax.rb
|
86
85
|
- lib/puppet-syntax/hiera.rb
|
@@ -93,6 +92,7 @@ files:
|
|
93
92
|
- spec/fixtures/hiera/data/hiera_2.eyaml
|
94
93
|
- spec/fixtures/hiera/data/test/hiera_3.yaml
|
95
94
|
- spec/fixtures/hiera/data/test/hiera_4.eyaml
|
95
|
+
- spec/fixtures/hiera/hiera_bad.eyaml
|
96
96
|
- spec/fixtures/hiera/hiera_bad.yaml
|
97
97
|
- spec/fixtures/hiera/hiera_bad_18.yaml
|
98
98
|
- spec/fixtures/hiera/hiera_badkey.yaml
|
@@ -141,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
|
-
|
145
|
-
rubygems_version: 2.6.11
|
144
|
+
rubygems_version: 3.0.2
|
146
145
|
signing_key:
|
147
146
|
specification_version: 4
|
148
147
|
summary: Syntax checks for Puppet manifests, templates, and Hiera YAML
|
@@ -151,6 +150,7 @@ test_files:
|
|
151
150
|
- spec/fixtures/hiera/data/hiera_2.eyaml
|
152
151
|
- spec/fixtures/hiera/data/test/hiera_3.yaml
|
153
152
|
- spec/fixtures/hiera/data/test/hiera_4.eyaml
|
153
|
+
- spec/fixtures/hiera/hiera_bad.eyaml
|
154
154
|
- spec/fixtures/hiera/hiera_bad.yaml
|
155
155
|
- spec/fixtures/hiera/hiera_bad_18.yaml
|
156
156
|
- spec/fixtures/hiera/hiera_badkey.yaml
|
data/appveyor.yml
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
build: off
|
2
|
-
|
3
|
-
branches:
|
4
|
-
only:
|
5
|
-
- master
|
6
|
-
|
7
|
-
# ruby versions under test
|
8
|
-
environment:
|
9
|
-
matrix:
|
10
|
-
- RUBY_VERSION: 21
|
11
|
-
PUPPET_VERSION: "~> 3.8.7"
|
12
|
-
- RUBY_VERSION: 21
|
13
|
-
PUPPET_VERSION: "~> 4.8.0"
|
14
|
-
- RUBY_VERSION: 23-x64
|
15
|
-
PUPPET_VERSION: "~> 4.9.0"
|
16
|
-
- RUBY_VERSION: 23-x64
|
17
|
-
PUPPET_VERSION: "> 0"
|
18
|
-
- RUBY_VERSION: 23-x64
|
19
|
-
PUPPET_VERSION: "git://github.com/puppetlabs/puppet.git#master"
|
20
|
-
|
21
|
-
matrix:
|
22
|
-
allow_failures:
|
23
|
-
- RUBY_VERSION: 23-x64
|
24
|
-
PUPPET_VERSION: "git://github.com/puppetlabs/puppet.git#master"
|
25
|
-
|
26
|
-
install:
|
27
|
-
- SET PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
|
28
|
-
- SET LOG_SPEC_ORDER=true
|
29
|
-
- bundle install --jobs 4 --retry 2 --without development
|
30
|
-
|
31
|
-
before_test:
|
32
|
-
- type Gemfile.lock
|
33
|
-
- ruby -v
|
34
|
-
- gem -v
|
35
|
-
- bundle -v
|
36
|
-
|
37
|
-
test_script:
|
38
|
-
- bundle exec rake spec
|