Sha256: 51100068feb16411cf4a079d9401379ac430ae5ce98bf497d5615917c18dff54

Contents?: true

Size: 958 Bytes

Versions: 18

Compression:

Stored size: 958 Bytes

Contents

require_relative '../configurations/list_configuration'

class UseWeakCryptoAlgorithmsRule < Rule
  @name = "Use of weak crypto algorithm"

  @poor_crypto = /^(sha1|md5)/

  @poor_crypto_conf = RegexConfiguration.new("Regular expression of weak Crypto Algorithms", @poor_crypto, "Regular expression for names of known weak Cryptographic algorithms that shouldn't be used to secure sensitive information.")

  @configurations+=[@poor_crypto_conf]

  def self.AnalyzeTokens(tokens)
    result = []

    tokens.each do |token|
      token_value = token.value.downcase
      token_type = token.type.to_s
      if !token.next_token.nil?
        next_token_type = token.next_token.type.to_s
      end
      if (token_value =~ @poor_crypto_conf.value) && (next_token_type.eql? "LPAREN")
        result.append(Sin.new(SinType::WeakCryptoAlgorithm, token.line, token.column, token.line, token.column+token_value.length))
      end
    end

    return result
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
puppet-sec-lint-1.0.0 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.17 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.16 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.15 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.14 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.13 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.11 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.10 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.9 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.8 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.7 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.6 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.5 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.4 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.3 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.2 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.1 lib/rules/use_weak_crypto_algorithms_rule.rb
puppet-sec-lint-0.5.0 lib/rules/use_weak_crypto_algorithms_rule.rb