mirror of https://github.com/MISP/MISP
Fix to the new sync issues since 2.3.39, fixing #365
Incorrectly trying to look up authenticated user in the model fixedpull/375/head
parent
b44f556f33
commit
6b6c62bd53
|
@ -1 +1 @@
|
|||
{"major":2, "minor":3, "hotfix":39}
|
||||
{"major":2, "minor":3, "hotfix":40}
|
||||
|
|
|
@ -18,7 +18,7 @@ class ServerShell extends AppShell
|
|||
$this->User->recursive = -1;
|
||||
$user = $this->User->read(null, $userId);
|
||||
$server = $this->Server->read(null, $serverId);
|
||||
$result = $this->Server->pull($user['User'], null, $technique, $server, $jobId);
|
||||
$result = $this->Server->pull($user['User'], $serverId, $technique, $server, $jobId);
|
||||
$this->Job->id = $jobId;
|
||||
$this->Job->save(array(
|
||||
'id' => $jobId,
|
||||
|
@ -53,20 +53,23 @@ class ServerShell extends AppShell
|
|||
$serverId = $this->args[0];
|
||||
$technique = $this->args[1];
|
||||
$jobId = $this->args[2];
|
||||
$userId = $this->args[3];
|
||||
$this->Job->read(null, $jobId);
|
||||
$server = $this->Server->read(null, $serverId);
|
||||
App::uses('SyncTool', 'Tools');
|
||||
$syncTool = new SyncTool();
|
||||
$HttpSocket = $syncTool->setupHttpSocket($server);
|
||||
$result = $this->Server->push($serverId, 'full', $jobId, $HttpSocket);
|
||||
$this->User->recursive = -1;
|
||||
$user = $this->User->read(array('id', 'org', 'email'), $userId);
|
||||
$result = $this->Server->push($serverId, 'full', $jobId, $HttpSocket, $user['User']['email']);
|
||||
$this->Job->save(array(
|
||||
'id' => $jobId,
|
||||
'message' => 'Job done.',
|
||||
'progress' => 100,
|
||||
'status' => 4
|
||||
));
|
||||
if (isset($this->args[3])) {
|
||||
$this->Task->id = $this->args[4];
|
||||
if (isset($this->args[4])) {
|
||||
$this->Task->id = $this->args[5];
|
||||
$this->Task->saveField('message', 'Job(s) started at ' . date('d/m/Y - H:i:s') . '.');
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +94,7 @@ class ServerShell extends AppShell
|
|||
'job_input' => 'Server: ' . $server['Server']['id'],
|
||||
'retries' => 0,
|
||||
'org' => $user['User']['org'],
|
||||
'process_id' => $this->Task->data['Task']['job_id'],
|
||||
'process_id' => 'Part of scheduled pull',
|
||||
'message' => 'Pushing.',
|
||||
);
|
||||
$this->Job->save($data);
|
||||
|
@ -150,6 +153,7 @@ class ServerShell extends AppShell
|
|||
$timestamp = $this->args[0];
|
||||
$taskId = $this->args[1];
|
||||
$org = $this->args[2];
|
||||
$userId = $this->args[3];
|
||||
$this->Task->id = $taskId;
|
||||
$task = $this->Task->read(null, $taskId);
|
||||
if ($timestamp != $task['Task']['next_execution_time']) {
|
||||
|
@ -167,7 +171,7 @@ class ServerShell extends AppShell
|
|||
'job_input' => 'Server: ' . $server['Server']['id'],
|
||||
'retries' => 0,
|
||||
'org' => $org,
|
||||
'process_id' => $this->Task->data['Task']['job_id'],
|
||||
'process_id' => 'Part of scheduled push',
|
||||
'message' => 'Pushing.',
|
||||
);
|
||||
$this->Job->save($data);
|
||||
|
@ -175,7 +179,7 @@ class ServerShell extends AppShell
|
|||
App::uses('SyncTool', 'Tools');
|
||||
$syncTool = new SyncTool();
|
||||
$HttpSocket = $syncTool->setupHttpSocket($server);
|
||||
$result = $this->Server->push($server['Server']['id'], 'full', $jobId, $HttpSocket);
|
||||
$result = $this->Server->push($server['Server']['id'], 'full', $jobId, $HttpSocket, $user['User']['email']);
|
||||
}
|
||||
$task['Task']['message'] = count($servers) . ' job(s) completed at ' . date('d/m/Y - H:i:s') . '.';
|
||||
if ($task['Task']['timer'] > 0) {
|
||||
|
@ -192,7 +196,7 @@ class ServerShell extends AppShell
|
|||
$task['Task']['next_execution_time'],
|
||||
'default',
|
||||
'ServerShell',
|
||||
array('enqueuePush', $task['Task']['next_execution_time'], $taskId, $org),
|
||||
array('enqueuePush', $task['Task']['next_execution_time'], $taskId, $org, $userId),
|
||||
true
|
||||
);
|
||||
$task['Task']['job_id'] = $process_id;
|
||||
|
|
|
@ -233,7 +233,7 @@ class ServersController extends AppController {
|
|||
App::uses('SyncTool', 'Tools');
|
||||
$syncTool = new SyncTool();
|
||||
$HttpSocket = $syncTool->setupHttpSocket($server);
|
||||
$result = $this->Server->push($this->Auth->user(), $id, $technique, false, $HttpSocket);
|
||||
$result = $this->Server->push($id, $technique, false, $HttpSocket, $this->Auth->user('email'));
|
||||
$this->set('successes', $result[0]);
|
||||
$this->set('fails', $result[1]);
|
||||
} else {
|
||||
|
@ -253,7 +253,7 @@ class ServersController extends AppController {
|
|||
$process_id = CakeResque::enqueue(
|
||||
'default',
|
||||
'ServerShell',
|
||||
array('push', $id, $technique, $jobId)
|
||||
array('push', $id, $technique, $jobId, $this->Auth->user('id'))
|
||||
);
|
||||
$this->Job->saveField('process_id', $process_id);
|
||||
$this->Session->setFlash('Push queued for background execution.');
|
||||
|
|
|
@ -99,7 +99,7 @@ class TasksController extends AppController {
|
|||
$timestamp,
|
||||
'default',
|
||||
'ServerShell',
|
||||
array('enqueuePush', $timestamp, $id, $this->Auth->user('org')),
|
||||
array('enqueuePush', $timestamp, $id, $this->Auth->user('org'), $this->Auth->user('id')),
|
||||
true
|
||||
);
|
||||
$this->Task->id = $id;
|
||||
|
|
|
@ -472,7 +472,7 @@ class Server extends AppModel {
|
|||
$this->Auth->login($user);
|
||||
$email = "Scheduled job";
|
||||
} else {
|
||||
$email = $this->Auth->user('email');
|
||||
$email = $user['email'];
|
||||
}
|
||||
$eventModel = ClassRegistry::init('Event');
|
||||
App::uses('HttpSocket', 'Network/Http');
|
||||
|
@ -663,13 +663,10 @@ class Server extends AppModel {
|
|||
return array($successes, $fails, $pulledProposals, $lastpulledid);
|
||||
}
|
||||
|
||||
public function push($id = null, $technique=false, $jobId = false, $HttpSocket) {
|
||||
public function push($id = null, $technique=false, $jobId = false, $HttpSocket, $email = "Scheduled job") {
|
||||
if ($jobId) {
|
||||
$job = ClassRegistry::init('Job');
|
||||
$job->read(null, $jobId);
|
||||
$email = "Scheduled job";
|
||||
} else {
|
||||
$email = $this->Auth->user('email');
|
||||
}
|
||||
$eventModel = ClassRegistry::init('Event');
|
||||
$this->read(null, $id);
|
||||
|
|
Loading…
Reference in New Issue