fix: add missing jobId param to enqueue() calls

pull/7939/head
Luciano Righetti 2021-11-02 16:25:43 +01:00
parent a5a4908556
commit cce5e581d4
7 changed files with 46 additions and 26 deletions

View File

@ -142,28 +142,35 @@ class EventShell extends AppShell
$fieldList = array('published', 'id', 'info');
$this->Event->save($event, array('fieldList' => $fieldList));
// only allow form submit CSRF protection.
$this->Job->saveField('status', 1);
$this->Job->saveField('message', 'Job done.');
$this->Job->save([
'status' => Job::STATUS_COMPLETED,
'message' => 'Job done.'
]);
}
public function correlateValue()
{
$this->ConfigLoad->execute();
$value = $this->args[0];
$this->Job->create();
$data = array(
'worker' => 'default',
'job_type' => 'correlateValue',
'job_input' => $value,
'status' => 0,
'retries' => 0,
'org' => 0,
'message' => 'Job created.',
);
$this->Job->save($data);
if (!empty($this->args[1])) {
$this->Job->id = intval($this->args[1]);
} else {
$this->Job->createJob(
'SYSTEM',
Job::WORKER_DEFAULT,
'correlateValue',
$value,
'Job created.'
);
}
$this->Correlation->correlateValue($value, $this->Job->id);
$this->Job->saveField('status', 1);
$this->Job->saveField('message', 'Job done.');
$this->Job->save([
'status' => Job::STATUS_COMPLETED,
'message' => 'Job done.',
'progress' => 100
]);
}
public function cache()

View File

@ -5790,7 +5790,7 @@ class EventsController extends AppController
$id
],
true,
$job
$jobId
);
$message = __('Recover event job queued. Job ID: %s', $jobId);

View File

@ -762,7 +762,9 @@ class ServersController extends AppController
$id,
$technique,
$jobId
]
],
false,
$jobId
);
$success = __('Pull queued for background execution. Job ID: %s', $jobId);
@ -847,7 +849,9 @@ class ServersController extends AppController
$id,
$technique,
$jobId
]
],
false,
$jobId
);
$message = sprintf(__('Push queued for background execution. Job ID: %s'), $jobId);
@ -2205,7 +2209,9 @@ misp.direct_call(relative_path, body)
$this->Auth->user('id'),
$id,
$jobId
]
],
false,
$jobId
);
$message = 'Server caching job initiated.';
@ -2587,7 +2593,8 @@ misp.direct_call(relative_path, body)
$jobId,
$this->Auth->user('id'),
],
true
true,
$jobId
);
$this->Flash->success(__('Job queued. You can view the progress if you navigate to the active jobs view (administration -> jobs).'));

View File

@ -2097,7 +2097,8 @@ class AppModel extends Model
'runUpdates',
$jobId
],
true
true,
$jobId
);
return true;
@ -2429,7 +2430,8 @@ class AppModel extends Model
'jobGenerateCorrelation',
$jobId
],
true
true,
$jobId
);
}

View File

@ -312,7 +312,8 @@ class AttachmentScan extends AppModel
$attribute['id'],
$jobId
],
true
true,
$jobId
);
}
}

View File

@ -62,7 +62,8 @@ class Correlation extends AppModel
$value,
$jobId
],
true
true,
$jobId
);
return true;
@ -606,7 +607,8 @@ class Correlation extends AppModel
'generateTopCorrelations',
$jobId
],
true
true,
$jobId
);
return $jobId;

View File

@ -84,7 +84,8 @@ class CorrelationExclusion extends AppModel
'cleanExcludedCorrelations',
$jobId
],
true
true,
$jobId
);
} else {
$this->clean();