mirror of https://github.com/MISP/MISP
chg: [attribute:restSearch] New paramter `includeFullModel` to attach
full model informationpull/5032/head
parent
519ec416ea
commit
893dd617c8
|
@ -1892,7 +1892,7 @@ class AttributesController extends AppController
|
||||||
'timestamp', 'enforceWarninglist', 'to_ids', 'deleted', 'includeEventUuid', 'event_timestamp', 'threat_level_id', 'includeEventTags',
|
'timestamp', 'enforceWarninglist', 'to_ids', 'deleted', 'includeEventUuid', 'event_timestamp', 'threat_level_id', 'includeEventTags',
|
||||||
'includeProposals', 'returnFormat', 'published', 'limit', 'page', 'requested_attributes', 'includeContext', 'headerless',
|
'includeProposals', 'returnFormat', 'published', 'limit', 'page', 'requested_attributes', 'includeContext', 'headerless',
|
||||||
'includeWarninglistHits', 'attackGalaxy', 'object_relation', 'includeSightings', 'includeCorrelations', 'includeDecayScore',
|
'includeWarninglistHits', 'attackGalaxy', 'object_relation', 'includeSightings', 'includeCorrelations', 'includeDecayScore',
|
||||||
'decayingModel', 'excludeDecayed', 'modelOverrides'
|
'decayingModel', 'excludeDecayed', 'modelOverrides', 'includeFullModel'
|
||||||
);
|
);
|
||||||
$filterData = array(
|
$filterData = array(
|
||||||
'request' => $this->request,
|
'request' => $this->request,
|
||||||
|
|
|
@ -3279,7 +3279,8 @@ 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]['Attribute'], $options['decayingModel'], $options['modelOverrides']);
|
$include_full_model = isset($options['includeFullModel']) && $options['includeFullModel'] ? 1 : 0;
|
||||||
|
$this->DecayingModel->attachScoresToAttribute($user, $results[$key]['Attribute'], $options['decayingModel'], $options['modelOverrides'], $include_full_model);
|
||||||
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) { // remove attribute if ALL score results in a decay
|
foreach ($results[$key]['Attribute']['decay_score'] as $decayResult) { // remove attribute if ALL score results in a decay
|
||||||
|
@ -4263,7 +4264,8 @@ class Attribute extends AppModel
|
||||||
'includeContext' => !empty($filters['includeContext']) ? $filters['includeContext'] : 0,
|
'includeContext' => !empty($filters['includeContext']) ? $filters['includeContext'] : 0,
|
||||||
'includeSightings' => !empty($filters['includeSightings']) ? $filters['includeSightings'] : 0,
|
'includeSightings' => !empty($filters['includeSightings']) ? $filters['includeSightings'] : 0,
|
||||||
'includeCorrelations' => !empty($filters['includeCorrelations']) ? $filters['includeCorrelations'] : 0,
|
'includeCorrelations' => !empty($filters['includeCorrelations']) ? $filters['includeCorrelations'] : 0,
|
||||||
'includeDecayScore' => !empty($filters['includeDecayScore']) ? $filters['includeDecayScore'] : 0
|
'includeDecayScore' => !empty($filters['includeDecayScore']) ? $filters['includeDecayScore'] : 0,
|
||||||
|
'includeFullModel' => !empty($filters['includeFullModel']) ? $filters['includeFullModel'] : 0
|
||||||
);
|
);
|
||||||
if (!empty($filters['attackGalaxy'])) {
|
if (!empty($filters['attackGalaxy'])) {
|
||||||
$params['attackGalaxy'] = $filters['attackGalaxy'];
|
$params['attackGalaxy'] = $filters['attackGalaxy'];
|
||||||
|
|
|
@ -510,7 +510,7 @@ class DecayingModel extends AppModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attachScoresToAttribute($user, &$attribute, $model_id=false, $model_overrides=array())
|
public function attachScoresToAttribute($user, &$attribute, $model_id=false, $model_overrides=array(), $include_full_model=0)
|
||||||
{
|
{
|
||||||
$models = array();
|
$models = array();
|
||||||
if ($model_id === false) { // fetch all allowed and associated models
|
if ($model_id === false) { // fetch all allowed and associated models
|
||||||
|
@ -530,7 +530,11 @@ class DecayingModel extends AppModel
|
||||||
}
|
}
|
||||||
$score = $this->getScore($attribute, $model, $user);
|
$score = $this->getScore($attribute, $model, $user);
|
||||||
$decayed = $this->isDecayed($attribute, $model, $score);
|
$decayed = $this->isDecayed($attribute, $model, $score);
|
||||||
$attribute['decay_score'][] = array('DecayingModel' => $model['DecayingModel'], 'score' => $score, 'decayed' => $decayed);
|
$to_attach = array('score' => $score, 'decayed' => $decayed, 'DecayingModel' => array('id' => $model['DecayingModel']['id']));
|
||||||
|
if ($include_full_model) {
|
||||||
|
$to_attach['DecayingModel'] = $model['DecayingModel'];
|
||||||
|
}
|
||||||
|
$attribute['decay_score'][] = $to_attach;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue