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
@@ -0,0 +1,18 @@
|
|
1
|
+
module Regex
|
2
|
+
class FromConfig
|
3
|
+
attr_accessor :whitelist, :dependencies
|
4
|
+
|
5
|
+
def initialize()
|
6
|
+
@whitelist = nil
|
7
|
+
@dependencies = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def load_whitelist(path)
|
11
|
+
@whitelist = Regexp.new File.open(path).read.gsub("\n",'|')
|
12
|
+
end
|
13
|
+
|
14
|
+
def load_dependencies(path)
|
15
|
+
@dependencies = Regexp.new YAML.load_file(path).join('|')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Rules
|
2
|
+
class << self
|
3
|
+
attr_accessor :password
|
4
|
+
attr_accessor :credentials
|
5
|
+
attr_accessor :cyrillic
|
6
|
+
attr_accessor :secret
|
7
|
+
attr_accessor :nonsecret
|
8
|
+
attr_accessor :ip_addr_bind
|
9
|
+
attr_accessor :susp_comment
|
10
|
+
attr_accessor :http
|
11
|
+
attr_accessor :poor_crypto
|
12
|
+
attr_accessor :whitelist
|
13
|
+
attr_accessor :dependencies
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.password
|
17
|
+
@password ||= /pass(word|_|$)|pwd/
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.credentials
|
21
|
+
@credentials ||= /user|usr|pass(word|_|$)|pwd/
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.cyrillic
|
25
|
+
@cyrillic ||= /^(http(s)?:\/\/)?.*\p{Cyrillic}+/
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.secret
|
29
|
+
@secret ||= /user|usr|pass(word|_|$)|pwd|key|secret/
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.nonsecret
|
33
|
+
@nonsecret ||= /gpg|path|type|buff|zone|mode|tag|header|scheme|length|guid/
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.ip_addr_bind
|
37
|
+
@ip_addr_bind ||= /^((http(s)?:\/\/)?0.0.0.0(:\d{1,5})?)$/
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.susp_comment
|
41
|
+
@susp_comment ||= /hack|fixme|ticket|bug|hack|checkme|secur|debug|defect|weak/
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.http
|
45
|
+
@http ||= /^http:\/\/.+/
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.poor_crypto
|
49
|
+
@poor_crypto ||= /^(sha1|md5)/
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'puppet-lint'
|
2
|
+
require 'puppet-lint/linter'
|
3
|
+
require 'puppet-lint-infrasecure/regex'
|
4
|
+
require 'puppet-lint-infrasecure/rules'
|
5
|
+
require 'dotenv/load'
|
6
|
+
require 'json'
|
7
|
+
require 'yaml'
|
8
|
+
|
9
|
+
|
10
|
+
def get_root()
|
11
|
+
return File.dirname(File.expand_path(__FILE__))
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_config(root)
|
15
|
+
return File.join(root, 'puppet-lint-infrasecure/config/')
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_depen(root)
|
19
|
+
return File.join(root, 'puppet-lint-infrasecure/dependencies/')
|
20
|
+
end
|
21
|
+
|
22
|
+
def load_regex(cpath)
|
23
|
+
regex = Regex::FromConfig.new()
|
24
|
+
# load dependencies list
|
25
|
+
dpath = "#{cpath}dependencies.yml"
|
26
|
+
regex.load_dependencies(dpath)
|
27
|
+
|
28
|
+
# if a .env files exists
|
29
|
+
if File.exist?('.env')
|
30
|
+
# loads .env file
|
31
|
+
Dotenv.load('.env')
|
32
|
+
# if config for WHITELIST exists
|
33
|
+
if ENV.has_key?('WHITELIST')
|
34
|
+
# loads whitelist urls
|
35
|
+
if ENV['WHITELIST'] != '' and File.exist?(ENV['WHITELIST'])
|
36
|
+
regex.load_whitelist(ENV['WHITELIST'])
|
37
|
+
return regex
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
# config default list
|
42
|
+
wpath = "#{cpath}whitelist"
|
43
|
+
regex.load_whitelist(wpath)
|
44
|
+
return regex
|
45
|
+
end
|
46
|
+
|
47
|
+
module Config
|
48
|
+
class << self
|
49
|
+
attr_accessor :regex
|
50
|
+
attr_accessor :path
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.regex
|
54
|
+
@regex ||= regex.new
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.dpath
|
58
|
+
@path ||= get_depen(get_root())
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
Config.regex = load_regex(get_config(get_root()))
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'admin_by_default' do
|
4
|
+
let(:msg) { '[SECURITY] Admin by default (line=6, col=24) | Do not make user/password as admin as for $user in line 6. This can be easily exploited.' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'user configuration as admin' do
|
8
|
+
let(:code) { "
|
9
|
+
class swift::test_file (
|
10
|
+
$password,
|
11
|
+
$auth_server = '127.0.0.1',
|
12
|
+
$tenant = 'openstack',
|
13
|
+
$user = 'admin'
|
14
|
+
|
15
|
+
) {
|
16
|
+
include swift::deps
|
17
|
+
|
18
|
+
file { '/tmp/swift_test_file.rb':
|
19
|
+
mode => '0755',
|
20
|
+
content => template('swift/swift_keystone_test.erb'),
|
21
|
+
tag => 'swift-file',
|
22
|
+
}
|
23
|
+
}
|
24
|
+
" }
|
25
|
+
it 'should detect one problem' do
|
26
|
+
expect(problems).to have(1).problem
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should create a warning for svnwc user config' do
|
30
|
+
expect(problems).to contain_warning(msg).on_line(6).in_column(24)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'cyrillic_homograph_attack' do
|
4
|
+
let(:msg) {'[SECURITY] Homograph Attack (line=2, col=35). This link (https://www.аpple.com/phish) has a cyrillic char. These are not rendered by browsers and are sometimes used for phishing attacks.' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'homograph attack using cyrillic chars not rendered by normal browsers' do
|
8
|
+
let(:code) { "
|
9
|
+
$apple_phishing = 'https://www.аpple.com/phish'
|
10
|
+
$apple_ok = 'https://www.apple.com/ok'
|
11
|
+
" }
|
12
|
+
|
13
|
+
it 'should detect a single problem' do
|
14
|
+
expect(problems).to have(1).problem
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should create a warning' do
|
18
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(35)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'empty_password' do
|
4
|
+
let(:msg) { '[SECURITY] Empty Password (line=12, col=32) | Do not keep the password field empty as for $password in line 12. Use kms/heira/vault instead.' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'code configuration using empty passwords' do
|
8
|
+
let(:code) { "
|
9
|
+
define znc::user (
|
10
|
+
$ensure = 'present',
|
11
|
+
$realname = undef,
|
12
|
+
$admin = false,
|
13
|
+
$buffer = 500,
|
14
|
+
$keepbuffer = true,
|
15
|
+
$server = 'irc.freenode.net',
|
16
|
+
$port = 6667,
|
17
|
+
$ssl = false,
|
18
|
+
$quitmsg = 'quit',
|
19
|
+
$password = '',
|
20
|
+
$channels = undef,
|
21
|
+
$network = undef,
|
22
|
+
$maxnetworks = 1,
|
23
|
+
$loadmodules = undef,) {
|
24
|
+
if ! defined(Class['znc']) {
|
25
|
+
fail('You must include znc base class before using any user defined resources')
|
26
|
+
}
|
27
|
+
include znc::params
|
28
|
+
|
29
|
+
File {
|
30
|
+
owner => $::znc::params::zc_user,
|
31
|
+
group => $::znc::params::zc_group,
|
32
|
+
mode => '0600',
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
$real_htpasswd_file = $htpasswd_file ? {
|
37
|
+
'' => '${apache::params::config_dir}/htpasswd'
|
38
|
+
}
|
39
|
+
|
40
|
+
Exec {
|
41
|
+
path => '/bin:/sbin:/usr/bin:/usr/sbin',
|
42
|
+
}
|
43
|
+
}
|
44
|
+
" }
|
45
|
+
|
46
|
+
it 'should detect one problem' do
|
47
|
+
expect(problems).to have(1).problem
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should create a warning for svnwc user config' do
|
51
|
+
expect(problems).to contain_warning(msg).on_line(12).in_column(32)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'hardcoded_secret' do
|
4
|
+
let(:msg) { '[SECURITY] Hard Coded Secret (line=10, col=27) | Do not keep secrets on your scripts as for $username = apmirror in 10. Use kms/heira/vault instead.' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'code contains hard coded usernames' do
|
8
|
+
let(:code) { "
|
9
|
+
class apmirror (
|
10
|
+
$uid = 508,
|
11
|
+
$gid = 508,
|
12
|
+
$group_present = 'present',
|
13
|
+
$groupname = 'apmirror',
|
14
|
+
$groups = [],
|
15
|
+
$service_ensure = 'running',
|
16
|
+
$shell = '/bin/bash',
|
17
|
+
$username = 'apmirror',
|
18
|
+
$packages = ['libwww-perl', 'libnet-dns-perl'],
|
19
|
+
){
|
20
|
+
package { $packages:
|
21
|
+
ensure => present,
|
22
|
+
}
|
23
|
+
|
24
|
+
$cert_generation_class = '::puppet::puppetserver::generate_cert'
|
25
|
+
|
26
|
+
$pwd = 'unset'
|
27
|
+
$pwd = $cert
|
28
|
+
$pwd = 'pe-puppet'
|
29
|
+
|
30
|
+
user { $username:
|
31
|
+
ensure => $user_present,
|
32
|
+
name => $username,
|
33
|
+
home => '/home/${username}',
|
34
|
+
shell => $shell,
|
35
|
+
uid => $uid,
|
36
|
+
gid => $groupname,
|
37
|
+
groups => $groups,
|
38
|
+
managehome => true,
|
39
|
+
require => [ Group[$groupname], Group[$apbackup::username] ],
|
40
|
+
}
|
41
|
+
}
|
42
|
+
" }
|
43
|
+
|
44
|
+
it 'should detect one problem' do
|
45
|
+
expect(problems).to have(1).problem
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should create a warning for username hard coded config' do
|
49
|
+
expect(problems).to contain_warning(msg).on_line(10).in_column(27)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'invalid_ip_addr_binding' do
|
4
|
+
let(:msg) {'[SECURITY] Invalid IP Address Binding (line=4, col=30) | Don\'t bind your host to 0.0.0.0. This config allows connections from every possible network. Restrict your available IPs.' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'invalid ip adress binding configuration' do
|
8
|
+
let(:code) { "
|
9
|
+
class centos_cloud::controller::nova (
|
10
|
+
$allowed_hosts = '172.22.6.%',
|
11
|
+
$bind_host = '0.0.0.0',
|
12
|
+
$controller = 'controller.openstack.ci.centos.org',
|
13
|
+
$memcached_servers = ['127.0.0.1:11211'],
|
14
|
+
$password = 'nova',
|
15
|
+
$password_api = 'nova_api',
|
16
|
+
$rabbit_port = '5672',
|
17
|
+
$user = 'nova',
|
18
|
+
$user_api = 'nova_api',
|
19
|
+
$neutron_password = 'neutron',
|
20
|
+
$workers = '8',
|
21
|
+
$threads = '1'
|
22
|
+
) {
|
23
|
+
rabbitmq_user { $user:
|
24
|
+
admin => true,
|
25
|
+
provider => 'rabbitmqctl',
|
26
|
+
require => Class['::rabbitmq']
|
27
|
+
}
|
28
|
+
|
29
|
+
if $bind_ip == '0.0.0.0' {
|
30
|
+
$bind_ip_real = '127.0.0.1'
|
31
|
+
} else {
|
32
|
+
$bind_ip_real = $bind_ip
|
33
|
+
}
|
34
|
+
}
|
35
|
+
" }
|
36
|
+
|
37
|
+
it 'should detect a single problem' do
|
38
|
+
expect(problems).to have(1).problem
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should create a warning' do
|
42
|
+
expect(problems).to contain_warning(msg).on_line(4).in_column(30)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'malicious_dependency' do
|
4
|
+
let(:msg) {'[SECURITY] Malicious Dependency (line=10, col=40) | This software is using a third-party library/software (postgresql v9.4) affected by known CVEs (CVE-2017-12172, CVE-2017-15098, CVE-2017-7484, CVE-2017-7485, CVE-2017-7486, CVE-2017-7546, CVE-2017-7547, CVE-2017-7548, CVE-2016-0766, CVE-2016-0773, CVE-2016-5423, CVE-2016-5424).'}
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'software uses malicious dependencies' do
|
8
|
+
let(:code) { "
|
9
|
+
postgresql::server::pg_hba_rule { 'allow application network to access app database':
|
10
|
+
description => 'Open up postgresql for access from 200.1.2.0/24',
|
11
|
+
type => 'host',
|
12
|
+
database => 'app',
|
13
|
+
user => 'app',
|
14
|
+
address => '200.1.2.0/24',
|
15
|
+
auth_method => 'md5',
|
16
|
+
target => '/path/to/pg_hba.conf',
|
17
|
+
postgresql_version => '9.4',
|
18
|
+
}
|
19
|
+
|
20
|
+
class { 'test':
|
21
|
+
openstack_version => '10'
|
22
|
+
}
|
23
|
+
|
24
|
+
class { 'postgresql::globals':
|
25
|
+
manage_package_repo => true,
|
26
|
+
version => '9.2',
|
27
|
+
}
|
28
|
+
" }
|
29
|
+
|
30
|
+
it 'should detect a single problem' do
|
31
|
+
expect(problems).to have(3).problem
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should create a warning' do
|
35
|
+
expect(problems).to contain_warning(msg).on_line(10).in_column(40)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'suspicious_comment' do
|
4
|
+
let(:msg) { '[SECURITY] Suspicious Comment (line=8, col=9) | Avoid doing comments containing info about a defect, missing functionality or weakness of the system.' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'code with suspicious comment' do
|
8
|
+
let(:code) { "
|
9
|
+
if $::realm == 'labs' {
|
10
|
+
# The 'ssh-key-ldap-lookup' tool is called during login ssh via AuthorizedKeysCommand. It
|
11
|
+
# returns public keys from ldap for the specified username.
|
12
|
+
# It is in /usr/sbin and not /usr/local/sbin because on Debian /usr/local is 0775
|
13
|
+
# and sshd refuses to use anything under /usr/local because of the permissive group
|
14
|
+
# permission there (and group is set to 'staff', slightly different from root).
|
15
|
+
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=538392
|
16
|
+
if os_version('debian == jessie') {
|
17
|
+
file { '/usr/sbin/ssh-key-ldap-lookup':
|
18
|
+
owner => 'root',
|
19
|
+
group => 'root',
|
20
|
+
mode => '0555',
|
21
|
+
source => 'puppet:///modules/ldap/scripts/ssh-key-ldap-lookup-python2.py',
|
22
|
+
}
|
23
|
+
} else {
|
24
|
+
file { '/usr/sbin/ssh-key-ldap-lookup':
|
25
|
+
owner => 'root',
|
26
|
+
group => 'root',
|
27
|
+
mode => '0555',
|
28
|
+
source => 'puppet:///modules/ldap/scripts/ssh-key-ldap-lookup.py',
|
29
|
+
}
|
30
|
+
}
|
31
|
+
# sshd will only run ssh-key-ldap-lookup as the 'ssh-key-ldap-lookup' user.
|
32
|
+
user { 'ssh-key-ldap-lookup':
|
33
|
+
ensure => present,
|
34
|
+
system => true,
|
35
|
+
home => '/nonexistent', # Since things seem to check for $HOME/.whatever unconditionally...
|
36
|
+
shell => '/bin/false',
|
37
|
+
}
|
38
|
+
}
|
39
|
+
" }
|
40
|
+
|
41
|
+
it 'should detect a single problem' do
|
42
|
+
expect(problems).to have(1).problem
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should create a warning' do
|
46
|
+
expect(problems).to contain_warning(msg).on_line(8).in_column(9)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'use_http_without_tls' do
|
4
|
+
let(:msg) { '[SECURITY] HTTP without TLS (line=2, col=23) | Do not use HTTP without TLS as in http://localhost:2021. This may cause a MITM attack.' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'configuration using http' do
|
8
|
+
let(:code) { "
|
9
|
+
$server = 'http://localhost:2021'
|
10
|
+
|
11
|
+
apt::source { 'deb-updates':
|
12
|
+
location => 'http://ftp.nl.debian.org/debian/',
|
13
|
+
release => 'jessie-updates',
|
14
|
+
repos => 'main',
|
15
|
+
include_src => true
|
16
|
+
}
|
17
|
+
|
18
|
+
wget::fetch { 'deb-updates':
|
19
|
+
location => 'http://ftp.nl.debian.org/debian/',
|
20
|
+
release => 'jessie-updates',
|
21
|
+
repos => 'main',
|
22
|
+
include_src => true
|
23
|
+
}
|
24
|
+
|
25
|
+
aptly::mirror {
|
26
|
+
'aptly':
|
27
|
+
location => 'http://repo.aptly.info',
|
28
|
+
release => 'squeeze',
|
29
|
+
key => 'ED75B5A4483DA07C';
|
30
|
+
'duplicity':
|
31
|
+
location => 'http://ppa.launchpad.net/duplicity-team/ppa/ubuntu',
|
32
|
+
release => 'trusty',
|
33
|
+
key => 'AF953139C1DF9EF3476DE1D58F571BB27A86F4A2';
|
34
|
+
'docker':
|
35
|
+
location => 'https://download.docker.com/linux/ubuntu',
|
36
|
+
release => 'trusty',
|
37
|
+
repos => ['stable'],
|
38
|
+
key => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88';
|
39
|
+
'govuk-ppa-trusty':
|
40
|
+
location => 'http://ppa.launchpad.net/gds/govuk/ubuntu',
|
41
|
+
release => 'trusty',
|
42
|
+
key => '914D5813';
|
43
|
+
'grafana':
|
44
|
+
location => 'https://packagecloud.io/grafana/stable/debian',
|
45
|
+
release => 'jessie',
|
46
|
+
key => '418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB';
|
47
|
+
}
|
48
|
+
|
49
|
+
apt::source {
|
50
|
+
'debian':
|
51
|
+
location => 'http://mirrors/debian/',
|
52
|
+
release => $::lsbdistcodename,
|
53
|
+
repos => $repos,
|
54
|
+
include => {
|
55
|
+
src => true
|
56
|
+
};
|
57
|
+
|
58
|
+
'debian-updates':
|
59
|
+
location => 'http://mirrors/debian/',
|
60
|
+
release => 'updates',
|
61
|
+
repos => $repos,
|
62
|
+
include => {
|
63
|
+
src => true
|
64
|
+
};
|
65
|
+
}
|
66
|
+
$package_gpg_key = 'http://www.rabbitmq.com/rabbitmq-signing-key-public.asc'
|
67
|
+
$elasticsearch_uri = 'http://elasticsearch6'
|
68
|
+
|
69
|
+
$check = $puppet_metrics_dashboard::use_dashboard_ssl ? {
|
70
|
+
true => 'https',
|
71
|
+
default => 'http',
|
72
|
+
}
|
73
|
+
|
74
|
+
mirrorlist => 'http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates'
|
75
|
+
|
76
|
+
|
77
|
+
$fedora = 'http://archives.fedoraproject.org/pub/archive/fedora/linux/releases'
|
78
|
+
$fedora_2 = 'http://archives.fedoraproject.org/pub/archive/fedora/linux/releases'
|
79
|
+
|
80
|
+
yumrepo{'contrib':
|
81
|
+
descr => 'CentOS-$releasever - Contrib',
|
82
|
+
baseurl => 'http://pulp.inuits.eu/pulp/repos/centos/$releasever/contrib/$basearch'
|
83
|
+
}
|
84
|
+
|
85
|
+
$backports_location = 'http://hello.com'
|
86
|
+
|
87
|
+
$pwd = root
|
88
|
+
changes => 'set exist/xquery/builtin-modules/module[#attribute/uri = \"http://exist-db.org/xquery/xmldiff\"]/#attribute/class org.exist.xquery.modules.xmldiff.XmlDiffModule'
|
89
|
+
" }
|
90
|
+
|
91
|
+
it 'should detect a single problem' do
|
92
|
+
expect(problems).to have(1).problem
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should create a warning' do
|
96
|
+
expect(problems).to contain_warning(msg).on_line(2).in_column(23)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'use_of_weak_crypto_algorithm' do
|
4
|
+
let(:msg) { '[SECURITY] Weak Crypto Algorithm (line=22, col=21) | Do not use sha1, as they have security weakness. Use SHA-512 instead.' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'code using unsecure algorithms' do
|
8
|
+
let(:code) { "
|
9
|
+
notice(artifactory_sha1('http://bit.ly/1Tfk4vQ'))
|
10
|
+
define tomcat::instance (
|
11
|
+
$catalina_home = undef,
|
12
|
+
$catalina_base = undef,
|
13
|
+
$user = undef,
|
14
|
+
$group = undef,
|
15
|
+
$manage_user = undef,
|
16
|
+
$manage_group = undef,
|
17
|
+
$manage_service = undef,
|
18
|
+
$manage_base = undef,
|
19
|
+
$java_home = undef,
|
20
|
+
$use_jsvc = undef,
|
21
|
+
$use_init = undef,
|
22
|
+
$install_from_source = undef,
|
23
|
+
$source_url = undef,
|
24
|
+
$source_strip_first_dir = undef,
|
25
|
+
$package_ensure = undef,
|
26
|
+
$package_name = undef,
|
27
|
+
$package_options = undef,
|
28
|
+
) {
|
29
|
+
$home_sha = sha1($_catalina_home)
|
30
|
+
}
|
31
|
+
" }
|
32
|
+
|
33
|
+
it 'should detect a single problem' do
|
34
|
+
expect(problems).to have(1).problem
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should create a warning' do
|
38
|
+
expect(problems).to contain_warning(msg).on_line(22).in_column(21)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'weak_password' do
|
4
|
+
let(:msg) { '[SECURITY] Weak Password (line=9, col=20) | Passwords should be strong to be hard to uncover by hackers (weak_password=12345678). In any case, you should use kms/heira/vault to store secrets instead.' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'code using weak password' do
|
8
|
+
let(:code) { "
|
9
|
+
$sievedir = '/var/imap/sieve'
|
10
|
+
$statedir = '/var/imap'
|
11
|
+
$spooldir = '/var/spool/imap'
|
12
|
+
$lmtp_external = get_var('imap_lmtp_external', false)
|
13
|
+
|
14
|
+
$dashboard_password = '!$jNb#khug679!'
|
15
|
+
$template_imapd = template_version($version_imapd, '2.3.12_p2@2.3.13@:2.3.12_p2,', '2.3.12_p2')
|
16
|
+
$pwd = '12345678'
|
17
|
+
|
18
|
+
" }
|
19
|
+
|
20
|
+
it 'should detect a single problem' do
|
21
|
+
expect(problems).to have(1).problem
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should create a warning' do
|
25
|
+
expect(problems).to contain_warning(msg).on_line(9).in_column(20)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED