mirror of https://github.com/MISP/MISP
chg: [eventReport] Improved html_to_markdown module handling
parent
3f25957d2a
commit
2143cdf83d
|
@ -186,7 +186,7 @@ class EventReportsController extends AppController
|
|||
if (!empty($filters['index_for_event'])) {
|
||||
$this->set('extendedEvent', !empty($filters['extended_event']));
|
||||
$fetcherModule = $this->EventReport->isFetchURLModuleEnabled();
|
||||
$this->set('importModuleEnabled', !empty($fetcherModule));
|
||||
$this->set('importModuleEnabled', is_array($fetcherModule));
|
||||
$this->render('ajax/indexForEvent');
|
||||
}
|
||||
}
|
||||
|
@ -298,10 +298,10 @@ class EventReportsController extends AppController
|
|||
'content' => $markdown
|
||||
];
|
||||
$errors = $this->EventReport->addReport($this->Auth->user(), $report, $event_id);
|
||||
$redirectTarget = array('controller' => 'events', 'action' => 'view', $event_id);
|
||||
} else {
|
||||
$errors[] = __('Could not fetch report from URL. Fetcher module not enabled or could not download the page');
|
||||
}
|
||||
$redirectTarget = array('controller' => 'events', 'action' => 'view', $event_id);
|
||||
if (!empty($errors)) {
|
||||
return $this->__getFailResponseBasedOnContext($errors, array(), 'addFromURL', $this->EventReport->id, $redirectTarget);
|
||||
} else {
|
||||
|
@ -310,7 +310,7 @@ class EventReportsController extends AppController
|
|||
return $this->__getSuccessResponseBasedOnContext($successMessage, $report, 'addFromURL', false, $redirectTarget);
|
||||
}
|
||||
}
|
||||
$this->set('importModuleEnabled', empty($fetcherModule));
|
||||
$this->set('importModuleEnabled', is_array($fetcherModule));
|
||||
$this->set('event_id', $event_id);
|
||||
$this->layout = 'ajax';
|
||||
$this->render('ajax/importReportFromUrl');
|
||||
|
|
|
@ -825,7 +825,10 @@ class EventReport extends AppModel
|
|||
public function downloadMarkdownFromURL($event_id, $url)
|
||||
{
|
||||
$this->Module = ClassRegistry::init('Module');
|
||||
$module = $this->Module->getEnabledModule('html_to_markdown', 'expansion');
|
||||
$module = $this->isFetchURLModuleEnabled();
|
||||
if (!is_array($module)) {
|
||||
return false;
|
||||
}
|
||||
$modulePayload = [
|
||||
'module' => $module['name'],
|
||||
'event_id' => $event_id,
|
||||
|
@ -833,7 +836,7 @@ class EventReport extends AppModel
|
|||
];
|
||||
$module = $this->isFetchURLModuleEnabled();
|
||||
if (!empty($module)) {
|
||||
$result = $this->Module->queryModuleServer('/query', json_encode($modulePayload), false, $moduleFamily = 'Import');
|
||||
$result = $this->Module->queryModuleServer('/query', $modulePayload, false);
|
||||
if (empty($result['results'][0]['values'][0])) {
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ class Module extends AppModel
|
|||
return 'The requested module is not enabled.';
|
||||
}
|
||||
if (is_array($modules)) {
|
||||
foreach ($modules['modules'] as $module) {
|
||||
foreach ($modules as $module) {
|
||||
if ($module['name'] == $name) {
|
||||
if ($type && in_array(strtolower($type), $module['meta']['module-type'])) {
|
||||
return $module;
|
||||
|
|
Loading…
Reference in New Issue