mirror of https://github.com/MISP/MISP
new: First implementation of the Noticelist system ready
parent
13e407fd7c
commit
05cf0563e1
|
@ -368,6 +368,9 @@ class AttributesController extends AppController {
|
||||||
foreach ($distributionLevels as $key => $value) {
|
foreach ($distributionLevels as $key => $value) {
|
||||||
$info['distribution'][$key] = array('key' => $value, 'desc' => $this->Attribute->distributionDescriptions[$key]['formdesc']);
|
$info['distribution'][$key] = array('key' => $value, 'desc' => $this->Attribute->distributionDescriptions[$key]['formdesc']);
|
||||||
}
|
}
|
||||||
|
$this->loadModel('Noticelist');
|
||||||
|
$notice_list_triggers = $this->Noticelist->getTriggerData();
|
||||||
|
$this->set('notice_list_triggers', json_encode($notice_list_triggers, true));
|
||||||
$this->set('info', $info);
|
$this->set('info', $info);
|
||||||
$this->set('typeDefinitions', $this->Attribute->typeDefinitions);
|
$this->set('typeDefinitions', $this->Attribute->typeDefinitions);
|
||||||
$this->set('categoryDefinitions', $this->Attribute->categoryDefinitions);
|
$this->set('categoryDefinitions', $this->Attribute->categoryDefinitions);
|
||||||
|
@ -937,6 +940,9 @@ class AttributesController extends AppController {
|
||||||
$this->set('categoryDefinitions', $categoryDefinitions);
|
$this->set('categoryDefinitions', $categoryDefinitions);
|
||||||
$this->set('compositeTypes', $this->Attribute->getCompositeTypes());
|
$this->set('compositeTypes', $this->Attribute->getCompositeTypes());
|
||||||
$this->set('action', $this->action);
|
$this->set('action', $this->action);
|
||||||
|
$this->loadModel('Noticelist');
|
||||||
|
$notice_list_triggers = $this->Noticelist->getTriggerData();
|
||||||
|
$this->set('notice_list_triggers', json_encode($notice_list_triggers, true));
|
||||||
$this->render('add');
|
$this->render('add');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,15 @@ class ACLComponent extends Component {
|
||||||
'delete' => array(),
|
'delete' => array(),
|
||||||
'index' => array('*'),
|
'index' => array('*'),
|
||||||
),
|
),
|
||||||
|
'noticelists' => array(
|
||||||
|
'delete' => array(),
|
||||||
|
'enableNoticelist' => array(),
|
||||||
|
'getToggleField' => array(),
|
||||||
|
'index' => array('*'),
|
||||||
|
'toggleEnable' => array(),
|
||||||
|
'update' => array(),
|
||||||
|
'view' => array('*')
|
||||||
|
),
|
||||||
'objects' => array(
|
'objects' => array(
|
||||||
'add' => array('perm_add'),
|
'add' => array('perm_add'),
|
||||||
'addValueField' => array('perm_add'),
|
'addValueField' => array('perm_add'),
|
||||||
|
|
|
@ -955,7 +955,7 @@ class AppModel extends Model {
|
||||||
'email' => 'SYSTEM',
|
'email' => 'SYSTEM',
|
||||||
'action' => 'update_database',
|
'action' => 'update_database',
|
||||||
'user_id' => 0,
|
'user_id' => 0,
|
||||||
'title' => 'Successfuly executed the SQL query for ' . $command,
|
'title' => 'Successfuly executed the SQL query for ' . $command,
|
||||||
'change' => 'The executed SQL query was: ' . $sql
|
'change' => 'The executed SQL query was: ' . $sql
|
||||||
));
|
));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
|
@ -90,4 +90,37 @@ class Noticelist extends AppModel{
|
||||||
return $this->validationErrors;
|
return $this->validationErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTriggerData($scope = 'attribute') {
|
||||||
|
$noticelists = $this->find('all', array(
|
||||||
|
'conditions' => array('enabled' => 1),
|
||||||
|
'recursive' => -1,
|
||||||
|
'contain' => 'NoticelistEntry'
|
||||||
|
));
|
||||||
|
$noticelist_triggers = array();
|
||||||
|
$validTriggers = array(
|
||||||
|
'attribute' => array(
|
||||||
|
'category',
|
||||||
|
'type'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
foreach ($noticelists as $noticelist) {
|
||||||
|
foreach ($noticelist['NoticelistEntry'] as $entry) {
|
||||||
|
if (in_array('attribute', $entry['data']['scope'])) {
|
||||||
|
foreach ($entry['data']['field'] as $data_field) {
|
||||||
|
if (in_array($data_field, $validTriggers[$scope])) {
|
||||||
|
foreach ($entry['data']['value'] as $value) {
|
||||||
|
$noticelist_triggers[$data_field][$value][] = array(
|
||||||
|
'message' => $entry['data']['message'],
|
||||||
|
'list_id' => $noticelist['Noticelist']['id'],
|
||||||
|
'list_name' => $noticelist['Noticelist']['name']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $noticelist_triggers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<p style="color:white;background-color:red;font-weight:bold;display:none;padding:5px;" id="warning-message"><?php echo __('Warning: You are about to share data that is of a classified nature. Make sure that you are authorised to share this.'); ?></p>
|
<p id="notice_message"><?php echo __('Warning: You are about to share data that is of a classified nature. Make sure that you are authorised to share this.'); ?></p>
|
||||||
<?php if ($ajax): ?>
|
<?php if ($ajax): ?>
|
||||||
<div class="overlay_spacing">
|
<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 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>
|
||||||
|
@ -104,6 +104,7 @@
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
var notice_list_triggers = <?php echo $notice_list_triggers; ?>;
|
||||||
var fieldsArray = new Array('AttributeCategory', 'AttributeType', 'AttributeValue', 'AttributeDistribution', 'AttributeComment', 'AttributeToIds', 'AttributeBatchImport', 'AttributeSharingGroupId');
|
var fieldsArray = new Array('AttributeCategory', 'AttributeType', 'AttributeValue', 'AttributeDistribution', 'AttributeComment', 'AttributeToIds', 'AttributeBatchImport', 'AttributeSharingGroupId');
|
||||||
<?php
|
<?php
|
||||||
$formInfoTypes = array('distribution' => 'Distribution', 'category' => 'Category', 'type' => 'Type');
|
$formInfoTypes = array('distribution' => 'Distribution', 'category' => 'Category', 'type' => 'Type');
|
||||||
|
@ -137,6 +138,13 @@ var category_type_mapping = new Array();
|
||||||
var composite_types = <?php echo json_encode($compositeTypes); ?>;
|
var composite_types = <?php echo json_encode($compositeTypes); ?>;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
<?php
|
||||||
|
if ($action == 'edit'):
|
||||||
|
?>
|
||||||
|
checkNoticeList('attribute');
|
||||||
|
<?php
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
initPopoverContent('Attribute');
|
initPopoverContent('Attribute');
|
||||||
$('#AttributeDistribution').change(function() {
|
$('#AttributeDistribution').change(function() {
|
||||||
if ($('#AttributeDistribution').val() == 4) $('#SGContainer').show();
|
if ($('#AttributeDistribution').val() == 4) $('#SGContainer').show();
|
||||||
|
@ -156,6 +164,10 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#AttributeCategory, #AttributeType").change(function() {
|
||||||
|
checkNoticeList('attribute');
|
||||||
|
});
|
||||||
|
|
||||||
$("#AttributeCategory, #AttributeType, #AttributeDistribution").change(function() {
|
$("#AttributeCategory, #AttributeType, #AttributeDistribution").change(function() {
|
||||||
var start = $("#AttributeType").val();
|
var start = $("#AttributeType").val();
|
||||||
initPopoverContent('Attribute');
|
initPopoverContent('Attribute');
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
<li><a href="<?php echo $baseurl;?>/whitelists/index">Signature Whitelist</a></li>
|
<li><a href="<?php echo $baseurl;?>/whitelists/index">Signature Whitelist</a></li>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
<li><a href="<?php echo $baseurl;?>/warninglists/index">List Warninglists</a></li>
|
<li><a href="<?php echo $baseurl;?>/warninglists/index">List Warninglists</a></li>
|
||||||
|
<li><a href="<?php echo $baseurl;?>/noticelists/index">List Noticelists</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
@ -212,4 +213,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" class="keyboardShortcutsConfig" value="/shortcuts/global_menu.json" />
|
<input type="hidden" class="keyboardShortcutsConfig" value="/shortcuts/global_menu.json" />
|
||||||
|
|
|
@ -3329,6 +3329,33 @@ $('.quickToggleCheckbox').toggle(function() {
|
||||||
var url = $(this).data('checkbox-url');
|
var url = $(this).data('checkbox-url');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function checkNoticeList(type) {
|
||||||
|
var fields_to_check = {
|
||||||
|
"attribute": ["category", "type"]
|
||||||
|
}
|
||||||
|
var warnings = [];
|
||||||
|
$('#notice_message').html('<h4>Notices:</h4>');
|
||||||
|
$('#notice_message').hide();
|
||||||
|
fields_to_check[type].forEach(function(field_name) {
|
||||||
|
if (field_name in notice_list_triggers) {
|
||||||
|
var field_value = $('#' + type.ucfirst() + field_name.ucfirst()).val();
|
||||||
|
if (field_value in notice_list_triggers[field_name]) {
|
||||||
|
notice_list_triggers[field_name][field_value].forEach(function(notice) {
|
||||||
|
$('#notice_message').show();
|
||||||
|
$('#notice_message').append(
|
||||||
|
$('<div/>')
|
||||||
|
.append($('<span/>').text('['))
|
||||||
|
.append($('<a/>', {href: '/noticelists/view/' + notice['list_id'], class:'bold'}).text(notice['list_name']))
|
||||||
|
.append($('<span/>').text(']: '))
|
||||||
|
.append($('<span/>').text(notice['message']['en']))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$(".correlation-expand-button").on("click", function() {
|
$(".correlation-expand-button").on("click", function() {
|
||||||
$(this).parent().children(".correlation-expanded-area").show();
|
$(this).parent().children(".correlation-expanded-area").show();
|
||||||
|
|
Loading…
Reference in New Issue