puppet-sec-lint 0.5.7 → 0.5.13

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: 7b342570d0cd33a8818a927585edab299dc3117eea0bd92ca2b017045627836f
4
- data.tar.gz: 14c9957c5262ca2b9dfa209740fc3de748fb326009ca24a98b3fc046b99defa2
3
+ metadata.gz: bfaad87ab6375c69dd2cb27773653373587f35e3cc74d4cba47c0bb05a69bd18
4
+ data.tar.gz: 9c5a606fc0867a133d38ab6033f9fe6b66eaae4a8e7426f45d59fea1ff3d4b34
5
5
  SHA512:
6
- metadata.gz: 326b1e1ef9084032fa9fe0e2403c666d7ea385806a42848a9939ff0e3b62837d28f2af794ee9f4cf45cabaffac891b5787164a8b89d0182f1d0cb21d3ba17fee
7
- data.tar.gz: 440a31bcac39c6818463e8fec34611e7df7f7779ac05b69b697c1caa24ce9006dbdd5e8316081708eeae19f85af18c381fb1a07cf25f4efb5fd3fe3d18074e63
6
+ metadata.gz: 26a4648b94a03331d14bcb1da29938809c5869b8f013c9f4510bfdd3dbf8557139ff66a5cb8834066cdd103ade3631001f4a7ebbc9d09b1292c4a7ec4413d96f
7
+ data.tar.gz: ce98ccc1b55c37bc67d3ba4bafdd68fee493af13cffcab88af893ce276a0b5ba860d4b0a3deb2dc9210e467e24d8f61f14395b9bab2db314c1354df8a8711351
@@ -13,43 +13,19 @@
13
13
  <orderEntry type="sourceFolder" forTests="false" />
14
14
  <orderEntry type="library" scope="PROVIDED" name="addressable (v2.7.0, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
