@newrelic/browser-agent 1.306.0-rc.0 → 1.306.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/constants/env.cdn.js +1 -1
- package/dist/cjs/common/constants/env.npm.js +1 -1
- package/dist/cjs/common/deny-list/deny-list.js +22 -36
- package/dist/esm/common/constants/env.cdn.js +1 -1
- package/dist/esm/common/constants/env.npm.js +1 -1
- package/dist/esm/common/deny-list/deny-list.js +22 -36
- package/dist/types/common/deny-list/deny-list.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/deny-list/deny-list.js +25 -40
|
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.RRWEB_PACKAGE_NAME = exports.D
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the version of the agent
|
|
19
19
|
*/
|
|
20
|
-
const VERSION = exports.VERSION = "1.306.0-rc.
|
|
20
|
+
const VERSION = exports.VERSION = "1.306.0-rc.2";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Exposes the build type of the agent
|
|
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.RRWEB_PACKAGE_NAME = exports.D
|
|
|
17
17
|
/**
|
|
18
18
|
* Exposes the version of the agent
|
|
19
19
|
*/
|
|
20
|
-
const VERSION = exports.VERSION = "1.306.0-rc.
|
|
20
|
+
const VERSION = exports.VERSION = "1.306.0-rc.2";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Exposes the build type of the agent
|
|
@@ -26,12 +26,12 @@ var denyList = [];
|
|
|
26
26
|
function shouldCollectEvent(params) {
|
|
27
27
|
if (!params || hasUndefinedHostname(params)) return false;
|
|
28
28
|
if (denyList.length === 0) return true;
|
|
29
|
+
|
|
30
|
+
// short circuit if deny list contains just a wildcard
|
|
31
|
+
if (denyList[0].hostname === '*') return false;
|
|
29
32
|
for (var i = 0; i < denyList.length; i++) {
|
|
30
33
|
var parsed = denyList[i];
|
|
31
|
-
if (parsed.hostname
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
if (domainMatchesPattern(parsed.hostname, params.hostname) && comparePath(parsed.pathname, params.pathname)) {
|
|
34
|
+
if (parsed.hostname.test(params.hostname) && parsed.pathname.test(params.pathname)) {
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -54,6 +54,13 @@ function setDenyList(denyListConfig) {
|
|
|
54
54
|
let url = denyListConfig[i];
|
|
55
55
|
if (!url) continue; // ignore bad values like undefined or empty strings
|
|
56
56
|
|
|
57
|
+
// short circuit if deny list entry is just a wildcard
|
|
58
|
+
if (url === '*') {
|
|
59
|
+
denyList = [{
|
|
60
|
+
hostname: '*'
|
|
61
|
+
}];
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
57
64
|
if (url.indexOf('http://') === 0) {
|
|
58
65
|
url = url.substring(7);
|
|
59
66
|
} else if (url.indexOf('https://') === 0) {
|
|
@@ -66,45 +73,24 @@ function setDenyList(denyListConfig) {
|
|
|
66
73
|
pathname = url.substring(firstSlash);
|
|
67
74
|
} else {
|
|
68
75
|
host = url;
|
|
69
|
-
pathname = '';
|
|
76
|
+
pathname = '*';
|
|
70
77
|
}
|
|
71
78
|
let [hostname] = host.split(':');
|
|
72
79
|
denyList.push({
|
|
73
|
-
hostname,
|
|
74
|
-
pathname
|
|
80
|
+
hostname: convertToRegularExpression(hostname),
|
|
81
|
+
pathname: convertToRegularExpression(pathname, true)
|
|
75
82
|
});
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Returns true if the right side of `domain` (end of string) matches `pattern`.
|
|
80
|
-
* @param {string} pattern - a string to be matched against the end of `domain` string
|
|
81
|
-
* @param {string} domain - a domain string with no protocol or path (e.g., app1.example.com)
|
|
82
|
-
* @returns {boolean} `true` if domain matches pattern; else `false`
|
|
83
|
-
*/
|
|
84
|
-
function domainMatchesPattern(pattern, domain) {
|
|
85
|
-
if (pattern.length > domain.length) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
return domain.indexOf(pattern) === domain.length - pattern.length;
|
|
89
|
-
}
|
|
90
85
|
|
|
91
86
|
/**
|
|
92
|
-
*
|
|
93
|
-
* @param {string}
|
|
94
|
-
* @param {
|
|
95
|
-
* @returns {
|
|
87
|
+
* Converts a deny list filter string into a regular expression object with wildcard support
|
|
88
|
+
* @param {string} filter - deny list filter to convert
|
|
89
|
+
* @param {boolean} [isPathname=false] - indicates if the filter is a pathname
|
|
90
|
+
* @returns {RegExp} - regular expression object built from the input string
|
|
96
91
|
*/
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (path.indexOf('/') === 0) {
|
|
102
|
-
path = path.substring(1);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// No path in pattern means match all paths.
|
|
106
|
-
if (pattern === '') {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
return pattern === path;
|
|
92
|
+
function convertToRegularExpression(filter, isPathname = false) {
|
|
93
|
+
const newFilter = filter.replace(/[.+?^${}()|[\]\\]/g, m => '\\' + m) // use a replacer function to not break apm injection
|
|
94
|
+
.replace(/\*/g, '.*?'); // use lazy matching instead of greedy
|
|
95
|
+
return new RegExp((isPathname ? '^' : '') + newFilter + '$');
|
|
110
96
|
}
|
|
@@ -18,12 +18,12 @@ var denyList = [];
|
|
|
18
18
|
export function shouldCollectEvent(params) {
|
|
19
19
|
if (!params || hasUndefinedHostname(params)) return false;
|
|
20
20
|
if (denyList.length === 0) return true;
|
|
21
|
+
|
|
22
|
+
// short circuit if deny list contains just a wildcard
|
|
23
|
+
if (denyList[0].hostname === '*') return false;
|
|
21
24
|
for (var i = 0; i < denyList.length; i++) {
|
|
22
25
|
var parsed = denyList[i];
|
|
23
|
-
if (parsed.hostname
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
if (domainMatchesPattern(parsed.hostname, params.hostname) && comparePath(parsed.pathname, params.pathname)) {
|
|
26
|
+
if (parsed.hostname.test(params.hostname) && parsed.pathname.test(params.pathname)) {
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -46,6 +46,13 @@ export function setDenyList(denyListConfig) {
|
|
|
46
46
|
let url = denyListConfig[i];
|
|
47
47
|
if (!url) continue; // ignore bad values like undefined or empty strings
|
|
48
48
|
|
|
49
|
+
// short circuit if deny list entry is just a wildcard
|
|
50
|
+
if (url === '*') {
|
|
51
|
+
denyList = [{
|
|
52
|
+
hostname: '*'
|
|
53
|
+
}];
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
49
56
|
if (url.indexOf('http://') === 0) {
|
|
50
57
|
url = url.substring(7);
|
|
51
58
|
} else if (url.indexOf('https://') === 0) {
|
|
@@ -58,45 +65,24 @@ export function setDenyList(denyListConfig) {
|
|
|
58
65
|
pathname = url.substring(firstSlash);
|
|
59
66
|
} else {
|
|
60
67
|
host = url;
|
|
61
|
-
pathname = '';
|
|
68
|
+
pathname = '*';
|
|
62
69
|
}
|
|
63
70
|
let [hostname] = host.split(':');
|
|
64
71
|
denyList.push({
|
|
65
|
-
hostname,
|
|
66
|
-
pathname
|
|
72
|
+
hostname: convertToRegularExpression(hostname),
|
|
73
|
+
pathname: convertToRegularExpression(pathname, true)
|
|
67
74
|
});
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Returns true if the right side of `domain` (end of string) matches `pattern`.
|
|
72
|
-
* @param {string} pattern - a string to be matched against the end of `domain` string
|
|
73
|
-
* @param {string} domain - a domain string with no protocol or path (e.g., app1.example.com)
|
|
74
|
-
* @returns {boolean} `true` if domain matches pattern; else `false`
|
|
75
|
-
*/
|
|
76
|
-
function domainMatchesPattern(pattern, domain) {
|
|
77
|
-
if (pattern.length > domain.length) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
return domain.indexOf(pattern) === domain.length - pattern.length;
|
|
81
|
-
}
|
|
82
77
|
|
|
83
78
|
/**
|
|
84
|
-
*
|
|
85
|
-
* @param {string}
|
|
86
|
-
* @param {
|
|
87
|
-
* @returns {
|
|
79
|
+
* Converts a deny list filter string into a regular expression object with wildcard support
|
|
80
|
+
* @param {string} filter - deny list filter to convert
|
|
81
|
+
* @param {boolean} [isPathname=false] - indicates if the filter is a pathname
|
|
82
|
+
* @returns {RegExp} - regular expression object built from the input string
|
|
88
83
|
*/
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (path.indexOf('/') === 0) {
|
|
94
|
-
path = path.substring(1);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// No path in pattern means match all paths.
|
|
98
|
-
if (pattern === '') {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
return pattern === path;
|
|
84
|
+
function convertToRegularExpression(filter, isPathname = false) {
|
|
85
|
+
const newFilter = filter.replace(/[.+?^${}()|[\]\\]/g, m => '\\' + m) // use a replacer function to not break apm injection
|
|
86
|
+
.replace(/\*/g, '.*?'); // use lazy matching instead of greedy
|
|
87
|
+
return new RegExp((isPathname ? '^' : '') + newFilter + '$');
|
|
102
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deny-list.d.ts","sourceRoot":"","sources":["../../../../src/common/deny-list/deny-list.js"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,2CAHW,MAAM,GACJ,OAAO,
|
|
1
|
+
{"version":3,"file":"deny-list.d.ts","sourceRoot":"","sources":["../../../../src/common/deny-list/deny-list.js"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,2CAHW,MAAM,GACJ,OAAO,CAoBnB;AAED,2DAEC;AAED;;;GAGG;AACH,4CAFW,MAAM,EAAE,QAyClB"}
|
package/package.json
CHANGED
|
@@ -20,15 +20,14 @@ export function shouldCollectEvent (params) {
|
|
|
20
20
|
|
|
21
21
|
if (denyList.length === 0) return true
|
|
22
22
|
|
|
23
|
+
// short circuit if deny list contains just a wildcard
|
|
24
|
+
if (denyList[0].hostname === '*') return false
|
|
25
|
+
|
|
23
26
|
for (var i = 0; i < denyList.length; i++) {
|
|
24
27
|
var parsed = denyList[i]
|
|
25
28
|
|
|
26
|
-
if (parsed.hostname
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (domainMatchesPattern(parsed.hostname, params.hostname) &&
|
|
31
|
-
comparePath(parsed.pathname, params.pathname)) {
|
|
29
|
+
if (parsed.hostname.test(params.hostname) &&
|
|
30
|
+
parsed.pathname.test(params.pathname)) {
|
|
32
31
|
return false
|
|
33
32
|
}
|
|
34
33
|
}
|
|
@@ -55,6 +54,12 @@ export function setDenyList (denyListConfig) {
|
|
|
55
54
|
let url = denyListConfig[i]
|
|
56
55
|
if (!url) continue // ignore bad values like undefined or empty strings
|
|
57
56
|
|
|
57
|
+
// short circuit if deny list entry is just a wildcard
|
|
58
|
+
if (url === '*') {
|
|
59
|
+
denyList = [{ hostname: '*' }]
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
58
63
|
if (url.indexOf('http://') === 0) {
|
|
59
64
|
url = url.substring(7)
|
|
60
65
|
} else if (url.indexOf('https://') === 0) {
|
|
@@ -68,46 +73,26 @@ export function setDenyList (denyListConfig) {
|
|
|
68
73
|
pathname = url.substring(firstSlash)
|
|
69
74
|
} else {
|
|
70
75
|
host = url
|
|
71
|
-
pathname = ''
|
|
76
|
+
pathname = '*'
|
|
72
77
|
}
|
|
73
78
|
let [hostname] = host.split(':')
|
|
74
79
|
|
|
75
|
-
denyList.push({
|
|
80
|
+
denyList.push({
|
|
81
|
+
hostname: convertToRegularExpression(hostname),
|
|
82
|
+
pathname: convertToRegularExpression(pathname, true)
|
|
83
|
+
})
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Returns true if the right side of `domain` (end of string) matches `pattern`.
|
|
80
|
-
* @param {string} pattern - a string to be matched against the end of `domain` string
|
|
81
|
-
* @param {string} domain - a domain string with no protocol or path (e.g., app1.example.com)
|
|
82
|
-
* @returns {boolean} `true` if domain matches pattern; else `false`
|
|
83
|
-
*/
|
|
84
|
-
function domainMatchesPattern (pattern, domain) {
|
|
85
|
-
if (pattern.length > domain.length) {
|
|
86
|
-
return false
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return domain.indexOf(pattern) === (domain.length - pattern.length)
|
|
90
|
-
}
|
|
91
86
|
|
|
92
87
|
/**
|
|
93
|
-
*
|
|
94
|
-
* @param {string}
|
|
95
|
-
* @param {
|
|
96
|
-
* @returns {
|
|
88
|
+
* Converts a deny list filter string into a regular expression object with wildcard support
|
|
89
|
+
* @param {string} filter - deny list filter to convert
|
|
90
|
+
* @param {boolean} [isPathname=false] - indicates if the filter is a pathname
|
|
91
|
+
* @returns {RegExp} - regular expression object built from the input string
|
|
97
92
|
*/
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (path.indexOf('/') === 0) {
|
|
104
|
-
path = path.substring(1)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// No path in pattern means match all paths.
|
|
108
|
-
if (pattern === '') {
|
|
109
|
-
return true
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return pattern === path
|
|
93
|
+
function convertToRegularExpression (filter, isPathname = false) {
|
|
94
|
+
const newFilter = filter
|
|
95
|
+
.replace(/[.+?^${}()|[\]\\]/g, (m) => '\\' + m) // use a replacer function to not break apm injection
|
|
96
|
+
.replace(/\*/g, '.*?') // use lazy matching instead of greedy
|
|
97
|
+
return new RegExp((isPathname ? '^' : '') + newFilter + '$')
|
|
113
98
|
}
|