mirror of https://github.com/MISP/MISP
fix: [bug] Potential fix for SQL return size limit reached when fetching a list of attributes
parent
8559af8c6a
commit
c67b575ba6
|
@ -2605,39 +2605,57 @@ class Attribute extends AppModel {
|
||||||
));
|
));
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
$results = $this->find('all', $params);
|
|
||||||
// return false if we're paginating
|
|
||||||
if (isset($options['limit']) && empty($results)) return false;
|
|
||||||
if ($options['enforceWarninglist']) {
|
if ($options['enforceWarninglist']) {
|
||||||
$this->Warninglist = ClassRegistry::init('Warninglist');
|
$this->Warninglist = ClassRegistry::init('Warninglist');
|
||||||
$warninglists = $this->Warninglist->fetchForEventView();
|
$warninglists = $this->Warninglist->fetchForEventView();
|
||||||
}
|
}
|
||||||
$results = array_values($results);
|
|
||||||
$proposals_block_attributes = Configure::read('MISP.proposals_block_attributes');
|
if (empty($params['limit'])) {
|
||||||
foreach ($results as $key => $attribute) {
|
$pagesToFetch = $this->find('count', array('conditions' => $params['conditions']));
|
||||||
if ($options['enforceWarninglist'] && !$this->Warninglist->filterWarninglistAttributes($warninglists, $attribute['Attribute'])) {
|
$loopLimit = 100000;
|
||||||
unset($results[$key]);
|
$pagesToFetch = ceil($pagesToFetch / $loopLimit);
|
||||||
continue;
|
$loop = true;
|
||||||
|
} else {
|
||||||
|
$loop = false;
|
||||||
|
$pagesToFetch = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributes = array();
|
||||||
|
for ($i = 0; $i < $pagesToFetch; $i++) {
|
||||||
|
if ($loop) {
|
||||||
|
$params['limit'] = $loopLimit;
|
||||||
|
$params['page'] = $i+1;
|
||||||
}
|
}
|
||||||
if (!empty($options['includeAttributeUuid']) || !empty($options['includeEventUuid'])) {
|
$results = $this->find('all', $params);
|
||||||
$results[$key]['Attribute']['event_uuid'] = $results[$key]['Event']['uuid'];
|
// return false if we're paginating
|
||||||
}
|
if (isset($options['limit']) && empty($results)) return false;
|
||||||
if ($proposals_block_attributes) {
|
$results = array_values($results);
|
||||||
if (!empty($attribute['ShadowAttribute'])) {
|
$proposals_block_attributes = Configure::read('MISP.proposals_block_attributes');
|
||||||
unset($results[$key]);
|
foreach ($results as $key => $attribute) {
|
||||||
} else {
|
if ($options['enforceWarninglist'] && !$this->Warninglist->filterWarninglistAttributes($warninglists, $attribute['Attribute'])) {
|
||||||
unset($results[$key]['ShadowAttribute']);
|
continue;
|
||||||
}
|
}
|
||||||
}
|
if (!empty($options['includeAttributeUuid']) || !empty($options['includeEventUuid'])) {
|
||||||
if ($options['withAttachments']) {
|
$results[$key]['Attribute']['event_uuid'] = $results[$key]['Event']['uuid'];
|
||||||
if ($this->typeIsAttachment($attribute['Attribute']['type'])) {
|
|
||||||
$encodedFile = $this->base64EncodeAttachment($attribute['Attribute']);
|
|
||||||
$results[$key]['Attribute']['data'] = $encodedFile;
|
|
||||||
}
|
}
|
||||||
|
if ($proposals_block_attributes) {
|
||||||
|
if (!empty($attribute['ShadowAttribute'])) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
unset($results[$key]['ShadowAttribute']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($options['withAttachments']) {
|
||||||
|
if ($this->typeIsAttachment($attribute['Attribute']['type'])) {
|
||||||
|
$encodedFile = $this->base64EncodeAttachment($attribute['Attribute']);
|
||||||
|
$results[$key]['Attribute']['data'] = $encodedFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$attributes[] = $results[$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$results = array_values($results);
|
return $attributes;
|
||||||
return $results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method gets and converts the contents of a file passed along as a base64 encoded string with the original filename into a zip archive
|
// Method gets and converts the contents of a file passed along as a base64 encoded string with the original filename into a zip archive
|
||||||
|
|
Loading…
Reference in New Issue