2015-02-03 17:06:05 +01:00
|
|
|
<div class="attributes <?php if (!isset($ajax) || !$ajax) echo 'form';?>">
|
2016-06-04 01:10:45 +02:00
|
|
|
<?php
|
2018-07-20 09:29:50 +02:00
|
|
|
$url_params = $action == 'add' ? 'add/' . $event_id : 'edit/' . $attribute['Attribute']['id'];
|
|
|
|
echo $this->Form->create('Attribute', array('id', 'url' => '/attributes/' . $url_params));
|
2014-04-14 15:13:01 +02:00
|
|
|
?>
|
2018-07-20 09:29:50 +02:00
|
|
|
<fieldset>
|
|
|
|
<legend><?php echo $action == 'add' ? __('Add Attribute') : __('Edit Attribute'); ?></legend>
|
|
|
|
<div id="formWarning" class="message ajaxMessage"></div>
|
|
|
|
<div id="compositeWarning" class="message <?php echo !empty($ajax) ? 'ajaxMessage' : '';?>" style="display:none;">Did you consider adding an object instead of a composite attribute?</div>
|
|
|
|
<div class="add_attribute_fields">
|
|
|
|
<?php
|
|
|
|
echo $this->Form->hidden('event_id');
|
|
|
|
echo $this->Form->input('category', array(
|
|
|
|
'empty' => __('(choose one)'),
|
|
|
|
'label' => __('Category ') . $this->element('formInfo', array('type' => 'category')),
|
|
|
|
));
|
|
|
|
echo $this->Form->input('type', array(
|
|
|
|
'empty' => __('(first choose category)'),
|
|
|
|
'label' => __('Type ') . $this->element('formInfo', array('type' => 'type')),
|
|
|
|
));
|
2015-04-14 18:11:51 +02:00
|
|
|
|
2018-07-20 09:29:50 +02:00
|
|
|
$initialDistribution = 5;
|
|
|
|
if (Configure::read('MISP.default_attribute_distribution') != null) {
|
|
|
|
if (Configure::read('MISP.default_attribute_distribution') === 'event') {
|
|
|
|
$initialDistribution = 5;
|
|
|
|
} else {
|
|
|
|
$initialDistribution = Configure::read('MISP.default_attribute_distribution');
|
|
|
|
}
|
|
|
|
}
|
2016-06-04 01:08:16 +02:00
|
|
|
|
2018-07-20 09:29:50 +02:00
|
|
|
?>
|
|
|
|
<div class="input clear"></div>
|
|
|
|
<?php
|
|
|
|
$distArray = array(
|
|
|
|
'options' => array($distributionLevels),
|
|
|
|
'label' => __('Distribution ') . $this->element('formInfo', array('type' => 'distribution')),
|
|
|
|
);
|
2018-04-24 16:45:24 +02:00
|
|
|
|
2018-07-20 09:29:50 +02:00
|
|
|
if ($action == 'add') {
|
|
|
|
$distArray['selected'] = $initialDistribution;
|
|
|
|
}
|
2018-04-24 16:45:24 +02:00
|
|
|
|
2018-07-20 09:29:50 +02:00
|
|
|
echo $this->Form->input('distribution', $distArray);
|
|
|
|
?>
|
|
|
|
<div id="SGContainer" style="display:none;">
|
|
|
|
<?php
|
|
|
|
if (!empty($sharingGroups)) {
|
|
|
|
echo $this->Form->input('sharing_group_id', array(
|
|
|
|
'options' => array($sharingGroups),
|
|
|
|
'label' => __('Sharing Group'),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
echo $this->Form->input('value', array(
|
|
|
|
'type' => 'textarea',
|
|
|
|
'error' => array('escape' => false),
|
|
|
|
'div' => 'input clear',
|
|
|
|
'class' => 'input-xxlarge'
|
|
|
|
));
|
|
|
|
?>
|
|
|
|
<div class="input clear"></div>
|
|
|
|
<?php
|
|
|
|
echo $this->Form->input('comment', array(
|
|
|
|
'type' => 'text',
|
|
|
|
'label' => __('Contextual Comment'),
|
|
|
|
'error' => array('escape' => false),
|
|
|
|
'div' => 'input clear',
|
|
|
|
'class' => 'input-xxlarge'
|
|
|
|
));
|
|
|
|
?>
|
|
|
|
<div class="input clear"></div>
|
|
|
|
<?php
|
|
|
|
echo $this->Form->input('to_ids', array(
|
|
|
|
'label' => __('for Intrusion Detection System'),
|
|
|
|
));
|
|
|
|
echo $this->Form->input('batch_import', array(
|
|
|
|
'type' => 'checkbox'
|
|
|
|
));
|
2019-01-17 07:57:23 +01:00
|
|
|
echo '<div class="input clear"></div>';
|
|
|
|
echo $this->Form->input('disable_correlation', array(
|
|
|
|
'type' => 'checkbox'
|
|
|
|
));
|
2018-07-20 09:29:50 +02:00
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
<p id="notice_message" style="display:none;"></p>
|
|
|
|
<?php if ($ajax): ?>
|
|
|
|
<div class="overlay_spacing">
|
|
|
|
<span id="submitButton" class="btn btn-primary" style="margin-bottom:5px;float:left;" title="<?php echo __('Submit'); ?>" role="button" tabindex="0" aria-label="<?php echo __('Submit'); ?>" onClick="submitPopoverForm('<?php echo $action == 'add' ? $event_id : $attribute['Attribute']['id'];?>', '<?php echo $action; ?>')"><?php echo __('Submit'); ?></span>
|
|
|
|
<span class="btn btn-inverse" style="float:right;" title="<?php echo __('Cancel'); ?>" role="button" tabindex="0" aria-label="<?php echo __('Cancel'); ?>" id="cancel_attribute_add"><?php echo __('Cancel'); ?></span>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
else:
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
echo $this->Form->button('Submit', array('class' => 'btn btn-primary'));
|
|
|
|
endif;
|
|
|
|
echo $this->Form->end();
|
|
|
|
?>
|
2013-05-30 11:14:00 +02:00
|
|
|
</div>
|
2016-06-04 01:10:45 +02:00
|
|
|
<?php
|
2018-07-20 09:29:50 +02:00
|
|
|
if (!$ajax) {
|
|
|
|
$event['Event']['id'] = $event_id;
|
|
|
|
$event['Event']['published'] = $published;
|
2019-02-13 14:45:01 +01:00
|
|
|
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'event', 'menuItem' => 'addAttribute', 'event' => $event));
|
2018-07-20 09:29:50 +02:00
|
|
|
}
|
2013-10-24 10:33:34 +02:00
|
|
|
?>
|
2013-05-30 11:14:00 +02:00
|
|
|
<script type="text/javascript">
|
2018-05-07 10:43:21 +02:00
|
|
|
var notice_list_triggers = <?php echo $notice_list_triggers; ?>;
|
2017-01-28 23:28:13 +01:00
|
|
|
var fieldsArray = new Array('AttributeCategory', 'AttributeType', 'AttributeValue', 'AttributeDistribution', 'AttributeComment', 'AttributeToIds', 'AttributeBatchImport', 'AttributeSharingGroupId');
|
2016-10-02 12:46:30 +02:00
|
|
|
<?php
|
2018-07-20 09:29:50 +02:00
|
|
|
$formInfoTypes = array('distribution' => 'Distribution', 'category' => 'Category', 'type' => 'Type');
|
|
|
|
echo 'var formInfoFields = ' . json_encode($formInfoTypes) . PHP_EOL;
|
|
|
|
foreach ($formInfoTypes as $formInfoType => $humanisedName) {
|
|
|
|
echo 'var ' . $formInfoType . 'FormInfoValues = {' . PHP_EOL;
|
|
|
|
foreach ($info[$formInfoType] as $key => $formInfoData) {
|
|
|
|
echo '"' . $key . '": "<span class=\"blue bold\">' . h($formInfoData['key']) . '</span>: ' . h($formInfoData['desc']) . '<br />",' . PHP_EOL;
|
|
|
|
}
|
|
|
|
echo '}' . PHP_EOL;
|
|
|
|
}
|
2016-10-02 12:46:30 +02:00
|
|
|
?>
|
|
|
|
|
2013-05-30 11:14:00 +02:00
|
|
|
//
|
|
|
|
//Generate Category / Type filtering array
|
|
|
|
//
|
|
|
|
var category_type_mapping = new Array();
|
|
|
|
<?php
|
2018-07-20 09:29:50 +02:00
|
|
|
foreach ($categoryDefinitions as $category => $def) {
|
|
|
|
echo "category_type_mapping['" . addslashes($category) . "'] = {";
|
|
|
|
$first = true;
|
|
|
|
foreach ($def['types'] as $type) {
|
|
|
|
if ($first) $first = false;
|
|
|
|
else echo ', ';
|
|
|
|
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
|
|
|
|
}
|
|
|
|
echo "}; \n";
|
|
|
|
}
|
2013-05-30 11:14:00 +02:00
|
|
|
?>
|
|
|
|
|
2018-01-18 11:59:26 +01:00
|
|
|
var composite_types = <?php echo json_encode($compositeTypes); ?>;
|
|
|
|
|
2013-06-06 16:36:28 +02:00
|
|
|
$(document).ready(function() {
|
2018-07-20 09:29:50 +02:00
|
|
|
<?php
|
|
|
|
if ($action == 'edit'):
|
|
|
|
?>
|
|
|
|
checkNoticeList('attribute');
|
|
|
|
<?php
|
|
|
|
endif;
|
|
|
|
?>
|
|
|
|
initPopoverContent('Attribute');
|
|
|
|
$('#AttributeDistribution').change(function() {
|
|
|
|
if ($('#AttributeDistribution').val() == 4) $('#SGContainer').show();
|
|
|
|
else $('#SGContainer').hide();
|
|
|
|
});
|
2015-04-14 18:11:51 +02:00
|
|
|
|
2018-07-20 09:29:50 +02:00
|
|
|
$("#AttributeCategory").on('change', function(e) {
|
|
|
|
formCategoryChanged('Attribute');
|
|
|
|
if ($(this).val() === 'Internal reference') {
|
|
|
|
$("#AttributeDistribution").val('0');
|
|
|
|
$('#SGContainer').hide();
|
|
|
|
}
|
|
|
|
});
|
2017-01-28 23:28:13 +01:00
|
|
|
|
2018-07-20 09:29:50 +02:00
|
|
|
$("#AttributeCategory, #AttributeType").change(function() {
|
|
|
|
checkNoticeList('attribute');
|
|
|
|
});
|
2018-05-07 10:43:21 +02:00
|
|
|
|
2018-07-20 09:29:50 +02:00
|
|
|
$("#AttributeCategory, #AttributeType, #AttributeDistribution").change(function() {
|
|
|
|
var start = $("#AttributeType").val();
|
|
|
|
initPopoverContent('Attribute');
|
|
|
|
$("#AttributeType").val(start);
|
|
|
|
if ($.inArray(start, composite_types) > -1) {
|
|
|
|
$('#compositeWarning').show();
|
|
|
|
} else {
|
|
|
|
$('#compositeWarning').hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
<?php if ($ajax): ?>
|
|
|
|
$('#cancel_attribute_add').click(function() {
|
|
|
|
cancelPopoverForm();
|
|
|
|
});
|
2014-03-24 16:33:40 +01:00
|
|
|
|
2018-07-20 09:29:50 +02:00
|
|
|
<?php endif; ?>
|
2013-06-06 16:36:28 +02:00
|
|
|
});
|
2013-05-30 11:14:00 +02:00
|
|
|
</script>
|
2016-06-06 10:09:55 +02:00
|
|
|
<?php echo $this->Js->writeBuffer(); // Write cached scripts
|