mirror of
https://github.com/hashicorp/vault.git
synced 2025-12-26 11:51:42 +01:00
* Update add-to-array and remove-from-array helpers * remove search-select-has-many, moved logic directly into mfa-login-enforcement-form (see #16470) * Replace add/remove object in MFA files - All MFA tests pass * Replace in PKI components (pki tests all passing) * Replace in core addon where applicable * glimmerize console service -- console tests pass * more replacements * update string-list, add comment to vertical-bar-chart * Refactor CSP Event service - only used one place (auth-form) so simplified that usage - glimmerize and refactor so that the tests work * small updates * more cleanup * Fix tests * Remove objectAt from console-helpers * Address PR comments * move commandIndex clearing back * Remove extra model set
38 lines
845 B
JavaScript
38 lines
845 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Service from '@ember/service';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { task, waitForEvent } from 'ember-concurrency';
|
|
import { addToArray } from 'vault/helpers/add-to-array';
|
|
|
|
export default class CspEventService extends Service {
|
|
@tracked connectionViolations = [];
|
|
|
|
attach() {
|
|
this.monitor.perform();
|
|
}
|
|
|
|
remove() {
|
|
this.monitor.cancelAll();
|
|
}
|
|
|
|
handleEvent(event) {
|
|
if (event.violatedDirective.startsWith('connect-src')) {
|
|
this.connectionViolations = addToArray(this.connectionViolations, event);
|
|
}
|
|
}
|
|
|
|
@task
|
|
*monitor() {
|
|
this.connectionViolations = [];
|
|
|
|
while (true) {
|
|
const event = yield waitForEvent(window.document, 'securitypolicyviolation');
|
|
this.handleEvent(event);
|
|
}
|
|
}
|
|
}
|