newrelic / newrelic-browser-agent

New Relic Browser Agent
Apache License 2.0
77 stars 40 forks source link

fix: Prevent agent using invalid date header #1122

Closed patrickhousley closed 2 months ago

patrickhousley commented 2 months ago

Shut down the agent when unable to read a correctly formatted date header for the page view event harvest. This prevents harvesting data with wildly inaccurate timestamps. This should only happen with third-party or non-agent code has tampered with the ajax response headers.

Overview

Adding supportability metrics to track when the calculated time diff is >= 12 hours, >= 6 hours, or >= 1 hour.

Related Issue(s)

https://new-relic.atlassian.net/browse/NR-295258 https://source.datanerd.us/agents/angler/pull/600

Testing

github-actions[bot] commented 2 months ago

Asset Size Report

Merging this pull request will result in the following asset size changes:

Agent Asset Previous Size New Size Diff
lite loader 32.44 kB / 11.33 kB (gzip) 32.44 kB / 11.33 kB (gzip) 0% / 0% (gzip)
lite async-chunk 50.14 kB / 16.15 kB (gzip) 50.9 kB / 16.39 kB (gzip) 1.5% / 1.45% (gzip)
pro loader 53.3 kB / 18.04 kB (gzip) 53.3 kB / 18.04 kB (gzip) 0% / 0.01% (gzip)
pro async-chunk 96.37 kB / 28.8 kB (gzip) 97.12 kB / 29.04 kB (gzip) 0.78% / 0.83% (gzip)
spa loader 61.24 kB / 20.48 kB (gzip) 61.24 kB / 20.48 kB (gzip) 0% / 0.01% (gzip)
spa async-chunk 111.42 kB / 33.14 kB (gzip) 112.18 kB / 33.37 kB (gzip) 0.68% / 0.7% (gzip)
lite-polyfills loader 125.99 kB / 40.61 kB (gzip) 125.99 kB / 40.62 kB (gzip) 0% / 0.02% (gzip)
lite-polyfills async-chunk 64.2 kB / 18.49 kB (gzip) 64.99 kB / 18.73 kB (gzip) 1.23% / 1.3% (gzip)
pro-polyfills loader 148.55 kB / 46.95 kB (gzip) 148.55 kB / 46.95 kB (gzip) 0% / 0% (gzip)
pro-polyfills async-chunk 116.53 kB / 31.11 kB (gzip) 117.32 kB / 31.32 kB (gzip) 0.68% / 0.69% (gzip)
spa-polyfills loader 156.75 kB / 49.11 kB (gzip) 156.75 kB / 49.11 kB (gzip) 0% / 0% (gzip)
spa-polyfills async-chunk 133.44 kB / 35.78 kB (gzip) 134.23 kB / 35.99 kB (gzip) 0.59% / 0.59% (gzip)
github-actions[bot] commented 2 months ago

Static Badge

Last ran on July 24, 2024 11:17:29 CDT Checking merge of (8c6db7458e046859f45eca68faeea738a1a3876c) into main (c22a39d4710360577820b8f210d396d0d26aaaa1)

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 29.41176% with 12 lines in your changes missing coverage. Please review.

Project coverage is 87.70%. Comparing base (c22a39d) to head (bb76965).

Files Patch % Lines
src/features/page_view_event/aggregate/index.js 0.00% 6 Missing and 4 partials :warning:
src/common/timing/time-keeper.js 71.42% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1122 +/- ## ========================================== - Coverage 87.83% 87.70% -0.13% ========================================== Files 162 162 Lines 7267 7282 +15 Branches 1428 1435 +7 ========================================== + Hits 6383 6387 +4 - Misses 766 773 +7 - Partials 118 122 +4 ``` | [Flag](https://app.codecov.io/gh/newrelic/newrelic-browser-agent/pull/1122/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=newrelic) | Coverage Δ | | |---|---|---| | [unit-tests](https://app.codecov.io/gh/newrelic/newrelic-browser-agent/pull/1122/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=newrelic) | `76.21% <29.41%> (-0.17%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=newrelic#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.