-
Notifications
You must be signed in to change notification settings - Fork 306
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
Add runtime guardrail for SSI #4319
Conversation
Overall package sizeSelf size: 6.73 MB Dependency sizes
🤖 This report was automatically generated by heaviest-objects-in-the-universe |
BenchmarksBenchmark execution time: 2024-06-25 19:25:41 Comparing candidate commit acb6c1e in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 260 metrics, 6 unstable metrics. |
74ff0c6
to
7a88c4f
Compare
integration-tests/init.spec.js
Outdated
it('should initialize the tracer, if DD_INJECTION_ENABLED', () => { | ||
return runTest(cwd, { NODE_OPTIONS, DD_INJECTION_ENABLED }, 'true\n') | ||
context('when node version is more than engines field', () => { | ||
const FAKE_VERSION = '50000.0.0' |
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.
make sure to update this in april of the year 27002, when node 50000 releases
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.
Maybe I should use Number.MAX_SAFE_INTEGER
instead?
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.
aefbd02
to
947e5d1
Compare
dea462d
to
95948d8
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4319 +/- ##
===========================================
- Coverage 92.64% 69.19% -23.46%
===========================================
Files 116 1 -115
Lines 4173 198 -3975
Branches 33 33
===========================================
- Hits 3866 137 -3729
+ Misses 307 61 -246 ☔ View full report in Codecov by Sentry. |
7b20ebf
to
077923f
Compare
077923f
to
eb145ba
Compare
integration-tests/init/setversion.js
Outdated
|
||
const desc = Reflect.getOwnPropertyDescriptor(process.versions, 'node') | ||
|
||
desc.value = process.env.FAKE_VERSION |
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.
Let's use a real old version instead. The version number is not what would typically cause issues, but rather things that we do that could be unsupported in older versions, and that includes the bailout logic.
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.
@rochdev Would one version prior to the current bottom of the engines field range suffice?
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.
To be honest I'd probably go with as low as we possibly can for the odd Node 4/6/8 that may try installing this, especially since it should be easy to support these versions for just the bailout script.
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.
New code looks good to me, but I'd say the minimum Node version should be lowered to at the very least 8, but if we can push 4 then that's even better. Both of those won't work on Apple Silicon though, so maybe the choice could be platform specific? In any case, this is not a blocker, but definitely something we should do, otherwise we have no idea if this works on older versions which may still fail.
944755a
to
98620da
Compare
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.
LGTM, one small nit.
if (points.length === 0) { | ||
return | ||
} |
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 move this before forEach
init.js
Outdated
|
||
let initBailout = false | ||
let clobberBailout = false | ||
const forced = ['1', 'true', 'True'].includes(process.env.DD_INJECT_FORCE) |
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 often see this ['1', 'true', 'True'].includes(…)
idiom. We do have an isTrue
function in util.js
though – could you use that instead for consistency? It also accepts the word "true" in any combination of letter cases and while "tRuE" is arguably weird, "TRUE" is reasonable.
const forced = ['1', 'true', 'True'].includes(process.env.DD_INJECT_FORCE) | |
const forced = isTrue(process.env.DD_INJECT_FORCE) |
Even better, since you're creating a Config
object on line 10 anyway you could let it read the env variable and expose its evaluation result as a property of the config object. That way the config object is the only source of configuration for all of the rest of the codebase. There's already some processing in there for e.g. DD_INJECTION_ENABLED
that I added for profiler's needs, but you'd be welcome to generalize it, and then you could use a Config property for that as well.
adc1630
to
0b093b4
Compare
0b093b4
to
acb6c1e
Compare
* Add guardrails for SSI * PR feedback * test on a swath of versions, in CI only
* Add guardrails for SSI * PR feedback * test on a swath of versions, in CI only
* Add guardrails for SSI * PR feedback * test on a swath of versions, in CI only
* Add guardrails for SSI * PR feedback * test on a swath of versions, in CI only
When in SSI, bail out if our version of Node.js is incompatible.