mirror of https://github.com/MISP/MISP
small change to file checks, use readable() instead of exists()
parent
f64f7ce17f
commit
e21fa21de8
|
@ -1502,7 +1502,7 @@ class EventsController extends AppController {
|
|||
} else {
|
||||
$file = new File($dir->pwd() . DS . 'misp.' . $k . '.' . $useOrg . $type['extension']);
|
||||
}
|
||||
if (!$file->exists()) {
|
||||
if (!$file->readable()) {
|
||||
$lastModified = 'N/A';
|
||||
$this->Event->export_types[$k]['recommendation'] = 1;
|
||||
} else {
|
||||
|
|
|
@ -500,7 +500,7 @@ class Attribute extends AppModel {
|
|||
// FIXME secure this filesystem access/delete by not allowing to change directories or go outside of the directory container.
|
||||
// only delete the file if it exists
|
||||
$filepath = APP . "files" . DS . $this->data['Attribute']['event_id'] . DS . $this->data['Attribute']['id'];
|
||||
$file = new File ($filepath);
|
||||
$file = new File($filepath);
|
||||
if ($file->exists()) {
|
||||
if (!$file->delete()) {
|
||||
throw new InternalErrorException('Delete of file attachment failed. Please report to administrator.');
|
||||
|
@ -1059,7 +1059,7 @@ class Attribute extends AppModel {
|
|||
public function base64EncodeAttachment($attribute) {
|
||||
$filepath = APP . "files" . DS . $attribute['event_id'] . DS . $attribute['id'];
|
||||
$file = new File($filepath);
|
||||
if (!$file->exists()) {
|
||||
if (!$file->readable()) {
|
||||
return '';
|
||||
}
|
||||
$content = $file->read();
|
||||
|
|
|
@ -265,7 +265,7 @@ class ShadowAttribute extends AppModel {
|
|||
// FIXME secure this filesystem access/delete by not allowing to change directories or go outside of the directory container.
|
||||
// only delete the file if it exists
|
||||
$filepath = APP . "files" . DS . 'shadow' . DS . $sa['ShadowAttribute']['event_id'] . DS . $sa['ShadowAttribute']['id'];
|
||||
$file = new File ($filepath);
|
||||
$file = new File($filepath);
|
||||
if ($file->exists()) {
|
||||
if (!$file->delete()) {
|
||||
throw new InternalErrorException('Delete of file attachment failed. Please report to administrator.');
|
||||
|
@ -293,7 +293,7 @@ class ShadowAttribute extends AppModel {
|
|||
// FIXME secure this filesystem access/delete by not allowing to change directories or go outside of the directory container.
|
||||
// only delete the file if it exists
|
||||
$filepath = APP . "files" . DS . 'shadow' . DS . $this->data['ShadowAttribute']['event_id'] . DS . $this->data['ShadowAttribute']['id'];
|
||||
$file = new File ($filepath);
|
||||
$file = new File($filepath);
|
||||
if ($file->exists()) {
|
||||
if (!$file->delete()) {
|
||||
throw new InternalErrorException('Delete of file attachment failed. Please report to administrator.');
|
||||
|
|
Loading…
Reference in New Issue