Class: Rails::Guarddog::Checkers::IdorChecker
- Inherits:
-
BaseChecker
- Object
- BaseChecker
- Rails::Guarddog::Checkers::IdorChecker
- Defined in:
- lib/rails/guarddog/checkers/idor_checker.rb
Instance Attribute Summary
Attributes inherited from BaseChecker
Instance Method Summary collapse
Methods inherited from BaseChecker
Constructor Details
This class inherits a constructor from Rails::Guarddog::Checkers::BaseChecker
Instance Method Details
#run ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rails/guarddog/checkers/idor_checker.rb', line 5 def run glob_files('app/controllers/**/*.rb').each do |file| content = File.read(file) content.each_line.with_index do |line, idx| if line.match?(/find\(params\[[:']id[']\]/) && !content.include?('authorize') add_finding( severity: :high, message: "Potential IDOR: object accessed by ID without ownership check", file: file, line: idx + 1, snippet: line.strip, remediation: "Add authorization check: authorize @object" ) end end end findings end |