puppet-sec-lint 0.5.9 → 0.5.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66d4c1a23074509e42349a4a98389d2d7cd6128b11e179a351bd06af41e3b8f2
4
- data.tar.gz: fc5bae0f4770b51b331d71b467ef2cb63d7967e8d86c7cf215305f1c63a70f15
3
+ metadata.gz: 269b5c5edfe9c78bf77bdee1dfd1d1a2cb3b20716c6aeec158d7b66c08d6e4a3
4
+ data.tar.gz: ab9c34d67d6320b4c235a394e7a5863d67a8eddc026978b30d14edd48de909cc
5
5
  SHA512:
6
- metadata.gz: e2fde00b171f537752af40db32884ae62a44adaf2ff707974d0a60a85beb835f680898504340a6ce6d00171ffffbf1e895c33f25ecaa040d480e7668eff9b09c
7
- data.tar.gz: 96eb37c5aa53750a5fba82011345b0187dead264a1d6c97522560a4181a770db30f59717bfee02cc37f1e443752037e657b761311d974895124d4dd0b4972bee
6
+ metadata.gz: 314f68b9f6bccd464511513006941fbcb2395a9cc5038ea30fad11f5c20debff9a92bb4343139159d15b0ffd66180514ff04383d7077c9628521b4bdf520b8ce
7
+ data.tar.gz: 44e430d28e8777da01a8277b3e5b3d1a59717e6a174c8e61ea26526d2c96cd916c0c0f7762f70bc29aee4147a405d2af75f7435b5a5e56f3488dbb85c2f38b4a
data/.idea/modules.xml CHANGED
@@ -2,6 +2,7 @@
2
2
  <project version="4">
3
3
  <component name="ProjectModuleManager">
4
4
  <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/modules/docs.iml" filepath="$PROJECT_DIR$/.idea/modules/docs.iml" />
5
6
  <module fileurl="file://$PROJECT_DIR$/.idea/puppet-sec-lint.iml" filepath="$PROJECT_DIR$/.idea/puppet-sec-lint.iml" />
6
7
  </modules>
7
8
  </component>
@@ -15,6 +15,7 @@
15
15
  <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.3, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
16
16
  <orderEntry type="library" scope="PROVIDED" name="inifile (v3.0.0, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