15
15
  <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.3, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="daemons (v1.3.1, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="eventmachine (v1.2.7, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
18
16
  <orderEntry type="library" scope="PROVIDED" name="inifile (v3.0.0, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
19
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" />
20
19
  <orderEntry type="library" scope="PROVIDED" name="minitest (v5.14.4, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
21
20
  <orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.6, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
22
21
  <orderEntry type="library" scope="PROVIDED" name="puppet-lint (v2.4.2, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
23
22
  <orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
24
23
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.3, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="thin (v1.8.0, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="webrick (v1.7.0, RVM: ruby-3.0.0 [global]) [gem]" level="application" />
26
25
  </component>
27
26
  <component name="RakeTasksCache">
28
27
  <option name="myRootTask">
29
- <RakeTaskImpl id="rake">
30
- <subtasks>
31
- <RakeTaskImpl description="Build puppet-sec-lint-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
32
- <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
33
- <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
34
- <RakeTaskImpl description="Build and install puppet-sec-lint-0.1.0.gem into system gems" fullCommand="install" id="install" />
35
- <RakeTaskImpl id="install">
36
- <subtasks>
37
- <RakeTaskImpl description="Build and install puppet-sec-lint-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
38
- </subtasks>
39
- </RakeTaskImpl>
40
- <RakeTaskImpl description="Create tag v0.1.0 and build and push puppet-sec-lint-0.1.0.gem to TODO: Set to 'http://mygemserver.com'" fullCommand="release[remote]" id="release[remote]" />
41
- <RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
42
- <RakeTaskImpl description="" fullCommand="default" id="default" />
43
- <RakeTaskImpl description="" fullCommand="release" id="release" />
44
- <RakeTaskImpl id="release">
45
- <subtasks>
46
- <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
47
- <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
48
- <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
49
- </subtasks>
50
- </RakeTaskImpl>
51
- </subtasks>
52
- </RakeTaskImpl>
28
+ <RakeTaskImpl id="rake" />
53
29
  </option>
54
30
  </component>
55
31
  </module>
data/Gemfile CHANGED
@@ -13,8 +13,10 @@ gem "puppet-lint"
13
13
 
14
14
  gem "rack"
15
15
 
16
- gem 'thin'
16
+ 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,33 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puppet-sec-lint (0.5.6)
4
+ puppet-sec-lint (0.5.13)
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/
14
16
  specs:
15
17
  addressable (2.7.0)
16
18
  public_suffix (>= 2.0.2, < 5.0)
17
- daemons (1.3.1)
18
- eventmachine (1.2.7)
19
19
  inifile (3.0.0)
20
20
  launchy (2.5.0)
21
21
  addressable (~> 2.7)
22
+ logger (1.4.3)
22
23
  minitest (5.14.4)
23
24
  public_suffix (4.0.6)
24
25
  puppet-lint (2.4.2)
25
26
  rack (2.2.3)
26
27
  rake (13.0.3)
27
- thin (1.8.0)
28
- daemons (~> 1.0, >= 1.0.9)
29
- eventmachine (~> 1.0, >= 1.0.4)
30
- rack (>= 1, < 3)
28
+ webrick (1.7.0)
31
29
 
32
30
  PLATFORMS
33
31
  x86_64-linux
@@ -35,12 +33,13 @@ PLATFORMS
35
33
  DEPENDENCIES
36
34
  inifile
37
35
  launchy
36
+ logger
38
37
  minitest (~> 5.0)
39
38
  puppet-lint
40
39
  puppet-sec-lint!
41
40
  rack
42
41
  rake (~> 13.0)
43
- thin
42
+ webrick
44
43
 
45
44
  BUNDLED WITH
46
45
  2.2.3
data/exe/puppet-sec-lint CHANGED
@@ -5,10 +5,17 @@ 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'
11
12
 
13
+ ConfigurationVisitor.GenerateIDs
14
+ ConfigurationFileFacade.LoadConfigurations
15
+
16
+ $logger = Logger.new(STDOUT)
17
+ $logger.level = Logger::ERROR
18
+
12
19
  #get free port
13
20
  loop do
14
21
  $port = rand(3000..9999)
@@ -46,6 +53,11 @@ OptionParser.new do |opts|
46
53
  opts.on("-p", "--port=PORT", "TCP Port open for socket communication with the language server (Default:5007)") do |port|
47
54
  options[:port] = port
48
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
49
61
  end.parse!
50
62
 
51
63
  puts '___ _ _ ___ ___ ____ ___ ____ ____ ____ _ _ ____ _ ___ _ _ _ _ _ _ ___ ____ ____ '
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PuppetSecLint
4
- VERSION = "0.5.7"
4
+ VERSION = "0.5.13"
5
5
  YEAR = "2021"
6
6
  AUTHOR = "Tiago Ribeiro"
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 @whitelist_conf.value
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
@@ -7,8 +7,6 @@ require_relative '../facades/configuration_page_facade'
7
7
  require_relative '../facades/configuration_file_facade'
8
8
 
9
9
  class LanguageServer
10
- ConfigurationVisitor.GenerateIDs
11
- ConfigurationFileFacade.LoadConfigurations
12
10
 
13
11
  def self.start(port)
14
12
  port ||= 5007
@@ -20,7 +18,7 @@ class LanguageServer
20
18
  length=Integer(line.scan(/\d/).join(''))
21
19
  line=client.read(length+2)
22
20
  request = JSON.parse(line)
23
- puts line
21
+ $logger.debug(line)
24
22
 
25
23
  method_name = request['method'].sub('/', '_')
26
24
  response = if self.respond_to? "client_"+method_name then self.send("client_"+method_name,request['id'],request['params']) end
@@ -29,7 +27,7 @@ class LanguageServer
29
27
  client.flush
30
28
  client.print("Content-Length: "+response.length.to_s+"\r\n\r\n")
31
29
  client.print(response)
32
- puts response
30
+ $logger.debug(response)
33
31
  end
34
32
  end
35
33
  client.close
@@ -1,5 +1,5 @@
1
1
  require "rack"
2
- require "thin"
2
+ require 'webrick'
3
3
  require 'json'
4
4
  require 'uri'
5
5
  require_relative '../rule_engine'
@@ -8,8 +8,6 @@ require_relative '../facades/configuration_page_facade'
8
8
  require_relative '../facades/configuration_file_facade'
9
9
 
10
10
  class LinterServer
11
- ConfigurationVisitor.GenerateIDs
12
- ConfigurationFileFacade.LoadConfigurations
13
11
 
14
12
  def call(env)
15
13
  req = Rack::Request.new(env)
@@ -46,7 +44,8 @@ class LinterServer
46
44
  end
47
45
 
48
46
  def self.start(port)
49
- Rack::Handler::Thin.run(LinterServer.new, :Port => port)
47
+ log = WEBrick::Log.new $stdout,1
48
+ Rack::Handler::WEBrick.run(LinterServer.new, :Port => port,Logger: log )
50
49
  end
51
50
 
52
51
  end
data/lib/settings.ini ADDED
@@ -0,0 +1,40 @@
1
+ [HardCodedCredentialsRule]
2
+ HardCodedCredentialsRule-enable_configuration = true
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 = true
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
+ NoHTTPRule-http_address_whitelist = (?-mix:^(127.0.0.1))
14
+
15
+ [AdminByDefaultRule]
16
+ AdminByDefaultRule-enable_configuration = true
17
+ AdminByDefaultRule-regular_expression_of_words_present_in_credentials = (?-mix:user|usr|pass(word|_|$)|pwd)
18
+
19
+ [EmptyPasswordRule]
20
+ EmptyPasswordRule-enable_configuration = true
21
+ EmptyPasswordRule-list_of_trigger_words = pwd,password,pass
22
+ EmptyPasswordRule-regular_expression_of_password_name = (?-mix:pass(word|_|$)|pwd)
23
+
24
+ [InvalidIPAddrBindingRule]
25
+ InvalidIPAddrBindingRule-enable_configuration = true
26
+ InvalidIPAddrBindingRule-regular_expression_of_an_invalid_ip_address = (?-mix:^((http(s)?:\/\/)?0.0.0.0(:\d{1,5})?)$)
27
+
28
+ [UseWeakCryptoAlgorithmsRule]
29
+ UseWeakCryptoAlgorithmsRule-enable_configuration = true
30
+ UseWeakCryptoAlgorithmsRule-regular_expression_of_weak_crypto_algorithms = (?-mix:^(sha1|md5))
31
+
32
+ [SuspiciousCommentRule]
33
+ SuspiciousCommentRule-enable_configuration = true
34
+ SuspiciousCommentRule-list_of_trigger_words = hack,fixme,later,later2,todo,ticket,launchpad,bug,to-do
35
+ SuspiciousCommentRule-regular_expression_of_keywords_present_in_suspicious_comments = (?-mix:hack|fixme|ticket|bug|secur|debug|defect|weak)
36
+
37
+ [CyrillicHomographAttack]
38
+ CyrillicHomographAttack-enable_configuration = true
39
+ CyrillicHomographAttack-regular_expression_of_links_with_cyrillic_characters = (?-mix:^(http(s)?:\/\/)?.*\p{Cyrillic}+)
40
+
@@ -34,8 +34,10 @@ Gem::Specification.new do |spec|
34
34
  spec.add_runtime_dependency 'rake', '~> 13.0'
35
35
  spec.add_runtime_dependency 'minitest', '~> 5.0'
36
36
  spec.add_runtime_dependency 'rack', '~> 2.2.3'
37
+ spec.add_runtime_dependency 'webrick', '~> 1.7.0'
37
38
  spec.add_runtime_dependency 'inifile', '~> 3.0.0'
38
39
  spec.add_runtime_dependency 'launchy', '~> 2.5.0'
40
+ spec.add_runtime_dependency 'logger', '~> 1.4.3'
39
41
 
40
42
  # For more information and examples about making a new gem, checkout our
41
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.7
4
+ version: 0.5.13
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-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: 2.2.3
75
+ - !ruby/object:Gem::Dependency
76
+ name: webrick
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 1.7.0
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 1.7.0
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: inifile
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +114,20 @@ dependencies:
100
114
  - - "~>"
101
115
  - !ruby/object:Gem::Version
102
116
  version: 2.5.0
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
103
131
  description: This is a more complete security linter for the puppet language
104
132
  email:
105
133
  - tiago7b27@gmail.com
@@ -169,6 +197,7 @@ files:
169
197
  - lib/rules/use_weak_crypto_algorithms_rule.rb
170
198
  - lib/servers/language_server.rb
171
199
  - lib/servers/linter_server.rb
200
+ - lib/settings.ini
172
201
  - lib/sin/sin.rb
173
202
  - lib/sin/sin_type.rb
174
203
  - lib/visitors/configuration_visitor.rb