mirror of https://github.com/MISP/MISP
chg: [internal] Convert array to const in ACLComponent
parent
98d75580a5
commit
19624a02f7
|
@ -12,7 +12,7 @@ class ACLComponent extends Component
|
|||
// $action == array('OR' => array()) - any role in the array has access
|
||||
// $action == array('AND' => array()) - roles with all permissions in the array have access
|
||||
// If we add any new functionality to MISP and we don't add it to this list, it will only be visible to site admins.
|
||||
private $__aclList = array(
|
||||
const ACL_LIST = array(
|
||||
'*' => array(
|
||||
'blackhole' => array(),
|
||||
'debugACL' => array(),
|
||||
|
@ -907,10 +907,10 @@ class ACLComponent extends Component
|
|||
if ($user && $user['Role']['perm_site_admin']) {
|
||||
return true;
|
||||
}
|
||||
if (!isset($this->__aclList[$controller])) {
|
||||
if (!isset(self::ACL_LIST[$controller])) {
|
||||
throw new NotFoundException('Invalid controller.');
|
||||
}
|
||||
$controllerAclList = array_change_key_case($this->__aclList[$controller]);
|
||||
$controllerAclList = array_change_key_case(self::ACL_LIST[$controller]);
|
||||
if (!empty($controllerAclList[$action])) {
|
||||
$rules = $controllerAclList[$action];
|
||||
if (in_array('*', $rules, true)) {
|
||||
|
@ -992,8 +992,8 @@ class ACLComponent extends Component
|
|||
$missing = array();
|
||||
foreach ($results as $controller => $functions) {
|
||||
foreach ($functions as $function) {
|
||||
if (!isset($this->__aclList[$controller])
|
||||
|| !in_array($function, array_keys($this->__aclList[$controller]))) {
|
||||
if (!isset(self::ACL_LIST[$controller])
|
||||
|| !in_array($function, array_keys(self::ACL_LIST[$controller]))) {
|
||||
$missing[$controller][] = $function;
|
||||
}
|
||||
}
|
||||
|
@ -1027,7 +1027,7 @@ class ACLComponent extends Component
|
|||
{
|
||||
$result = array();
|
||||
$fakeUser = ['Role' => $role, 'org_id' => Configure::read('MISP.host_org_id')];
|
||||
foreach ($this->__aclList as $controller => $actions) {
|
||||
foreach (self::ACL_LIST as $controller => $actions) {
|
||||
$controllerNames = Inflector::variable($controller) === Inflector::underscore($controller) ?
|
||||
array(Inflector::variable($controller)) :
|
||||
array(Inflector::variable($controller), Inflector::underscore($controller));
|
||||
|
|
|
@ -31,6 +31,18 @@ class ComplexTypeTool
|
|||
)
|
||||
);
|
||||
|
||||
const HEX_HASH_TYPES = array(
|
||||
32 => array('single' => array('md5', 'imphash', 'x509-fingerprint-md5'), 'composite' => array('filename|md5', 'filename|imphash')),
|
||||
40 => array('single' => array('sha1', 'pehash', 'x509-fingerprint-sha1', 'cdhash'), 'composite' => array('filename|sha1', 'filename|pehash')),
|
||||
56 => array('single' => array('sha224', 'sha512/224'), 'composite' => array('filename|sha224', 'filename|sha512/224')),
|
||||
64 => array('single' => array('sha256', 'authentihash', 'sha512/256', 'x509-fingerprint-sha256'), 'composite' => array('filename|sha256', 'filename|authentihash', 'filename|sha512/256')),
|
||||
96 => array('single' => array('sha384'), 'composite' => array('filename|sha384')),
|
||||
128 => array('single' => array('sha512'), 'composite' => array('filename|sha512'))
|
||||
);
|
||||
|
||||
// algorithms to run through in order, without Hashes that are checked separately
|
||||
const CHECKS = array('Email', 'IP', 'DomainOrFilename', 'SimpleRegex', 'AS', 'BTC');
|
||||
|
||||
private $__tlds = null;
|
||||
|
||||
public static function refangValue($value, $type)
|
||||
|
@ -223,18 +235,6 @@ class ComplexTypeTool
|
|||
return array_values($resultArray);
|
||||
}
|
||||
|
||||
private $__hexHashTypes = array(
|
||||
32 => array('single' => array('md5', 'imphash', 'x509-fingerprint-md5'), 'composite' => array('filename|md5', 'filename|imphash')),
|
||||
40 => array('single' => array('sha1', 'pehash', 'x509-fingerprint-sha1', 'cdhash'), 'composite' => array('filename|sha1', 'filename|pehash')),
|
||||
56 => array('single' => array('sha224', 'sha512/224'), 'composite' => array('filename|sha224', 'filename|sha512/224')),
|
||||
64 => array('single' => array('sha256', 'authentihash', 'sha512/256', 'x509-fingerprint-sha256'), 'composite' => array('filename|sha256', 'filename|authentihash', 'filename|sha512/256')),
|
||||
96 => array('single' => array('sha384'), 'composite' => array('filename|sha384')),
|
||||
128 => array('single' => array('sha512'), 'composite' => array('filename|sha512'))
|
||||
);
|
||||
|
||||
// algorithms to run through in order, without Hashes that are checked separately
|
||||
private $__checks = array('Email', 'IP', 'DomainOrFilename', 'SimpleRegex', 'AS', 'BTC');
|
||||
|
||||
/**
|
||||
* @param string $raw_input Trimmed value
|
||||
* @return array|false
|
||||
|
@ -263,7 +263,7 @@ class ComplexTypeTool
|
|||
$input = $this->__refangInput($input);
|
||||
$input = $this->__extractPort($input);
|
||||
|
||||
foreach ($this->__checks as $check) {
|
||||
foreach (self::CHECKS as $check) {
|
||||
$result = $this->{'__checkFor' . $check}($input);
|
||||
if ($result) {
|
||||
return $result;
|
||||
|
@ -511,8 +511,8 @@ class ComplexTypeTool
|
|||
private function __resolveHash($value)
|
||||
{
|
||||
$strlen = strlen($value);
|
||||
if (isset($this->__hexHashTypes[$strlen]) && ctype_xdigit($value)) {
|
||||
return $this->__hexHashTypes[$strlen];
|
||||
if (isset(self::HEX_HASH_TYPES[$strlen]) && ctype_xdigit($value)) {
|
||||
return self::HEX_HASH_TYPES[$strlen];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue