mirror of https://github.com/MISP/MISP
chg: [attribute:restSearch] Search support for first_seen and last_seen
parent
11bee7c6e5
commit
b8b6a170fe
|
@ -2396,7 +2396,6 @@ class AppModel extends Model
|
|||
$multiplier = $multiplierArray[$lastChar];
|
||||
$delta = substr($delta, 0, -1);
|
||||
} else if(strtotime($delta) !== false) {
|
||||
debug(strtotime($delta));
|
||||
return strtotime($delta);
|
||||
} else {
|
||||
// invalid filter, make sure we don't return anything
|
||||
|
|
|
@ -3563,7 +3563,7 @@ class Attribute extends AppModel
|
|||
return $conditions;
|
||||
}
|
||||
|
||||
public function setTimestampSeenConditions($timestamp, $conditions, $scope = 'Event.timestamp', $returnRaw = false)
|
||||
public function setTimestampSeenConditions($timestamp, $conditions, $scope = 'Attribute.first_seen', $returnRaw = false)
|
||||
{
|
||||
if (is_array($timestamp)) {
|
||||
$timestamp[0] = intval($this->Event->resolveTimeDelta($timestamp[0])) * 1000000; // seen in stored in micro-seconds in the DB
|
||||
|
@ -3577,7 +3577,11 @@ class Attribute extends AppModel
|
|||
$conditions['AND'][] = array($scope . ' <=' => $timestamp[1]);
|
||||
} else {
|
||||
$timestamp = intval($this->Event->resolveTimeDelta($timestamp)) * 1000000; // seen in stored in micro-seconds in the DB
|
||||
$conditions['AND'][] = array($scope . ' >=' => $timestamp);
|
||||
if ($scope == 'Attribute.first_seen') {
|
||||
$conditions['AND'][] = array($scope . ' >=' => $timestamp);
|
||||
} else {
|
||||
$conditions['AND'][] = array($scope . ' <=' => $timestamp);
|
||||
}
|
||||
}
|
||||
if ($returnRaw) {
|
||||
return $timestamp;
|
||||
|
@ -4132,8 +4136,6 @@ class Attribute extends AppModel
|
|||
),
|
||||
'Object' => array(
|
||||
'object_name' => array('function' => 'set_filter_object_name'),
|
||||
'first_seen' => array('function' => 'set_filter_seen'),
|
||||
'last_seen' => array('function' => 'set_filter_seen'),
|
||||
'deleted' => array('function' => 'set_filter_deleted')
|
||||
)
|
||||
);
|
||||
|
|
|
@ -2607,22 +2607,8 @@ class Event extends AppModel
|
|||
|
||||
public function set_filter_seen(&$params, $conditions, $options)
|
||||
{
|
||||
if (empty($options['scope'])) {
|
||||
$scope = 'Attribute';
|
||||
} else {
|
||||
$scope = $options['scope'];
|
||||
}
|
||||
$filters = array(
|
||||
'first_seen' => array(
|
||||
'Attribute.first_seen'
|
||||
),
|
||||
'last_seen' => array(
|
||||
'Attribute.last_seen'
|
||||
)
|
||||
);
|
||||
foreach ($filters[$options['filter']] as $f) {
|
||||
$conditions = $this->Attribute->setTimestampSeenConditions($params[$options['filter']], $conditions, $f);
|
||||
}
|
||||
$f = $options['scope'] . '.' . $options['filter'];
|
||||
$conditions = $this->Attribute->setTimestampSeenConditions($params[$options['filter']], $conditions, $f);
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
'label' => __('Alternate Search Result (Events)')
|
||||
));
|
||||
?>
|
||||
<div class="input clear"></div>
|
||||
<?php echo $this->element('form_seen_input'); ?>
|
||||
</fieldset>
|
||||
<?php
|
||||
echo $this->Form->button(__('Search'), array('class' => 'btn btn-primary'));
|
||||
|
|
|
@ -306,7 +306,13 @@ function reflect_change_on_form() {
|
|||
$(document).ready(function() {
|
||||
|
||||
<?php if ($this->params->controller === 'attributes'): ?>
|
||||
var sliders_container = "<?php echo '#AttributeForm fieldset'; ?>"
|
||||
<?php if ($this->params->action === 'add'): ?>
|
||||
var sliders_container = "<?php echo '#AttributeForm fieldset'; ?>"
|
||||
<?php elseif ($this->params->action === 'search'): ?>
|
||||
var sliders_container = "<?php echo '#AttributeSearchForm fieldset'; ?>"
|
||||
<?php else: ?>
|
||||
var sliders_container = "<?php echo '#AttributeForm fieldset'; ?>"
|
||||
<?php endif; ?>
|
||||
<?php elseif ($this->params->controller === 'shadow_attributes'): ?>
|
||||
var sliders_container = "<?php echo '#ShadowAttributeAddForm fieldset'; ?>"
|
||||
<?php else: ?>
|
||||
|
|
Loading…
Reference in New Issue