Skip to content
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

chore(deps): Updated @newrelic/security-agent to v2.2.0 #2842

Merged
merged 17 commits into from
Dec 18, 2024

Conversation

sumitsuthar
Copy link
Contributor

Description

  • Updated @newrelic/security-agent to v2.2.0.
  • Updated versioned test file "test/versioned/express/ignoring.test.js" due to change in metric count.

v2.2.0 (2024-12-18)

Features

  • Support for express 5.x
  • IAST support for GraphQL
  • Added support for trustboundary security events

Bug fixes

  • Fix for empty route in fastify

How to Test

npm run versioned:security

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.21%. Comparing base (972b59d) to head (f26e747).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2842      +/-   ##
==========================================
- Coverage   97.26%   97.21%   -0.05%     
==========================================
  Files         294      294              
  Lines       46405    46405              
==========================================
- Hits        45135    45113      -22     
- Misses       1270     1292      +22     
Flag Coverage Δ
integration-tests-cjs-18.x 73.18% <ø> (ø)
integration-tests-cjs-20.x 73.18% <ø> (+<0.01%) ⬆️
integration-tests-cjs-22.x 73.21% <ø> (+<0.01%) ⬆️
integration-tests-esm-18.x 49.91% <ø> (ø)
integration-tests-esm-20.x 49.91% <ø> (ø)
integration-tests-esm-22.x 49.96% <ø> (ø)
unit-tests-18.x 88.96% <ø> (ø)
unit-tests-20.x 88.96% <ø> (ø)
unit-tests-22.x 88.96% <ø> (ø)
versioned-tests-18.x 78.98% <ø> (-0.20%) ⬇️
versioned-tests-20.x 78.99% <ø> (-0.20%) ⬇️
versioned-tests-22.x 79.02% <ø> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -36,13 +36,12 @@ test('ignoring an Express route', async function (t) {

const metrics = agent.metrics._metrics.unscoped
// loading k2 adds instrumentation metrics for things it loads
const expectedMetrics = helper.isSecurityAgentEnabled(agent) ? 11 : 3
const expectedMetrics = helper.isSecurityAgentEnabled(agent) ? Object.keys(metrics).length : 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the actual expected number? How many metrics does the security agent add on top of the baseline 3 that are expected without the security agent?

Copy link
Contributor Author

@sumitsuthar sumitsuthar Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This number changes whenever there is code refactoring or change in invocation of instrumentation module of security agent. In past, I have updated these numbers as well.
#2239

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although 11 works fine but in one run it was expecting 12

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Security agent starts instrumenting native module like crypto or Random then the metric count changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but just doing Object.keys(metrics) isn't going to catch when things aren't working. what was added that makes this test fail?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated metric count to 13 now.

Copy link
Contributor Author

@sumitsuthar sumitsuthar Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@bizob2828 bizob2828 Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't see the update to the test. your addition to express router only exists in 5.x+ so you'll have to check the express version before deciding how many metrics exist with the security agent enabled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff --git a/test/versioned/express/ignoring.test.js b/test/versioned/express/ignoring.test.js
index a1a94a9ae..827a3c858 100644
--- a/test/versioned/express/ignoring.test.js
+++ b/test/versioned/express/ignoring.test.js
@@ -18,7 +18,7 @@ test.beforeEach(async (ctx) => {
 test.afterEach(teardown)
 
 test('ignoring an Express route', async function (t) {
-  const { agent, app, port } = t.nr
+  const { agent, app, port, isExpress5 } = t.nr
   const plan = tsplan(t, { plan: 7 })
 
   const api = new API(agent)
@@ -36,7 +36,7 @@ test('ignoring an Express route', async function (t) {
 
     const metrics = agent.metrics._metrics.unscoped
     // loading k2 adds instrumentation metrics for things it loads
-    const expectedMetrics = helper.isSecurityAgentEnabled(agent) ? 11 : 3
+    const expectedMetrics = helper.isSecurityAgentEnabled(agent) ? isExpress5 ? 13 : 11 : 3

@bizob2828 bizob2828 added the dev:tests Indicates only changes to tests label Dec 18, 2024
Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tagging this with dev:tests as this doesn't have to get released. The semver range will pick up latest security agent when customers install agent

@bizob2828 bizob2828 merged commit 170941e into newrelic:main Dec 18, 2024
28 of 29 checks passed
@github-actions github-actions bot mentioned this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev:tests Indicates only changes to tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants