puppet-lint-world_writable_files-check 0.0.1

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: 8b2909f71fa762b4d7e478b53f5dadd7b45e0d3f
4
+ data.tar.gz: f6af4485074efc3167488d9453a0eebee01f49e1
5
+ SHA512:
6
+ metadata.gz: a1894c08b740718a36019f57194d137b7efcca2768e74428a14e86a15eae655eac2e77286065423493e91cb5216ccad226016333fcf4b7860bf6a23ce731b045
7
+ data.tar.gz: 9721fe6ed35fc6f4b56fc26f3f651eff712841731beaaf2476209c3cb92d2bd0432fcbb25a6a7f015c9310865e2203f8b74e8cf19e2ccc8af87671704a2cc95f
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,45 @@
1
+ # puppet-lint world_writable_files check #
2
+
3
+ A puppet-lint extension that ensures file resources do not have a mode
4
+ that makes them world writable.
5
+
6
+ [![Build Status](https://travis-ci.org/deanwilson/puppet-lint-world_writable_files-check.svg?branch=master)](https://travis-ci.org/deanwilson/puppet-lint-world_writable_files-check)
7
+
8
+ On a *nix system a world writable file is one that anyone can write to.
9
+ This is often undesirable, especially in production, where who can
10
+ write to certain files should be limited and enabled with deliberation,
11
+ not by accident.
12
+
13
+ This plugin currently only checks octal file modes, the
14
+ [no_symbolic_file_modes](https://github.com/deanwilson/puppet-lint-no_symbolic_file_modes-check)
15
+ `puppet-lint` check ensure this isn't a problem for my code bases but it
16
+ might be a consideration for other peoples usages.
17
+
18
+ ## Installation ##
19
+
20
+ To use this plugin add the following line to your `Gemfile`
21
+
22
+ gem 'puppet-lint-world_writable_files-check'
23
+
24
+ and then run `bundle install`
25
+
26
+ ## Usage ##
27
+
28
+ This plugin provides a new check to `puppet-lint` that warns if it finds
29
+ a file resource that would be created with a mode that allowed every one
30
+ to write to it.
31
+
32
+ class locked_down_file {
33
+ file { '/tmp/open_octal':
34
+ ensure => 'file',
35
+ mode => '0666',
36
+ }
37
+ }
38
+
39
+ This example makes a file that can be read and written to by all users
40
+ of the system and so will raise:
41
+
42
+ files should not be created with world writable permissions
43
+
44
+ ### Author ###
45
+ [Dean Wilson](http://www.unixdaemon.net)
@@ -0,0 +1,24 @@
1
+ PuppetLint.new_check(:world_writable_files) do
2
+ def check
3
+ resource_indexes.each do |resource|
4
+ if resource[:type].value == 'file'
5
+ resource[:param_tokens].select { |param_token|
6
+ param_token.value == 'mode'
7
+ }.each do |param_token|
8
+
9
+ # get the file modes value
10
+ value_token = param_token.next_code_token.next_code_token
11
+
12
+ break if value_token.value =~ /\d+[^2367]$/
13
+
14
+ notify :warning, {
15
+ message: 'files should not be created with world writable permissions',
16
+ line: value_token.line,
17
+ column: value_token.column,
18
+ token: value_token,
19
+ }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'world_writable_files' do
4
+ context 'file with a mode of 640' do
5
+ let(:code) do
6
+ <<-EOS
7
+ class locked_down_file {
8
+ file { '/tmp/locked_down':
9
+ ensure => 'file',
10
+ mode => '0640',
11
+ }
12
+ }
13
+ EOS
14
+ end
15
+
16
+ it 'should not detect any problems' do
17
+ expect(problems).to have(0).problems
18
+ end
19
+ end
20
+
21
+ context 'file with a world writable octal mode of 666' do
22
+ let(:msg) { 'files should not be created with world writable permissions' }
23
+ let(:code) do
24
+ <<-EOS
25
+ class locked_down_file {
26
+ file { '/tmp/open_octal':
27
+ ensure => 'file',
28
+ mode => '0666',
29
+ }
30
+ }
31
+ EOS
32
+ end
33
+
34
+ it 'should detect a 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(4).in_column(23)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ require 'puppet-lint'
2
+
3
+ PuppetLint::Plugins.load_spec_helper
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-lint-world_writable_files-check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dean Wilson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-01 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: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.36.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.36.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: |2
98
+ A puppet-lint extension that ensures file resources do not have a mode that makes
99
+ them world writable.
100
+ email: dean.wilson@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - LICENSE
106
+ - README.md
107
+ - lib/puppet-lint/plugins/world_writable_files.rb
108
+ - spec/puppet-lint/plugins/puppet-lint-world_writable_files_spec.rb
109
+ - spec/spec_helper.rb
110
+ homepage: https://github.com/deanwilson/puppet-lint-world_writable_files-check
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.4.8
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: puppet-lint check to ensure file resources are not world writable
134
+ test_files:
135
+ - spec/puppet-lint/plugins/puppet-lint-world_writable_files_spec.rb
136
+ - spec/spec_helper.rb
137
+ has_rdoc: