Skip to content

Commit 1b0b52a

Browse files
committed
whitelist
1 parent 387159d commit 1b0b52a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## X.X.X
2+
3+
* added content whitelist
4+
15
## 25.1.0
26

37
* Mitigated an issue where content resizing did not work in certain orientations.

modules/CountlyClass.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ class CountlyClass {
214214
this.maxStackTraceLinesPerThread = getConfig("max_stack_trace_lines_per_thread", ob, configurationDefaultValues.MAX_STACKTRACE_LINES_PER_THREAD);
215215
this.maxStackTraceLineLength = getConfig("max_stack_trace_line_length", ob, configurationDefaultValues.MAX_STACKTRACE_LINE_LENGTH);
216216
this.heatmapWhitelist = getConfig("heatmap_whitelist", ob, []);
217+
this.contentWhitelist = getConfig("content_whitelist", ob, []);
217218
this.salt = getConfig("salt", ob, null);
218219
this.hcErrorCount = this.#getValueFromStorage(healthCheckCounterEnum.errorCount) || 0;
219220
this.hcWarningCount = this.#getValueFromStorage(healthCheckCounterEnum.warningCount) || 0;
@@ -276,6 +277,14 @@ class CountlyClass {
276277
}
277278
}
278279

280+
if (Array.isArray(this.contentWhitelist)) {
281+
this.contentWhitelist.push(this.url);
282+
this.contentWhitelist = this.contentWhitelist.map((e) => {
283+
// remove trailing slashes from the entries
284+
return stripTrailingSlash(e);
285+
});
286+
}
287+
279288
if ((this.passed_data && this.passed_data.app_key && this.passed_data.app_key === this.app_key) || (this.passed_data && !this.passed_data.app_key && this.#global)) {
280289
if (this.passed_data.token && this.passed_data.purpose) {
281290
if (this.passed_data.token !== this.#getValueFromStorage("cly_old_token")) {
@@ -3825,7 +3834,7 @@ class CountlyClass {
38253834
};
38263835

38273836
#interpretContentMessage = (messageEvent) => {
3828-
if (messageEvent.origin !== this.url) {
3837+
if (this.contentWhitelist.indexOf(messageEvent.origin) === -1) {
38293838
// this.#log(logLevelEnums.ERROR, "interpretContentMessage, Received message from invalid origin");
38303839
// silent ignore
38313840
return;

0 commit comments

Comments
 (0)