puppet-lint-no_symbolic_file_modes-check 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a879d214278d7ede417115e5ea44ae4fd240d56a
4
+ data.tar.gz: 826315192d79abbda51de1034b50234fcbfa0832
5
+ SHA512:
6
+ metadata.gz: 027096ef8f757bf084d5a37dc490078eb56b951141f29b8a0af50609e85fd536004a662ac7011bec470022f5232e8d970b3c510efc0936063c8edf37bf76bcf2
7
+ data.tar.gz: 3e8dd08019faa700e593d1306438cf61657e8a783608945c575bf36defb271459099cc2c19d6cae8f0fcfc5453257c7a6f28bbb6e32eeec126ce9db479b72c94
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dean Wilson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # puppet-lint no symbolic file modes check
2
+
3
+ Extends puppet-lint to ensure all file resource modes are defined as octal
4
+ values and not symbolic ones.
5
+
6
+ While symbolic modes can be more flexible than numeric modes they allow
7
+ you to become less absolute about the permissions a file will end up
8
+ with. `mode => 'ug+w'` for example will set the user and group write
9
+ bits, without affecting any other bits, leaving you unable to determine
10
+ the files final permissions from just reading the puppet code.
11
+
12
+ # a good, octal mode.
13
+ class octal_file_mode {
14
+ file { '/tmp/octal-mode':
15
+ mode => '0600',
16
+ }
17
+ }
18
+
19
+ # A bad, symbolic mode.
20
+ class symbolic_file_mode {
21
+ file { '/tmp/symbolic-mode':
22
+ mode => 'ug=rw,o=rx',
23
+ }
24
+ }
25
+
26
+ ## Installation
27
+
28
+ To use this plugin add the following line to your Gemfile
29
+
30
+ gem 'puppet-lint-no_symbolic_file_modes-check'
31
+
32
+ and then run `bundle install`.
33
+
34
+ ## Usage
35
+
36
+ This plugin provides a new check to `puppet-lint`.
37
+
38
+ mode should be a 4 digit octal value, not a symbolic mode
39
+
40
+ ## Notes
41
+
42
+ The code for this was heavily borrowed/stolen from the original,
43
+ including in puppet-lint, file mode check written by @rodjek
@@ -0,0 +1,28 @@
1
+ PuppetLint.new_check(:no_symbolic_file_modes) do
2
+
3
+ IGNORE_TYPES = Set[:VARIABLE, :UNDEF]
4
+ WARNING = 'mode should be a 4 digit octal value, not a symbolic mode'
5
+
6
+ def check
7
+ resource_indexes.each do |resource|
8
+ if resource[:type].value == "file"
9
+ resource[:param_tokens].select { |param_token|
10
+ param_token.value == 'mode'
11
+ }.each do |param_token|
12
+ value_token = param_token.next_code_token.next_code_token
13
+
14
+ break if IGNORE_TYPES.include?(value_token.type)
15
+ break if value_token.value =~ /^[0-7]{4}$/
16
+
17
+ notify :warning, {
18
+ :message => WARNING,
19
+ :line => value_token.line,
20
+ :column => value_token.column,
21
+ :token => value_token,
22
+ }
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'no_symbolic_file_modes' do
4
+
5
+ let(:msg) { 'mode should be a 4 digit octal value, not a symbolic mode' }
6
+
7
+ context 'file with all octal mode' do
8
+ let(:code) do
9
+ <<-EOS
10
+ class octal_file_mode {
11
+ file { '/tmp/octal-mode':
12
+ mode => '0600',
13
+ }
14
+ }
15
+ EOS
16
+ end
17
+
18
+ it 'should not detect any problems' do
19
+ expect(problems).to have(0).problems
20
+ end
21
+ end
22
+
23
+ context 'file with a symbolic mode' do
24
+ let(:code) do
25
+ <<-EOS
26
+ class symbolic_file_mode {
27
+ file { '/tmp/symbolic-mode':
28
+ mode => 'ug=rw,o=rx',
29
+ }
30
+ }
31
+ EOS
32
+ end
33
+
34
+ it 'should detect a single problem' do
35
+ expect(problems).to have(1).problem
36
+ end
37
+
38
+ it 'should create a warning' do
39
+ expect(problems).to contain_warning(msg).on_line(3).in_column(21)
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,3 @@
1
+ require 'puppet-lint'
2
+
3
+ PuppetLint::Plugins.load_spec_helper
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-lint-no_symbolic_file_modes-check
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dean Wilson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: puppet-lint
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-its
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-collection_matchers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: " Extends puppet-lint to ensure all file resource modes are defined
84
+ as octal\n values and not symbolic ones. \n"
85
+ email: dean.wilson@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE
91
+ - README.md
92
+ - lib/puppet-lint/plugins/no_symbolic_file_modes.rb
93
+ - spec/puppet-lint/plugins/puppet-lint-no_symbolic_file_modes_spec.rb
94
+ - spec/spec_helper.rb
95
+ homepage: https://github.com/deanwilson/puppet-lint-no_symbolic_file_modes-check
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.4.8
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: puppet-lint no_symbolic_file_modes check
119
+ test_files:
120
+ - spec/spec_helper.rb
121
+ - spec/puppet-lint/plugins/puppet-lint-no_symbolic_file_modes_spec.rb
122
+ has_rdoc: