Sha256: a4f688271b0ef61bf3a7274d8787939c3048cae55e318e725d0ed5b370d79788

Contents?: true

Size: 1.13 KB

Versions: 18

Compression:

Stored size: 1.13 KB

Contents

require_relative '../configurations/list_configuration'

class SuspiciousCommentRule < Rule
  @trigger_words = %w[hack fixme later later2 todo ticket launchpad bug to-do]
  @suspicious = /hack|fixme|ticket|bug|secur|debug|defect|weak/

  @trigger_words_conf = ListConfiguration.new("List of trigger words", @trigger_words, "List of words that identify a suspicious comment")
  @suspicious_conf = RegexConfiguration.new("Regular expression of keywords present in suspicious comments", @suspicious, "Regular expression that identifies words that are immediately considered suspicious comments that shouldn't be present in a finalized product.")

  @configurations+=[@trigger_words_conf, @suspicious_conf]

  @name = "Suspicious comments"

  def self.AnalyzeTokens(tokens)
    result = []

    ftokens = self.get_comments(tokens)
    ftokens.each do |token|
      token_value = token.value.downcase
      token_type = token.type.to_s
      if (token_value =~ @suspicious_conf.value)
        result.append(Sin.new(SinType::SuspiciousComments, 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/suspicious_comment_rule.rb
puppet-sec-lint-0.5.17 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.16 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.15 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.14 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.13 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.11 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.10 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.9 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.8 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.7 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.6 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.5 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.4 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.3 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.2 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.1 lib/rules/suspicious_comment_rule.rb
puppet-sec-lint-0.5.0 lib/rules/suspicious_comment_rule.rb