Closed gazayas closed 3 weeks ago
The pull request updates the Brakeman application security scanner's AppTree
class to improve the reliability and consistency of the tool by updating the EXCLUDED_PATHS
constant and adding a check to ensure that the relative path starts with a slash before checking if it includes any of the excluded paths.
We ran 9 analyzers
against 1 file
and 0 analyzers
had findings. 9 analyzers
had no findings.
:green_circle: Risk threshold not exceeded.
Ah, thank you for the contribution.
I actually had a branch sitting around with a slightly better solution (I think), which I've pushed in #1880
Cool, I didn't realize regexp_for_paths was in the code base. I tested #1880 with the Catalog::Order
model from above and it works for me! I'll go ahead and close this one.
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!