@newrelic/browser-agent 1.306.0-rc.1 → 1.306.0
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 +36 -22
- 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 +36 -22
- package/dist/types/common/deny-list/deny-list.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/deny-list/deny-list.js +40 -25
|
@@ -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
|
|
20
|
+
const VERSION = exports.VERSION = "1.306.0";
|
|
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
|
|
20
|
+
const VERSION = exports.VERSION = "1.306.0";
|
|
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;
|
|
32
29
|
for (var i = 0; i < denyList.length; i++) {
|
|
33
30
|
var parsed = denyList[i];
|
|
34
|
-
if (parsed.hostname
|
|
31
|
+
if (parsed.hostname === '*') {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (domainMatchesPattern(parsed.hostname, params.hostname) && comparePath(parsed.pathname, params.pathname)) {
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -54,13 +54,6 @@ 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
|
-
}
|
|
64
57
|
if (url.indexOf('http://') === 0) {
|
|
65
58
|
url = url.substring(7);
|
|
66
59
|
} else if (url.indexOf('https://') === 0) {
|
|
@@ -73,24 +66,45 @@ function setDenyList(denyListConfig) {
|
|
|
73
66
|
pathname = url.substring(firstSlash);
|
|
74
67
|
} else {
|
|
75
68
|
host = url;
|
|
76
|
-
pathname = '
|
|
69
|
+
pathname = '';
|
|
77
70
|
}
|
|
78
71
|
let [hostname] = host.split(':');
|
|
79
72
|
denyList.push({
|
|
80
|
-
hostname
|
|
81
|
-
pathname
|
|
73
|
+
hostname,
|
|
74
|
+
pathname
|
|
82
75
|
});
|
|
83
76
|
}
|
|
84
77
|
}
|
|
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
|
+
}
|
|
85
90
|
|
|
86
91
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @param {string}
|
|
89
|
-
* @param {
|
|
90
|
-
* @returns {
|
|
92
|
+
* Returns true if a URL path matches a pattern string, disregarding leading slashes.
|
|
93
|
+
* @param {string} pattern - a string to compare with path (e.g., api/v1)
|
|
94
|
+
* @param {string} path - a string representing a URL path (e.g., /api/v1)
|
|
95
|
+
* @returns {boolean} `true` if path and pattern are an exact string match (except for leading slashes); else `false`
|
|
91
96
|
*/
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
function comparePath(pattern, path) {
|
|
98
|
+
if (pattern.indexOf('/') === 0) {
|
|
99
|
+
pattern = pattern.substring(1);
|
|
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;
|
|
96
110
|
}
|
|
@@ -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;
|
|
24
21
|
for (var i = 0; i < denyList.length; i++) {
|
|
25
22
|
var parsed = denyList[i];
|
|
26
|
-
if (parsed.hostname
|
|
23
|
+
if (parsed.hostname === '*') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (domainMatchesPattern(parsed.hostname, params.hostname) && comparePath(parsed.pathname, params.pathname)) {
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -46,13 +46,6 @@ 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
|
-
}
|
|
56
49
|
if (url.indexOf('http://') === 0) {
|
|
57
50
|
url = url.substring(7);
|
|
58
51
|
} else if (url.indexOf('https://') === 0) {
|
|
@@ -65,24 +58,45 @@ export function setDenyList(denyListConfig) {
|
|
|
65
58
|
pathname = url.substring(firstSlash);
|
|
66
59
|
} else {
|
|
67
60
|
host = url;
|
|
68
|
-
pathname = '
|
|
61
|
+
pathname = '';
|
|
69
62
|
}
|
|
70
63
|
let [hostname] = host.split(':');
|
|
71
64
|
denyList.push({
|
|
72
|
-
hostname
|
|
73
|
-
pathname
|
|
65
|
+
hostname,
|
|
66
|
+
pathname
|
|
74
67
|
});
|
|
75
68
|
}
|
|
76
69
|
}
|
|
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
|
+
}
|
|
77
82
|
|
|
78
83
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @param {string}
|
|
81
|
-
* @param {
|
|
82
|
-
* @returns {
|
|
84
|
+
* Returns true if a URL path matches a pattern string, disregarding leading slashes.
|
|
85
|
+
* @param {string} pattern - a string to compare with path (e.g., api/v1)
|
|
86
|
+
* @param {string} path - a string representing a URL path (e.g., /api/v1)
|
|
87
|
+
* @returns {boolean} `true` if path and pattern are an exact string match (except for leading slashes); else `false`
|
|
83
88
|
*/
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
function comparePath(pattern, path) {
|
|
90
|
+
if (pattern.indexOf('/') === 0) {
|
|
91
|
+
pattern = pattern.substring(1);
|
|
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;
|
|
88
102
|
}
|
|
@@ -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,CAqBnB;AAED,2DAEC;AAED;;;GAGG;AACH,4CAFW,MAAM,EAAE,QAgClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newrelic/browser-agent",
|
|
3
|
-
"version": "1.306.0
|
|
3
|
+
"version": "1.306.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "New Relic Browser Agent Team <browser-agent@newrelic.com>",
|
|
6
6
|
"description": "New Relic Browser Agent",
|
|
@@ -292,4 +292,4 @@
|
|
|
292
292
|
"README.md",
|
|
293
293
|
"CHANGELOG.md"
|
|
294
294
|
]
|
|
295
|
-
}
|
|
295
|
+
}
|
|
@@ -20,14 +20,15 @@ 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
|
-
|
|
26
23
|
for (var i = 0; i < denyList.length; i++) {
|
|
27
24
|
var parsed = denyList[i]
|
|
28
25
|
|
|
29
|
-
if (parsed.hostname
|
|
30
|
-
|
|
26
|
+
if (parsed.hostname === '*') {
|
|
27
|
+
return false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (domainMatchesPattern(parsed.hostname, params.hostname) &&
|
|
31
|
+
comparePath(parsed.pathname, params.pathname)) {
|
|
31
32
|
return false
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -54,12 +55,6 @@ export function setDenyList (denyListConfig) {
|
|
|
54
55
|
let url = denyListConfig[i]
|
|
55
56
|
if (!url) continue // ignore bad values like undefined or empty strings
|
|
56
57
|
|
|
57
|
-
// short circuit if deny list entry is just a wildcard
|
|
58
|
-
if (url === '*') {
|
|
59
|
-
denyList = [{ hostname: '*' }]
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
|
|
63
58
|
if (url.indexOf('http://') === 0) {
|
|
64
59
|
url = url.substring(7)
|
|
65
60
|
} else if (url.indexOf('https://') === 0) {
|
|
@@ -73,26 +68,46 @@ export function setDenyList (denyListConfig) {
|
|
|
73
68
|
pathname = url.substring(firstSlash)
|
|
74
69
|
} else {
|
|
75
70
|
host = url
|
|
76
|
-
pathname = '
|
|
71
|
+
pathname = ''
|
|
77
72
|
}
|
|
78
73
|
let [hostname] = host.split(':')
|
|
79
74
|
|
|
80
|
-
denyList.push({
|
|
81
|
-
hostname: convertToRegularExpression(hostname),
|
|
82
|
-
pathname: convertToRegularExpression(pathname, true)
|
|
83
|
-
})
|
|
75
|
+
denyList.push({ hostname, pathname })
|
|
84
76
|
}
|
|
85
77
|
}
|
|
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
|
+
}
|
|
86
91
|
|
|
87
92
|
/**
|
|
88
|
-
*
|
|
89
|
-
* @param {string}
|
|
90
|
-
* @param {
|
|
91
|
-
* @returns {
|
|
93
|
+
* Returns true if a URL path matches a pattern string, disregarding leading slashes.
|
|
94
|
+
* @param {string} pattern - a string to compare with path (e.g., api/v1)
|
|
95
|
+
* @param {string} path - a string representing a URL path (e.g., /api/v1)
|
|
96
|
+
* @returns {boolean} `true` if path and pattern are an exact string match (except for leading slashes); else `false`
|
|
92
97
|
*/
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
function comparePath (pattern, path) {
|
|
99
|
+
if (pattern.indexOf('/') === 0) {
|
|
100
|
+
pattern = pattern.substring(1)
|
|
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
|
|
98
113
|
}
|