mirror of https://github.com/MISP/MISP
Fixed various things
- logging of event publishing enabled for background jobs - disabled a gpg debug mode that was enabled by accident - better feedback for publishingpull/217/head
parent
6cc9778979
commit
07c4536932
|
@ -229,11 +229,12 @@ class EventShell extends AppShell
|
|||
public function alertemail() {
|
||||
$org = $this->args[0];
|
||||
$processId = $this->args[1];
|
||||
$this->Job->id = $processId;
|
||||
$job = $this->Job->read(null, $processId);
|
||||
$eventId = $this->args[2];
|
||||
$result = $this->Event->sendAlertEmail($eventId, $org, $processId);
|
||||
$this->Job->saveField('progress', '100');
|
||||
if ($result != true) $this->Job->saveField('message', 'Job done.');
|
||||
$job['Job']['progress'] = 100;
|
||||
$job['Job']['message'] = 'Emails sent.';
|
||||
$this->Job->save($job);
|
||||
}
|
||||
|
||||
public function contactemail() {
|
||||
|
@ -289,11 +290,34 @@ class EventShell extends AppShell
|
|||
$id = $this->args[0];
|
||||
$passAlong = $this->args[1];
|
||||
$jobId = $this->args[2];
|
||||
$this->Job->id = $jobId;
|
||||
$org = $this->args[3];
|
||||
$email = $this->args[4];
|
||||
$user = $this->User->find('first', array(
|
||||
'conditions' => array('email' => $email),
|
||||
'fields' => array('email', 'org', 'id'),
|
||||
'recursive' => -1,
|
||||
));
|
||||
$job = $this->Job->read(null, $jobId);
|
||||
$eventId = $this->args[2];
|
||||
$result = $this->Event->publish($id, $passAlong, $jobId);
|
||||
$this->Job->saveField('progress', '100');
|
||||
if ($result != true) $this->Job->saveField('message', 'Job done.');
|
||||
$this->Event->Behaviors->unload('SysLogLogable.SysLogLogable');
|
||||
$result = $this->Event->publish($id, $passAlong);
|
||||
$job['Job']['progress'] = 100;
|
||||
if ($result) {
|
||||
$job['Job']['message'] = 'Event published.';
|
||||
} else {
|
||||
$job['Job']['message'] = 'Event published, but the upload to other instances may have failed.';
|
||||
}
|
||||
$this->Job->save($job);
|
||||
$log = ClassRegistry::init('Log');
|
||||
$log->create();
|
||||
$log->save(array(
|
||||
'org' => $user['User']['org'],
|
||||
'email' =>$user['User']['email'],
|
||||
'user_id' => $user['User']['id'],
|
||||
'action' => 'publish',
|
||||
'title' => 'Event (' . $id . '): published.',
|
||||
'change' => 'published () => (1)'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -979,7 +979,7 @@ class EventsController extends AppController {
|
|||
// only allow form submit CSRF protection.
|
||||
if ($this->request->is('post') || $this->request->is('put')) {
|
||||
// Performs all the actions required to publish an event
|
||||
$result = $this->Event->publishRouter($id, null, $this->Auth->user('org'));
|
||||
$result = $this->Event->publishRouter($id, null, $this->Auth->user('org'), $this->Auth->user('email'));
|
||||
if (!Configure::read('MISP.background_jobs')) {
|
||||
if (!is_array($result)) {
|
||||
// redirect to the view event page
|
||||
|
@ -1021,7 +1021,7 @@ class EventsController extends AppController {
|
|||
$emailResult = $this->Event->sendAlertEmailRouter($id, $this->Auth->user(), $this->_isSiteAdmin());
|
||||
if (is_bool($emailResult) && $emailResult = true) {
|
||||
// Performs all the actions required to publish an event
|
||||
$result = $this->Event->publishRouter($id, null, $this->Auth->user('org'));
|
||||
$result = $this->Event->publishRouter($id, null, $this->Auth->user('org'), $this->Auth->user('email'));
|
||||
if (!is_array($result)) {
|
||||
|
||||
// redirect to the view event page
|
||||
|
|
|
@ -28,7 +28,7 @@ class LogsController extends AppController {
|
|||
parent::beforeFilter();
|
||||
|
||||
// permit reuse of CSRF tokens on the search page.
|
||||
if ('admin_search' == $this->request->params['action']) {
|
||||
if ('search' == $this->request->params['action']) {
|
||||
$this->Security->csrfUseOnce = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -697,7 +697,7 @@ class UsersController extends AppController {
|
|||
$i = 0;
|
||||
foreach ($recipients as $recipient) {
|
||||
if (!empty($recipientGPG[$i])) {
|
||||
$gpg = new Crypt_GPG(array('homedir' => Configure::read('GnuPG.homedir'), 'debug' => true)); // , 'debug' => true
|
||||
$gpg = new Crypt_GPG(array('homedir' => Configure::read('GnuPG.homedir'))); // , 'debug' => true
|
||||
$gpg->addSignKey(Configure::read('GnuPG.email'), Configure::read('GnuPG.password'));
|
||||
$messageSigned = $gpg->sign($message[$i], Crypt_GPG::SIGN_MODE_CLEAR);
|
||||
$keyImportOutput = $gpg->importKey($recipientGPG[$i]);
|
||||
|
|
|
@ -1137,6 +1137,7 @@ class Event extends AppModel {
|
|||
$Email->send($bodySigned);
|
||||
$Email->reset();
|
||||
if ($processId) {
|
||||
$this->Job->id = $processId;
|
||||
$this->Job->saveField('progress', $k / $max * 50);
|
||||
}
|
||||
}
|
||||
|
@ -1485,7 +1486,7 @@ class Event extends AppModel {
|
|||
}
|
||||
}
|
||||
|
||||
public function publishRouter($id, $passAlong = null, $org = null) {
|
||||
public function publishRouter($id, $passAlong = null, $org = null, $email = null) {
|
||||
if (Configure::read('MISP.background_jobs')) {
|
||||
$job = ClassRegistry::init('Job');
|
||||
$job->create();
|
||||
|
@ -1503,7 +1504,7 @@ class Event extends AppModel {
|
|||
$process_id = CakeResque::enqueue(
|
||||
'default',
|
||||
'EventShell',
|
||||
array('publish', $id, $passAlong, $jobId)
|
||||
array('publish', $id, $passAlong, $jobId, $org, $email)
|
||||
);
|
||||
$job->saveField('process_id', $process_id);
|
||||
return $process_id;
|
||||
|
@ -1518,7 +1519,10 @@ class Event extends AppModel {
|
|||
*
|
||||
* @param unknown_type $id
|
||||
*/
|
||||
public function publish($id, $passAlong = null, $processId = null) {
|
||||
public function publish($id, $passAlong = null, $jobId = null) {
|
||||
if ($jobId) {
|
||||
$this->Behaviors->unload('SysLogLogable.SysLogLogable');
|
||||
}
|
||||
$this->id = $id;
|
||||
$this->recursive = 0;
|
||||
$event = $this->read(null, $id);
|
||||
|
@ -1526,7 +1530,7 @@ class Event extends AppModel {
|
|||
$fieldList = array('published', 'id', 'info', 'publish_timestamp');
|
||||
$event['Event']['published'] = 1;
|
||||
$event['Event']['publish_timestamp'] = time();
|
||||
$this->save($event, array('fieldList' => $fieldList));
|
||||
$this->save($event, array('fieldList' => $fieldList));
|
||||
$uploaded = false;
|
||||
if ('true' == Configure::read('MISP.sync') && $event['Event']['distribution'] > 1) {
|
||||
$uploaded = $this->uploadEventToServersRouter($id, $passAlong);
|
||||
|
@ -1534,12 +1538,6 @@ class Event extends AppModel {
|
|||
$this->saveField('published', 0);
|
||||
}
|
||||
} else {
|
||||
if ($processId != null) {
|
||||
$job = ClassRegistry::init('Job');
|
||||
$job->id = $processId;
|
||||
$job->saveField('progress', 100);
|
||||
$job->saveField('message', 'Event (' . $id . ') published.');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return $uploaded;
|
||||
|
|
Loading…
Reference in New Issue