2021-06-17 17:14:22 +02:00
<?php
2021-06-22 17:46:33 +02:00
$edit = $this->request->params['action'] === 'edit' ? true : false;
2021-06-17 17:14:22 +02:00
echo $this->element('genericElements/Form/genericForm', [
'data' => [
2021-07-08 11:55:42 +02:00
'title' => $edit ? __('Edit MISP feed') : __('Add MISP Feed'),
2021-06-17 17:14:22 +02:00
'description' => __('Add a new MISP feed source.'),
2021-07-13 12:25:57 +02:00
'notice' => !empty(Configure::read('Security.disable_local_feed_access')) ? __('Warning: local feeds are currently disabled by policy, to re-enable the feature, set the Security.disable_local_feed_access flag to false in the server settings. This setting can only be set via the CLI.') : '',
2021-06-17 17:14:22 +02:00
'fields' => [
[
'field' => 'enabled',
'label' => __('Enabled'),
'type' => 'checkbox'
],
[
'field' => 'caching_enabled',
'label' => __('Caching enabled'),
'type' => 'checkbox'
],
[
'field' => 'lookup_visible',
'label' => __('Lookup visible'),
'type' => 'checkbox'
],
2022-04-28 16:41:30 +02:00
[
'field' => 'Feed.settings.disable_correlation',
'label' => __('Disable correlation'),
'type' => 'checkbox'
],
2021-06-17 17:14:22 +02:00
[
'field' => 'name',
'label' => __('Name'),
2021-07-08 11:55:42 +02:00
'placeholder' => __('Feed name'),
'required' => 1,
'class' => 'form-control span6'
2021-06-17 17:14:22 +02:00
],
[
'field' => 'provider',
2019-03-21 15:59:02 +01:00
'label' => __('Provider'),
2021-07-08 11:55:42 +02:00
'placeholder' => __('Name of the content provider'),
'required' => 1,
'class' => 'form-control span6'
2021-06-17 17:14:22 +02:00
],
[
'field' => 'input_source',
2018-07-20 09:29:50 +02:00
'label' => __('Input Source'),
2021-06-17 17:14:22 +02:00
'options' => $dropdownData['inputSources'],
2021-07-08 11:55:42 +02:00
'type' => 'dropdown',
'class' => 'form-control span6'
2021-06-17 17:14:22 +02:00
],
[
'field' => 'url',
2019-03-21 15:59:02 +01:00
'label' => __('URL'),
2021-06-17 17:14:22 +02:00
'placeholder' => 'URL of the feed',
2021-07-08 11:55:42 +02:00
'required' => 1,
'class' => 'form-control span6'
2021-06-17 17:14:22 +02:00
],
[
'field' => 'source_format',
2018-07-20 09:29:50 +02:00
'label' => __('Source Format'),
2021-06-17 17:14:22 +02:00
'options' => $dropdownData['feedTypes'],
2021-07-08 11:55:42 +02:00
'type' => 'dropdown',
'class' => 'form-control span6'
2021-06-17 17:14:22 +02:00
],
[
'field' => 'headers',
2018-07-20 09:29:50 +02:00
'label' => __('Any headers to be passed with requests (for example: Authorization)'),
2021-07-08 11:55:42 +02:00
'class' => 'input-xxlarge',
'type' => 'headers',
'placeholder' => __('Line break separated list of headers in the "headername: value" format'),
2021-06-17 17:14:22 +02:00
'rows' => 4,
],
2021-07-08 11:55:42 +02:00
[
'field' => 'orgc_id',
'label' => __('Creator organisation'),
'options' => $dropdownData['orgs'],
2023-01-10 12:04:56 +01:00
'value' => $this->request->params['action'] === 'add' ? $me['org_id'] : null,
2021-07-08 11:55:42 +02:00
'type' => 'dropdown',
2021-07-08 15:20:30 +02:00
'div' => ['id' => 'OrgcDiv', 'style' => 'display:none', 'class' => 'optionalField'],
2021-07-08 11:55:42 +02:00
'class' => 'form-control span6'
],
[
'field' => 'fixed_event',
'label' => __('Target Event'),
2022-09-22 12:35:23 +02:00
'options' => [1 =>'Fixed Event', 0 => 'New Event Each Pull'],
2021-07-08 11:55:42 +02:00
'type' => 'dropdown',
2021-07-08 15:20:30 +02:00
'div' => ['id' => 'TargetDiv', 'style' => 'display:none', 'class' => 'optionalField'],
2021-07-08 11:55:42 +02:00
'class' => 'form-control span6'
],
[
2022-09-22 12:35:23 +02:00
'field' => 'event_id',
2021-07-08 11:55:42 +02:00
'label' => __('Target Event ID'),
'placeholder' => __('Leave blank unless you want to reuse an existing event.'),
2021-07-08 15:20:30 +02:00
'div' => ['id' => 'TargetEventDiv', 'style' => 'display:none', 'class' => 'optionalField'],
2021-07-08 11:55:42 +02:00
'class' => 'form-control span6'
],
[
'field' => 'Feed.settings.csv.value',
'label' => __('Value field(s) in the CSV'),
'title' => __('Select one or several fields that should be parsed by the CSV parser and converted into MISP attributes'),
'placeholder' => __('2,3,4 (column position separated by commas)'),
2021-07-08 15:20:30 +02:00
'div' => ['id' => 'settingsCsvValueDiv', 'style' => 'display:none', 'class' => 'optionalField'],
2021-07-08 11:55:42 +02:00
'class' => 'form-control span6'
],
[
'field' => 'Feed.settings.csv.delimiter',
'label' => __('Delimiter'),
'title' => __('Set the default CSV delimiter (default = ",")'),
'placeholder' => ',',
2021-07-08 15:20:30 +02:00
'div' => ['id' => 'settingsCsvDelimiterDiv', 'style' => 'display:none', 'class' => 'optionalField'],
2021-07-08 11:55:42 +02:00
'class' => 'form-control span6',
'value' => isset($entity['Feed']['settings']['csv']['delimiter']) ? $entity['Feed']['settings']['csv']['delimiter'] : ','
],
[
'field' => 'Feed.settings.common.excluderegex',
'label' => __('Exclusion Regex'),
2021-07-08 15:20:30 +02:00
'div' => ['id' => 'settingsCommonExcluderegexDiv', 'style' => 'display:none', 'class' => 'optionalField'],
2021-07-08 11:55:42 +02:00
'placeholder' => __('Regex pattern, for example: "/^https://myfeedurl/i'),
'class' => 'form-control span6'
],
[
'field' => 'publish',
'label' => __('Auto Publish'),
'title' => __('Publish events directly after pulling the feed - if you would like to review the event before publishing uncheck this'),
'type' => 'checkbox',
2021-07-08 15:20:30 +02:00
'div' => ['id' => 'PublishDiv', 'style' => 'display:none', 'class' => 'input checkbox optionalField']
2021-07-08 11:55:42 +02:00
],
[
'field' => 'override_ids',
'label' => __('Override IDS Flag'),
'title' => __('If checked, the IDS flags will always be set to off when pulling from this feed'),
'type' => 'checkbox',
2021-07-08 15:20:30 +02:00
'div' => ['id' => 'OverrideIdsDiv', 'style' => 'display:none', 'class' => 'input checkbox optionalField']
2021-07-08 11:55:42 +02:00
],
[
'field' => 'delta_merge',
'label' => __('Delta Merge'),
'title' => __('Merge attributes (only add new attributes, remove revoked attributes)'),
'type' => 'checkbox',
2021-07-08 15:20:30 +02:00
'div' => ['id' => 'DeltaMergeDiv', 'style' => 'display:none', 'class' => 'input checkbox optionalField']
2021-07-08 11:55:42 +02:00
],
2021-06-17 17:14:22 +02:00
[
'field' => 'distribution',
2018-07-20 09:29:50 +02:00
'label' => __('Distribution'),
2021-06-17 17:14:22 +02:00
'options' => $dropdownData['distributionLevels'],
2021-06-22 17:46:33 +02:00
'selected' => isset($entity['Feed']['distribution']) ? $entity['Feed']['distribution'] : 3,
2021-06-17 17:14:22 +02:00
'type' => 'dropdown'
],
2021-10-08 10:32:48 +02:00
[
'field' => 'sharing_group_id',
'label' => __('Sharing Group'),
'div' => ['id' => 'SGContainer', 'style' => 'display:none', 'class' => 'optionalField'],
'options' => $dropdownData['sharingGroups'],
'type' => 'dropdown'
],
2021-06-17 17:14:22 +02:00
[
'field' => 'tag_id',
2018-07-20 09:29:50 +02:00
'label' => __('Default Tag'),
2021-06-17 17:14:22 +02:00
'options' => $dropdownData['tags'],
2021-06-22 17:46:33 +02:00
'selected' => isset($entity['Feed']['tag_id']) ? $entity['Feed']['tag_id'] : '0',
2021-06-17 17:14:22 +02:00
'type' => 'dropdown',
'searchable' => 1
],
2021-06-18 18:02:40 +02:00
[
'field' => 'rules',
'label' => __('Filter rules'),
2021-06-22 17:46:33 +02:00
'type' => 'pullRules',
'tags' => $dropdownData['tags'],
'orgs' => $dropdownData['orgs'],
2021-06-24 12:07:09 +02:00
'pull_rules' => $edit ? $entity['Feed']['rules'] : $defaultPullRules
2021-06-18 18:02:40 +02:00
],
2021-06-17 17:14:22 +02:00
],
'submit' => [
'action' => $this->request->params['action'],
'ajaxSubmit' => 'submitGenericFormInPlace();'
]
]
]);
2021-06-18 18:02:40 +02:00
?>
<?php
2021-06-17 17:14:22 +02:00
if (!$ajax) {
echo $this->element('/genericElements/SideMenu/side_menu', $menuData);
}
2021-07-08 11:55:42 +02:00
?>
<script type="text/javascript">
$(document).ready(function() {
feedFormUpdate();
2021-10-08 10:32:48 +02:00
$("#FeedSourceFormat, #FeedFixedEvent, #FeedInputSource, #FeedDistribution").change(function() {
2021-07-08 11:55:42 +02:00
feedFormUpdate();
});
});
2021-12-28 19:34:33 +01:00
</script>