-
Notifications
You must be signed in to change notification settings - Fork 323
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
graceful fallback if appsec template files are missing #2841
Conversation
Overall package sizeSelf size: 3.84 MB Dependency sizes
🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov Report
@@ Coverage Diff @@
## master #2841 +/- ##
==========================================
+ Coverage 89.26% 91.47% +2.21%
==========================================
Files 317 269 -48
Lines 11282 9459 -1823
Branches 33 33
==========================================
- Hits 10071 8653 -1418
+ Misses 1211 806 -405
... and 48 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Perhaps it would be better to just inline the current files with template strings or something?
@@ -8,6 +8,9 @@ let templateLoaded = false | |||
let templateHtml = '' | |||
let templateJson = '' | |||
|
|||
const ERROR_HTML = '<html>blocked</html>' | |||
const ERROR_JSON = '{"error": "blocked"}' |
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 could just set these to the template*
variables directly and skip needing these extra vars.
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.
Change has been made
345f888
to
2016762
Compare
2016762
to
4d5a1a9
Compare
There is another file which is read at runtime, it's |
Shouldn't we have some tests for this ? |
After discussion with the guild, the best solution would I think be to embed the html and json templates directly in js files as a string and require those files. As for the rules files I mentionned above, basically just require it. I'm not sure if we should require those 3 files at startup time or we can keep it during runtime like it is currently. |
this is the simplest solution but templates and rules file are configurable by the user.
And |
Another detail, esbuild can bundle requires with packages that it can resolve during build time but it cannot with things like:
I'm trying to extend Thomas esbuild plugin to detect the load of certain files like appsec/index.js or appsec/blocking.js and make some expression replacements in order to embed the template and json files content inside them |
one solution using |
What does this PR do?
Motivation