Merge branch '2.4' into i18n

pull/4276/head
Steve Clement 2019-03-07 10:41:13 +06:00
commit 3c554c5a96
33 changed files with 14369 additions and 137 deletions

View File

@ -1 +1 @@
{"major":2, "minor":4, "hotfix":102}
{"major":2, "minor":4, "hotfix":103}

View File

@ -1,34 +1,57 @@
#!/usr/bin/env bash
# TODO: Improve script to bring workers up that are not.
# TODO: Put some logic inside if many worker PIDs are detected
# Extract base directory where this script is and cd into it
cd "${0%/*}"
# Set to the current webroot owner
WWW_USER=$(ls -l ../cake |awk {'print $3'}|tail -1)
# In most cases the owner of the cake script is also the user as which it should be executed.
if [[ "$USER" != "$WWW_USER" ]]; then
echo "You run this script as $USER and the owner of the cake command is $WWW_USER. This might be an issue."
fi
# Check if run as root
if [ "$EUID" -eq 0 ]; then
if [[ "$EUID" -eq "0" ]]; then
echo "Please DO NOT run the worker script as root"
exit 1
fi
##[[ $(../cake CakeResque.CakeResque stop --all |grep "not permitted" ; echo $?) != 1 ]] && echo "Either you have no permissions or CakeResque is not installed/configured" && exit 1
## FIXME: PIDs seem off by 1
# Check which workers are currently running
WORKERS_PID=$(ps a |grep CakeResque |grep -v grep |cut -f 1 -d\ )
if [[ ! -z $WORKERS_PID ]]; then
for p in $WORKERS_PID; do
WORKER_RUNNING=$(ps $p |grep CakeRes|grep -v grep |grep -o -e "QUEUE=.[a-z]*" |cut -f2 -d\')
#echo "Worker $WORKER_RUNNING with PID $p"
done
# Check if jq is present and enable advanced checks
if [[ "$(jq -V > /dev/null 2> /dev/null; echo $?)" != 0 ]]; then
echo "jq is not installed, disabling advanced checks."
ADVANCED="0"
else
ADVANCED="1"
fi
../cake CakeResque.CakeResque stop --all
../cake CakeResque.CakeResque start --interval 5 --queue default
../cake CakeResque.CakeResque start --interval 5 --queue prio
../cake CakeResque.CakeResque start --interval 5 --queue cache
../cake CakeResque.CakeResque start --interval 5 --queue email
../cake CakeResque.CakeResque startscheduler --interval 5
if [[ "$ADVANCED" == "1" ]]; then
for worker in `echo cache default email prio scheduler`; do
workerStatus=$(../cake Admin getWorkers |tail -n +7 |jq -r ".$worker" |jq -r '.ok')
PIDcount=$(../cake admin getWorkers |tail -n +7 |jq -r ".$worker.workers" |grep pid | wc -l)
echo -n "$worker has $PIDcount PID(s)"
if [[ "$workerStatus" != "true" ]]; then
echo ", trying to restart."
if [[ "$worker" != "scheduler" ]]; then
../cake CakeResque.CakeResque start --interval 5 --queue $worker
else
../cake CakeResque.CakeResque startscheduler --interval 5
fi
else
echo ", up and running."
fi
done
exit 0
else
exit 0
../cake CakeResque.CakeResque stop --all
../cake CakeResque.CakeResque start --interval 5 --queue default
../cake CakeResque.CakeResque start --interval 5 --queue prio
../cake CakeResque.CakeResque start --interval 5 --queue cache
../cake CakeResque.CakeResque start --interval 5 --queue email
../cake CakeResque.CakeResque startscheduler --interval 5
exit 0
fi

22
app/Console/worker/stop.sh Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# TODO: Put some logic inside if many worker PIDs are detected
# Extract base directory where this script is and cd into it
cd "${0%/*}"
# Set to the current webroot owner
WWW_USER=$(ls -l ../cake |awk {'print $3'}|tail -1)
# In most cases the owner of the cake script is also the user as which it should be executed.
if [[ "$USER" != "$WWW_USER" ]]; then
echo "You run this script as $USER and the owner of the cake command is $WWW_USER. This might be an issue."
fi
# Check if run as root
if [[ "$EUID" -eq "0" ]]; then
echo "Please DO NOT run the worker script as root"
exit 1
fi
../cake CakeResque.CakeResque stop --all

View File

@ -296,19 +296,31 @@ class EventsController extends AppController
$passedArgsArray = array();
$urlparams = "";
$overrideAbleParams = array('all', 'attribute', 'published', 'eventid', 'datefrom', 'dateuntil', 'org', 'eventinfo', 'tag', 'tags', 'distribution', 'sharinggroup', 'analysis', 'threatlevel', 'email', 'hasproposal', 'timestamp', 'publishtimestamp', 'publish_timestamp', 'minimal');
$paginationParams = array('limit', 'page', 'sort', 'direction', 'order');
$passedArgs = $this->passedArgs;
if (isset($this->request->data)) {
if (isset($this->request->data['request'])) {
$this->request->data = $this->request->data['request'];
}
foreach ($overrideAbleParams as $oap) {
if (isset($this->request->data['search' . $oap])) {
$this->request->data[$oap] = $this->request->data['search' . $oap];
foreach ($this->request->data as $k => $v) {
if (substr($k, 0, 6) === 'search' && in_array(strtolower(substr($k, 6)), $overrideAbleParams)) {
unset($this->request->data[$k]);
$this->request->data[strtolower(substr($k, 6))] = $v;
} else if (in_array(strtolower($k), $overrideAbleParams)) {
unset($this->request->data[$k]);
$this->request->data[strtolower($k)] = $v;
}
}
foreach ($overrideAbleParams as $oap) {
if (isset($this->request->data[$oap])) {
$passedArgs['search' . $oap] = $this->request->data[$oap];
}
}
foreach ($paginationParams as $paginationParam) {
if (isset($this->request->data[$paginationParam])) {
$passedArgs[$paginationParam] = $this->request->data[$paginationParam];
}
}
}
$this->set('passedArgs', json_encode($passedArgs));
// check each of the passed arguments whether they're a filter (could also be a sort for example) and if yes, add it to the pagination conditions
@ -699,12 +711,6 @@ class EventsController extends AppController
} else {
$rules['order'] = array('Event.id' => 'DESC');
}
if (isset($passedArgs['limit'])) {
$rules['limit'] = intval($passedArgs['limit']);
}
if (isset($passedArgs['page'])) {
$rules['page'] = intval($passedArgs['page']);
}
$rules['contain'] = $this->paginate['contain'];
if (isset($this->paginate['conditions'])) {
$rules['conditions'] = $this->paginate['conditions'];
@ -714,6 +720,12 @@ class EventsController extends AppController
$rules['recursive'] = -1;
$rules['fields'] = array('id', 'timestamp', 'published', 'uuid');
}
$paginationRules = array('page', 'limit', 'sort', 'direction', 'order');
foreach ($paginationRules as $paginationRule) {
if (isset($passedArgs[$paginationRule])) {
$rules[$paginationRule] = $passedArgs[$paginationRule];
}
}
if (empty($rules['limit'])) {
$events = array();
$i = 1;

View File

@ -7345,8 +7345,21 @@ msgstr ""
msgid "Events with the date set to a date after the one specified in the from field (format: 2015-02-15)"
msgstr ""
<<<<<<< HEAD
#: View/Events/legacy_automation.ctp:305
msgid "Events with the date set to a date before the one specified in the to field (format: 2015-02-15)"
=======
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
>>>>>>> 2.4
msgstr ""
#: View/Events/legacy_automation.ctp:312

File diff suppressed because it is too large Load Diff

View File

@ -7357,9 +7357,23 @@ msgstr "Events med datoen sat til en dato efter den der blev specificeret i fra
msgid "Events with the date set to a date before the one specified in the to field (format: 2015-02-15)"
msgstr "Events med datoen sat til en dato før den angivne i feltet til (format: 2015-02-15)"
<<<<<<< HEAD
#: View/Events/legacy_automation.ctp:312
msgid "Restrict the results by the timestamp (of the attribute). Any attributes with a timestamp newer than the given timestamp will be returned."
msgstr "Begræns resultaterne ved hjælp af tidsstempel (på attributten). Eventuelle attributter med et tidsstempel nyere end den angivne tidsstempel returneres."
=======
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
msgstr "Filter"
>>>>>>> 2.4
#: View/Events/legacy_automation.ctp:317
msgid "Only return attributes from events that have received a modification after the given timestamp."

View File

@ -6989,7 +6989,27 @@ msgstr ""
msgid "Delete selected Events"
msgstr ""
<<<<<<< HEAD
#: View/Events/index.ctp:73
=======
#: View/Events/index.ctp:44
msgid "Quickfilter"
msgstr ""
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
msgstr ""
#: View/Events/index.ctp:58
>>>>>>> 2.4
msgid "My events only"
msgstr ""

View File

@ -7349,8 +7349,21 @@ msgstr ""
msgid "Events with the date set to a date before the one specified in the to field (format: 2015-02-15)"
msgstr ""
<<<<<<< HEAD
#: View/Events/legacy_automation.ctp:312
msgid "Restrict the results by the timestamp (of the attribute). Any attributes with a timestamp newer than the given timestamp will be returned."
=======
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
>>>>>>> 2.4
msgstr ""
#: View/Events/legacy_automation.ctp:317

View File

@ -7364,9 +7364,23 @@ msgstr "Pour ne retourner qu'une liste d'attributs, utiliser la syntaxe suivante
msgid "Events with the date set to a date after the one specified in the from field (format: 2015-02-15)"
msgstr "Événements avec une date définie à une date supérieure à celle spécifiée dans le champ \"from\" (format : 2015-02-15)"
<<<<<<< HEAD
#: View/Events/legacy_automation.ctp:305
msgid "Events with the date set to a date before the one specified in the to field (format: 2015-02-15)"
msgstr "Événements avec une date définie à une date antérieure à celle spécifiée dans le champ \"to\" (format : 2015-02-15)"
=======
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
msgstr "Filtre"
>>>>>>> 2.4
#: View/Events/legacy_automation.ctp:312
msgid "Restrict the results by the timestamp (of the attribute). Any attributes with a timestamp newer than the given timestamp will be returned."

View File

@ -6624,6 +6624,10 @@ msgstr ""
msgid "Quickfilter"
msgstr ""
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45

View File

@ -7350,9 +7350,23 @@ msgstr "Per ottenere una elenco di attributi, utilizzare la sintassi seguente"
msgid "Events with the date set to a date after the one specified in the from field (format: 2015-02-15)"
msgstr "Eventi con data successiva a quella specificata nel capo da (formato: 2015-02-15)"
<<<<<<< HEAD
#: View/Events/legacy_automation.ctp:305
msgid "Events with the date set to a date before the one specified in the to field (format: 2015-02-15)"
msgstr "Eventi con data precedente a quella specificata nel capo da (formato: 2015-02-15)"
=======
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
msgstr "Filtro"
>>>>>>> 2.4
#: View/Events/legacy_automation.ctp:312
msgid "Restrict the results by the timestamp (of the attribute). Any attributes with a timestamp newer than the given timestamp will be returned."

View File

@ -7358,9 +7358,23 @@ msgstr "アトリビュートのリストを返すには、次のシンタック
msgid "Events with the date set to a date after the one specified in the from field (format: 2015-02-15)"
msgstr "from 項目で指定された日付より後の日付のイベント (フォーマット: 2015-02-15)"
<<<<<<< HEAD
#: View/Events/legacy_automation.ctp:305
msgid "Events with the date set to a date before the one specified in the to field (format: 2015-02-15)"
msgstr "to 項目に指定された日付より前の日付のイベント (フォーマット: 2015-02-15)"
=======
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
msgstr "フィルター"
>>>>>>> 2.4
#: View/Events/legacy_automation.ctp:312
msgid "Restrict the results by the timestamp (of the attribute). Any attributes with a timestamp newer than the given timestamp will be returned."

View File

@ -7345,8 +7345,21 @@ msgstr ""
msgid "Events with the date set to a date after the one specified in the from field (format: 2015-02-15)"
msgstr ""
<<<<<<< HEAD
#: View/Events/legacy_automation.ctp:305
msgid "Events with the date set to a date before the one specified in the to field (format: 2015-02-15)"
=======
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
>>>>>>> 2.4
msgstr ""
#: View/Events/legacy_automation.ctp:312

View File

@ -7345,8 +7345,21 @@ msgstr ""
msgid "Events with the date set to a date after the one specified in the from field (format: 2015-02-15)"
msgstr ""
<<<<<<< HEAD
#: View/Events/legacy_automation.ctp:305
msgid "Events with the date set to a date before the one specified in the to field (format: 2015-02-15)"
=======
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
>>>>>>> 2.4
msgstr ""
#: View/Events/legacy_automation.ctp:312

View File

@ -7349,8 +7349,21 @@ msgstr ""
msgid "Events with the date set to a date before the one specified in the to field (format: 2015-02-15)"
msgstr ""
<<<<<<< HEAD
#: View/Events/legacy_automation.ctp:312
msgid "Restrict the results by the timestamp (of the attribute). Any attributes with a timestamp newer than the given timestamp will be returned."
=======
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
>>>>>>> 2.4
msgstr ""
#: View/Events/legacy_automation.ctp:317

View File

@ -7345,8 +7345,21 @@ msgstr ""
msgid "Events with the date set to a date after the one specified in the from field (format: 2015-02-15)"
msgstr ""
<<<<<<< HEAD
#: View/Events/legacy_automation.ctp:305
msgid "Events with the date set to a date before the one specified in the to field (format: 2015-02-15)"
=======
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
>>>>>>> 2.4
msgstr ""
#: View/Events/legacy_automation.ctp:312

View File

@ -6624,6 +6624,10 @@ msgstr ""
msgid "Quickfilter"
msgstr ""
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45

View File

@ -7014,7 +7014,27 @@ msgstr ""
msgid "Delete selected Events"
msgstr ""
<<<<<<< HEAD
#: View/Events/index.ctp:73
=======
#: View/Events/index.ctp:44
msgid "Quickfilter"
msgstr ""
#: View/Events/index.ctp:95
msgid "Enter value to search"
msgstr ""
#: View/Events/index.ctp:44
#: View/Organisations/index.ctp:59
#: View/Servers/preview_index.ctp:45
#: View/Tags/index.ctp:56
#: View/Taxonomies/view.ctp:65
msgid "Filter"
msgstr ""
#: View/Events/index.ctp:58
>>>>>>> 2.4
msgid "My events only"
msgstr ""

View File

@ -5702,14 +5702,20 @@ class Event extends AppModel
}
}
}
if ($saved == 1) {
$messageScopeSaved = Inflector::singularize($messageScope);
} else {
$messageScopeSaved = Inflector::pluralize($messageScope);
}
if ($failed > 0) {
if ($failed == 1) {
$message = $saved . ' ' . $messageScope . ' created' . $emailResult . '. ' . $failed . ' ' . $messageScope . ' could not be saved. Reason for the failure: ' . json_encode($lastError);
$messageScopeFailed = Inflector::singularize($messageScope);
$message = $saved . ' ' . $messageScopeSaved . ' created' . $emailResult . '. ' . $failed . ' ' . $messageScopeFailed . ' could not be saved. Reason for the failure: ' . json_encode($lastError);
} else {
$message = $saved . ' ' . $messageScope . ' created' . $emailResult . '. ' . $failed . ' ' . $messageScope . ' could not be saved. This may be due to attributes with similar values already existing.';
$message = $saved . ' ' . $messageScopeSaved . ' created' . $emailResult . '. ' . $failed . ' ' . $messageScope . ' could not be saved. This may be due to attributes with similar values already existing.';
}
} else {
$message = $saved . ' ' . $messageScope . ' created' . $emailResult . '.';
$message = $saved . ' ' . $messageScopeSaved . ' created' . $emailResult . '.';
}
if ($jobId) {
if ($i % 20 == 0) {

View File

@ -79,11 +79,11 @@
<?php
if ($event['Event']['published'] == 1) {
?>
<a href="<?php echo $baseurl."/events/view/".$event['Event']['id'] ?>" title = "<?php echo __('View');?>"><i class="black fa fa-check"></i></a>
<a href="<?php echo $baseurl."/events/view/".$event['Event']['id'] ?>" title = "<?php echo __('View');?>" aria-label = "<?php echo __('View');?>"><i class="black fa fa-check"></i></a>
<?php
} else {
?>
<a href="<?php echo $baseurl."/events/view/".$event['Event']['id'] ?>" title = "<?php echo __('View');?>"><i class="black fa fa-times"></i></a>
<a href="<?php echo $baseurl."/events/view/".$event['Event']['id'] ?>" title = "<?php echo __('View');?>" aria-label = "<?php echo __('View');?>"><i class="black fa fa-times"></i></a>
<?php
}?>&nbsp;
</td>
@ -135,7 +135,7 @@
<span class="blue">
&nbsp;
<a href="<?php echo $baseurl; ?>/events/index/searchtag:<?php echo h($cluster['tag_id']); ?>"><?php echo h($cluster['value']); ?></a>
<a href="<?php echo $baseurl; ?>/galaxy_clusters/view/<?php echo h($cluster['id']); ?>"><i class="black fa fa-search"></i></a>
<a aria-label="<?php echo __('View cluster');?>" href="<?php echo $baseurl; ?>/galaxy_clusters/view/<?php echo h($cluster['id']); ?>"><i class="black fa fa-search"></i></a>
</span>
<?php
endforeach;
@ -218,18 +218,18 @@
<td class="short action-links">
<?php
if (0 == $event['Event']['published'] && ($isSiteAdmin || ($isAclPublish && $event['Event']['orgc_id'] == $me['org_id'])))
echo $this->Form->postLink('', array('action' => 'alert', $event['Event']['id']), array('class' => 'black fa fa-upload', 'title' => __('Publish Event'), __('Are you sure this event is complete and everyone should be informed?')));
echo $this->Form->postLink('', array('action' => 'alert', $event['Event']['id']), array('class' => 'black fa fa-upload', 'title' => __('Publish Event'), 'aria-label' => __('Publish Event')), __('Are you sure this event is complete and everyone should be informed?'));
else if (0 == $event['Event']['published']) echo __('Not published');
if ($isSiteAdmin || ($isAclModify && $event['Event']['user_id'] == $me['id']) || ($isAclModifyOrg && $event['Event']['orgc_id'] == $me['org_id'])):
?>
<a href='<?php echo $baseurl."/events/edit/".$event['Event']['id'];?>' title = "<?php echo __('Edit');?>"><i class="black fa fa-edit"></i></a>
<a href='<?php echo $baseurl."/events/edit/".$event['Event']['id'];?>' title = "<?php echo __('Edit');?>" aria-label = "<?php echo __('Edit');?>"><i class="black fa fa-edit"></i></a>
<?php
echo $this->Form->postLink('', array('action' => 'delete', $event['Event']['id']), array('class' => 'fa fa-trash', 'title' => __('Delete')), __('Are you sure you want to delete # %s?', $event['Event']['id']));
echo $this->Form->postLink('', array('action' => 'delete', $event['Event']['id']), array('class' => 'fa fa-trash', 'title' => __('Delete'), 'aria-label' => __('Delete')), __('Are you sure you want to delete # %s?', $event['Event']['id']));
endif;
?>
<a href='<?php echo $baseurl."/events/view/".$event['Event']['id'];?>' title = "<?php echo __('View');?>"><i class="fa black fa-eye"></i></a>
<a href='<?php echo $baseurl."/events/view/".$event['Event']['id'];?>' title = "<?php echo __('View');?>" aria-label = "<?php echo __('View');?>"><i class="fa black fa-eye"></i></a>
</td>
</tr>
<?php endforeach; ?>

View File

@ -105,7 +105,6 @@ function redrawChosenWithTemplate($select, $chosenContainer, eventType) {
if (optionLength > 1000) {
$chosenContainer.parent().find('.generic-picker-wrapper-warning-text').show(0)
} else {
console.log(eventType);
$chosenContainer.find('.generic-picker-wrapper-warning-text').hide(0)
var $matches;
if (eventType == 'chosen:picked' || eventType == 'change') {

View File

@ -91,8 +91,8 @@
),
array(
'type' => 'search',
'button' => 'Filter',
'placeholder' => 'Enter value to search',
'button' => __('Filter'),
'placeholder' => __('Enter value to search'),
'data' => '',
)
)

View File

@ -72,8 +72,8 @@
),
array(
'type' => 'search',
'button' => 'Filter',
'placeholder' => 'Enter value to search',
'button' => __('Filter'),
'placeholder' => __('Enter value to search'),
'data' => '',
)
)

View File

@ -61,8 +61,8 @@
),
array(
'type' => 'search',
'button' => 'Filter',
'placeholder' => 'Enter value to search',
'button' => __('Filter'),
'placeholder' => __('Enter value to search'),
'data' => '',
)
)

