-
Notifications
You must be signed in to change notification settings - Fork 4
fix(hsts): added StartsWith rule #44
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
Conversation
Reviewer's Guide by SourceryThis pull request introduces a new HSTS middleware rule, 'StartsWith', that evaluates if a request path starts with a specified prefix after converting it to lowercase. Additionally, it refactors the existing rule by renaming the 'Ignore' function to 'Match' for clarity, and updates the tests to use both the new 'StartsWith' rule and the refactored naming. Class diagram for HSTS Rules in MiddlewareclassDiagram
%% Define function type for rules
class IgnoreRule {
<<Function>>
+func(*http.Request) bool
}
%% Function that renames the previous 'Ignore' to 'Match'
class Match {
<<Function>>
+func(...string) IgnoreRule
}
%% New function to create a rule that checks for lower case prefix in the URL path
class StartsWith {
<<Function>>
+func(...string) IgnoreRule
}
%% Relationships indicating both functions return an IgnoreRule
Match ..> IgnoreRule : returns
StartsWith ..> IgnoreRule : returns
%% Additional note regarding renaming for clarity
note for Match "Renamed from 'Ignore' for clarity"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Here's the code health analysis summary for commits Analysis Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #44 +/- ##
==========================================
+ Coverage 92.41% 92.47% +0.05%
==========================================
Files 43 43
Lines 1662 1675 +13
==========================================
+ Hits 1536 1549 +13
Misses 93 93
Partials 33 33
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @cnlangzi - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider renaming
Match
toEqual
for clarity, as it checks for exact path equality. - The comment for
StartsWith
sayspaths MUST be lower case
- should this be enforced in code?
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Changed
Fixed
Added
StartsWith
rule inRedirect
Tests
Tasks to complete before merging PR:
make unit-test
to check for any regressions 📋make lint
to check for any issuesSummary by Sourcery
Add a new
StartsWith
rule to theRedirect
middleware, allowing requests with paths that start with specific prefixes to be ignored by HSTS.New Features:
StartsWith
rule to theRedirect
middleware in thehsts
extension.Tests:
StartsWith
rule.