Skip to content

Commit

Permalink
Prevent errors in Express 5.x applications (#4872)
Browse files Browse the repository at this point in the history
* Fix integration by preventing unsafe access to properties.

---------

Co-authored-by: William Conti <[email protected]>
Co-authored-by: William Conti <[email protected]>
  • Loading branch information
3 people authored Nov 12, 2024
1 parent 0a44e6e commit b81d9d8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/datadog-instrumentations/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ function createWrapRouterMethod (name) {
path: pattern instanceof RegExp ? `(${pattern})` : pattern,
test: layer => {
const matchers = layerMatchers.get(layer)

return !isFastStar(layer, matchers) &&
!isFastSlash(layer, matchers) &&
cachedPathToRegExp(pattern).test(layer.path)
Expand All @@ -121,15 +120,15 @@ function createWrapRouterMethod (name) {
}

function isFastStar (layer, matchers) {
if (layer.regexp.fast_star !== undefined) {
if (layer.regexp?.fast_star !== undefined) {
return layer.regexp.fast_star
}

return matchers.some(matcher => matcher.path === '*')
}

function isFastSlash (layer, matchers) {
if (layer.regexp.fast_slash !== undefined) {
if (layer.regexp?.fast_slash !== undefined) {
return layer.regexp.fast_slash
}

Expand Down

0 comments on commit b81d9d8

Please sign in to comment.