mirror of https://github.com/MISP/MISP
fix: [decaying] Do not access existing keys anymore
parent
8a6dbd033e
commit
0c8b7b5820
|
@ -3182,7 +3182,7 @@ class Attribute extends AppModel
|
||||||
}
|
}
|
||||||
if ($options['includeDecayScore']) {
|
if ($options['includeDecayScore']) {
|
||||||
$this->DecayingModel = ClassRegistry::init('DecayingModel');
|
$this->DecayingModel = ClassRegistry::init('DecayingModel');
|
||||||
$this->DecayingModel->attachScoresToAttribute($user, $results[$key], $options['decayingModel']);
|
$this->DecayingModel->attachScoresToAttribute($user, $results[$key]['Attribute'], $options['decayingModel']);
|
||||||
if ($options['excludeDecayed']) { // filter out decayed attribute
|
if ($options['excludeDecayed']) { // filter out decayed attribute
|
||||||
$decayed_flag = true;
|
$decayed_flag = true;
|
||||||
foreach ($results[$key]['Attribute']['decay_score'] as $decayResult) {
|
foreach ($results[$key]['Attribute']['decay_score'] as $decayResult) {
|
||||||
|
|
|
@ -254,7 +254,7 @@ class DecayingModel extends AppModel
|
||||||
private function __include_formula_file_and_return_instance($filename='Polynomial.php')
|
private function __include_formula_file_and_return_instance($filename='Polynomial.php')
|
||||||
{
|
{
|
||||||
$filename_no_extension = str_replace('.php', '', $filename);
|
$filename_no_extension = str_replace('.php', '', $filename);
|
||||||
$filename = preg_replace('/[^a-zA-Z0-9_]+/', '-', $filename_no_extension) . '.php'; // sanitization
|
$filename = preg_replace('/[^a-zA-Z0-9_]+/', '-', $filename_no_extension) . '.php'; // sanitization & TO BE REVIEWED
|
||||||
$full_path = APP . 'Model/DecayingModelsFormulas/' . $filename;
|
$full_path = APP . 'Model/DecayingModelsFormulas/' . $filename;
|
||||||
$expected_classname = $filename_no_extension;
|
$expected_classname = $filename_no_extension;
|
||||||
if (is_file($full_path)) {
|
if (is_file($full_path)) {
|
||||||
|
|
|
@ -43,16 +43,18 @@ abstract class DecayingModelBase
|
||||||
$temp_mapping[$namespace_predicate] = $i;
|
$temp_mapping[$namespace_predicate] = $i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($attribute['AttributeTag'] as $tag) {
|
if (isset($attribute['AttributeTag'])) {
|
||||||
$namespace_predicate = explode('=', $tag['Tag']['name'])[0];
|
foreach ($attribute['AttributeTag'] as $tag) {
|
||||||
if (isset($temp_mapping[$namespace_predicate])) { // need to override event tag
|
$namespace_predicate = explode('=', $tag['Tag']['name'])[0];
|
||||||
$overridden_tags[] = array(
|
if (isset($temp_mapping[$namespace_predicate])) { // need to override event tag
|
||||||
'EventTag' => $tags[$temp_mapping[$namespace_predicate]],
|
$overridden_tags[] = array(
|
||||||
'AttributeTag' => $tag
|
'EventTag' => $tags[$temp_mapping[$namespace_predicate]],
|
||||||
);
|
'AttributeTag' => $tag
|
||||||
$tags[$temp_mapping[$namespace_predicate]] = $tag;
|
);
|
||||||
} else {
|
$tags[$temp_mapping[$namespace_predicate]] = $tag;
|
||||||
$tags[] = $tag;
|
} else {
|
||||||
|
$tags[] = $tag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array('tags' => $tags, 'overridden' => $overridden_tags);
|
return array('tags' => $tags, 'overridden' => $overridden_tags);
|
||||||
|
|
Loading…
Reference in New Issue