-
Notifications
You must be signed in to change notification settings - Fork 327
Update blocking page and status from RC or rules file #3195
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
Overall package sizeSelf size: 4.22 MB Dependency sizes
🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov Report
@@ Coverage Diff @@
## master #3195 +/- ##
==========================================
+ Coverage 86.49% 86.59% +0.09%
==========================================
Files 337 337
Lines 12020 12059 +39
Branches 33 33
==========================================
+ Hits 10397 10442 +45
+ Misses 1623 1617 -6
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
2a43d97
to
a7eaaa9
Compare
bc71599
to
c723fe8
Compare
* Update blocking page and status from RC or rules file * Use if/else instead of return * Code styles * Split block in two methods * Fix test * Unapply after test * Fix tests * Reorder params in method * Change the signature of updateBlockingConfiguration method * Clear blocking configuration on clear rules * Update blocking response type by configuration * Fix lint
* Update blocking page and status from RC or rules file * Use if/else instead of return * Code styles * Split block in two methods * Fix test * Unapply after test * Fix tests * Reorder params in method * Change the signature of updateBlockingConfiguration method * Clear blocking configuration on clear rules * Update blocking response type by configuration * Fix lint
* Update blocking page and status from RC or rules file * Use if/else instead of return * Code styles * Split block in two methods * Fix test * Unapply after test * Fix tests * Reorder params in method * Change the signature of updateBlockingConfiguration method * Clear blocking configuration on clear rules * Update blocking response type by configuration * Fix lint
* Update blocking page and status from RC or rules file * Use if/else instead of return * Code styles * Split block in two methods * Fix test * Unapply after test * Fix tests * Reorder params in method * Change the signature of updateBlockingConfiguration method * Clear blocking configuration on clear rules * Update blocking response type by configuration * Fix lint
* Update blocking page and status from RC or rules file * Use if/else instead of return * Code styles * Split block in two methods * Fix test * Unapply after test * Fix tests * Reorder params in method * Change the signature of updateBlockingConfiguration method * Clear blocking configuration on clear rules * Update blocking response type by configuration * Fix lint
* Update blocking page and status from RC or rules file * Use if/else instead of return * Code styles * Split block in two methods * Fix test * Unapply after test * Fix tests * Reorder params in method * Change the signature of updateBlockingConfiguration method * Clear blocking configuration on clear rules * Update blocking response type by configuration * Fix lint
@@ -49,7 +93,12 @@ function setTemplates (config) { | |||
} | |||
} | |||
|
|||
function updateBlockingConfiguration (newBlockingConfiguration) { |
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.
why is this called update... when there is a function above called set...
if (blockingConfiguration && blockingConfiguration.type === 'block_request' && | ||
blockingConfiguration.parameters.status_code) { | ||
res.statusCode = blockingConfiguration.parameters.status_code |
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.
all of the complicated blockingConfiguration checks should be done in updateBlockingConfiguration()
that would compile the variables neccesary only when updated, not in every request. You don't need to check that blockingConfiguration.type is block_request in EVERY request do you ?
if (!blockingConfiguration || blockingConfiguration.parameters.type === 'auto') { | ||
if (accept && accept.includes('text/html') && !accept.includes('application/json')) { | ||
type = 'text/html; charset=utf-8' | ||
body = templateHtml | ||
} else { | ||
type = 'application/json' | ||
body = templateJson | ||
} | ||
} else { | ||
type = 'application/json' | ||
body = templateJson | ||
if (blockingConfiguration.parameters.type === 'html') { | ||
type = 'text/html; charset=utf-8' | ||
body = templateHtml | ||
} else { | ||
type = 'application/json' | ||
body = templateJson | ||
} | ||
} |
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.
This whole block should be rewritten to be clearer tbh
|
||
if (newActions.modified) { | ||
blocking.updateBlockingConfiguration(concatArrays(newActions).find(action => action.id === 'block')) | ||
appliedActions = newActions | ||
} |
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.
you still need to apply the new applyState here since it's not done by the batch thing above.
Also wouldn't updating actions when the waf fails cause synchronisation problems ? waf rules are referencing an action, so if you update the actions but not the waf rules then you might end of with an inconsistent state no ?
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.
I don't think so.
actions thing is not directly related with the WAF, the waf result would be the same, block or not to block, but the action to do with the result is different.
We don't need to say anything to the waf, we just need to change the behaviour of the blocking.
block with redirect, with custome message, with different status code etc.
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.
you still need to apply the new applyState here since it's not done by the batch thing above.
What does this PR do?
Make it possible for the customers to define the status code or the redirect url for the blocking page.
If they are defined in the custom rules file, the tracer will start to take the action defined there.
Plugin Checklist