puppet-lint-infrasecure 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +81 -0
- data/lib/puppet-lint/linter.rb +132 -0
- data/lib/puppet-lint/plugins/check_admin_by_default.rb +26 -0
- data/lib/puppet-lint/plugins/check_cyrillic_homograph_attack.rb +19 -0
- data/lib/puppet-lint/plugins/check_empty_password.rb +26 -0
- data/lib/puppet-lint/plugins/check_hard_coded_secret.rb +31 -0
- data/lib/puppet-lint/plugins/check_invalid_ip_addr_binding.rb +23 -0
- data/lib/puppet-lint/plugins/check_malicious_dependency.rb +24 -0
- data/lib/puppet-lint/plugins/check_suspicious_comment.rb +19 -0
- data/lib/puppet-lint/plugins/check_use_http_without_tls.rb +27 -0
- data/lib/puppet-lint/plugins/check_use_of_weak_crypto_algorithm.rb +21 -0
- data/lib/puppet-lint/plugins/check_weak_password.rb +27 -0
- data/lib/puppet-lint-infrasecure/config/dependencies.yml +33 -0
- data/lib/puppet-lint-infrasecure/config/whitelist +19 -0
- data/lib/puppet-lint-infrasecure/dependencies/activemq.json +407 -0
- data/lib/puppet-lint-infrasecure/dependencies/apt.json +453 -0
- data/lib/puppet-lint-infrasecure/dependencies/cassandra.json +122 -0
- data/lib/puppet-lint-infrasecure/dependencies/docker.json +200 -0
- data/lib/puppet-lint-infrasecure/dependencies/elasticsearch.json +32 -0
- data/lib/puppet-lint-infrasecure/dependencies/gitlab.json +1161 -0
- data/lib/puppet-lint-infrasecure/dependencies/grafana.json +31 -0
- data/lib/puppet-lint-infrasecure/dependencies/haproxy.json +159 -0
- data/lib/puppet-lint-infrasecure/dependencies/jenkins.json +876 -0
- data/lib/puppet-lint-infrasecure/dependencies/jira.json +460 -0
- data/lib/puppet-lint-infrasecure/dependencies/kafka.json +32 -0
- data/lib/puppet-lint-infrasecure/dependencies/kubernetes.json +123 -0
- data/lib/puppet-lint-infrasecure/dependencies/mongodb.json +156 -0
- data/lib/puppet-lint-infrasecure/dependencies/mysql.json +14549 -0
- data/lib/puppet-lint-infrasecure/dependencies/nagios_core.json +8 -0
- data/lib/puppet-lint-infrasecure/dependencies/nginx.json +1322 -0
- data/lib/puppet-lint-infrasecure/dependencies/nodejs.json +247 -0
- data/lib/puppet-lint-infrasecure/dependencies/ntp.json +2163 -0
- data/lib/puppet-lint-infrasecure/dependencies/openstack.json +447 -0
- data/lib/puppet-lint-infrasecure/dependencies/openvpn.json +816 -0
- data/lib/puppet-lint-infrasecure/dependencies/postgresql.json +4256 -0
- data/lib/puppet-lint-infrasecure/dependencies/puppet_agent.json +23 -0
- data/lib/puppet-lint-infrasecure/dependencies/python.json +1134 -0
- data/lib/puppet-lint-infrasecure/dependencies/rabbitmq.json +602 -0
- data/lib/puppet-lint-infrasecure/dependencies/redis.json +51 -0
- data/lib/puppet-lint-infrasecure/dependencies/ruby.json +487 -0
- data/lib/puppet-lint-infrasecure/dependencies/sqlite.json +52 -0
- data/lib/puppet-lint-infrasecure/dependencies/systemd.json +180 -0
- data/lib/puppet-lint-infrasecure/dependencies/tomcat.json +8635 -0
- data/lib/puppet-lint-infrasecure/dependencies/vault.json +14 -0
- data/lib/puppet-lint-infrasecure/dependencies/wget.json +129 -0
- data/lib/puppet-lint-infrasecure/dependencies/yum.json +14 -0
- data/lib/puppet-lint-infrasecure/dependencies/zabbix.json +940 -0
- data/lib/puppet-lint-infrasecure/regex.rb +18 -0
- data/lib/puppet-lint-infrasecure/rules.rb +51 -0
- data/lib/puppet-lint-infrasecure/version.rb +3 -0
- data/lib/puppet-lint-infrasecure.rb +62 -0
- data/spec/puppet-lint/plugins/check_admin_by_default_spec.rb +34 -0
- data/spec/puppet-lint/plugins/check_cyrillic_homograph_attack_spec.rb +22 -0
- data/spec/puppet-lint/plugins/check_empty_password_spec.rb +55 -0
- data/spec/puppet-lint/plugins/check_hard_coded_secret_spec.rb +53 -0
- data/spec/puppet-lint/plugins/check_invalid_ip_addr_binding_spec.rb +46 -0
- data/spec/puppet-lint/plugins/check_malicious_dependency_spec.rb +39 -0
- data/spec/puppet-lint/plugins/check_suspicious_comment_spec.rb +50 -0
- data/spec/puppet-lint/plugins/check_use_http_without_tls_spec.rb +100 -0
- data/spec/puppet-lint/plugins/check_use_of_weak_crypto_algorithm_spec.rb +42 -0
- data/spec/puppet-lint/plugins/check_weak_password_spec.rb +29 -0
- data/spec/spec_helper.rb +3 -0
- metadata +284 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: af41dd57d2277014626a4346718c4fecc7ac7f1bb62a544d69853058837092bc
|
4
|
+
data.tar.gz: 0f174a79194cdfaae29db7de3d720e5194a06ee91d9808b4db3c910c408565ed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a94c3cf0b774ec50dcc4610b7cf281768af290a025f7a282c5d7a1281e3152c9607e5cba886007a56465f416bd5458c6eaefe66545c50526a27d266a796121fd
|
7
|
+
data.tar.gz: 9eff8346d97c2c31b9716b276c9905e29a7e9d2cfb0e6c0e0dd7b7a40404bfb2fa1d05edb0e5d4ec2fe8ac2f9cb351a32f538fc963b623a02bccd25c342ac790
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# puppet-lint-infrasecure [](https://badge.fury.io/rb/puppet-lint-infrasecure)
|
2
|
+
|
3
|
+
The goal of this project is to identify potential security issues in your puppet scripts. Ten different checks/plug-ins for puppet-lint are implemented. Contributions are welcome.
|
4
|
+
|
5
|
+
#### Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install puppet-lint-infrasecure
|
9
|
+
```
|
10
|
+
|
11
|
+
#### Run
|
12
|
+
|
13
|
+
```
|
14
|
+
puppet-lint --json <file>
|
15
|
+
```
|
16
|
+
|
17
|
+
#### Security Plug-ins
|
18
|
+
|
19
|
+
Usage documentation is available here.
|
20
|
+
|
21
|
+
| CWE-ID | Anti-Pattern | Example |
|
22
|
+
|:---------------|----------------------------------------|----------------------------------|
|
23
|
+
| `CWE-250` | Admin by default credentials <br /> `admin_by_default` | `$user = 'admin'` <br /> `$pwd = 'admin'` |
|
24
|
+
| `CWE-798` | Hard-coded secrets (password, user, keys) <br /> `hardcoded_secret` | `$username = 'apmirror'` |
|
25
|
+
| `CWE-258` | Invalid IP address binding <br />`invalid_ip_addr_binding` | `$bind_host = '0.0.0.0'` |
|
26
|
+
| `CWE-319` | Use of HTTP without TLS (whitelist config) <br /> `use_http_without_tls` | `$auth_url = 'http://127.0.0.1:35357/v2.0'` |
|
27
|
+
| `CWE-326` | Usage of weak crypto algorithms (sha1, md5) <br /> `use_of_weak_crypto_algorithm` | `password => md5($debian_password)` |
|
28
|
+
| `CWE-521` | Usage of weak passwords (uses [strong_password](https://github.com/bdmac/strong_password)) <br /> `weak_password` | `$pwd = '12345'` |
|
29
|
+
| `CWE-546` | Suspicious comments <br /> `suspicious_comment` | `# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=538392` |
|
30
|
+
| `CWE-829` | Malicious dependencies (beta) <br /> `malicious_dependency` | `$postgresql_version = '8.4'` |
|
31
|
+
| `CWE-1007` | Homograph Attacks (e.g., [Apple](https://www.xudongz.com/blog/2017/idn-phishing/)) <br /> `cyrillic_homograph_attack`| `$source = 'https://downloads.аpаche.org/activemq/5.17.0/apache-activemq-5.17.0-bin.zip'` |
|
32
|
+
|
33
|
+
List security plug-ins:
|
34
|
+
```
|
35
|
+
puppet-lint --list-checks
|
36
|
+
```
|
37
|
+
Output should integrate the following list of plug-ins:
|
38
|
+
|
39
|
+
```
|
40
|
+
admin_by_default
|
41
|
+
cyrillic_homograph_attack
|
42
|
+
empty_password
|
43
|
+
hardcoded_secret
|
44
|
+
invalid_ip_addr_binding
|
45
|
+
malicious_dependency
|
46
|
+
suspicious_comment
|
47
|
+
use_http_without_tls
|
48
|
+
use_of_weak_crypto_algorithm
|
49
|
+
weak_password
|
50
|
+
```
|
51
|
+
|
52
|
+
A default `whitelist` is available for `use_http_without_tls`. You can set your own personalized whitelist.
|
53
|
+
|
54
|
+
1. Create `.env` file.
|
55
|
+
2. Add the whitelist path to the `.env` file.
|
56
|
+
```
|
57
|
+
WHITELIST=~/path/to/whitelist
|
58
|
+
```
|
59
|
+
3. Whitelist Schema
|
60
|
+
```
|
61
|
+
<link1>
|
62
|
+
<link2>
|
63
|
+
<link3>
|
64
|
+
```
|
65
|
+
e.g.,
|
66
|
+
|
67
|
+
```
|
68
|
+
http://apt.postgresql.org/.*
|
69
|
+
http://packages.vmware.com
|
70
|
+
http://.*.jenkins-ci.org/.*
|
71
|
+
```
|
72
|
+
|
73
|
+
|
74
|
+
#### Reporting bugs
|
75
|
+
|
76
|
+
Any bugs related with our plug-ins, please create an issue in our [issue tracker](https://github.com/TQRG/puppet-lint-infrasecure).
|
77
|
+
|
78
|
+
#### Contributions
|
79
|
+
|
80
|
+
Many other security anti-patterns may be out there, therefore feel free to contribute through a [pull request](https://github.com/TQRG/puppet-lint-infrasecure/pulls).
|
81
|
+
|
@@ -0,0 +1,132 @@
|
|
1
|
+
class PuppetLint::CheckPlugin
|
2
|
+
|
3
|
+
def get_malicious_cves(dependency, version)
|
4
|
+
path = "#{Config.dpath}#{dependency}.json"
|
5
|
+
cves = JSON.parse(File.read(path))
|
6
|
+
if !cves[version].nil?
|
7
|
+
return cves[version]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_dependencies(tokens)
|
12
|
+
is_resource = false
|
13
|
+
ftokens = []
|
14
|
+
dependency = ''
|
15
|
+
tokens.each do |token|
|
16
|
+
|
17
|
+
is_next_brace = (not token.next_code_token.nil? and token.next_code_token.type == :LBRACE)
|
18
|
+
is_prev_brace = (not token.prev_code_token.nil? and token.prev_code_token.type == :LBRACE)
|
19
|
+
|
20
|
+
if (token.value.downcase[Config.regex.dependencies] and token.type == :NAME and is_next_brace) or (token.value.downcase[Config.regex.dependencies] and token.type == :SSTRING and is_prev_brace)
|
21
|
+
is_resource = true
|
22
|
+
dependency = token.value.downcase[Config.regex.dependencies]
|
23
|
+
end
|
24
|
+
|
25
|
+
if is_resource and token.type == :RBRACE
|
26
|
+
is_resource = false
|
27
|
+
end
|
28
|
+
|
29
|
+
if not is_resource and not token.next_code_token.nil?
|
30
|
+
if token.value.downcase[Config.regex.dependencies] and token.value.downcase[/_version/]
|
31
|
+
dependency = token.value.downcase[Config.regex.dependencies]
|
32
|
+
variable_name = "#{dependency}_version"
|
33
|
+
if token.value.downcase == variable_name and [:EQUALS, :FARROW].include? token.next_code_token.type
|
34
|
+
ftokens += [{"token": token.next_code_token, "dependency": dependency}]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
is_assign = (not token.prev_code_token.nil? and not token.next_code_token.nil?)
|
40
|
+
is_version = (is_assign and token.prev_code_token.value.downcase =~ /version/)
|
41
|
+
|
42
|
+
if is_resource and is_version and [:EQUALS, :FARROW].include? token.type and ![:VARIABLE, :NAME].include? token.next_code_token.type
|
43
|
+
if !token.prev_code_token.value.downcase[Config.regex.dependencies].eql? dependency and token.prev_code_token.value.downcase[Config.regex.dependencies]
|
44
|
+
ftokens += [{"token": token, "dependency": token.prev_code_token.value.downcase[Config.regex.dependencies]}]
|
45
|
+
else
|
46
|
+
ftokens += [{"token": token, "dependency": dependency}]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
return ftokens
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_string_tokens(tokens, token)
|
55
|
+
ftokens=tokens.find_all do |hash|
|
56
|
+
[:SSTRING, :STRING].include? hash.type and hash.value.downcase.include? token
|
57
|
+
end
|
58
|
+
return ftokens
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_tokens(tokens, token)
|
62
|
+
ftokens=tokens.find_all do |hash|
|
63
|
+
[:NAME, :VARIABLE, :SSTRING, :STRING].include? hash.type and hash.value.downcase.include? token
|
64
|
+
end
|
65
|
+
return ftokens
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_comments(tokens)
|
69
|
+
ftokens=tokens.find_all do |hash|
|
70
|
+
[:COMMENT, :MLCOMMENT, :SLASH_COMMENT].include? hash.type
|
71
|
+
end
|
72
|
+
return ftokens
|
73
|
+
end
|
74
|
+
|
75
|
+
def filter_resources(tokens, resources)
|
76
|
+
is_resource = false
|
77
|
+
brackets = 0
|
78
|
+
ftokens=tokens.find_all do |hash|
|
79
|
+
|
80
|
+
if resources.include? hash.value.downcase
|
81
|
+
is_resource = true
|
82
|
+
elsif is_resource and hash.type == :LBRACE
|
83
|
+
brackets += 1
|
84
|
+
elsif is_resource and hash.type == :RBRACE
|
85
|
+
brackets -=1
|
86
|
+
end
|
87
|
+
|
88
|
+
if is_resource and hash.type == :RBRACE and brackets == 0
|
89
|
+
is_resource = false
|
90
|
+
end
|
91
|
+
|
92
|
+
if !is_resource
|
93
|
+
[:NAME, :VARIABLE, :SSTRING, :STRING].include? hash.type
|
94
|
+
end
|
95
|
+
end
|
96
|
+
return ftokens
|
97
|
+
end
|
98
|
+
|
99
|
+
def filter_whitelist(tokens)
|
100
|
+
whitelist=Config.regex.whitelist
|
101
|
+
ftokens=tokens.find_all do |hash|
|
102
|
+
!(whitelist =~ hash.value.downcase)
|
103
|
+
end
|
104
|
+
return ftokens
|
105
|
+
end
|
106
|
+
|
107
|
+
def filter_tokens_per_value(tokens, token)
|
108
|
+
ftokens=tokens.find_all do |hash|
|
109
|
+
[:NAME, :SSTRING, :STRING].include? hash.type and !hash.value.downcase.include? token
|
110
|
+
end
|
111
|
+
return ftokens
|
112
|
+
end
|
113
|
+
|
114
|
+
def filter_tokens(tokens)
|
115
|
+
ftokens=tokens.find_all do |hash|
|
116
|
+
[:NAME, :VARIABLE, :SSTRING, :STRING].include? hash.type
|
117
|
+
end
|
118
|
+
return ftokens
|
119
|
+
end
|
120
|
+
|
121
|
+
def filter_variables(tokens, keywords)
|
122
|
+
line = -1
|
123
|
+
kw_regex = Regexp.new keywords.join("|")
|
124
|
+
ftokens=tokens.find_all do |hash|
|
125
|
+
if [:NAME, :VARIABLE].include? hash.type and hash.value.downcase =~ kw_regex
|
126
|
+
line = hash.line
|
127
|
+
elsif hash.line != line
|
128
|
+
hash
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'puppet-lint-infrasecure'
|
2
|
+
|
3
|
+
PuppetLint.new_check(:admin_by_default) do
|
4
|
+
|
5
|
+
def check
|
6
|
+
ftokens = get_tokens(tokens,'admin')
|
7
|
+
ftokens.each do |token|
|
8
|
+
token_value = token.value.downcase
|
9
|
+
if [:EQUALS, :FARROW].include? token.prev_code_token.type
|
10
|
+
prev_token = token.prev_code_token
|
11
|
+
left_side = prev_token.prev_code_token
|
12
|
+
if left_side.value.downcase =~ Rules.credentials and [:VARIABLE, :NAME].include? left_side.type
|
13
|
+
if token_value == 'admin'
|
14
|
+
notify :warning, {
|
15
|
+
message: "[SECURITY] Admin by default (line=#{token.line}, col=#{token.column}) | Do not make user/password as admin as for $#{prev_token.prev_code_token.value.downcase} in line #{token.line}. This can be easily exploited.",
|
16
|
+
line: token.line,
|
17
|
+
column: token.column,
|
18
|
+
token: token_value,
|
19
|
+
cwe: 'CWE-250'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'puppet-lint-infrasecure'
|
2
|
+
|
3
|
+
PuppetLint.new_check(:cyrillic_homograph_attack) do
|
4
|
+
def check
|
5
|
+
ftokens = filter_tokens(tokens)
|
6
|
+
tokens.each do |token|
|
7
|
+
token_value = token.value.downcase
|
8
|
+
if [:STRING, :SSTRING].include? token.type and token_value =~ Rules.cyrillic
|
9
|
+
notify :warning, {
|
10
|
+
message: "[SECURITY] Homograph Attack (line=#{token.line}, col=#{token.column}). This link (#{token_value}) has a cyrillic char. These are not rendered by browsers and are sometimes used for phishing attacks.",
|
11
|
+
line: token.line,
|
12
|
+
column: token.column,
|
13
|
+
token: token_value,
|
14
|
+
cwe: 'CWE-1007'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'puppet-lint-infrasecure'
|
2
|
+
|
3
|
+
PuppetLint.new_check(:empty_password) do
|
4
|
+
|
5
|
+
def check
|
6
|
+
ftokens = get_string_tokens(tokens,'')
|
7
|
+
ftokens.each do |token|
|
8
|
+
token_value = token.value.downcase
|
9
|
+
if [:EQUALS, :FARROW].include? token.prev_code_token.type
|
10
|
+
prev_token = token.prev_code_token
|
11
|
+
left_side = prev_token.prev_code_token
|
12
|
+
if left_side.value.downcase =~ Rules.password and [:VARIABLE, :NAME].include? left_side.type
|
13
|
+
if token_value == ''
|
14
|
+
notify :warning, {
|
15
|
+
message: "[SECURITY] Empty Password (line=#{token.line}, col=#{token.column}) | Do not keep the password field empty as for $#{prev_token.prev_code_token.value.downcase} in line #{token.line}. Use kms/heira/vault instead.",
|
16
|
+
line: token.line,
|
17
|
+
column: token.column,
|
18
|
+
token: token_value,
|
19
|
+
cwe: 'CWE-258'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'puppet-lint-infrasecure'
|
2
|
+
|
3
|
+
PuppetLint.new_check(:hardcoded_secret) do
|
4
|
+
def check
|
5
|
+
# list of known credentials - not considered secrets by the community (https://puppet.com/docs/pe/2019.8/what_gets_installed_and_where.html#user_and_group_accounts_installed)
|
6
|
+
user_default = ['pe-puppet', 'pe-webserver', 'pe-puppetdb', 'pe-postgres', 'pe-console-services', 'pe-orchestration-services','pe-ace-server', 'pe-bolt-server']
|
7
|
+
# some were advised by puppet specialists
|
8
|
+
invalid_values = ['undefined', 'unset', 'www-data', 'wwwrun', 'www', 'no', 'yes', '[]', 'root']
|
9
|
+
ftokens = filter_tokens(tokens)
|
10
|
+
ftokens.each do |token|
|
11
|
+
next if token.next_code_token.nil?
|
12
|
+
token_value = token.value.downcase
|
13
|
+
token_type = token.type
|
14
|
+
next_token = token.next_code_token
|
15
|
+
# accepts <VARIABLE> <EQUALS> secret OR <NAME> <FARROW> secret, checks if <VARIABLE> | <NAME> satisfy SECRETS but not satisfy NON_SECRETS
|
16
|
+
if [:VARIABLE, :NAME].include? token_type and [:EQUALS, :FARROW].include? next_token.type and token_value =~ Rules.secret and !(token_value =~ Rules.nonsecret)
|
17
|
+
right_side_type = next_token.next_code_token.type
|
18
|
+
right_side_value = next_token.next_code_token.value.downcase
|
19
|
+
if [:STRING, :SSTRING].include? right_side_type and right_side_value.length > 1 and !invalid_values.include? right_side_value and !(right_side_value =~ /::|\/|\.|\\/ ) and !user_default.include? right_side_value
|
20
|
+
notify :warning, {
|
21
|
+
message: "[SECURITY] Hard Coded Secret (line=#{next_token.next_code_token.line}, col=#{next_token.next_code_token.column}) | Do not keep secrets on your scripts as for $#{token_value} = #{right_side_value} in #{next_token.next_code_token.line}. Use kms/heira/vault instead.",
|
22
|
+
line: next_token.next_code_token.line,
|
23
|
+
column: next_token.next_code_token.column,
|
24
|
+
token: right_side_value,
|
25
|
+
cwe: 'CWE-798'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'puppet-lint-infrasecure'
|
2
|
+
|
3
|
+
PuppetLint.new_check(:invalid_ip_addr_binding) do
|
4
|
+
def check
|
5
|
+
ftokens = get_tokens(tokens,"0.0.0.0")
|
6
|
+
ftokens.each do |token|
|
7
|
+
token_value = token.value.downcase
|
8
|
+
if [:EQUALS, :FARROW].include? token.prev_code_token.type
|
9
|
+
prev_token = token.prev_code_token
|
10
|
+
left_side = prev_token.prev_code_token
|
11
|
+
if token_value =~ Rules.ip_addr_bind and [:VARIABLE, :NAME].include? left_side.type
|
12
|
+
notify :warning, {
|
13
|
+
message: "[SECURITY] Invalid IP Address Binding (line=#{token.line}, col=#{token.column}) | Don\'t bind your host to #{token_value}. This config allows connections from every possible network. Restrict your available IPs.",
|
14
|
+
line: token.line,
|
15
|
+
column: token.column,
|
16
|
+
token: token_value,
|
17
|
+
cwe: 'CWE-284'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'puppet-lint-infrasecure'
|
2
|
+
|
3
|
+
PuppetLint.new_check(:malicious_dependency) do
|
4
|
+
def check
|
5
|
+
ftokens = get_dependencies(tokens)
|
6
|
+
ftokens.each do |token|
|
7
|
+
version = token[:token].next_code_token.value.downcase
|
8
|
+
if version.include? "v"
|
9
|
+
version = version.gsub("v", "")
|
10
|
+
end
|
11
|
+
dependency = token[:dependency]
|
12
|
+
cves = get_malicious_cves(dependency, version)
|
13
|
+
if !cves.nil?
|
14
|
+
notify :warning, {
|
15
|
+
message: "[SECURITY] Malicious Dependency (line=#{token[:token].line}, col=#{token[:token].column}) | This software is using a third-party library/software (#{dependency} v#{version}) affected by known CVEs (#{cves.join(', ')}).",
|
16
|
+
line: token[:token].line,
|
17
|
+
column: token[:token].column,
|
18
|
+
token: token[:token].prev_code_token.value.downcase,
|
19
|
+
cwe: "CWE-829"
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'puppet-lint-infrasecure'
|
2
|
+
|
3
|
+
PuppetLint.new_check(:suspicious_comment) do
|
4
|
+
def check
|
5
|
+
ftokens = get_comments(tokens)
|
6
|
+
ftokens.each do |token|
|
7
|
+
token_value = token.value.downcase
|
8
|
+
if (token_value =~ Rules.susp_comment)
|
9
|
+
notify :warning, {
|
10
|
+
message: "[SECURITY] Suspicious Comment (line=#{token.line}, col=#{token.column}) | Avoid doing comments containing info about a defect, missing functionality or weakness of the system.",
|
11
|
+
line: token.line,
|
12
|
+
column: token.column,
|
13
|
+
token: token_value,
|
14
|
+
cwe: 'CWE-546'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'puppet-lint-infrasecure'
|
2
|
+
|
3
|
+
PuppetLint.new_check(:use_http_without_tls) do
|
4
|
+
def check
|
5
|
+
resources = ['apt::source', '::apt::source', 'wget::fetch', 'yumrepo', 'yum::', 'aptly::mirror', 'util::system_package', 'yum::managed_yumrepo']
|
6
|
+
ptokens = filter_resources(tokens, resources)
|
7
|
+
keywords = ['backport', 'key', 'download', 'uri', 'mirror']
|
8
|
+
ctokens = filter_variables(ptokens, keywords)
|
9
|
+
if Config.regex.whitelist
|
10
|
+
wtokens = filter_whitelist(ctokens)
|
11
|
+
else
|
12
|
+
wtokens = ptokens
|
13
|
+
end
|
14
|
+
wtokens.each do |token|
|
15
|
+
token_value = token.value.downcase
|
16
|
+
if (token_value =~ Rules.http)
|
17
|
+
notify :warning, {
|
18
|
+
message: "[SECURITY] HTTP without TLS (line=#{token.line}, col=#{token.column}) | Do not use HTTP without TLS as in #{token_value}. This may cause a MITM attack.",
|
19
|
+
line: token.line,
|
20
|
+
column: token.column,
|
21
|
+
token: token_value,
|
22
|
+
cwe: 'CWE-319'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'puppet-lint-infrasecure'
|
2
|
+
|
3
|
+
PuppetLint.new_check(:use_of_weak_crypto_algorithm) do
|
4
|
+
def check
|
5
|
+
tokens.each do |token|
|
6
|
+
token_value = token.value.downcase
|
7
|
+
if !token.next_token.nil?
|
8
|
+
next_token_type = token.next_token.type
|
9
|
+
end
|
10
|
+
if (token_value =~ Rules.poor_crypto) && (next_token_type.eql? :LPAREN)
|
11
|
+
notify :warning, {
|
12
|
+
message: "[SECURITY] Weak Crypto Algorithm (line=#{token.line}, col=#{token.column}) | Do not use #{token_value}, as they have security weakness. Use SHA-512 instead.",
|
13
|
+
line: token.line,
|
14
|
+
column: token.column,
|
15
|
+
token: token_value,
|
16
|
+
cwe: 'CWE-326'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'puppet-lint-infrasecure'
|
2
|
+
require 'strong_password'
|
3
|
+
|
4
|
+
PuppetLint.new_check(:weak_password) do
|
5
|
+
def check
|
6
|
+
checker = StrongPassword::StrengthChecker.new
|
7
|
+
tokens.each do |token|
|
8
|
+
token_value = token.value.downcase
|
9
|
+
token_type = token.type
|
10
|
+
next if token.prev_code_token.nil? or token.next_code_token.nil?
|
11
|
+
if [:EQUALS, :FARROW].include? token_type and [:VARIABLE,:NAME].include? token.prev_code_token.type
|
12
|
+
left_side_value = token.prev_code_token.value.downcase
|
13
|
+
right_side_value = token.next_code_token.value.downcase
|
14
|
+
right_side_token = token.next_code_token
|
15
|
+
if left_side_value =~ Rules.password and checker.is_weak?(right_side_value) and right_side_value != '' and token.next_code_token.type == :SSTRING
|
16
|
+
notify :warning, {
|
17
|
+
message: "[SECURITY] Weak Password (line=#{right_side_token.line}, col=#{right_side_token.column}) | Passwords should be strong to be hard to uncover by hackers (weak_password=#{right_side_value}). In any case, you should use kms/heira/vault to store secrets instead.",
|
18
|
+
line: right_side_token.line,
|
19
|
+
column: right_side_token.column,
|
20
|
+
token: right_side_value,
|
21
|
+
cwe: 'CWE-521'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
- activemq
|
2
|
+
- apt
|
3
|
+
- cassandra
|
4
|
+
- docker
|
5
|
+
- elasticsearch
|
6
|
+
- gitlab
|
7
|
+
- grafana
|
8
|
+
- haproxy
|
9
|
+
- jenkins
|
10
|
+
- jira
|
11
|
+
- kafka
|
12
|
+
- kubernetes
|
13
|
+
- mongodb
|
14
|
+
- mysql
|
15
|
+
- nagios_core
|
16
|
+
- nginx
|
17
|
+
- nodejs
|
18
|
+
- ntp
|
19
|
+
- openstack
|
20
|
+
- openvpn
|
21
|
+
- postgresql
|
22
|
+
- puppet_agent
|
23
|
+
- python
|
24
|
+
- rabbitmq
|
25
|
+
- redis
|
26
|
+
- ruby
|
27
|
+
- sqlite
|
28
|
+
- systemd
|
29
|
+
- tomcat
|
30
|
+
- vault
|
31
|
+
- wget
|
32
|
+
- yum
|
33
|
+
- zabbix
|
@@ -0,0 +1,19 @@
|
|
1
|
+
http://archives.fedoraproject.org/.*
|
2
|
+
http://packages.elasticsearch.org/.*
|
3
|
+
http://http.debian.net/debian/.*
|
4
|
+
http://downloads-distro.mongodb.org/repo/.*
|
5
|
+
http://dl.fedoraproject.org/pub/.*
|
6
|
+
http://download.fedoraproject.org/.*
|
7
|
+
http://download.virtualbox.org/virtualbox/.*
|
8
|
+
http://archive.apache.org/.*
|
9
|
+
http://links.puppetlabs.com/.*
|
10
|
+
http://repos.fedorapeople.org
|
11
|
+
http://fastdl.mongodb.org/.*
|
12
|
+
http://bitbucket.org/.*
|
13
|
+
http://download.java.net/.*
|
14
|
+
http://github.com/.*
|
15
|
+
http://www.prestashop.com/.*
|
16
|
+
http://www.scala-lang.org/.*
|
17
|
+
http://download.eclipse.org/.*
|
18
|
+
http://apache.org/.*
|
19
|
+
http://jdbc.postgresql.org/.*
|