-
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
Embed AppSec rules and templates files to be compatible with bundlers #2913
Conversation
Overall package sizeSelf size: 3.99 MB Dependency sizes
🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov Report
@@ Coverage Diff @@
## master #2913 +/- ##
===========================================
- Coverage 87.26% 71.75% -15.52%
===========================================
Files 321 167 -154
Lines 11453 6558 -4895
Branches 33 33
===========================================
- Hits 9995 4706 -5289
- Misses 1458 1852 +394
... and 204 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
BenchmarksComparing candidate commit 89288e5 in PR branch Found 4 performance improvements and 0 performance regressions! Performance is the same for 663 metrics, 41 unstable metrics. scenario:plugin-graphql-with-depth-off-16
scenario:plugin-graphql-with-depth-on-max-16
scenario:plugin-graphql-with-depth-and-collapse-on-16
scenario:plugin-dns-with-tracer-16
|
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.
Seems to me like it would be a whole lot cleaner to just do all the file loading stuff in config.js rather than spreading this file loading stuff all over the codebase.
That's what trace is doing for DD_SPAN_SAMPLING_RULES_FILE
here. 🤔
Problem of reading the files directly in config.js: telemetry sends the config object at startup, and it would also include the files we read, which is a bit dirty. |
8bffe79
to
f370e86
Compare
b667cd4
to
302ddc9
Compare
f2fc119
to
3f8117e
Compare
I do prefer this approach compared to #2899. I could see #2899 being upstreamed into esbuild itself somehow. Maybe a community plugin that somehow interacts with |
…N.stringify blocked template json
expect(config.appsec.blockedTemplateJson).to.be | ||
.equal(path.join(__dirname, '..', 'src', 'appsec', 'templates', 'blocked.json')) | ||
|
||
expect(log.error).to.be.called |
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 is really not good coverage, please use more precise asserts like
expect(log.error).to.have.been.calledTwice
expect(log.error.firstCall).to.have.been.calledWithExactly('...')
expect(log.error.secondCall).to.have.been.calledWithExactly('...')
or something like that
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.
yes, but have we decided the error message?
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 think this is adequate: dd-trace: Error reading file /not/found/file/path. Is the 'DD_APPSEC_RULES' environment variable correct?
…#2913) * gentle fallback if appsec template files are missing * Load appsec template files with require --------- Co-authored-by: Thomas Hunter II <tlhunter@datadog.com> Co-authored-by: simon-id <simon.id@datadoghq.com>
…#2913) * gentle fallback if appsec template files are missing * Load appsec template files with require --------- Co-authored-by: Thomas Hunter II <tlhunter@datadog.com> Co-authored-by: simon-id <simon.id@datadoghq.com>
…#2913) * gentle fallback if appsec template files are missing * Load appsec template files with require --------- Co-authored-by: Thomas Hunter II <tlhunter@datadog.com> Co-authored-by: simon-id <simon.id@datadoghq.com>
…#2913) * gentle fallback if appsec template files are missing * Load appsec template files with require --------- Co-authored-by: Thomas Hunter II <tlhunter@datadog.com> Co-authored-by: simon-id <simon.id@datadoghq.com>
What does this PR do?
Move
templates/blocked.html
andtemplates/blocked.json
file contents toblocked_templates.js
file and require it in order to load the appsec templates.Now is in
config.js
where the template and rules are loaded, establishing the corresponding values forconfig.appsec.blockedTemplateHtml
andconfig.appsec.blockedTemplateJson
.Closes #2841
Closes #2899
Motivation
Avoid errors with esbuild bundles