fix: Moved attachment access diagnostic tool to attributes controller

pull/2279/head
iglocska 2017-06-18 10:12:48 +02:00
parent c0ba6a1646
commit c9784cc4f8
5 changed files with 19 additions and 20 deletions

View File

@ -46,7 +46,7 @@ class AppController extends Controller {
public $helpers = array('Utility');
private $__queryVersion = '10';
private $__queryVersion = '11';
public $pyMispVersion = '2.4.71';
public $phpmin = '5.6.5';
public $phprec = '7.0.16';

View File

@ -2787,4 +2787,20 @@ class AttributesController extends AppController {
$this->render('ajax/toggle_correlation');
}
}
public function checkAttachments() {
$attributes = $this->Attribute->find('all', array(
'conditions' => array('Attribute.type' => array('attachment', 'malware-sample')),
'recursive' => -1)
);
$counter = 0;
foreach ($attributes as $attribute) {
$path = APP . "files" . DS . $attribute['Attribute']['event_id'] . DS;
$file = $attribute['Attribute']['id'];
if (!file_exists($path . $file)) {
$counter++;
}
}
return new CakeResponse(array('body'=>$counter, 'status'=>200));
}
}

View File

@ -35,6 +35,7 @@ class ACLComponent extends Component {
'attributeReplace' => array('perm_add'),
'attributeStatistics' => array('*'),
'bro' => array('*'),
'checkAttachments' => array(),
'checkComposites' => array('perm_admin'),
'checkOrphanedAttributes' => array(),
'delete' => array('perm_add'),
@ -368,7 +369,6 @@ class ACLComponent extends Component {
'attributehistogram' => array('*'),
'change_pw' => array('*'),
'checkAndCorrectPgps' => array(),
'checkAttachments' => array(),
'dashboard' => array('*'),
'delete' => array('perm_admin'),
'downloadTerms' => array('*'),

View File

@ -1451,21 +1451,4 @@ class UsersController extends AppController {
$this->set('notifications', $notifications);
$this->set('events', $events);
}
public function checkAttachments() {
$this->loadModel('Attribute');
$attributes = $this->Attribute->find('all', array(
'conditions' => array('Attribute.type' => array('attachment', 'malware-sample')),
'recursive' => -1)
);
$counter = 0;
foreach ($attributes as $attribute) {
$path = APP . "files" . DS . $attribute['Attribute']['event_id'] . DS;
$file = $attribute['Attribute']['id'];
if (!file_exists($path . $file)) {
$counter++;
}
}
return new CakeResponse(array('body'=>$counter, 'status'=>200));
}
}

View File

@ -2786,7 +2786,7 @@ function checkAttachments() {
},
type:"get",
cache: false,
url: "/users/checkAttachments/",
url: "/attributes/checkAttachments/",
});
}