puppet-lint-file_ensure-check 1.1.0 → 2.0.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57769e66e286d300d039e15ba4ab871ba1008fc3cf6a65f374d8c5b42f1c8022
|
4
|
+
data.tar.gz: 1a1ec2f4427e2d3a90d4258718b79dac39bd126177e2988d0560581ed1dd9f97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96e38cf8c1a28ef389e238c98e05bc6567b9a3ab50d760b15e915c73b3d690205cd39b278873146741c7e7171ea79429fa032b678b54bf1e4cfe54fb56ba1327
|
7
|
+
data.tar.gz: 93fecbbf38081246b2402e59438e8e96c1f3cf45f77541a2e08bbc7ee2e184bff192036ff1f174b629914115cd793ecc1c8ad51059a8aca354690ca221278461
|
@@ -1,33 +1,39 @@
|
|
1
1
|
PuppetLint.new_check(:file_ensure) do
|
2
2
|
def check
|
3
3
|
resource_indexes.each do |resource|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
next unless val_token.value == 'present'
|
11
|
-
next unless [:NAME, :STRING, :SSTRING].include? val_token.type
|
12
|
-
notify :warning, {
|
13
|
-
:message => 'ensure set to present on file resource',
|
14
|
-
:line => val_token.line,
|
15
|
-
:column => val_token.column,
|
16
|
-
:token => val_token,
|
17
|
-
:resource => resource,
|
18
|
-
}
|
4
|
+
next unless resource[:type].value == 'file'
|
5
|
+
|
6
|
+
attr = resource[:tokens].select do |t|
|
7
|
+
t.type == :NAME &&
|
8
|
+
t.value == 'ensure' &&
|
9
|
+
t.next_code_token.type == :FARROW
|
19
10
|
end
|
11
|
+
next if attr.empty?
|
12
|
+
|
13
|
+
val_token = attr[0].next_code_token.next_code_token
|
14
|
+
next unless val_token.value == 'present'
|
15
|
+
next unless %i[NAME STRING SSTRING].include? val_token.type
|
16
|
+
|
17
|
+
notify :warning, {
|
18
|
+
message: 'ensure set to present on file resource',
|
19
|
+
line: val_token.line,
|
20
|
+
column: val_token.column,
|
21
|
+
token: val_token,
|
22
|
+
resource: resource,
|
23
|
+
}
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
23
27
|
def fix(problem)
|
24
|
-
target_attr = problem[:resource][:tokens].select
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
problem[:token].value = 'file'
|
29
|
-
else
|
30
|
-
problem[:token].value = 'link'
|
28
|
+
target_attr = problem[:resource][:tokens].select do |t|
|
29
|
+
t.type == :NAME &&
|
30
|
+
t.value == 'target' &&
|
31
|
+
t.next_code_token.type == :FARROW
|
31
32
|
end
|
33
|
+
problem[:token].value = if target_attr.empty?
|
34
|
+
'file'
|
35
|
+
else
|
36
|
+
'link'
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'file_ensure' do
|
4
|
-
let
|
4
|
+
let(:msg) { 'ensure set to present on file resource' }
|
5
5
|
|
6
6
|
context 'with fix disabled' do
|
7
7
|
context 'correct file resource declarations' do
|
8
|
-
let
|
8
|
+
let(:code) do
|
9
9
|
<<-EOS
|
10
10
|
file { '/etc/sudoers':
|
11
11
|
ensure => file,
|
@@ -20,15 +20,15 @@ describe 'file_ensure' do
|
|
20
20
|
ensure => $present,
|
21
21
|
}
|
22
22
|
EOS
|
23
|
-
|
23
|
+
end
|
24
24
|
|
25
|
-
it '
|
25
|
+
it 'does not detect any problems' do
|
26
26
|
expect(problems).to have(0).problems
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'wrong file resource declarations' do
|
31
|
-
let
|
31
|
+
let(:code) do
|
32
32
|
<<-EOS
|
33
33
|
file { '/etc/sudoers':
|
34
34
|
ensure => present,
|
@@ -43,13 +43,13 @@ describe 'file_ensure' do
|
|
43
43
|
ensure => $present,
|
44
44
|
}
|
45
45
|
EOS
|
46
|
-
|
46
|
+
end
|
47
47
|
|
48
|
-
it '
|
48
|
+
it 'detects problems' do
|
49
49
|
expect(problems).to have(2).problems
|
50
50
|
end
|
51
51
|
|
52
|
-
it '
|
52
|
+
it 'creates a warning' do
|
53
53
|
expect(problems).to contain_warning(msg).on_line(2).in_column(21)
|
54
54
|
expect(problems).to contain_warning(msg).on_line(6).in_column(21)
|
55
55
|
end
|
@@ -66,7 +66,7 @@ describe 'file_ensure' do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
context 'correct file resource declarations' do
|
69
|
-
let
|
69
|
+
let(:code) do
|
70
70
|
<<-EOS
|
71
71
|
file { '/etc/sudoers':
|
72
72
|
ensure => file,
|
@@ -81,19 +81,19 @@ describe 'file_ensure' do
|
|
81
81
|
ensure => $present,
|
82
82
|
}
|
83
83
|
EOS
|
84
|
-
|
84
|
+
end
|
85
85
|
|
86
|
-
it '
|
86
|
+
it 'does not detect any problems' do
|
87
87
|
expect(problems).to have(0).problems
|
88
88
|
end
|
89
89
|
|
90
|
-
it '
|
90
|
+
it 'does not modify the manifest' do
|
91
91
|
expect(manifest).to eq(code)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
context 'wrong file resource declarations' do
|
96
|
-
let
|
96
|
+
let(:code) do
|
97
97
|
<<-EOS
|
98
98
|
file { '/etc/sudoers':
|
99
99
|
ensure => present,
|
@@ -108,20 +108,20 @@ describe 'file_ensure' do
|
|
108
108
|
ensure => $present,
|
109
109
|
}
|
110
110
|
EOS
|
111
|
-
|
111
|
+
end
|
112
112
|
|
113
|
-
it '
|
113
|
+
it 'detects two problems' do
|
114
114
|
expect(problems).to have(2).problems
|
115
115
|
end
|
116
116
|
|
117
|
-
it '
|
117
|
+
it 'creates a warning' do
|
118
118
|
expect(problems).to contain_fixed(msg).on_line(2).in_column(21)
|
119
119
|
expect(problems).to contain_fixed(msg).on_line(6).in_column(21)
|
120
120
|
end
|
121
121
|
|
122
|
-
it '
|
122
|
+
it 'fixes the ensure parameter' do
|
123
123
|
expect(manifest).to eq(
|
124
|
-
<<-EOS
|
124
|
+
<<-EOS,
|
125
125
|
file { '/etc/sudoers':
|
126
126
|
ensure => file,
|
127
127
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-file_ensure-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
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: 2023-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -16,104 +16,40 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '5'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '3'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: rspec
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.0'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '3.0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rspec-its
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '1.0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '1.0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: rspec-collection_matchers
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '1.0'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '1.0'
|
32
|
+
version: '5'
|
75
33
|
- !ruby/object:Gem::Dependency
|
76
34
|
name: mime-types
|
77
35
|
requirement: !ruby/object:Gem::Requirement
|
78
36
|
requirements:
|
79
|
-
- - "
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - ">="
|
37
|
+
- - "~>"
|
87
38
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: simplecov
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
39
|
+
version: '3.4'
|
93
40
|
- - ">="
|
94
41
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
42
|
+
version: 3.4.1
|
96
43
|
type: :development
|
97
44
|
prerelease: false
|
98
45
|
version_requirements: !ruby/object:Gem::Requirement
|
99
46
|
requirements:
|
100
|
-
- - "
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '0'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: rake
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - ">="
|
47
|
+
- - "~>"
|
108
48
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
49
|
+
version: '3.4'
|
114
50
|
- - ">="
|
115
51
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
52
|
+
version: 3.4.1
|
117
53
|
description: " A puppet-lint plugin to check the ensure attribute on file resources.\n"
|
118
54
|
email: voxpupuli@groups.io
|
119
55
|
executables: []
|
@@ -137,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
73
|
requirements:
|
138
74
|
- - ">="
|
139
75
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
76
|
+
version: 2.7.0
|
141
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
78
|
requirements:
|
143
79
|
- - ">="
|
@@ -148,6 +84,4 @@ rubygems_version: 3.2.33
|
|
148
84
|
signing_key:
|
149
85
|
specification_version: 4
|
150
86
|
summary: A puppet-lint plugin to check the ensure attribute on file resources.
|
151
|
-
test_files:
|
152
|
-
- spec/puppet-lint/plugins/check_file_ensure/check_file_ensure_spec.rb
|
153
|
-
- spec/spec_helper.rb
|
87
|
+
test_files: []
|