View File

@ -3,7 +3,7 @@
echo '<h2>' . __('Scheduled Tasks') . '</h2>';
echo '<p>' . __('Here you can schedule pre-defined tasks that will be executed every x hours. You can alter the date and time of the next scheduled execution and the frequency at which it will be repeated (expressed in hours). If you set the frequency to 0 then the task will not be repeated. To change and of the above mentioned settings just click on the appropriate field and hit update all when you are done editing the scheduled tasks.') . '</p>';
echo '<p class="red bold">' . __('Warning: Scheduled tasks come with a lot of caveats and little in regards of customisations / granularity. You can instead simply create cron jobs out of the console commands as described here: ');
echo '<a href="' . $baseurl . '/events/automation/#console_tasks">' . __('Automating certain console tasks') . '</a>' . '</p>';
echo '<a href="' . $baseurl . '/events/automation/#console_admin_tasks">' . __('Automating certain console tasks') . '</a>' . '</p>';
?>
<div class="pagination">
<ul>

View File

@ -29,7 +29,7 @@ from stix2misp_mapping import *
from collections import defaultdict
_MISP_dir = "/".join([p for p in os.path.dirname(os.path.realpath(__file__)).split('/')[:-4]])
_PyMISP_dir = '{_MISP_dir}/PyMISP/pymisp'.format(_MISP_dir=_MISP_dir)
_PyMISP_dir = '{_MISP_dir}/PyMISP'.format(_MISP_dir=_MISP_dir)
_MISP_objects_path = '{_MISP_dir}/app/files/misp-objects/objects'.format(_MISP_dir=_MISP_dir)
sys.path.append(_PyMISP_dir)
from pymisp.mispevent import MISPEvent, MISPObject, MISPAttribute
@ -38,7 +38,7 @@ TAG_REGEX = re.compile(r"\(.+\) .+ = .+")
special_parsing = ('relationship', 'report', 'galaxy', 'marking-definition')
galaxy_types = {'attack-pattern': 'Attack Pattern', 'intrusion-set': 'Intrusion Set',
'malware': 'Malware', 'threat-actor': 'Threat Actor', 'tool': 'Tool'}
with open('{_PyMISP_dir}/data/describeTypes.json'.format(_PyMISP_dir=_PyMISP_dir), 'r') as f:
with open('{_PyMISP_dir}/pymisp/data/describeTypes.json'.format(_PyMISP_dir=_PyMISP_dir), 'r') as f:
misp_types = json.loads(f.read())['result'].get('types')
class StixParser():

