Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match globally excluded paths more accurately #1880

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

presidentbeef
Copy link
Owner

Closes #1830

Copy link

dryrunsecurity bot commented Nov 4, 2024

DryRun Security Summary

The changes in this pull request focus on improving the handling of excluded paths in the Brakeman security scanner for Ruby on Rails applications, aiming to enhance the accuracy and performance of the scanner by more effectively excluding certain directories and files from the analysis.

Expand for full summary

Summary:

The changes in this pull request are focused on improving the handling of excluded paths in the Brakeman security scanner for Ruby on Rails applications. Brakeman is a static code analysis tool used to identify potential security vulnerabilities, and these changes are aimed at enhancing the accuracy and performance of the scanner by more effectively excluding certain directories and files from the analysis.

The key changes include:

  1. Updating the EXCLUDED_PATHS constant to use a regular expression-based approach instead of a simple array of strings, allowing for more flexible and efficient matching of excluded paths.
  2. Modifying the reject_global_excludes method to use the new match_path helper method, which checks if a given path matches the EXCLUDED_PATHS regular expression.
  3. Introducing the match_path method to handle the matching of paths against the regular expression-based exclusions, converting the absolute path to a project-relative path and then checking if it matches the exclusion patterns.

These changes are likely to improve the overall performance and accuracy of the Brakeman scanner by focusing its analysis on the relevant parts of the application and avoiding unnecessary processing of directories and files that are not directly relevant to the security analysis, such as generators, tasks, templates, databases, and test-related files.

Files Changed:

  • lib/brakeman/app_tree.rb: This file contains the changes related to the handling of excluded paths in the Brakeman security scanner. The changes include updating the EXCLUDED_PATHS constant to use a regular expression-based approach, modifying the reject_global_excludes method to use the new match_path helper method, and introducing the match_path method to handle the matching of paths against the exclusion patterns.

Code Analysis

We ran 9 analyzers against 1 file and 0 analyzers had findings. 9 analyzers had no findings.

Riskiness

🟢 Risk threshold not exceeded.

View PR in the DryRun Dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Controller with "log" in pathname excluded from scan
1 participant