Class: Rails::Guarddog::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/guarddog/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rails/guarddog/configuration.rb', line 7

def initialize
  @root = nil
  @enabled_checkers = all_checkers
  # Checkers to turn off without having to list every other checker in
  # enabled_checkers. Takes priority over enabled_checkers.
  # Example: disable just dos and rate_limit:
  #   config.disabled_checkers = %w[dos rate_limit]
  @disabled_checkers = []
  @excluded_paths = %w[vendor node_modules]
  # Per-directory checker suppression: keys are path substrings, values are
  # arrays of checker names (same format as enabled_checkers).
  # Defaults suppress the `secrets` checker inside spec/test trees because
  # dummy passwords in test fixtures are intentional and not a real risk.
  @ignored_checks = {
    "spec"   => %w[secrets],
    "test"   => %w[secrets]
  }
  @output_format = :console
end

Instance Attribute Details

#disabled_checkersObject

Returns the value of attribute disabled_checkers.



5
6
7
# File 'lib/rails/guarddog/configuration.rb', line 5

def disabled_checkers
  @disabled_checkers
end

#enabled_checkersObject

Returns the value of attribute enabled_checkers.



5
6
7
# File 'lib/rails/guarddog/configuration.rb', line 5

def enabled_checkers
  @enabled_checkers
end

#excluded_pathsObject

Returns the value of attribute excluded_paths.



5
6
7
# File 'lib/rails/guarddog/configuration.rb', line 5

def excluded_paths
  @excluded_paths
end

#ignored_checksObject

Returns the value of attribute ignored_checks.



5
6
7
# File 'lib/rails/guarddog/configuration.rb', line 5

def ignored_checks
  @ignored_checks
end

#output_formatObject

Returns the value of attribute output_format.



5
6
7
# File 'lib/rails/guarddog/configuration.rb', line 5

def output_format
  @output_format
end

#rootObject



33
34
35
# File 'lib/rails/guarddog/configuration.rb', line 33

def root
  @root || Rails.root.to_s
end

Instance Method Details

#active_checkersObject

The final resolved list of checkers to run: enabled_checkers minus anything in disabled_checkers.



29
30
31
# File 'lib/rails/guarddog/configuration.rb', line 29

def active_checkers
  enabled_checkers - Array(@disabled_checkers).map(&:to_s)
end

#all_checkersObject



37
38
39
40
41
42
# File 'lib/rails/guarddog/configuration.rb', line 37

def all_checkers
  %w[
    sql_injection xss csrf mass_assignment open_redirect secrets
    dos idor ai_injection rate_limit dependency graphql
  ]
end