foodcritic 13.1.1 → 14.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/chef_dsl_metadata/chef_13.4.19.json +0 -212
- data/chef_dsl_metadata/chef_13.5.3.json +0 -212
- data/chef_dsl_metadata/chef_13.6.0.json +0 -212
- data/chef_dsl_metadata/chef_13.7.16.json +0 -212
- data/chef_dsl_metadata/{chef_13.3.42.json → chef_13.9.1.json} +189 -48
- data/chef_dsl_metadata/{chef_13.1.31.json → chef_14.1.12.json} +8735 -1444
- data/chef_dsl_metadata/{chef_13.0.113.json → chef_14.2.0.json} +8763 -1432
- data/features/continuous_integration_support.feature +0 -2
- data/features/step_definitions/cookbook_steps.rb +0 -26
- data/features/support/command_helpers.rb +0 -2
- data/lib/foodcritic/api.rb +6 -1
- data/lib/foodcritic/linter.rb +1 -1
- data/lib/foodcritic/rules/fc048.rb +1 -1
- data/lib/foodcritic/rules/fc069.rb +145 -115
- data/lib/foodcritic/rules/fc071.rb +1 -1
- data/lib/foodcritic/rules/fc078.rb +54 -48
- data/lib/foodcritic/rules/fc121.rb +6 -0
- data/lib/foodcritic/version.rb +1 -1
- data/spec/functional/fc009_spec.rb +6 -6
- data/spec/functional/fc040_spec.rb +156 -0
- data/spec/functional/fc041_spec.rb +121 -0
- data/spec/functional/fc048_spec.rb +67 -0
- data/spec/functional/fc121_spec.rb +43 -0
- data/spec/regression/expected/aix.txt +4 -0
- data/spec/regression/expected/apt.txt +1 -1
- data/spec/regression/expected/ark.txt +1 -0
- data/spec/regression/expected/boost.txt +1 -0
- data/spec/regression/expected/chef-client.txt +4 -4
- data/spec/regression/expected/chef-ingredient.txt +1 -0
- data/spec/regression/expected/chef_client_updater.txt +1 -0
- data/spec/regression/expected/chef_nginx.txt +2 -0
- data/spec/regression/expected/dmg.txt +3 -3
- data/spec/regression/expected/docker.txt +1 -0
- data/spec/regression/expected/erlang.txt +1 -0
- data/spec/regression/expected/gecode.txt +2 -0
- data/spec/regression/expected/mysql.txt +2 -0
- data/spec/regression/expected/passenger_apache2.txt +2 -0
- data/spec/regression/expected/php.txt +2 -0
- data/spec/regression/expected/tomcat.txt +16 -0
- data/spec/regression/expected/transmission.txt +2 -0
- data/spec/regression/expected/ufw.txt +1 -0
- data/spec/regression/expected/windows.txt +2 -1
- data/spec/regression/expected/xml.txt +2 -0
- data/spec/unit/linter_spec.rb +1 -1
- metadata +11 -11
- data/features/040_check_raw_git_usage.feature +0 -43
- data/features/041_check_raw_download.feature +0 -34
- data/features/048_check_for_shellout.feature +0 -44
- data/lib/foodcritic/rules/fc012.rb +0 -8
- data/spec/functional/fc012_spec.rb +0 -20
@@ -1,5 +1,5 @@
|
|
1
1
|
rule "FC071", "Missing LICENSE file" do
|
2
|
-
tags %w{style license}
|
2
|
+
tags %w{style license opensource}
|
3
3
|
cookbook do |path|
|
4
4
|
unless ::File.exist?(::File.join(path, "metadata.rb")) && field_value(read_ast(::File.join(path, "metadata.rb")), "license").to_s.casecmp("All Rights Reserved") == 0
|
5
5
|
ensure_file_exists(path, "LICENSE")
|
@@ -8,123 +8,129 @@ rule "FC078", "Ensure cookbook shared under an OSI-approved open source license"
|
|
8
8
|
# require 'json'
|
9
9
|
# require 'net/http'
|
10
10
|
# json_data = JSON.parse(Net::HTTP.get(URI('https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json')))
|
11
|
-
# licenses = json_data['licenses']
|
12
|
-
# .select { |license| license['isOsiApproved'] }
|
13
|
-
# .map {|l| l['licenseId'] }
|
11
|
+
# licenses = json_data['licenses'].select { |license| license['isOsiApproved'] }.map {|l| l['licenseId']}.sort
|
14
12
|
#
|
15
13
|
osi_approved_licenses = %w{
|
14
|
+
AAL
|
16
15
|
AFL-1.1
|
17
16
|
AFL-1.2
|
18
17
|
AFL-2.0
|
19
18
|
AFL-2.1
|
20
19
|
AFL-3.0
|
20
|
+
AGPL-3.0
|
21
|
+
AGPL-3.0-only
|
22
|
+
AGPL-3.0-or-later
|
21
23
|
APL-1.0
|
22
|
-
Apache-1.1
|
23
|
-
Apache-2.0
|
24
24
|
APSL-1.0
|
25
25
|
APSL-1.1
|
26
26
|
APSL-1.2
|
27
27
|
APSL-2.0
|
28
|
+
Apache-1.1
|
29
|
+
Apache-2.0
|
28
30
|
Artistic-1.0
|
29
31
|
Artistic-1.0-Perl
|
30
32
|
Artistic-1.0-cl8
|
31
33
|
Artistic-2.0
|
32
|
-
AAL
|
33
|
-
BSL-1.0
|
34
34
|
BSD-2-Clause
|
35
|
+
BSD-2-Clause-Patent
|
35
36
|
BSD-3-Clause
|
36
|
-
|
37
|
+
BSL-1.0
|
38
|
+
CATOSL-1.1
|
39
|
+
CDDL-1.0
|
37
40
|
CECILL-2.1
|
38
41
|
CNRI-Python
|
39
|
-
CDDL-1.0
|
40
42
|
CPAL-1.0
|
41
43
|
CPL-1.0
|
42
|
-
CATOSL-1.1
|
43
44
|
CUA-OPL-1.0
|
44
|
-
EPL-1.0
|
45
45
|
ECL-1.0
|
46
46
|
ECL-2.0
|
47
47
|
EFL-1.0
|
48
48
|
EFL-2.0
|
49
|
-
|
49
|
+
EPL-1.0
|
50
|
+
EPL-2.0
|
50
51
|
EUDatagrid
|
51
52
|
EUPL-1.1
|
53
|
+
EUPL-1.2
|
54
|
+
Entessa
|
52
55
|
Fair
|
53
56
|
Frameworx-1.0
|
54
|
-
AGPL-3.0
|
55
57
|
GPL-2.0
|
58
|
+
GPL-2.0+
|
59
|
+
GPL-2.0-only
|
60
|
+
GPL-2.0-or-later
|
56
61
|
GPL-3.0
|
57
|
-
|
58
|
-
|
59
|
-
|
62
|
+
GPL-3.0+
|
63
|
+
GPL-3.0-only
|
64
|
+
GPL-3.0-or-later
|
65
|
+
GPL-3.0-with-GCC-exception
|
60
66
|
HPND
|
61
|
-
IPL-1.0
|
62
|
-
Intel
|
63
67
|
IPA
|
68
|
+
IPL-1.0
|
64
69
|
ISC
|
70
|
+
Intel
|
71
|
+
LGPL-2.0
|
72
|
+
LGPL-2.0+
|
73
|
+
LGPL-2.0-only
|
74
|
+
LGPL-2.0-or-later
|
75
|
+
LGPL-2.1
|
76
|
+
LGPL-2.1+
|
77
|
+
LGPL-2.1-only
|
78
|
+
LGPL-2.1-or-later
|
79
|
+
LGPL-3.0
|
80
|
+
LGPL-3.0+
|
81
|
+
LGPL-3.0-only
|
82
|
+
LGPL-3.0-or-later
|
83
|
+
LPL-1.0
|
84
|
+
LPL-1.02
|
65
85
|
LPPL-1.3c
|
66
86
|
LiLiQ-P-1.1
|
67
|
-
LiLiQ-Rplus-1.1
|
68
87
|
LiLiQ-R-1.1
|
69
|
-
|
70
|
-
LPL-1.0
|
71
|
-
MS-PL
|
72
|
-
MS-RL
|
73
|
-
MirOS
|
88
|
+
LiLiQ-Rplus-1.1
|
74
89
|
MIT
|
75
|
-
|
90
|
+
MIT-0
|
76
91
|
MPL-1.0
|
77
92
|
MPL-1.1
|
78
93
|
MPL-2.0
|
79
94
|
MPL-2.0-no-copyleft-exception
|
95
|
+
MS-PL
|
96
|
+
MS-RL
|
97
|
+
MirOS
|
98
|
+
Motosoto
|
80
99
|
Multics
|
81
100
|
NASA-1.3
|
82
|
-
|
101
|
+
NCSA
|
83
102
|
NGPL
|
84
|
-
Nokia
|
85
103
|
NPOSL-3.0
|
86
104
|
NTP
|
105
|
+
Naumen
|
106
|
+
Nokia
|
87
107
|
OCLC-2.0
|
108
|
+
OFL-1.1
|
88
109
|
OGTSL
|
110
|
+
OSET-PL-2.1
|
89
111
|
OSL-1.0
|
90
112
|
OSL-2.0
|
91
113
|
OSL-2.1
|
92
114
|
OSL-3.0
|
93
|
-
OSET-PL-2.1
|
94
115
|
PHP-3.0
|
95
116
|
PostgreSQL
|
96
117
|
Python-2.0
|
97
118
|
QPL-1.0
|
98
|
-
RPSL-1.0
|
99
119
|
RPL-1.1
|
100
120
|
RPL-1.5
|
121
|
+
RPSL-1.0
|
101
122
|
RSCPL
|
102
|
-
OFL-1.1
|
103
|
-
SimPL-2.0
|
104
|
-
Sleepycat
|
105
123
|
SISSL
|
106
124
|
SPL-1.0
|
107
|
-
|
125
|
+
SimPL-2.0
|
126
|
+
Sleepycat
|
108
127
|
UPL-1.0
|
109
|
-
NCSA
|
110
128
|
VSL-1.0
|
111
129
|
W3C
|
130
|
+
Watcom-1.0
|
112
131
|
Xnet
|
113
|
-
Zlib
|
114
132
|
ZPL-2.0
|
115
|
-
|
116
|
-
GPL-2.0-with-autoconf-exception
|
117
|
-
GPL-2.0-with-bison-exception
|
118
|
-
GPL-2.0-with-classpath-exception
|
119
|
-
GPL-2.0-with-font-exception
|
120
|
-
GPL-2.0-with-GCC-exception
|
121
|
-
GPL-3.0+
|
122
|
-
GPL-3.0-with-autoconf-exception
|
123
|
-
GPL-3.0-with-GCC-exception
|
124
|
-
LGPL-2.1+
|
125
|
-
LGPL-3.0+
|
126
|
-
LGPL-2.0+
|
127
|
-
WXwindows
|
133
|
+
Zlib
|
128
134
|
}
|
129
135
|
[file_match(filename)] unless osi_approved_licenses.include?(license)
|
130
136
|
rescue NoMethodError # no license in the metadata
|
@@ -0,0 +1,6 @@
|
|
1
|
+
rule "FC121", "Cookbook depends on cookbook made obsolete by Chef 14" do
|
2
|
+
tags %w{correctness}
|
3
|
+
metadata do |ast, filename|
|
4
|
+
[file_match(filename)] unless (declared_dependencies(ast) & %w{build-essential dmg chef_handler chef_hostname mac_os_x swap sysctl}).empty?
|
5
|
+
end
|
6
|
+
end
|
data/lib/foodcritic/version.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "FC009" do
|
4
|
-
context "on chef
|
5
|
-
foodcritic_command("--chef-version", "
|
4
|
+
context "on chef 14.2.0 with a cookbook that uses ifconfig attributes introduced in 14.0" do
|
5
|
+
foodcritic_command("--chef-version", "14.2.0", "--no-progress", ".")
|
6
6
|
recipe_file <<-EOH
|
7
7
|
ifconfig 'foo' do
|
8
|
-
|
8
|
+
family 'inet'
|
9
9
|
end
|
10
10
|
EOH
|
11
11
|
it { is_expected.not_to violate_rule }
|
12
12
|
end
|
13
13
|
|
14
|
-
context "on chef 13.
|
15
|
-
foodcritic_command("--chef-version", "13.
|
14
|
+
context "on chef 13.9.1 with a cookbook that uses ifconfig attributes introduced in 14.0" do
|
15
|
+
foodcritic_command("--chef-version", "13.9.1", "--no-progress", ".")
|
16
16
|
recipe_file <<-EOH
|
17
17
|
ifconfig 'foo' do
|
18
|
-
|
18
|
+
family 'inet'
|
19
19
|
end
|
20
20
|
EOH
|
21
21
|
it { is_expected.to violate_rule }
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC040" do
|
4
|
+
context "with a recipe that contains an execute resource named 'git pull'" do
|
5
|
+
recipe_file <<-EOH
|
6
|
+
execute 'git pull' do
|
7
|
+
action :run
|
8
|
+
end
|
9
|
+
EOH
|
10
|
+
it { is_expected.to violate_rule }
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with a recipe that contains an execute resource named 'git clone'" do
|
14
|
+
recipe_file <<-EOH
|
15
|
+
execute 'git clone' do
|
16
|
+
action :run
|
17
|
+
end
|
18
|
+
EOH
|
19
|
+
it { is_expected.to violate_rule }
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with a recipe that contains an execute resource named 'git fetch'" do
|
23
|
+
recipe_file <<-EOH
|
24
|
+
execute 'git fetch' do
|
25
|
+
action :run
|
26
|
+
end
|
27
|
+
EOH
|
28
|
+
it { is_expected.to violate_rule }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with a recipe that contains an execute resource named 'git checkout'" do
|
32
|
+
recipe_file <<-EOH
|
33
|
+
execute 'git checkout' do
|
34
|
+
action :run
|
35
|
+
end
|
36
|
+
EOH
|
37
|
+
it { is_expected.to violate_rule }
|
38
|
+
end
|
39
|
+
|
40
|
+
context "with a recipe that contains an execute resource named 'git reset --hard'" do
|
41
|
+
recipe_file <<-EOH
|
42
|
+
execute 'git reset --hard' do
|
43
|
+
action :run
|
44
|
+
end
|
45
|
+
EOH
|
46
|
+
it { is_expected.to violate_rule }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with a recipe that contains an execute resource named 'git show'" do
|
50
|
+
recipe_file <<-EOH
|
51
|
+
execute 'git show' do
|
52
|
+
action :run
|
53
|
+
end
|
54
|
+
EOH
|
55
|
+
it { is_expected.to_not violate_rule }
|
56
|
+
end
|
57
|
+
|
58
|
+
context "with a recipe that contains an execute resource named 'echo 'bob' && git show'" do
|
59
|
+
recipe_file <<-EOH
|
60
|
+
execute "echo 'bob' && git show" do
|
61
|
+
action :run
|
62
|
+
end
|
63
|
+
EOH
|
64
|
+
it { is_expected.to_not violate_rule }
|
65
|
+
end
|
66
|
+
|
67
|
+
context "with a recipe that contains an execute resource to run 'git clone https://github.com/git/git.git'" do
|
68
|
+
recipe_file <<-EOH
|
69
|
+
execute "a git command" do
|
70
|
+
command 'git clone https://github.com/git/git.git'
|
71
|
+
action :run
|
72
|
+
end
|
73
|
+
EOH
|
74
|
+
it { is_expected.to violate_rule }
|
75
|
+
end
|
76
|
+
|
77
|
+
context "with a recipe that contains an execute resource to run 'git clone --depth 10 https://github.com/git/git.git'" do
|
78
|
+
recipe_file <<-EOH
|
79
|
+
execute "a git command" do
|
80
|
+
command 'git clone --depth 10 https://github.com/git/git.git'
|
81
|
+
action :run
|
82
|
+
end
|
83
|
+
EOH
|
84
|
+
it { is_expected.to violate_rule }
|
85
|
+
end
|
86
|
+
|
87
|
+
context "with a recipe that contains an execute resource to run 'get checkout master'" do
|
88
|
+
recipe_file <<-EOH
|
89
|
+
execute "a git command" do
|
90
|
+
command 'git checkout master'
|
91
|
+
action :run
|
92
|
+
end
|
93
|
+
EOH
|
94
|
+
it { is_expected.to violate_rule }
|
95
|
+
end
|
96
|
+
|
97
|
+
context "with a recipe that contains an execute resource to run 'git reset --hard'" do
|
98
|
+
recipe_file <<-EOH
|
99
|
+
execute "a git command" do
|
100
|
+
command 'git reset hard'
|
101
|
+
action :run
|
102
|
+
end
|
103
|
+
EOH
|
104
|
+
it { is_expected.to violate_rule }
|
105
|
+
end
|
106
|
+
|
107
|
+
context "with a recipe that contains an execute resource to run 'git pull" do
|
108
|
+
recipe_file <<-EOH
|
109
|
+
execute "a git command" do
|
110
|
+
command 'git pull'
|
111
|
+
action :run
|
112
|
+
end
|
113
|
+
EOH
|
114
|
+
it { is_expected.to violate_rule }
|
115
|
+
end
|
116
|
+
|
117
|
+
context "with a recipe that contains an execute resource to run 'git fetch origin'" do
|
118
|
+
recipe_file <<-EOH
|
119
|
+
execute "a git command" do
|
120
|
+
command 'git fetch origin'
|
121
|
+
action :run
|
122
|
+
end
|
123
|
+
EOH
|
124
|
+
it { is_expected.to violate_rule }
|
125
|
+
end
|
126
|
+
|
127
|
+
context "with a recipe that contains an execute resource to run 'git status && git pull '" do
|
128
|
+
recipe_file <<-EOH
|
129
|
+
execute "a git command" do
|
130
|
+
command 'git status && git pull'
|
131
|
+
action :run
|
132
|
+
end
|
133
|
+
EOH
|
134
|
+
it { is_expected.to violate_rule }
|
135
|
+
end
|
136
|
+
|
137
|
+
context "with a recipe that contains an execute resource to run 'git show'" do
|
138
|
+
recipe_file <<-EOH
|
139
|
+
execute "a git command" do
|
140
|
+
command 'git show'
|
141
|
+
action :run
|
142
|
+
end
|
143
|
+
EOH
|
144
|
+
it { is_expected.to_not violate_rule }
|
145
|
+
end
|
146
|
+
|
147
|
+
context "with a recipe that contains an execute resource to run 'curl http://github.com/ '" do
|
148
|
+
recipe_file <<-EOH
|
149
|
+
execute "a git command" do
|
150
|
+
command 'curl http://github.com/ '
|
151
|
+
action :run
|
152
|
+
end
|
153
|
+
EOH
|
154
|
+
it { is_expected.to_not violate_rule }
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC041" do
|
4
|
+
context "with a recipe that contains an execute resource to run curl" do
|
5
|
+
recipe_file <<-EOH
|
6
|
+
execute 'curl "http://www.chef.io/"' do
|
7
|
+
action :run
|
8
|
+
end
|
9
|
+
EOH
|
10
|
+
it { is_expected.to_not violate_rule }
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with a recipe that contains an execute resource to run which curl" do
|
14
|
+
recipe_file <<-EOH
|
15
|
+
execute 'which curl' do
|
16
|
+
action :run
|
17
|
+
end
|
18
|
+
EOH
|
19
|
+
it { is_expected.to_not violate_rule }
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with a recipe that contains an execute resource to run wget" do
|
23
|
+
recipe_file <<-EOH
|
24
|
+
execute 'wget "http://www.chef.io/"' do
|
25
|
+
action :run
|
26
|
+
end
|
27
|
+
EOH
|
28
|
+
it { is_expected.to violate_rule }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with a recipe that contains an execute resource to run sudo wget" do
|
32
|
+
recipe_file <<-EOH
|
33
|
+
execute 'sudo wget "http://www.chef.io/"' do
|
34
|
+
action :run
|
35
|
+
end
|
36
|
+
EOH
|
37
|
+
it { is_expected.to violate_rule }
|
38
|
+
end
|
39
|
+
|
40
|
+
context "with a recipe that contains an execute resource to curl with -o" do
|
41
|
+
recipe_file <<-EOH
|
42
|
+
execute "curl 'http://example.org/' -o foo" do
|
43
|
+
action :run
|
44
|
+
end
|
45
|
+
EOH
|
46
|
+
it { is_expected.to violate_rule }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with a recipe that contains an execute resource to curl with a post request" do
|
50
|
+
recipe_file <<-EOH
|
51
|
+
execute "curl -X POST 'http://example.org/'" do
|
52
|
+
action :run
|
53
|
+
end
|
54
|
+
EOH
|
55
|
+
it { is_expected.to_not violate_rule }
|
56
|
+
end
|
57
|
+
|
58
|
+
context "with a recipe that contains an execute resource to curl with --output" do
|
59
|
+
recipe_file <<-EOH
|
60
|
+
execute "curl 'http://example.org/' --output foo" do
|
61
|
+
action :run
|
62
|
+
end
|
63
|
+
EOH
|
64
|
+
it { is_expected.to violate_rule }
|
65
|
+
end
|
66
|
+
|
67
|
+
context "with a recipe that contains an execute resource to curl with --output" do
|
68
|
+
recipe_file <<-EOH
|
69
|
+
execute "curl 'http://example.org/' --output foo" do
|
70
|
+
action :run
|
71
|
+
end
|
72
|
+
EOH
|
73
|
+
it { is_expected.to violate_rule }
|
74
|
+
end
|
75
|
+
|
76
|
+
context "with a recipe that contains an execute resource to curl then redirect stdout" do
|
77
|
+
recipe_file <<-EOH
|
78
|
+
execute "curl 'http://example.org/' > foo" do
|
79
|
+
action :run
|
80
|
+
end
|
81
|
+
EOH
|
82
|
+
it { is_expected.to violate_rule }
|
83
|
+
end
|
84
|
+
|
85
|
+
context "with a recipe that contains an execute resource to curl then redirect stdout/stderr" do
|
86
|
+
recipe_file <<-EOH
|
87
|
+
execute "curl 'http://example.org/' &> foo" do
|
88
|
+
action :run
|
89
|
+
end
|
90
|
+
EOH
|
91
|
+
it { is_expected.to violate_rule }
|
92
|
+
end
|
93
|
+
|
94
|
+
context "with a recipe that contains an execute resource to run something & wget" do
|
95
|
+
recipe_file <<-EOH
|
96
|
+
execute "mkdir bob && wget 'http://example.org/'" do
|
97
|
+
action :run
|
98
|
+
end
|
99
|
+
EOH
|
100
|
+
it { is_expected.to violate_rule }
|
101
|
+
end
|
102
|
+
|
103
|
+
context "with a recipe that contains an execute resource with command run sudo wget" do
|
104
|
+
recipe_file <<-EOH
|
105
|
+
execute 'my command' do
|
106
|
+
command 'sudo wget "http://www.chef.io/"'
|
107
|
+
action :run
|
108
|
+
end
|
109
|
+
EOH
|
110
|
+
it { is_expected.to violate_rule }
|
111
|
+
end
|
112
|
+
|
113
|
+
context "with a recipe that contains an execute resource with command run which curl" do
|
114
|
+
recipe_file <<-EOH
|
115
|
+
execute 'my command' do
|
116
|
+
command 'which curl'
|
117
|
+
end
|
118
|
+
EOH
|
119
|
+
it { is_expected.to_not violate_rule }
|
120
|
+
end
|
121
|
+
end
|