Ensure exact match when rejecting global excludes with EXCLUDED_PATHS
#1879
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1830.
We can scaffold a simple, namespaced model to test the new changes.
Due to the problem in #1830 The current version of brakeman (6.2.2) won't report any warnings:
However, with the changes in this PR we get the following output.
Experimenting with Regular Expressions
Since the value of
relative_path
often times does not start with a leading/
, I chose to add one at the beginning when it doesn't exist. That way we can be sure we're getting an exact match for the directories we need to exclude.I primarily was thinking about scanning for exact matches with a Regular Expression instead of adding the leading
/
:However, since we have nested directories like
lib/tasks/
andlib/templates/
inEXCLUDED_PATHS
, I experimented with some regular expressions to extract those two by themselves. I ultimately refrained from this because I felt it made the code more convoluted/hard to read, so I left things simple and just went with the leading/
inEXCLUDED_PATHS
. I hope this helps!