Class: Rails::Guarddog::Checkers::GraphqlChecker
- Inherits:
-
BaseChecker
- Object
- BaseChecker
- Rails::Guarddog::Checkers::GraphqlChecker
- Defined in:
- lib/rails/guarddog/checkers/graphql_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 23 |
# File 'lib/rails/guarddog/checkers/graphql_checker.rb', line 5 def run glob_files('app/graphql/**/*.rb').each do |file| content = File.read(file) if content.include?('field') || content.include?('def resolve') unless content.include?('authorize') || content.include?('current_user') add_finding( severity: :high, message: "GraphQL field missing authorization check", file: file, line: 1, snippet: "GraphQL resolver without auth", remediation: "Add authorization: authorize @object or Pundit check" ) end end end findings end |