View File

@ -28,7 +28,7 @@ from stix.core import STIXPackage
from collections import defaultdict
_MISP_dir = "/".join([p for p in os.path.dirname(os.path.realpath(__file__)).split('/')[:-3]])
_PyMISP_dir = '{_MISP_dir}/PyMISP/pymisp'.format(_MISP_dir=_MISP_dir)
_PyMISP_dir = '{_MISP_dir}/PyMISP'.format(_MISP_dir=_MISP_dir)
_MISP_objects_path = '{_MISP_dir}/app/files/misp-objects/objects'.format(_MISP_dir=_MISP_dir)
sys.path.append(_PyMISP_dir)
from pymisp.mispevent import MISPEvent, MISPObject, MISPAttribute
@ -40,7 +40,7 @@ cybox_to_misp_object = {"Account": "credential", "AutonomousSystem": "asn",
threat_level_mapping = {'High': '1', 'Medium': '2', 'Low': '3', 'Undefined': '4'}
with open("{_PyMISP_dir}/data/describeTypes.json".format(_PyMISP_dir=_PyMISP_dir), 'r') as f:
with open("{_PyMISP_dir}/pymisp/data/describeTypes.json".format(_PyMISP_dir=_PyMISP_dir), 'r') as f:
categories = json.loads(f.read())['result'].get('categories')
class StixParser():

@ -1 +1 @@
Subproject commit 8b57a1bf144e6cfb9a65d7c15cba3ff1eccbc103
Subproject commit bb9cf757ed648786e424b9e2624905a7d0372aa5

@ -1 +1 @@
Subproject commit 2b6b07b28a2937f658accc2f7eeb825396b8120c
Subproject commit d24febd23c17dc7c330672dd0a5b03e0d9ea6248

View File

@ -1,5 +1,5 @@
# Path to your MISP installation
MISPPath=/var/www/MISP
PATH_TO_MISP=/var/www/MISP
# First part of output file name
# Name of output file for default would be e.g. MISP-Backup-20170601_215628.tar.gz

View File

@ -1,8 +1,7 @@
#@IgnoreInspection BashAddShebang
#!/bin/sh
#!/usr/bin/env bash
## $Id: misp-backup.sh 07.04.2016 $
##
## script to backup MISP on debian/ubuntu 18.04.1
## script to backup MISP on debian/ubuntu 18.04.2
##
## Authored by daverstephens@gmail.com
## https://github.com/daverstephens/The-SOC-Shop
@ -15,22 +14,31 @@
##
## This script can be used to backup a complete MISP
## DB and config to restore onto a freshly
## MySQL DB and config to restore onto a freshly
## built system. This is not intended as an upgrade script
## to move between MISP versions - But it might work ;).
##
## Tested against MISP 2.4.101
## Tested against MISP 2.4.102
##
## Run the script as the standard user with the command below
## Run the script as the standard web user with the command below
##
## cp misp-backup.conf.sample misp-backup.conf
## vi misp-backup.conf # adjust values
## sudo sh -x misp-backup.sh 2>&1 | tee misp-backup.log
## sudo bash misp-backup.sh 2>&1 | tee misp-backup.log
##
## TODO: Target directory, rudimentary free space check: stat -f --format="%a" OutputDirName
## TODO: Make sure no directories are blank
## TODO: Review how much sense it makes to ask fo MySQL credentials when most of the script does auto detection anyway.
##
# Leave empty for NO debug messages, if run with set -x or bash -x it will enable DEBUG by default
DEBUG=
case "$-" in
*x*) NO_PROGRESS=1; DEBUG=1 ;;
*) NO_PROGRESS=0 ;;
esac
## Functions
# Dynamic horizontal spacer
@ -48,89 +56,128 @@ space () {
# Make sure the target has enough free space
checkDiskFree () {
if [[ ! -e $1 ]]; then
echo "$1 does not exist, creating"
mkdir -p $1
fi
threshhold=90
free=$(df -l --sync --output=pcent $1 |tail -1|cut -f 1 -d% | tr -d \ )
if [ $free > $threshhold ]; then
if [[ "$free" > "$threshhold" ]]; then
space
echo "Your destination folder is $threshhold% full."
space
exit 1
fi
}
# Check if variable is empty
checkVar () {
[[ -z $1 ]] && echo "$1 is empty, please investigate." && exit 1
}
## Time to set some variables
##
FILE=./misp-backup.conf
# Extract base directory where this script is and cd into it
cd "${0%/*}"
# Set to the current webroot owner
WWW_USER=$(ls -l $0 |awk {'print $3'}|tail -1)
# In most cases the owner of the cake script is also the user as which it should be executed.
if [[ "$USER" != "$WWW_USER" ]]; then
echo "You run this script as $USER and the owner of the backup script is $WWW_USER. FYI."
fi
# Check if run as root
if [[ "$EUID" != "0" ]]; then
echo "Please run the backup script as root"
exit 1
fi
# Source configuration file
if [ -f $FILE ];
then
echo "File $FILE exists."
echo "File $(pwd)$FILE exists."
. $FILE
else
echo "Config File $FILE does not exist. Please enter values manually"
## MySQL stuff
echo 'Please enter your MySQL root account username'
space
echo -n 'Please enter your MySQL root account username: '
read MySQLRUser
echo 'Please enter your MySQL root account password'
echo -n 'Please enter your MySQL root account password: '
read MySQLRPass
echo 'What would you like to call the backup archive?'
echo 'Eg. MISPBackup'
echo -n 'Please enter a name for the backup archive (e.g MISPBackup): '
read OutputFileName
echo 'Where would you like to save the file?'
echo 'Eg. /tmp'
echo -n 'Please enter the destination for the archive (e.g /tmp): '
read OutputDirName
fi
# Fill in any missing values with defaults
# MISP path
MISPPath=${MISPPath:-$(locate MISP/app/webroot/index.php|sed 's/\/app\/webroot\/index\.php//')}
# MISP path detector
if [[ -z $PATH_TO_MISP ]]; then
if [[ "$(locate > /dev/null 2> /dev/null ; echo $?)" != "127" ]]; then
if [[ "$(locate MISP/app/webroot/index.php |wc -l)" > 1 ]]; then
echo "We located more then 1 MISP/app/webroot, reverting to manual"
PATH_TO_MISP=${PATH_TO_MISP:-$(locate MISP/app/webroot/index.php|sed 's/\/app\/webroot\/index\.php//')}
echo -n 'Please enter the base path of your MISP install (e.g /var/www/MISP): '
read PATH_TO_MISP
fi
fi
fi
# Output
OutputFileName=${OutputFileName:-MISP-Backup}
OutputDirName=${OutputDirName:-/tmp}
OutputFull="${OutputDirName}/${OutputFileName}-$(date '+%Y%m%d_%H%M%S').tar.gz"
# database.php
MySQLUUser=$(grep -o -P "(?<='login' => ').*(?=')" $MISPPath/app/Config/database.php)
MySQLUPass=$(grep -o -P "(?<='password' => ').*(?=')" $MISPPath/app/Config/database.php)
MISPDB=$(grep -o -P "(?<='database' => ').*(?=')" $MISPPath/app/Config/database.php)
DB_Port=$(grep -o -P "(?<='port' => ).*(?=,)" $MISPPath/app/Config/database.php)
MISPDBHost=$(grep -o -P "(?<='host' => ').*(?=')" $MISPPath/app/Config/database.php)
# config.php
Salt=$(grep -o -P "(?<='salt' => ').*(?=')" $MISPPath/app/Config/config.php)
BaseURL=$(grep -o -P "(?<='baseurl' => ').*(?=')" $MISPPath/app/Config/config.php)
OrgName=$(grep -o -P "(?<='org' => ').*(?=')" $MISPPath/app/Config/config.php)
LogEmail=$(grep -o -P "(?<='email' => ').*(?=')" $MISPPath/app/Config/config.php|head -1)
AdminEmail=$(grep -o -P "(?<='contact' => ').*(?=')" $MISPPath/app/Config/config.php)
GnuPGEmail=$(sed -n -e '/GnuPG/,$p' $MISPPath/app/Config/config.php|grep -o -P "(?<='email' => ').*(?=')")
GnuPGHomeDir=$(grep -o -P "(?<='homedir' => ').*(?=')" $MISPPath/app/Config/config.php)
GnuPGPass=$(grep -o -P "(?<='password' => ').*(?=')" $MISPPath/app/Config/config.php)
## Folders to be checked for useable space: OutputDirName
## To be checked for emptiness: all?
# database.php
MySQLUUser=$(grep -o -P "(?<='login' => ').*(?=')" $PATH_TO_MISP/app/Config/database.php) ; checkVar MySQLUUser
MySQLUPass=$(grep -o -P "(?<='password' => ').*(?=')" $PATH_TO_MISP/app/Config/database.php) ; checkVar MySQLUPass
MISPDB=$(grep -o -P "(?<='database' => ').*(?=')" $PATH_TO_MISP/app/Config/database.php) ; checkVar MISPDB
DB_Port=$(grep -o -P "(?<='port' => ).*(?=,)" $PATH_TO_MISP/app/Config/database.php) ; checkVar DB_Port
MISPDBHost=$(grep -o -P "(?<='host' => ').*(?=')" $PATH_TO_MISP/app/Config/database.php) ; checkVar MISPDBHost
# config.php
Salt=$(grep -o -P "(?<='salt' => ').*(?=')" $PATH_TO_MISP/app/Config/config.php) ; checkVar Salt
BaseURL=$(grep -o -P "(?<='baseurl' => ').*(?=')" $PATH_TO_MISP/app/Config/config.php) # BaseURL can be empty
OrgName=$(grep -o -P "(?<='org' => ').*(?=')" $PATH_TO_MISP/app/Config/config.php) ; checkVar OrgName
LogEmail=$(grep -o -P "(?<='email' => ').*(?=')" $PATH_TO_MISP/app/Config/config.php|head -1) ; checkVar LogEmail
AdminEmail=$(grep -o -P "(?<='contact' => ').*(?=')" $PATH_TO_MISP/app/Config/config.php) ; checkVar AdminEmail
GnuPGEmail=$(sed -n -e '/GnuPG/,$p' $PATH_TO_MISP/app/Config/config.php|grep -o -P "(?<='email' => ').*(?=')") ; checkVar GnuPGEmail
GnuPGHomeDir=$(grep -o -P "(?<='homedir' => ').*(?=')" $PATH_TO_MISP/app/Config/config.php) ; checkVar GnuPGHomeDir
GnuPGPass=$(grep -o -P "(?<='password' => ').*(?=')" $PATH_TO_MISP/app/Config/config.php) ; checkVar GnuPGPass
checkDiskFree $OutputDirName
# Create backup files
TmpDir="$(mktemp --tmpdir=$OutputDirName -d)"
cp -r $GnuPGHomeDir/* $TmpDir/
cp -rp $GnuPGHomeDir/* $TmpDir/
echo "copy of org images and other custom images"
cp -r $MISPPath/app/webroot/img/orgs $TmpDir/
cp -r $MISPPath/app/webroot/img/custom $TmpDir/
cp -r $MISPPath/app/files $TmpDir
cp -rp $PATH_TO_MISP/app/webroot/img/orgs $TmpDir/
cp -rp $PATH_TO_MISP/app/webroot/img/custom $TmpDir/
cp -rp $PATH_TO_MISP/app/files $TmpDir
# MISP Config files
mkdir -p $TmpDir/Config
cp $MISPPath/app/Config/bootstrap.php $TmpDir/Config
cp $MISPPath/app/Config/config.php $TmpDir/Config
cp $MISPPath/app/Config/core.php $TmpDir/Config
cp $MISPPath/app/Config/database.php $TmpDir/Config
cp -p $PATH_TO_MISP/app/Config/bootstrap.php $TmpDir/Config
cp -p $PATH_TO_MISP/app/Config/config.php $TmpDir/Config
cp -p $PATH_TO_MISP/app/Config/core.php $TmpDir/Config
cp -p $PATH_TO_MISP/app/Config/database.php $TmpDir/Config
echo "MySQL Dump"
MySQLRUser=${MySQLRUser:-$MySQLUUser}
MySQLRPass=${MySQLRPass:-$MySQLUPass}
mysqldump --opt -u $MySQLRUser -p$MySQLRPass $MISPDB > $TmpDir/MISPbackupfile.sql
if [[ "$?" != "0" ]]; then
echo "MySQLdump failed, abort." && exit 1
fi
# Create compressed archive
cd $TmpDir
tar -zcf $OutputFull ./*
tar -pzcf $OutputFull ./*
cd -
rm -rf $TmpDir
echo "MISP Backup Completed, OutputDir: ${OutputDirName}"

147
tools/misp-backup/misp-restore.sh Normal file → Executable file
View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
#
# Inspired from daverstephens@gmail.com and @alexanderjaeger work on misp-backup.sh
#
@ -22,58 +22,131 @@
#
# sudo sh ./misp-restore.sh PATH_TO_ARCHIVE.tar.gz
#
# Leave empty for NO debug messages, if run with set -x or bash -x it will enable DEBUG by default
DEBUG=
case "$-" in
*x*) NO_PROGRESS=1; DEBUG=1 ;;
*) NO_PROGRESS=0 ;;
esac
## Functions
# Dynamic horizontal spacer
space () {
if [[ "$NO_PROGRESS" == "1" ]]; then
return
fi
# Check terminal width
num=`tput cols`
for i in `seq 1 $num`; do
echo -n "-"
done
echo ""
}
# Make sure the target has enough free space
checkDiskFree () {
if [[ ! -e $1 ]]; then
echo "$1 does not exist, creating"
mkdir -p $1
fi
threshhold=90
free=$(df -l --sync --output=pcent $1 |tail -1|cut -f 1 -d% | tr -d \ )
if [[ "$free" > "$threshhold" ]]; then
space
echo "Your destination folder is $threshhold% full."
space
exit 1
fi
}
# Check if variable is empty
checkVar () {
[[ -z $1 ]] && echo "$1 is empty, please investigate." && exit 1
}
echo '-- Starting MISP restore process'
FILE=./misp-backup.conf
if [ ! -z $1 ] && [ -f $1 ];
then
# Extract base directory where this script is and cd into it
cd "${0%/*}"
# Set to the current webroot owner
WWW_USER=$(ls -l $0 |awk {'print $3'}|tail -1)
# In most cases the owner of the cake script is also the user as which it should be executed.
if [[ "$USER" != "$WWW_USER" ]]; then
echo "You run this script as $USER and the owner of the backup script is $WWW_USER, this should be your web server user. FYI."
fi
# Check if run as root
if [[ "$EUID" != "0" ]]; then
echo "Please run the backup script as root"
exit 1
fi
if [ ! -z $1 ] && [ -f $1 ]; then
BackupFile=$1
else
echo 'Specify backup file by running ./misp-restore.sh PATH_TO_ARCHIVE.tar.gz'
exit 1
exit 1
fi
# Source configuration file
if [ -f $FILE ];
then
echo "--- File $FILE exists."
. $FILE
if [ -f $FILE ]; then
echo "--- File $(pwd)$FILE exists."
. $FILE
else
echo "--- Config File $FILE does not exist. Please enter values manually"
echo '--- Where would you like to decompress backup files?'
echo 'Eg. /tmp'
read OutputDirName
echo "--- Config File $FILE does not exist. Please enter values manually"
echo '--- Where would you like to decompress backup files?'
echo 'Eg. /tmp'
read OutputDirName
fi
checkDiskFree OutputDirName
# Decompress archive
BackupDir=$OutputDirName/$(basename -s ".tar.gz" $BackupFile)
mkdir $BackupDir
echo '--- Decompressing files'
tar zxf $1 -C $BackupDir
tar zxpf $BackupFile -C $BackupDir
# Fill in any missing values with defaults
# MISP path - Required : MISP should be installed
MISPPath=${MISPPath:-$(locate MISP/app/webroot/index.php|sed 's/\/app\/webroot\/index\.php//')}
# MISP path detector
if [[ -z $PATH_TO_MISP ]]; then
if [[ "$(locate > /dev/null 2> /dev/null ; echo $?)" != "127" ]]; then
if [[ "$(locate MISP/app/webroot/index.php |wc -l)" > 1 ]]; then
echo "We located more then 1 MISP/app/webroot, reverting to manual"
PATH_TO_MISP=${PATH_TO_MISP:-$(locate MISP/app/webroot/index.php|sed 's/\/app\/webroot\/index\.php//')}
echo -n 'Please enter the base path of your MISP install (e.g /var/www/MISP): '
read PATH_TO_MISP
fi
fi
fi
if [[ -d $PATH_TO_MISP ]]; then
:
fi
# database.php
MySQLUUser=$(grep -o -P "(?<='login' => ').*(?=')" $BackupDir/Config/database.php)
MySQLUPass=$(grep -o -P "(?<='password' => ').*(?=')" $BackupDir/Config/database.php)
MISPDB=$(grep -o -P "(?<='database' => ').*(?=')" $BackupDir/Config/database.php)
DB_Port=$(grep -o -P "(?<='port' => ).*(?=,)" $BackupDir/Config/database.php)
MISPDBHost=$(grep -o -P "(?<='host' => ').*(?=')" $BackupDir/Config/database.php)
MySQLUUser=$(grep -o -P "(?<='login' => ').*(?=')" $BackupDir/Config/database.php) ; checkVar MySQLUUser
MySQLUPass=$(grep -o -P "(?<='password' => ').*(?=')" $BackupDir/Config/database.php) ; checkVar MySQLUPass
MISPDB=$(grep -o -P "(?<='database' => ').*(?=')" $BackupDir/Config/database.php) ; checkVar MISPDB
DB_Port=$(grep -o -P "(?<='port' => ).*(?=,)" $BackupDir/Config/database.php) ; checkVar DB_Port
MISPDBHost=$(grep -o -P "(?<='host' => ').*(?=')" $BackupDir/Config/database.php) ; checkVar MISPDBHost
# config.php
Salt=$(grep -o -P "(?<='salt' => ').*(?=')" $BackupDir/Config/config.php)
BaseURL=$(grep -o -P "(?<='baseurl' => ').*(?=')" $BackupDir/Config/config.php)
OrgName=$(grep -o -P "(?<='org' => ').*(?=')" $BackupDir/Config/config.php)
LogEmail=$(grep -o -P "(?<='email' => ').*(?=')" $BackupDir/Config/config.php|head -1)
AdminEmail=$(grep -o -P "(?<='contact' => ').*(?=')" $BackupDir/Config/config.php)
GnuPGEmail=$(sed -n -e '/GnuPG/,$p' $BackupDir/Config/config.php|grep -o -P "(?<='email' => ').*(?=')")
GnuPGHomeDir=$(grep -o -P "(?<='homedir' => ').*(?=')" $BackupDir/Config/config.php)
GnuPGPass=$(grep -o -P "(?<='password' => ').*(?=')" $BackupDir/Config/config.php)
Salt=$(grep -o -P "(?<='salt' => ').*(?=')" $BackupDir/Config/config.php) ; checkVar Salt
BaseURL=$(grep -o -P "(?<='baseurl' => ').*(?=')" $BackupDir/Config/config.php) # BaseURL can be empty
OrgName=$(grep -o -P "(?<='org' => ').*(?=')" $BackupDir/Config/config.php) ; checkVar OrgName
LogEmail=$(grep -o -P "(?<='email' => ').*(?=')" $BackupDir/Config/config.php|head -1) ; checkVar LogEmail
AdminEmail=$(grep -o -P "(?<='contact' => ').*(?=')" $BackupDir/Config/config.php) ; checkVar AdminEmail
GnuPGEmail=$(sed -n -e '/GnuPG/,$p' $BackupDir/Config/config.php|grep -o -P "(?<='email' => ').*(?=')") ; checkVar GnuPGEmail
GnuPGHomeDir=$(grep -o -P "(?<='homedir' => ').*(?=')" $BackupDir/Config/config.php) ; checkVar GnuPGHomeDir
GnuPGPass=$(grep -o -P "(?<='password' => ').*(?=')" $BackupDir/Config/config.php) ; checkVar GnuPGPass
# Restore backup files
echo "--- Copy of GnuPG files"
@ -83,21 +156,21 @@ cp $BackupDir/random_seed $GnuPGHomeDir/
echo "--- Copy of org and images and files"
cp -r $BackupDir/orgs $MISPPath/app/webroot/img/
cp -r $BackupDir/custom $MISPPath/app/webroot/img/
cp -r $BackupDir/files $MISPPath/app/
cp -pr $BackupDir/orgs $MISPPath/app/webroot/img/
cp -pr $BackupDir/custom $MISPPath/app/webroot/img/
cp -pr $BackupDir/files $MISPPath/app/
# Restore MISP Config files
echo "--- Copy of app/Config files"
cp $BackupDir/Config/bootstrap.php $MISPPath/app/Config
cp $BackupDir/Config/config.php $MISPPath/app/Config
cp $BackupDir/Config/core.php $MISPPath/app/Config
cp $BackupDir/Config/database.php $MISPPath/app/Config
cp -p $BackupDir/Config/bootstrap.php $MISPPath/app/Config
cp -p $BackupDir/Config/config.php $MISPPath/app/Config
cp -p $BackupDir/Config/core.php $MISPPath/app/Config
cp -p $BackupDir/Config/database.php $MISPPath/app/Config
# Permissions
echo "--- Setting persmissions"
chown -R www-data:www-data /var/www/MISP
chown -R $WWW_USER:$WWW_USER /var/www/MISP
chmod -R 750 /var/www/MISP
chmod -R g+ws /var/www/MISP/app/tmp
chmod -R g+ws /var/www/MISP/app/files