17
17
  <orderEntry type="library" scope="PROVIDED" name="launchy (v2.5.0, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="logger (v1.4.3, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
18
19
  <orderEntry type="library" scope="PROVIDED" name="minitest (v5.14.4, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
19
20
  <orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.6, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
20
21
  <orderEntry type="library" scope="PROVIDED" name="puppet-lint (v2.4.2, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
@@ -24,30 +25,7 @@
24
25
  </component>
25
26
  <component name="RakeTasksCache">
26
27
  <option name="myRootTask">
27
- <RakeTaskImpl id="rake">
28
- <subtasks>
29
- <RakeTaskImpl description="Build puppet-sec-lint-0.5.7.gem into the pkg directory" fullCommand="build" id="build" />
30
- <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
31
- <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
32
- <RakeTaskImpl description="Build and install puppet-sec-lint-0.5.7.gem into system gems" fullCommand="install" id="install" />
33
- <RakeTaskImpl id="install">
34
- <subtasks>
35
- <RakeTaskImpl description="Build and install puppet-sec-lint-0.5.7.gem into system gems without network access" fullCommand="install:local" id="local" />
36
- </subtasks>
37
- </RakeTaskImpl>
38
- <RakeTaskImpl description="Create tag v0.5.7 and build and push puppet-sec-lint-0.5.7.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
39
- <RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
40
- <RakeTaskImpl description="" fullCommand="default" id="default" />
41
- <RakeTaskImpl description="" fullCommand="release" id="release" />
42
- <RakeTaskImpl id="release">
43
- <subtasks>
44
- <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
45
- <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
46
- <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
47
- </subtasks>
48
- </RakeTaskImpl>
49
- </subtasks>
50
- </RakeTaskImpl>
28
+ <RakeTaskImpl id="rake" />
51
29
  </option>
52
30
  </component>
53
31
  </module>
data/Gemfile CHANGED
@@ -17,4 +17,6 @@ gem 'webrick'
17
17
 
18
18
  gem 'inifile'
19
19
 
20
- gem 'launchy'
20
+ gem 'launchy'
21
+
22
+ gem 'logger'
data/Gemfile.lock CHANGED
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puppet-sec-lint (0.5.7)
4
+ puppet-sec-lint (0.5.14)
5
5
  inifile (~> 3.0.0)
6
6
  launchy (~> 2.5.0)
7
+ logger (~> 1.4.3)
7
8
  minitest (~> 5.0)
8
9
  puppet-lint (~> 2.4, >= 2.4.2)
9
10
  rack (~> 2.2.3)
10
11
  rake (~> 13.0)
12
+ webrick (~> 1.7.0)
11
13
 
12
14
  GEM
13
15
  remote: https://rubygems.org/
@@ -17,6 +19,7 @@ GEM
17
19
  inifile (3.0.0)
18
20
  launchy (2.5.0)
19
21
  addressable (~> 2.7)
22
+ logger (1.4.3)
20
23
  minitest (5.14.4)
21
24
  public_suffix (4.0.6)
22
25
  puppet-lint (2.4.2)
@@ -30,6 +33,7 @@ PLATFORMS
30
33
  DEPENDENCIES
31
34
  inifile
32
35
  launchy
36
+ logger
33
37
  minitest (~> 5.0)
34
38
  puppet-lint
35
39
  puppet-sec-lint!
data/README.md CHANGED
@@ -25,14 +25,6 @@ If the linter is called with a folder, all puppet files inside are recursively a
25
25
  puppet-sec-lint /folder
26
26
  ```
27
27
 
28
- To open the configurations page to better tune the different rules applied, use the appropriate flag:
29
-
30
- ```bash
31
- puppet-sec-lint -c
32
- ```
33
- (this will open the configurations page on the computer default web browser)
34
-
35
-
36
28
  ### Integration with Visual Studio Code
37
29
 
38
30
  The linter can also work inside Visual Studio code. For it, please ensure that the 'puppet-sec-lint' gem was installed on your system.
@@ -43,12 +35,36 @@ Now, after that the extension is activate, it should be activated automatically
43
35
 
44
36
  ![puppet-sec-lint console execution](docs/images/puppet-sec-lint_vscode.png)
45
37
 
38
+ ###Customization of Linter Rules
39
+
40
+ All rules applied by the linter to detect vulnerabilities can be configured to better adapt the tool to any project conventions and requirements.
41
+
42
+ To open the configurations page, use the appropriate flag:
43
+
44
+ ```bash
45
+ puppet-sec-lint -c
46
+ ```
47
+ (this will open the configurations page on the computer default web browser)
48
+
49
+ ![puppet-sec-lint configurations page](docs/images/puppet-sec-lint_configurations.png)
50
+
46
51
  ## Development
47
52
 
53
+ ### Development of new rules
54
+
55
+ The linter was built on top of a modular architecture, which means that new customizable rules can be added fairly easy facing the discovery of new scenarios and vulnerabilities.
56
+
57
+ <!--
58
+ (add instructions on how to clone, build and run tool)
59
+
60
+ (add instructions on where and how to add new rule and configurations)
61
+ -->
62
+
48
63
  <!--After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
64
 
50
65
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).-->
51
66
 
67
+
52
68
  ## Contributing
53
69
 
54
70
  <!-- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/puppet-sec-lint. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/puppet-sec-lint/blob/master/CODE_OF_CONDUCT.md). -->
@@ -24,4 +24,8 @@ Any account with the power to do everything in the system is a very dangerous si
24
24
 
25
25
  ## How to avoid it?
26
26
 
27
- Accounts should always be setup up with the [Principle of least privilege](https://us-cert.cisa.gov/bsi/articles/knowledge/principles/least-privilege) in mind, meaning that all accounts should only get the permissions strictly necessary to perform their required tasks during the minimum amount of time possible. This severely limits the exposure to accidental errors and also to malicious attackers.
27
+ Accounts should always be setup up with the [Principle of least privilege](https://us-cert.cisa.gov/bsi/articles/knowledge/principles/least-privilege) in mind, meaning that all accounts should only get the permissions strictly necessary to perform their required tasks during the minimum amount of time possible. This severely limits the exposure to accidental errors and also to malicious attackers.
28
+
29
+ ## More related information
30
+
31
+ * [CWE-250: Execution with Unnecessary Privileges](https://cwe.mitre.org/data/definitions/250.html)
@@ -37,4 +37,8 @@ This malicious domain on a Puppet manifest can point to a fake package repositor
37
37
  After the tool detects the presence of Cyrillic characters on a URL, the best course of action is to replace all Cyrillic characters with their Latin counterparts, as these characters are very rarely used in legitimate domains.
38
38
  Then, check if the domain is well written (subtle misspellings with similar letters are very common in these kinds of attacks).
39
39
 
40
- To better ensure that the domain is actually the correct one, the URL can also be copied from a trusted source.
40
+ To better ensure that the domain is actually the correct one, the URL can also be copied from a trusted source.
41
+
42
+ ## More related information
43
+
44
+ * [CWE-1007: Insufficient Visual Distinction of Homoglyphs Presented to User](https://cwe.mitre.org/data/definitions/1007.html)
@@ -24,4 +24,8 @@ An attacker looking to gain access to an account my try a couple of different ge
24
24
 
25
25
  ## How to avoid it?
26
26
 
27
- Secure software systems should have a decent password policy that prevents, among other types, empty passwords. This means that it's very likely for the Puppet manifest to fail as the password would be rejected. But even if the target software accepts empty passwords, a long and hard to guess password is always a much safer option against malicious attacks.
27
+ Secure software systems should have a decent password policy that prevents, among other types, empty passwords. This means that it's very likely for the Puppet manifest to fail as the password would be rejected. But even if the target software accepts empty passwords, a long and hard to guess password is always a much safer option against malicious attacks.
28
+
29
+ ## More related information
30
+
31
+ * [CWE-258: Empty Password in Configuration File](https://cwe.mitre.org/data/definitions/258.html)
@@ -77,4 +77,9 @@ file { '/etc/mysql/server-key.pem':
77
77
  ensure => file,
78
78
  content => hiera("privatekey"),
79
79
  }
80
- ```
80
+ ```
81
+
82
+ ## More related information
83
+
84
+ * [CWE-259: Use of Hard-coded Password](https://cwe.mitre.org/data/definitions/259.html)
85
+ * [CWE-798: Use of Hard-coded Credentials](https://cwe.mitre.org/data/definitions/798.html)
@@ -0,0 +1,46 @@
1
+ ---
2
+ title: Use HTTP without TLS
3
+ permalink: /http-without-tls/
4
+ layout: default
5
+ ---
6
+
7
+ # Use HTTP without TLS
8
+
9
+ ## What is it?
10
+
11
+ Connecting to a server using the regular HTTP protocol instead of the secure HTTPS, which uses TLS, doesn't allow for an encrypted connection. This means that all the data is sent in plaintext and easily viewed and modified by anyone, including malicious attackers.
12
+
13
+ ### Example
14
+ Providing a server to run the PHPMyAdmin application:
15
+ ```puppet
16
+ define phpmyadmin::server (
17
+ $blowfish_key = md5("${::fqdn}${::ipaddress}"),
18
+ $absolute_uri = "http://${::fqdn}/phpmyadmin/",
19
+ $config_file = $::phpmyadmin::params::config_file
20
+ )
21
+ ```
22
+ This newly created service will be available to clients through a non secure HTTP address.
23
+
24
+ A more secure way of hosting the server would be by using an HTTPS url:
25
+ ```puppet
26
+ define phpmyadmin::server (
27
+ $blowfish_key = md5("${::fqdn}${::ipaddress}"),
28
+ $absolute_uri = "https://${::fqdn}/phpmyadmin/",
29
+ $config_file = $::phpmyadmin::params::config_file
30
+ )
31
+ ```
32
+
33
+
34
+ ## How can it be exploited?
35
+
36
+ When a connection is made to a website using a non-secure HTTP address, all communications are sent unencrypted. An attacker can capture the traffic sent and received by a victim, for example, in the same Wifi network. After analyzing his traffic, the attacker can extract sensitive information exchanged by the victim with the websites visited, like passwords and tokens.
37
+
38
+ The attacker can then use this information to attack his victim, by logging in and impersonating him in several different websites that don't use the TLS protocol.
39
+
40
+ ## How to avoid it?
41
+
42
+ All connections to internet addresses or made available to the public by a service configured with a Puppet manifest must use some kind of secure protocol, to ensure the confidentiality, authenticity and integrity of all data exchanged. Making an HTTPS connection is the easiest way to do this and it's also the recommended way of addressing this security vulnerability. In some cases, if the transferred information is verified afterwards by an hashing algorithm, like packages transferred from a repository, then this solution can be considered optional.
43
+
44
+ ## More related information
45
+
46
+ * [CWE-319: Cleartext Transmission of Sensitive Information](https://cwe.mitre.org/data/definitions/319.html)
@@ -6,7 +6,7 @@ layout: default
6
6
 
7
7
  # Invalid IP Address binding
8
8
 
9
- ## What it it?
9
+ ## What is it?
10
10
 
11
11
  Binding an IP address to a server or service means authorizing connections incoming from those networks. This allows to limit what kind of incoming connections a server may or may not accept. Binding the 0.0.0.0 IP address to a service means that any connection from any network is accepted.
12
12
 
@@ -28,4 +28,8 @@ A server or service that's open to all kinds of connections it's more exposed to
28
28
 
29
29
  ## How to avoid it?
30
30
 
31
- Properly configuring binding addresses means that the server should only accept connections from trusted networks known to use the service. This ensures a greater level of control and also protection, as an attacker would know have an extra obstacle in trying to gain access first to one of those networks.
31
+ Properly configuring binding addresses means that the server should only accept connections from trusted networks known to use the service. This ensures a greater level of control and also protection, as an attacker would know have an extra obstacle in trying to gain access first to one of those networks.
32
+
33
+ ## More related information
34
+
35
+ * [CWE-284: Improper Access Control](https://cwe.mitre.org/data/definitions/284.html)
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: Suspicious Comments
3
+ permalink: /suspicious-comments/
4
+ layout: default
5
+ ---
6
+
7
+ # Suspicious Comments
8
+
9
+ ## What are they?
10
+
11
+ Suspicious comments are all comments left in a release of a Puppet Manifest that might suggest the existence of bugs, missing security functionalities or other weaknesses.
12
+
13
+
14
+ ### Example
15
+ ```puppet
16
+ # TODO: switch password from weak hash to sha256
17
+ $key = md5("${client_name} ${client_ip} ${client_seed}")
18
+ ```
19
+ This comment immediately tells that developers are aware of the weakness of using a compromised hashing algorithm, but still hadn't made the necessary fix.
20
+
21
+ ## How can it be exploited?
22
+
23
+ In the previous example, the presence of the comment immediately draws the attention of a malicious hacker who might have gained access to the code repository. By stating the portion of code that is considered insecure, it tells to an attacker exactly where to look for unpatched vulnerabilities. In this case, he could start working on ways to break the weak hashing algorithm.
24
+
25
+ ## How to avoid it?
26
+
27
+ All comments indicating to be implemented features or non-resolved security issues should be erased, as they pose a very serious threat by gaining the attackers attention. Instead, proper and secure defect management solutions should be used. As a plus, the code stays clean and easy to read.
28
+
29
+ ## More related information
30
+
31
+ * [CWE-546: Suspicious Comment](https://cwe.mitre.org/data/definitions/546.html)
@@ -28,4 +28,9 @@ An attacker who was able to gain access to a server and steal the hashes from al
28
28
 
29
29
  ## How to avoid it?
30
30
 
31
- If the Puppet manifest is being used to generate hashes for passwords or important data, using a more secure algorithm like SHA256 is very advisable as it avoids exposure to the risks mentioned above, ensuring that the algorithm actually performs what's intended to.
31
+ If the Puppet manifest is being used to generate hashes for passwords or important data, using a more secure algorithm like SHA256 is very advisable as it avoids exposure to the risks mentioned above, ensuring that the algorithm actually performs what's intended to.
32
+
33
+ ## More related information
34
+
35
+ * [CWE-326: Inadequate Encryption Strength](https://cwe.mitre.org/data/definitions/326.html)
36
+ * [CWE-327: Use of a Broken or Risky Cryptographic Algorithm](https://cwe.mitre.org/data/definitions/327.html)
data/exe/puppet-sec-lint CHANGED
@@ -5,6 +5,7 @@ require 'json'
5
5
  require 'launchy'
6
6
  require 'optparse'
7
7
  require 'optparse/uri'
8
+ require 'logger'
8
9
  require_relative '../lib/puppet-sec-lint/version'
9
10
  require_relative '../lib/visitors/configuration_visitor'
10
11
  require_relative '../lib/facades/configuration_file_facade'
@@ -12,6 +13,9 @@ require_relative '../lib/facades/configuration_file_facade'
12
13
  ConfigurationVisitor.GenerateIDs
13
14
  ConfigurationFileFacade.LoadConfigurations
14
15
 
16
+ $logger = Logger.new(STDOUT)
17
+ $logger.level = Logger::ERROR
18
+
15
19
  #get free port
16
20
  loop do
17
21
  $port = rand(3000..9999)
@@ -49,6 +53,11 @@ OptionParser.new do |opts|
49
53
  opts.on("-p", "--port=PORT", "TCP Port open for socket communication with the language server (Default:5007)") do |port|
50
54
  options[:port] = port
51
55
  end
56
+
57
+ opts.on("-v", "--verbose", "Verbose mode (shows all communications and other debug info)") do |v|
58
+ options[:verbose] = v
59
+ $logger.level = Logger::DEBUG
60
+ end
52
61
  end.parse!
53
62
 
54
63
  puts '___ _ _ ___ ___ ____ ___ ____ ____ ____ _ _ ____ _ ___ _ _ _ _ _ _ ___ ____ ____ '
data/lib/lol2.pp ADDED
@@ -0,0 +1,11 @@
1
+ # addresses bug: https://bugs.launchpad.net/keystone/+bug/1472285
2
+ class example (
3
+ $power_username= 'admin',
4
+ $power_password= ‘’,
5
+ $pwd = ‘EHDJSKD’
6
+ ){
7
+ $bind_host = ‘0.0.0.0’
8
+ $quantum_auth_url = ‘http://127.0.0.1:35357/v2.0’
9
+ “ $”tr = "hey"
10
+ $message = sha1($str)
11
+ }
data/lib/manifest.pp ADDED
@@ -0,0 +1,83 @@
1
+ #class path_attribute {
2
+ # file { 'ssh_config_file':
3
+ # path => '/etc/ssh/sshd_config',
4
+ # content => 'Bad path attribute, bad.',
5
+ # }
6
+ #}
7
+
8
+ # the following code addresses the bug: https://bugs.launchpad.net/keystone/+bug/1472285 .
9
+
10
+ class consul_template::service (
11
+ $rpc_password = '{6ad470ec62b0511b63340dca2950d750181598efnHKvN1ge',
12
+ $admin_username = 'admin',
13
+ $password = 'ceilometer',
14
+ $admin_password = 'admin',
15
+ ) {
16
+ exec { 'network-restart':
17
+ command => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDM release-runner key',
18
+ path => '/usr/bin:/usr/sbin:/bin:/sbin',
19
+ refreshonly => true,
20
+ vmware_md5 => 'LOL',
21
+ autho => 'MD5',
22
+ cmd => 'virsh secret-define --file ${secret_xml} && virsh secret-set-value --secret ${rbd_secret_uuid} --base64 $(ceph auth get-key client.${user})',
23
+ $auth_uri => 'http://127.0.0.1:5000',
24
+ 'bind_address' => '0.0.0.0',
25
+ password => '',
26
+ }
27
+ case $::osfamily {
28
+ 'RedHat': {
29
+ exec { 'upload-img':
30
+ command => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} add name=${img_name} is_public=${public} container_format=${container_format} disk_format=${disk_format} distro=${os_name} < /opt/vm/cirros-x86_64-disk.img",
31
+ unless => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index && (/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index | grep ${img_name})",
32
+
33
+ }
34
+ }
35
+ 'Debian': {
36
+ exec { 'upload-img':
37
+ command => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} add name=${img_name} is_public=${public} container_format=${container_format} disk_format=${disk_format} distro=${os_name} < /usr/share/cirros-testvm/cirros-x86_64-disk.img",
38
+ unless => "/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index && (/usr/bin/glance -N ${os_auth_url} -T ${os_tenant_name} -I ${os_username} -K ${os_password} index | grep ${img_name})",
39
+ key => "E8CC67053ED3B199",
40
+ key_content => '-----BEGIN PGP PUBLIC KEY BLOCK-----
41
+ Version: GnuPG v1.4.11 (GNU/Linux)
42
+
43
+ mQENBE/oXVkBCACcjAcV7lRGskECEHovgZ6a2robpBroQBW+tJds7B+qn/DslOAN
44
+ 1hm0UuGQsi8pNzHDE29FMO3yOhmkenDd1V/T6tHNXqhHvf55nL6anlzwMmq3syIS
45
+ uqVjeMMXbZ4d+Rh0K/rI4TyRbUiI2DDLP+6wYeh1pTPwrleHm5FXBMDbU/OZ5vKZ
46
+ 67j99GaARYxHp8W/be8KRSoV9wU1WXr4+GA6K7ENe2A8PT+jH79Sr4kF4uKC3VxD
47
+ BF5Z0yaLqr+1V2pHU3AfmybOCmoPYviOqpwj3FQ2PhtObLs+hq7zCviDTX2IxHBb
48
+ Q3mGsD8wS9uyZcHN77maAzZlL5G794DEr1NLABEBAAG0NU9wZW5TdGFja0BDaXNj
49
+ byBBUFQgcmVwbyA8b3BlbnN0YWNrLWJ1aWxkZEBjaXNjby5jb20+iQE4BBMBAgAi
50
+ BQJP6F1ZAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRDozGcFPtOxmXcK
51
+ B/9WvQrBwxmIMV2M+VMBhQqtipvJeDX2Uv34Ytpsg2jldl0TS8XheGlUNZ5djxDy
52
+ u3X0hKwRLeOppV09GVO3wGizNCV1EJjqQbCMkq6VSJjD1B/6Tg+3M/XmNaKHK3Op
53
+ zSi+35OQ6xXc38DUOrigaCZUU40nGQeYUMRYzI+d3pPlNd0+nLndrE4rNNFB91dM
54
+ BTeoyQMWd6tpTwz5MAi+I11tCIQAPCSG1qR52R3bog/0PlJzilxjkdShl1Cj0RmX
55
+ 7bHIMD66uC1FKCpbRaiPR8XmTPLv29ZTk1ABBzoynZyFDfliRwQi6TS20TuEj+ZH
56
+ xq/T6MM6+rpdBVz62ek6/KBcuQENBE/oXVkBCACgzyyGvvHLx7g/Rpys1WdevYMH
57
+ THBS24RMaDHqg7H7xe0fFzmiblWjV8V4Yy+heLLV5nTYBQLS43MFvFbnFvB3ygDI
58
+ IdVjLVDXcPfcp+Np2PE8cJuDEE4seGU26UoJ2pPK/IHbnmGWYwXJBbik9YepD61c
59
+ NJ5XMzMYI5z9/YNupeJoy8/8uxdxI/B66PL9QN8wKBk5js2OX8TtEjmEZSrZrIuM
60
+ rVVXRU/1m732lhIyVVws4StRkpG+D15Dp98yDGjbCRREzZPeKHpvO/Uhn23hVyHe
61
+ PIc+bu1mXMQ+N/3UjXtfUg27hmmgBDAjxUeSb1moFpeqLys2AAY+yXiHDv57ABEB
62
+ AAGJAR8EGAECAAkFAk/oXVkCGwwACgkQ6MxnBT7TsZng+AgAnFogD90f3ByTVlNp
63
+ Sb+HHd/cPqZ83RB9XUxRRnkIQmOozUjw8nq8I8eTT4t0Sa8G9q1fl14tXIJ9szzz
64
+ BUIYyda/RYZszL9rHhucSfFIkpnp7ddfE9NDlnZUvavnnyRsWpIZa6hJq8hQEp92
65
+ IQBF6R7wOws0A0oUmME25Rzam9qVbywOh9ZQvzYPpFaEmmjpCRDxJLB1DYu8lnC4
66
+ h1jP1GXFUIQDbcznrR2MQDy5fNt678HcIqMwVp2CJz/2jrZlbSKfMckdpbiWNns/
67
+ xKyLYs5m34d4a0it6wsMem3YCefSYBjyLGSd/kCI/CgOdGN1ZY1HSdLmmjiDkQPQ
68
+ UcXHbA==
69
+ =v6jg
70
+ -----END PGP PUBLIC KEY BLOCK-----',
71
+
72
+ }
73
+ }
74
+ }
75
+ file { '/var/lib/gerrit/.ssh/id_rsa' :
76
+ owner => 'gerrit',
77
+ group => 'gerrit',
78
+ mode => '0600',
79
+ content => $ssh_replication_rsa_key_contents,
80
+ replace => true,
81
+ require => File['/var/lib/gerrit/.ssh']
82
+ }
83
+ }
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PuppetSecLint
4
- VERSION = "0.5.9"
4
+ VERSION = "0.5.15"
5
5
  YEAR = "2021"
6
- AUTHOR = "Tiago Ribeiro"
6
+ AUTHOR = "TQRG"
7
7
  end
data/lib/rule_engine.rb CHANGED
@@ -21,8 +21,9 @@ class RuleEngine
21
21
  begin
22
22
  lexer = PuppetLint::Lexer.new
23
23
  tokens = lexer.tokenise(code)
24
- rescue
25
- puts "Error in getting tokens from Puppet-Lint"
24
+ rescue => error
25
+ $logger.error("Error in getting tokens from Puppet-Lint")
26
+ $logger.error(error.backtrace)
26
27
  tokens = []
27
28
  end
28
29
 
@@ -34,8 +35,12 @@ class RuleEngine
34
35
  tokens = self.getTokens(code)
35
36
 
36
37
  @rules.each do |rule|
37
- if rule.configurations[0].value
38
- (result << rule.AnalyzeTokens(tokens)).flatten!
38
+ begin
39
+ if rule.configurations[0].value
40
+ (result << rule.AnalyzeTokens(tokens)).flatten!
41
+ end
42
+ rescue
43
+ $logger.error("Error in running rule #{rule.name}")
39
44
  end
40
45
  end
41
46
 
@@ -8,21 +8,22 @@ class NoHTTPRule < Rule
8
8
  @resources = %w[apt::source ::apt::source wget::fetch yumrepo yum:: aptly::mirror util::system_package yum::managed_yumrepo]
9
9
  @keywords = %w[backport key download uri mirror]
10
10
  @http = /^http:\/\/.+/
11
- @whitelist = [] # Todo:Need to check how is this set up
11
+ @whitelist = ""
12
12
 
13
13
  @resources_conf = ListConfiguration.new("List of resources that can use HTTP", @resources, "List of resources that are known to not use HTTPS but that validate the transferred content with other secure methods.")
14
14
  @keywords_conf = ListConfiguration.new("List of keywords for URLs", @keywords, "List of keywords that identify hyperlinks that should be analyzed.")
15
+ @whitelist_conf = RegexConfiguration.new("HTTP Address whitelist", @whitelist, "List of addresses that are allowed to have non-secure http connections to them.")
15
16
  @http_conf = RegexConfiguration.new("Regular expression of a normal HTTP address", @http, "Regular expression that identifies the URL of a website using the regular non-secure HTTP protocol.")
16
17
 
17
- @configurations+=[@resources_conf, @keywords_conf, @http_conf]
18
+ @configurations+=[@resources_conf, @keywords_conf, @http_conf, @whitelist_conf]
18
19
 
19
20
  def self.AnalyzeTokens(tokens)
20
21
  result = []
21
22
 
22
23
  ptokens = self.filter_resources(tokens, @resources_conf.value)
23
- ctokens = self.filter_variables(ptokens, @keywords_conf.value)
24
- if @whitelist
25
- wtokens = self.filter_whitelist(ctokens)
24
+ ctokens = self.filter_variables(ptokens, @keywords_conf.value) #TODO: It's working upside down
25
+ if not @whitelist_conf.value.empty?
26
+ wtokens = self.filter_whitelist(ctokens, @whitelist_conf.value)
26
27
  else
27
28
  wtokens = ptokens
28
29
  end
data/lib/rules/rule.rb CHANGED
@@ -67,10 +67,9 @@ class Rule
67
67
  return ftokens
68
68
  end
69
69
 
70
- def self.filter_whitelist(tokens)
70
+ def self.filter_whitelist(tokens, whitelist)
71
71
  ftokens=tokens.find_all do |hash|
72
- #!(@whitelist =~ hash.value.downcase)
73
- true # TODO: Understand the whitelist
72
+ !(whitelist =~ hash.value.downcase)
74
73
  end
75
74
  return ftokens
76
75
  end
@@ -18,7 +18,7 @@ class LanguageServer
18
18
  length=Integer(line.scan(/\d/).join(''))
19
19
  line=client.read(length+2)
20
20
  request = JSON.parse(line)
21
- puts line
21
+ $logger.debug(line)
22
22
 
23
23
  method_name = request['method'].sub('/', '_')
24
24
  response = if self.respond_to? "client_"+method_name then self.send("client_"+method_name,request['id'],request['params']) end
@@ -27,7 +27,7 @@ class LanguageServer
27
27
  client.flush
28
28
  client.print("Content-Length: "+response.length.to_s+"\r\n\r\n")
29
29
  client.print(response)
30
- puts response
30
+ $logger.debug(response)
31
31
  end
32
32
  end
33
33
  client.close
@@ -1,4 +1,5 @@
1
1
  require "rack"
2
+ require 'webrick'
2
3
  require 'json'
3
4
  require 'uri'
4
5
  require_relative '../rule_engine'
@@ -43,7 +44,8 @@ class LinterServer
43
44
  end
44
45
 
45
46
  def self.start(port)
46
- Rack::Handler::WEBrick.run(LinterServer.new, :Port => port)
47
+ log = WEBrick::Log.new $stdout,1
48
+ Rack::Handler::WEBrick.run(LinterServer.new, :Port => port,Logger: log )
47
49
  end
48
50
 
49
51
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Tiago Ribeiro"]
9
9
  spec.email = ["tiago7b27@gmail.com"]
10
10
 
11
- spec.summary = "This is a security linter for the puppet language"
12
- spec.description = "This is a more complete security linter for the puppet language"
11
+ spec.summary = "Security vulnerabilities linter for Puppet Manifests"
12
+ spec.description = "Linter built to detect potential security vulnerabilities in Puppet manifests code. It also offers integration with Visual Studio Code https://marketplace.visualstudio.com/items?itemName=tiago1998.puppet-sec-lint-vscode"
13
13
  spec.homepage = "https://github.com/TiagoR98/puppet-sec-lint"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_runtime_dependency 'webrick', '~> 1.7.0'
38
38
  spec.add_runtime_dependency 'inifile', '~> 3.0.0'
39
39
  spec.add_runtime_dependency 'launchy', '~> 2.5.0'
40
+ spec.add_runtime_dependency 'logger', '~> 1.4.3'
40
41
 
41
42
  # For more information and examples about making a new gem, checkout our
42
43
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-sec-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.5.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Ribeiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-14 00:00:00.000000000 Z
11
+ date: 2021-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint
@@ -114,7 +114,22 @@ dependencies:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: 2.5.0
117
- description: This is a more complete security linter for the puppet language
117
+ - !ruby/object:Gem::Dependency
118
+ name: logger
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: 1.4.3
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: 1.4.3
131
+ description: Linter built to detect potential security vulnerabilities in Puppet manifests
132
+ code. It also offers integration with Visual Studio Code https://marketplace.visualstudio.com/items?itemName=tiago1998.puppet-sec-lint-vscode
118
133
  email:
119
134
  - tiago7b27@gmail.com
120
135
  executables:
@@ -157,10 +172,13 @@ files:
157
172
  - docs/cyrillic-homograph-attack.md
158
173
  - docs/empty-password.md
159
174
  - docs/hard-coded-credentials.md
175
+ - docs/http-without-tls.md
176
+ - docs/images/puppet-sec-lint_configurations.png
160
177
  - docs/images/puppet-sec-lint_console.png
161
178
  - docs/images/puppet-sec-lint_vscode.png
162
179
  - docs/index.md
163
180
  - docs/invalid-ip-addr-binding.md
181
+ - docs/suspicious-comments.md
164
182
  - docs/weak-crypto-algorithm.md
165
183
  - exe/puppet-sec-lint
166
184
  - lib/configurations/boolean_configuration.rb
@@ -170,6 +188,8 @@ files:
170
188
  - lib/facades/configuration_file_facade.rb
171
189
  - lib/facades/configuration_page_facade.rb
172
190
  - lib/lol.pp
191
+ - lib/lol2.pp
192
+ - lib/manifest.pp
173
193
  - lib/puppet-sec-lint/version.rb
174
194
  - lib/rule_engine.rb
175
195
  - lib/rules/admin_by_default_rule.rb
@@ -183,11 +203,9 @@ files:
183
203
  - lib/rules/use_weak_crypto_algorithms_rule.rb
184
204
  - lib/servers/language_server.rb
185
205
  - lib/servers/linter_server.rb
186
- - lib/settings.ini
187
206
  - lib/sin/sin.rb
188
207
  - lib/sin/sin_type.rb
189
208
  - lib/visitors/configuration_visitor.rb
190
- - puppet-sec-lint-0.5.8.gem
191
209
  - puppet-sec-lint.gemspec
192
210
  homepage: https://github.com/TiagoR98/puppet-sec-lint
193
211
  licenses:
@@ -215,5 +233,5 @@ requirements: []
215
233
  rubygems_version: 3.2.3
216
234
  signing_key:
217
235
  specification_version: 4
218
- summary: This is a security linter for the puppet language
236
+ summary: Security vulnerabilities linter for Puppet Manifests
219
237
  test_files: []
data/lib/settings.ini DELETED
@@ -1,39 +0,0 @@
1
- [HardCodedCredentialsRule]
2
- HardCodedCredentialsRule-enable_configuration = false
3
- HardCodedCredentialsRule-list_of_known_words_not_considered_in_credentials = pe-puppet,pe-webserver,pe-puppetdb,pe-postgres,pe-console-services,pe-orchestration-services,pe-ace-server,pe-bolt-server
4
- HardCodedCredentialsRule-list_of_invalid_values_in_credentials = undefined,unset,www-data,wwwrun,www,no,yes,[],root
5
- HardCodedCredentialsRule-regular_expression_of_words_present_in_credentials = (?-mix:user|usr|pass(word|_|$)|pwd|key|secret)
6
- HardCodedCredentialsRule-regular_expression_of_words_not_present_in_credentials = (?-mix:gpg|path|type|buff|zone|mode|tag|header|scheme|length|guid)
7
-
8
- [NoHTTPRule]
9
- NoHTTPRule-enable_configuration = false
10
- NoHTTPRule-list_of_resources_that_can_use_http = apt::source,::apt::source,wget::fetch,yumrepo,yum::,aptly::mirror,util::system_package,yum::managed_yumrepo
11
- NoHTTPRule-list_of_keywords_for_urls = backport,key,download,uri,mirror
12
- NoHTTPRule-regular_expression_of_a_normal_http_address = (?-mix:^http:\/\/.+)
13
-
14
- [AdminByDefaultRule]
15
- AdminByDefaultRule-enable_configuration = true
16
- AdminByDefaultRule-regular_expression_of_words_present_in_credentials = (?-mix:user|usr|pass(word|_|$)|pwd)
17
-
18
- [EmptyPasswordRule]
19
- EmptyPasswordRule-enable_configuration = true
20
- EmptyPasswordRule-list_of_trigger_words = pwd,password,pass
21
- EmptyPasswordRule-regular_expression_of_password_name = (?-mix:pass(word|_|$)|pwd)
22
-
23
- [InvalidIPAddrBindingRule]
24
- InvalidIPAddrBindingRule-enable_configuration = true
25
- InvalidIPAddrBindingRule-regular_expression_of_an_invalid_ip_address = (?-mix:^((http(s)?:\/\/)?0.0.0.0(:\d{1,5})?)$)
26
-
27
- [UseWeakCryptoAlgorithmsRule]
28
- UseWeakCryptoAlgorithmsRule-enable_configuration = true
29
- UseWeakCryptoAlgorithmsRule-regular_expression_of_weak_crypto_algorithms = (?-mix:^(sha1|md5))
30
-
31
- [SuspiciousCommentRule]
32
- SuspiciousCommentRule-enable_configuration = true
33
- SuspiciousCommentRule-list_of_trigger_words = hack,fixme,later,later2,todo,ticket,launchpad,bug,to-do
34
- SuspiciousCommentRule-regular_expression_of_keywords_present_in_suspicious_comments = (?-mix:hack|fixme|ticket|bug|secur|debug|defect|weak)
35
-
36
- [CyrillicHomographAttack]
37
- CyrillicHomographAttack-enable_configuration = true
38
- CyrillicHomographAttack-regular_expression_of_links_with_cyrillic_characters = (?-mix:^(http(s)?:\/\/)?.*\p{Cyrillic}+)
39
-
Binary file