fix: [eventReport:markdownEditor] Avoid override of legitimate tags if

they don't have data linked to them
pull/6412/head
mokaddem 2020-10-02 11:52:20 +02:00
parent 0780d9a088
commit 5ecd3b7236
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 11 additions and 2 deletions

View File

@ -1158,20 +1158,26 @@ class TagsController extends AppController
if (!$searchIfTagExists && empty($tags)) {
$tags = [];
foreach ($tag as $i => $tagName) {
$tags[] = ['Tag' => ['name' => $tagName]];
$tags[] = ['Tag' => ['name' => $tagName], 'simulatedTag' => true];
}
}
$this->loadModel('Taxonomy');
foreach ($tags as $k => $t) {
$dataFound = false;
$taxonomy = $this->Taxonomy->getTaxonomyForTag($t['Tag']['name'], false);
if (!empty($taxonomy)) {
$dataFound = true;
$tags[$k]['Taxonomy'] = $taxonomy['Taxonomy'];
$tags[$k]['TaxonomyPredicate'] = $taxonomy['TaxonomyPredicate'][0];
}
$cluster = $this->GalaxyCluster->getCluster($t['Tag']['name']);
if (!empty($cluster)) {
$dataFound = true;
$tags[$k]['GalaxyCluster'] = $cluster['GalaxyCluster'];
}
if (!$searchIfTagExists && !$dataFound && !empty($t['simulatedTag'])) {
unset($tags[$k]);
}
}
return $this->RestResponse->viewData($tags, $this->response->type());
}

View File

@ -612,7 +612,7 @@ function attachTagInfo($elem, eventid, elementID) {
}
if (tagData === undefined) {
tagData = {}
$tag = constructTagHtml(elementID, 'white')
$tag = constructTagHtml(elementID, '#ffffff', {'border': '1px solid #000'})
} else {
$tag = getTagReprensentation(tagData)
proxyMISPElements['tag'][elementID] = tagData
@ -868,8 +868,10 @@ function constructTagHtml(tagName, tagColour, additionalCSS) {
}
function constructClusterTagHtml(tagData) {
var addBorder = false
if (tagData.Tag.colour === undefined) {
tagData.Tag.colour = '#ffffff'
addBorder = true
}
var $tag = $('<span/>').append(
$('<i/>').addClass('fa fa-' + tagData.GalaxyCluster.Galaxy.icon).css('margin-right', '5px'),
@ -880,6 +882,7 @@ function constructClusterTagHtml(tagData) {
'background-color': tagData.Tag.colour,
'color': getTextColour(tagData.Tag.colour),
'box-shadow': '3px 3px 3px #888888',
'border': (addBorder ? '1px solid #000' : 'none')
})
return $tag
}