Commit version 24.12.13800
This commit is contained in:
@ -4,7 +4,11 @@ $base_dir = realpath(__DIR__ . '/..');
|
||||
$config['install_dir'] = $base_dir;
|
||||
|
||||
include(__DIR__ . '/../includes/defaults.inc.php');
|
||||
//include(dirname(__FILE__) . '/../config.php');
|
||||
//include(dirname(__FILE__) . '/../config.php'); // Do not include user editable config here
|
||||
include(__DIR__ . "/../includes/polyfill.inc.php");
|
||||
include(__DIR__ . "/../includes/autoloader.inc.php");
|
||||
include(__DIR__ . "/../includes/debugging.inc.php");
|
||||
require_once(__DIR__ ."/../includes/constants.inc.php");
|
||||
include(__DIR__ . '/../includes/common.inc.php');
|
||||
include(__DIR__ . '/../includes/definitions.inc.php');
|
||||
include(__DIR__ . '/../includes/functions.inc.php');
|
||||
@ -47,7 +51,7 @@ class HtmlIncludesPrintTest extends \PHPUnit\Framework\TestCase
|
||||
<th style="width: 20px;"></th>
|
||||
<th style="width: 150px;"><a href="routing/protocol=bgp/type=all/sort=peer_ip/">Peer address</a></th>
|
||||
<th style="width: 50px;"><a href="routing/protocol=bgp/type=all/sort=type/">Type</a></th>
|
||||
<th >Family</th>
|
||||
<th>Family</th>
|
||||
<th><a href="routing/protocol=bgp/type=all/sort=peer_as/">Remote AS</a></th>
|
||||
<th><a href="routing/protocol=bgp/type=all/sort=state/">State</a></th>
|
||||
<th>Uptime / Updates</th>
|
||||
@ -64,8 +68,8 @@ class HtmlIncludesPrintTest extends \PHPUnit\Framework\TestCase
|
||||
<th style="width: 150px;"><a href="routing/protocol=bgp/type=all/sort=device/">Local address</a></th>
|
||||
<th style="width: 20px;"></th>
|
||||
<th style="width: 150px;"><a href="routing/protocol=bgp/type=all/sort=peer_ip/">Peer address</a></th>
|
||||
<th style="width: 50px;"><a href="routing/protocol=bgp/type=all/sort=type/sort_order=desc/">Type <i class="small glyphicon glyphicon-triangle-bottom"></i></a></th>
|
||||
<th >Family</th>
|
||||
<th style="width: 50px;"><a href="routing/protocol=bgp/type=all/sort=type/sort_order=desc/"><span class="text-primary" style="font-style: italic">Type</span> <i class="text-primary small glyphicon glyphicon-arrow-up"></i></a></th>
|
||||
<th>Family</th>
|
||||
<th><a href="routing/protocol=bgp/type=all/sort=peer_as/">Remote AS</a></th>
|
||||
<th><a href="routing/protocol=bgp/type=all/sort=state/">State</a></th>
|
||||
<th>Uptime / Updates</th>
|
||||
@ -83,7 +87,7 @@ class HtmlIncludesPrintTest extends \PHPUnit\Framework\TestCase
|
||||
<th style="width: 20px;"></th>
|
||||
<th style="width: 150px;">Peer address</th>
|
||||
<th style="width: 50px;">Type</th>
|
||||
<th >Family</th>
|
||||
<th>Family</th>
|
||||
<th>Remote AS</th>
|
||||
<th>State</th>
|
||||
<th>Uptime / Updates</th>
|
||||
@ -94,6 +98,198 @@ class HtmlIncludesPrintTest extends \PHPUnit\Framework\TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerGenerateTableHeader
|
||||
* @group common
|
||||
*/
|
||||
public function testGenerateTableHeader($cols, $result, $vars = [])
|
||||
{
|
||||
$this->assertSame($result, generate_table_header($cols, $vars));
|
||||
}
|
||||
|
||||
public function providerGenerateTableHeader()
|
||||
{
|
||||
$ports_basic = [
|
||||
'state-marker' => '',
|
||||
[ NULL, 'style' => "width: 1px;" ],
|
||||
'device' => [ 'device' => 'Device', 'style' => "min-width: 150px;"],
|
||||
[ 'port' => 'Port Name', 'descr' => 'Description', 'errors' => 'Errors', 'style' => "min-width: 250px;"],
|
||||
[ 'traffic' => [ 'Bits', 'subfields' => [ 'traffic_in' => 'In', 'traffic_out' => 'Out' ] ], 'style' => "width: 100px;" ],
|
||||
[ 'traffic_perc' => [ '%', 'subfields' => [ 'traffic_perc_in' => 'In', 'traffic_perc_out' => 'Out' ] ], 'style' => "width: 110px;" ],
|
||||
[ 'packets' => [ 'Pkts', 'subfields' => [ 'packets_in' => 'In', 'packets_out' => 'Out' ] ], 'style' => "width: 90px;" ],
|
||||
[ 'speed' => 'Speed', 'mtu' => 'MTU', 'style' => "width: 90px;" ],
|
||||
[ 'media' => 'Media', 'mac' => 'MAC', 'style' => "width: 150px;" ]
|
||||
];
|
||||
|
||||
$ports_detail = [
|
||||
'state-marker' => '',
|
||||
[ NULL, 'style' => "width: 1px;" ],
|
||||
'device' => [ 'device' => 'Device', 'style' => "min-width: 150px;" ],
|
||||
[ 'port' => 'Port Name', 'descr' => 'Description', 'errors' => 'Errors', 'style' => "min-width: 250px;" ],
|
||||
[ NULL ],
|
||||
[ 'traffic' => [ 'Bits', 'subfields' => [ 'traffic_in' => 'In', 'traffic_out' => 'Out' ] ],
|
||||
'packets' => [ 'Pkts', 'subfields' => [ 'packets_in' => 'In', 'packets_out' => 'Out' ] ], 'style' => "width: 100px;" ],
|
||||
[ 'media' => "Media", 'speed' => 'Speed' ],
|
||||
[ 'mac' => "MAC" ],
|
||||
];
|
||||
|
||||
$ports_detail2 = [
|
||||
'state-marker' => '',
|
||||
[ NULL, 'style' => "width: 1px;" ],
|
||||
[ 'device' => 'Device', 'style' => "min-width: 150px;" ],
|
||||
[ 'port' => 'Port Name', 'descr' => 'Description', 'errors' => 'Errors', 'style' => "min-width: 250px;" ],
|
||||
[ NULL ],
|
||||
[ 'traffic' => [ 'Bits', 'subfields' => [ 'traffic_in' => 'In', 'traffic_out' => 'Out' ] ],
|
||||
'packets' => [ 'Pkts', 'subfields' => [ 'packets_in' => 'In', 'packets_out' => 'Out' ] ], 'style' => "width: 100px;" ],
|
||||
[ 'media' => "Media", 'speed' => 'Speed' ],
|
||||
[ 'mac' => "MAC" ],
|
||||
];
|
||||
|
||||
$mixed = [
|
||||
'class' => 'header',
|
||||
'style' => 'width: 100%;',
|
||||
'state-marker' => '',
|
||||
[ 'Date', 'style' => 'width: 150px;' ],
|
||||
[ 'user' => 'User' ],
|
||||
[ 'from' => 'From' ],
|
||||
[ 'User-Agent', 'style' => 'width: 200px;' ],
|
||||
[ 'Action', 'Test' ],
|
||||
];
|
||||
|
||||
$array = [];
|
||||
|
||||
$array[] = [
|
||||
$ports_basic,
|
||||
' <thead>
|
||||
<tr>
|
||||
<th class="state-marker"></th>
|
||||
<th style="width: 1px;"></th>
|
||||
<th style="min-width: 150px;"><a href="ports/format=list/view=basic/sort=device/">Device</a></th>
|
||||
<th style="min-width: 250px;"><a href="ports/format=list/view=basic/sort=port/">Port Name</a> / <a href="ports/format=list/view=basic/sort=descr/">Description</a> / <a href="ports/format=list/view=basic/sort=errors/">Errors</a></th>
|
||||
<th style="width: 100px;"><a href="ports/format=list/view=basic/sort=traffic/">Bits</a> [<a href="ports/format=list/view=basic/sort=traffic_in/">In</a> / <a href="ports/format=list/view=basic/sort=traffic_out/">Out</a>]</th>
|
||||
<th style="width: 110px;"><a href="ports/format=list/view=basic/sort=traffic_perc/">%</a> [<a href="ports/format=list/view=basic/sort=traffic_perc_in/">In</a> / <a href="ports/format=list/view=basic/sort=traffic_perc_out/">Out</a>]</th>
|
||||
<th style="width: 90px;"><a href="ports/format=list/view=basic/sort=packets/">Pkts</a> [<a href="ports/format=list/view=basic/sort=packets_in/">In</a> / <a href="ports/format=list/view=basic/sort=packets_out/">Out</a>]</th>
|
||||
<th style="width: 90px;"><a href="ports/format=list/view=basic/sort=speed/">Speed</a> / <a href="ports/format=list/view=basic/sort=mtu/">MTU</a></th>
|
||||
<th style="width: 150px;"><a href="ports/format=list/view=basic/sort=media/">Media</a> / <a href="ports/format=list/view=basic/sort=mac/">MAC</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
',
|
||||
[ 'page' => 'ports', 'format' => 'list', 'view' => 'basic' ]
|
||||
];
|
||||
|
||||
$array[] = [
|
||||
$ports_detail,
|
||||
' <thead>
|
||||
<tr>
|
||||
<th class="state-marker"></th>
|
||||
<th style="width: 1px;"></th>
|
||||
<th style="min-width: 150px;"><a href="ports/format=list/view=detail/sort=device/">Device</a></th>
|
||||
<th style="min-width: 250px;"><a href="ports/format=list/view=detail/sort=port/">Port Name</a> / <a href="ports/format=list/view=detail/sort=descr/">Description</a> / <a href="ports/format=list/view=detail/sort=errors/">Errors</a></th>
|
||||
<th></th>
|
||||
<th style="width: 100px;"><a href="ports/format=list/view=detail/sort=traffic/">Bits</a> [<a href="ports/format=list/view=detail/sort=traffic_in/">In</a> / <a href="ports/format=list/view=detail/sort=traffic_out/">Out</a>] / <a href="ports/format=list/view=detail/sort=packets/">Pkts</a> [<a href="ports/format=list/view=detail/sort=packets_in/">In</a> / <a href="ports/format=list/view=detail/sort=packets_out/">Out</a>]</th>
|
||||
<th><a href="ports/format=list/view=detail/sort=media/">Media</a> / <a href="ports/format=list/view=detail/sort=speed/">Speed</a></th>
|
||||
<th><a href="ports/format=list/view=detail/sort=mac/">MAC</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
',
|
||||
[ 'page' => 'ports', 'format' => 'list', 'view' => 'detail' ]
|
||||
];
|
||||
|
||||
$array[] = [
|
||||
$ports_detail2,
|
||||
' <thead>
|
||||
<tr>
|
||||
<th class="state-marker"></th>
|
||||
<th style="width: 1px;"></th>
|
||||
<th style="min-width: 150px;"><a href="ports/format=list/view=detail/sort=device/">Device</a></th>
|
||||
<th style="min-width: 250px;"><a href="ports/format=list/view=detail/sort=port/">Port Name</a> / <a href="ports/format=list/view=detail/sort=descr/">Description</a> / <a href="ports/format=list/view=detail/sort=errors/">Errors</a></th>
|
||||
<th></th>
|
||||
<th style="width: 100px;"><a href="ports/format=list/view=detail/sort=traffic/">Bits</a> [<a href="ports/format=list/view=detail/sort=traffic_in/">In</a> / <a href="ports/format=list/view=detail/sort=traffic_out/">Out</a>] / <a href="ports/format=list/view=detail/sort=packets/">Pkts</a> [<a href="ports/format=list/view=detail/sort=packets_in/">In</a> / <a href="ports/format=list/view=detail/sort=packets_out/">Out</a>]</th>
|
||||
<th><a href="ports/format=list/view=detail/sort=media/">Media</a> / <a href="ports/format=list/view=detail/sort=speed/">Speed</a></th>
|
||||
<th><a href="ports/format=list/view=detail/sort=mac/">MAC</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
',
|
||||
[ 'page' => 'ports', 'format' => 'list', 'view' => 'detail' ]
|
||||
];
|
||||
|
||||
$array[] = [
|
||||
$mixed,
|
||||
' <thead class="header" style="width: 100%;">
|
||||
<tr>
|
||||
<th class="state-marker"></th>
|
||||
<th style="width: 150px;">Date</th>
|
||||
<th><a href="/sort=user/">User</a></th>
|
||||
<th><a href="/sort=from/">From</a></th>
|
||||
<th style="width: 200px;">User-Agent</th>
|
||||
<th>Action / Test</th>
|
||||
</tr>
|
||||
</thead>
|
||||
',
|
||||
[ TRUE ] // just not empty vars
|
||||
];
|
||||
|
||||
$array[] = [
|
||||
$mixed,
|
||||
' <thead class="header" style="line-height: 0; visibility: collapse;">
|
||||
<tr>
|
||||
<th class="state-marker"></th>
|
||||
<th style="width: 150px;">Date</th>
|
||||
<th><a href="/sort=user/">User</a></th>
|
||||
<th><a href="/sort=from/">From</a></th>
|
||||
<th style="width: 200px;">User-Agent</th>
|
||||
<th>Action / Test</th>
|
||||
</tr>
|
||||
</thead>
|
||||
',
|
||||
[ 'show_header' => 0 ]
|
||||
];
|
||||
|
||||
$array[] = [
|
||||
$mixed,
|
||||
' <thead class="header" style="width: 100%;">
|
||||
<tr>
|
||||
<th class="state-marker"></th>
|
||||
<th style="width: 150px;">Date</th>
|
||||
<th>User</th>
|
||||
<th>From</th>
|
||||
<th style="width: 200px;">User-Agent</th>
|
||||
<th>Action / Test</th>
|
||||
</tr>
|
||||
</thead>
|
||||
',
|
||||
[ 'show_sort' => 0 ]
|
||||
];
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerGenerateButtonGroup
|
||||
* @group common
|
||||
*/
|
||||
public function testGenerateButtonGroup($buttons, $opts, $result)
|
||||
{
|
||||
$this->assertSame($result, generate_button_group($buttons, $opts));
|
||||
}
|
||||
|
||||
public function providerGenerateButtonGroup()
|
||||
{
|
||||
return [
|
||||
[
|
||||
[
|
||||
[ 'title' => 'Edit', 'event' => 'default', 'url' => '#modal-edit_syslog_rule_' . $la['la_id'], 'icon' => 'icon-cog text-muted', 'attribs' => [ 'data-toggle' => 'modal' ] ],
|
||||
[ 'title' => 'Delete', 'event' => 'danger', 'url' => '#modal-delete_syslog_rule_' . $la['la_id'], 'icon' => 'icon-trash', 'attribs' => [ 'data-toggle' => 'modal' ] ],
|
||||
],
|
||||
[ 'title' => 'Rule actions' ],
|
||||
' <div class="btn-group btn-group-xs" role="group" aria-label="Rule actions">
|
||||
<a role="group" class="btn btn-default" title="Edit" href="#modal-edit_syslog_rule_"data-toggle="modal"><i class="icon-cog text-muted "></i></a>
|
||||
<a role="group" class="btn btn-danger" title="Delete" href="#modal-delete_syslog_rule_"data-toggle="modal"><i class="icon-trash "></i></a>
|
||||
</div>' . PHP_EOL
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerGetForm
|
||||
* @group forms
|
||||
@ -318,7 +514,8 @@ FORM;
|
||||
<div id="remember_div" class="control-group" style="margin-bottom: 5px;"> <!-- START row-2 -->
|
||||
|
||||
<div id="remember_div" class="controls">
|
||||
<input type="checkbox" name="remember" id="remember" value="1" /> <label for="remember" class="help-inline" style="margin-top: 4px;"><span style="min-width: 150px;">Remember my login</span></label>
|
||||
<input type="checkbox" name="remember" id="remember" value="1" />
|
||||
<label for="remember" class="help-inline" style="margin-top: 4px;"><span style="min-width: 150px;">Remember my login</span></label>
|
||||
</div>
|
||||
</div> <!-- END row-2 -->
|
||||
|
||||
@ -362,6 +559,10 @@ FORM;
|
||||
$array[] = [ 'Please read [FAQ](' . OBSERVIUM_DOCS_URL . '/faq/#snmpv3-strong-authentication-or-encryption){target=_blank}.',
|
||||
'<span style="min-width: 150px;">Please read <a href="' . OBSERVIUM_DOCS_URL . '/faq/#snmpv3-strong-authentication-or-encryption" target="_blank">FAQ</a>.</span>', TRUE ];
|
||||
|
||||
// XSS
|
||||
$array[] = [ 'inside of brackets [javascript:alert(1)], inside of braces {javascript:alert(1)}, inside of parentheses (javascript:alert(1)), [click me](javascript:alert(1))',
|
||||
'<span style="min-width: 150px;">inside of brackets [javascript:alert(1)], inside of braces {javascript:alert(1)}, inside of parentheses (javascript:alert(1)), <a href="javascript:void(0)">click me</a></span>' ];
|
||||
|
||||
// Multiline
|
||||
$text = <<<TEXT
|
||||
Welcome to the demo:
|
||||
|
Reference in New Issue
Block a user