**Breaking changes** The livechat v13 introduced a new library to handle regular expressions in forbidden words, to avoid [ReDOS](https://en.wikipedia.org/wiki/ReDoS) attacks. Unfortunately, this library was not able to install itself properly on some systems, and some admins were not able to install the livechat plugin. That's why we have disabled this library in v14, and introduce a new settings to enable regexp in forbidden words. By default this settings is disabled, and your users won't be able to use regexp in their forbidden words. The risk by enabling this feature is that a malicious user could cause a denial of service for the chat bot, by using a special crafted regular expression in their channel options, and sending a special crafter message in one of their rooms. If you trust your users (those who have rights to livestream), you can enable the settings. Otherwise it is not recommanded. See the documentation for more informations. **Minor changes and fixes** * Channel's forbidden words: new "enable" column. * New settings to enable regular expressions for channel forbidden words. * "Channel advanced configuration" settings: removing the "experimental feature" label.
92 lines
3.0 KiB
TypeScript
92 lines
3.0 KiB
TypeScript
// SPDX-FileCopyrightText: 2024-2025 John Livingston <https://www.john-livingston.fr/>
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
// FIXME: @stylistic/indent is buggy with strings literrals.
|
|
/* eslint-disable @stylistic/indent */
|
|
|
|
import type { AdminFirewallElement } from '../elements/admin-firewall'
|
|
import type { TemplateResult } from 'lit'
|
|
import type { DynamicFormHeader, DynamicFormSchema } from '../../../lib/elements/dynamic-table-form'
|
|
import { maxFirewallFiles, maxFirewallNameLength, maxFirewallFileSize } from 'shared/lib/admin-firewall'
|
|
import { ptTr } from '../../../lib/directives/translation'
|
|
import { html } from 'lit'
|
|
|
|
export function tplAdminFirewall (el: AdminFirewallElement): TemplateResult {
|
|
const tableHeaderList: DynamicFormHeader = {
|
|
enabled: {
|
|
colName: ptTr(LOC_ENABLED)
|
|
},
|
|
name: {
|
|
colName: ptTr(LOC_PROSODY_FIREWALL_NAME),
|
|
description: ptTr(LOC_PROSODY_FIREWALL_NAME_DESC),
|
|
headerClassList: ['peertube-livechat-admin-firewall-col-name']
|
|
},
|
|
content: {
|
|
colName: ptTr(LOC_PROSODY_FIREWALL_CONTENT),
|
|
headerClassList: ['peertube-livechat-admin-firewall-col-content']
|
|
}
|
|
}
|
|
const tableSchema: DynamicFormSchema = {
|
|
enabled: {
|
|
inputType: 'checkbox',
|
|
default: true
|
|
},
|
|
name: {
|
|
inputType: 'text',
|
|
default: '',
|
|
maxlength: maxFirewallNameLength
|
|
},
|
|
content: {
|
|
inputType: 'textarea',
|
|
default: '',
|
|
maxlength: maxFirewallFileSize
|
|
}
|
|
}
|
|
|
|
return html`
|
|
<div class="margin-content peertube-plugin-livechat-admin-firewall">
|
|
<h1>
|
|
${ptTr(LOC_PROSODY_FIREWALL_CONFIGURATION)}
|
|
</h1>
|
|
<p>
|
|
${ptTr(LOC_PROSODY_FIREWALL_CONFIGURATION_HELP, true)}
|
|
<livechat-help-button .page=${'documentation/admin/mod_firewall'}>
|
|
</livechat-help-button>
|
|
</p>
|
|
${
|
|
el.firewallConfiguration?.enabled
|
|
? ''
|
|
: html`<p class="peertube-plugin-livechat-warning">${ptTr(LOC_PROSODY_FIREWALL_DISABLED_WARNING, true)}</p>`
|
|
}
|
|
|
|
<form role="form" @submit=${el.saveConfig} @change=${el.resetValidation}>
|
|
<livechat-dynamic-table-form
|
|
.header=${tableHeaderList}
|
|
.schema=${tableSchema}
|
|
.maxLines=${maxFirewallFiles}
|
|
.validation=${el.validationError?.properties}
|
|
.validationPrefix=${'files'}
|
|
.rows=${el.firewallConfiguration?.files ?? []}
|
|
@update=${(e: CustomEvent) => {
|
|
el.resetValidation(e)
|
|
if (el.firewallConfiguration) {
|
|
el.firewallConfiguration.files = e.detail
|
|
el.requestUpdate('firewallConfiguration')
|
|
}
|
|
}
|
|
}
|
|
></livechat-dynamic-table-form>
|
|
|
|
<div class="form-group mt-5">
|
|
<button type="reset" @click=${el.reset} ?disabled=${el.actionDisabled}>
|
|
${ptTr(LOC_CANCEL)}
|
|
</button>
|
|
<button type="submit" ?disabled=${el.actionDisabled}>
|
|
${ptTr(LOC_SAVE)}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>`
|
|
}
|