Skip to content

Commit

Permalink
fix(2.3): Disable phpcs Magento2.Legacy.EscapeMethodsOnBlockClass for…
Browse files Browse the repository at this point in the history
… some templates
  • Loading branch information
julienloizelet committed Jan 25, 2024
1 parent 6a88777 commit 4c046f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
8 changes: 6 additions & 2 deletions view/adminhtml/templates/report/events-list-title.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
* @author CrowdSec team
*
*/
/**
*
* @phpcs:disable Magento2.Legacy.EscapeMethodsOnBlockClass
*
*/

/** @var \Magento\Backend\Block\Template $block */
/** @var \Magento\Framework\Escaper $escaper */
?>

<div>
<h2 class="crowdsec-engine-report-subtitle"><?= $escaper->escapeHtml(__('Detected events list'))?></h2>
<h2 class="crowdsec-engine-report-subtitle"><?= $block->escapeHtml(__('Detected events list'))?></h2>
</div>


42 changes: 23 additions & 19 deletions view/adminhtml/templates/report/metrics.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,36 @@
* @author CrowdSec team
*
*/
/**
*
* @phpcs:disable Magento2.Legacy.EscapeMethodsOnBlockClass
*
*/

/** @var \CrowdSec\Engine\Block\Adminhtml\Report\Metrics $block */
/** @var \Magento\Framework\Escaper $escaper */
?>

<?php
$origins = $block->getOriginsCount();
?>

<div id="crowdsec-engine-remediation-metrics" >
<h2 class="crowdsec-engine-report-subtitle"><?= $escaper->escapeHtml(__('Metrics')) ?></h2>
<h2 class="crowdsec-engine-report-subtitle"><?= $block->escapeHtml(__('Metrics')) ?></h2>
<div class="description">
<h3><?= $escaper->escapeHtml(__('Current bouncing behaviors settings')) ?></h3>
<h3><?= $block->escapeHtml(__('Current bouncing behaviors settings')) ?></h3>
<ul>
<li>&bull;
<?php if ($block->isLocalBanEnabled()): ?>
<?=
$escaper->escapeHtml(
$block->escapeHtml(
__('<i>Ban IP locally</i> <b>enabled</b>
&rarr; When a Magento scenario triggers an alert, IP <b>is banned</b> locally.'),
['i','a','b']
)
?>
<?php else: ?>
<?=
$escaper->escapeHtml(
$block->escapeHtml(
__('<i>Ban IP locally</i> <b>disabled</b>
&rarr; When a Magento scenario triggers an alert, IP <b>is not banned locally</b>.'),
['i','a','b']
Expand All @@ -59,69 +63,69 @@
<li>&bull;
<?php if ($block->isBanBouncingEnabled()): ?>
<?=
$escaper->escapeHtml(
$block->escapeHtml(
__('<i>Block banned IP</i> <b>enabled</b>
&rarr; Access is currently <b>blocked</b> for banned IP addresses.'),
['i','a','b']
) ?>
<?php else: ?>
<?=
$escaper->escapeHtml(
$block->escapeHtml(
__('<i>Block banned IP</i> <b>disabled</b>
&rarr; Access is currently <b>allowed</b> for banned IP addresses.'),
['i','a','b']
) ?>
<?php endif; ?>
</li>
</ul>
<p class="notice"><?= $escaper->escapeHtml(__(
<p class="notice"><?= $block->escapeHtml(__(
'You can change these behaviors by modifying decisions settings <a href="%1">here</a>.',
$block->getSettingsUrl() .'#crowdsec_engine_decisions-link'
), ['i','a','b'])
?></p>
</div>
<div class="description">
<h3><?= $escaper->escapeHtml(__('Decision metrics')) ?><sup>(1)</sup></h3>
<h3><?= $block->escapeHtml(__('Decision metrics')) ?><sup>(1)</sup></h3>
</div>

<div class="admin_data-grid-wrap">
<table id="crowdsec-engine-metrics" class="data-grid">
<thead>
<th class="data_grid-th">
<span class="data-grid-cell-content">
<?= $escaper->escapeHtml(__('Origin of the decision')) ?>
<?= $block->escapeHtml(__('Origin of the decision')) ?>
</span>
</th>
<th class="data_grid-th">
<span class="data-grid-cell-content"><?= $escaper->escapeHtml(__('Count')) ?></span>
<span class="data-grid-cell-content"><?= $block->escapeHtml(__('Count')) ?></span>
</th>
</thead>
<tbody>
<tr class="data-row">
<td class="origin">
<?= $escaper->escapeHtml(__('CrowdSec Engine extension (Local decision)')) ?>
<?= $block->escapeHtml(__('CrowdSec Engine extension (Local decision)')) ?>
</td>
<td class="count"><?= $escaper->escapeHtml($origins[$block->getOriginCrowdsec()] ?? 0) ?></td>
<td class="count"><?= $block->escapeHtml($origins[$block->getOriginCrowdsec()] ?? 0) ?></td>
</tr>
<tr class="data-row">
<td class="origin"><?= $escaper->escapeHtml(__('CrowdSec Community blocklist')) ?></td>
<td class="count"><?= $escaper->escapeHtml($origins[$block->getOriginCapi()] ?? 0) ?></td>
<td class="origin"><?= $block->escapeHtml(__('CrowdSec Community blocklist')) ?></td>
<td class="count"><?= $block->escapeHtml($origins[$block->getOriginCapi()] ?? 0) ?></td>
</tr>
<tr class="data-row">
<td class="origin"><?= $escaper->escapeHtml(__('Subscribed third-party blocklists')) ?></td>
<td class="count"><?= $escaper->escapeHtml($origins[$block->getOriginLists()] ?? 0) ?></td>
<td class="origin"><?= $block->escapeHtml(__('Subscribed third-party blocklists')) ?></td>
<td class="count"><?= $block->escapeHtml($origins[$block->getOriginLists()] ?? 0) ?></td>
</tr>
</tbody>
</table>
</div>
<div>
<p><span>1. </span>
<?= $escaper->escapeHtml(
<?= $block->escapeHtml(
__('This module stores CrowdSec decision metrics only if the <i>Block banned IP</i> setting is enabled.'),
['i']
) ?><br>
<?=
$escaper->escapeHtml(
$block->escapeHtml(
__('As this information is stored in cache,
it will be reset if you clear the CrowdSec Engine cache.')
)?>
Expand Down

0 comments on commit 4c046f4

Please sign in to comment.