mirror of https://github.com/MISP/MISP
commit
e7076d1afc
|
@ -1108,8 +1108,12 @@ class TagsController extends AppController
|
|||
$conditions['OR'][] = array('LOWER(Tag.name) LIKE' => $t);
|
||||
}
|
||||
} else {
|
||||
foreach ($tag as $k => $t) {
|
||||
$conditions['OR'][] = array('Tag.name' => $t);
|
||||
foreach ($tag as $t) {
|
||||
if (is_numeric($t)) {
|
||||
$conditions['OR'][] = ['Tag.id' => $t];
|
||||
} else {
|
||||
$conditions['OR'][] = array('Tag.name' => $t);
|
||||
}
|
||||
}
|
||||
}
|
||||
$tags = $this->Tag->find('all', array(
|
||||
|
|
|
@ -867,8 +867,18 @@ class GalaxyCluster extends AppModel
|
|||
return $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $user
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getCluster($name, $user)
|
||||
{
|
||||
$isGalaxyTag = strpos($name, 'misp-galaxy:') === 0;
|
||||
if (!$isGalaxyTag) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isset($this->__clusterCache[$name])) {
|
||||
return $this->__clusterCache[$name];
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
);
|
||||
if (!empty($tag['Tag']['id'])) {
|
||||
$span_tag = sprintf(
|
||||
'<a href="%s" style="%s" class="%s" title="%s">%s</a>',
|
||||
'<a href="%s" style="%s" class="%s" title="%s" data-tag-id="%s">%s</a>',
|
||||
sprintf(
|
||||
'%s%s%s',
|
||||
$baseurl,
|
||||
|
@ -86,6 +86,7 @@
|
|||
$aStyle,
|
||||
$aClass,
|
||||
$aText,
|
||||
h($tag['Tag']['id']),
|
||||
isset($aTextModified) ? $aTextModified : $aText
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
foreach ($cluster_fields as $cluster_field) {
|
||||
$key = sprintf('<span class="blue bold">%s</span>', Inflector::humanize(h($cluster_field['key'])));
|
||||
if (is_array($cluster_field['value'])) {
|
||||
if ($cluster_field['key'] == 'refs') {
|
||||
if ($cluster_field['key'] === 'refs') {
|
||||
$value = array();
|
||||
foreach ($cluster_field['value'] as $k => $v) {
|
||||
$v_name = $v;
|
||||
|
@ -41,25 +41,25 @@
|
|||
}
|
||||
$value[$k] = '<a href="' . h($v) . '" title="' . h($v) . '">' . h($v_name) . '</a>';
|
||||
}
|
||||
$value_contents = nl2br(implode("\n", $value));
|
||||
} else if($cluster_field['key'] == 'country') {
|
||||
$value_contents = implode("<br>", $value);
|
||||
} else if ($cluster_field['key'] === 'country') {
|
||||
$value = array();
|
||||
foreach ($cluster_field['value'] as $k => $v) {
|
||||
$value[] = $this->Icon->countryFlag($v) . ' ' . h($v);
|
||||
}
|
||||
$value_contents = nl2br(implode("\n", $value));
|
||||
$value_contents = implode("<br>", $value);
|
||||
} else {
|
||||
$value_contents = nl2br(h(implode("\n", $cluster_field['value'])));
|
||||
$value_contents = nl2br(h(implode("\n", $cluster_field['value'])), false);
|
||||
}
|
||||
} else {
|
||||
if ($cluster_field['key'] == 'source' && filter_var($cluster_field['value'], FILTER_VALIDATE_URL)) {
|
||||
$value_contents = '<a href="' . h($cluster_field['value']) . '">' . h($cluster_field['value']) . '</a>';;
|
||||
if ($cluster_field['key'] === 'source' && filter_var($cluster_field['value'], FILTER_VALIDATE_URL)) {
|
||||
$value_contents = '<a href="' . h($cluster_field['value']) . '">' . h($cluster_field['value']) . '</a>';
|
||||
} else {
|
||||
$value_contents = h($cluster_field['value']);
|
||||
}
|
||||
}
|
||||
$value = sprintf('<span class="black">%s</span>', $value_contents);
|
||||
$popover_data .= sprintf('<span>%s: %s</span><br />', $key, $value);
|
||||
$popover_data .= "<span>$key: $value</span><br>";
|
||||
}
|
||||
echo sprintf(
|
||||
'<div class="large-left-margin">%s %s %s %s</div>',
|
||||
|
@ -135,17 +135,3 @@
|
|||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$('<?= isset($rowId) ? '#'.$rowId : '' ?> .expandable')
|
||||
.on('click', function() {
|
||||
loadClusterRelations($(this).data('clusterid'));
|
||||
})
|
||||
.popover({
|
||||
html: true,
|
||||
trigger: 'hover'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -4894,6 +4894,16 @@ $(document).ready(function() {
|
|||
$this.addClass('fa-eye');
|
||||
}
|
||||
});
|
||||
|
||||
// For galaxyQuickViewMini.ctp
|
||||
$('.expandable[data-clusterid]')
|
||||
.on('click', function() {
|
||||
loadClusterRelations($(this).data('clusterid'));
|
||||
})
|
||||
.popover({
|
||||
html: true,
|
||||
trigger: 'hover'
|
||||
});
|
||||
});
|
||||
|
||||
$(document.body).on("click", ".correlation-expand-button", function() {
|
||||
|
@ -5520,3 +5530,102 @@ $('body').on('click', '.hex-value-convert', function() {
|
|||
.attr('aria-label', 'Switch to binary representation');
|
||||
}
|
||||
});
|
||||
|
||||
// Tag popover with taxonomy description
|
||||
(function() {
|
||||
var tagDataCache = {};
|
||||
function fetchTagInfo(tagId, callback) {
|
||||
if (tagId in tagDataCache) {
|
||||
callback(tagDataCache[tagId]);
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
success: function (data) {
|
||||
data = $.parseJSON(data);
|
||||
var tagData;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var tag = data[i];
|
||||
if (tag.Tag.id == tagId) {
|
||||
tagData = data[i]
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tagData !== undefined) {
|
||||
callback(tagData);
|
||||
tagDataCache[tagId] = tagData;
|
||||
}
|
||||
},
|
||||
type: "get",
|
||||
url: baseurl + "/tags/search/" + tagId + "/1/1"
|
||||
})
|
||||
}
|
||||
|
||||
function constructTaxonomyInfo(tagData) {
|
||||
var predicateText = tagData.TaxonomyPredicate.expanded;
|
||||
if (tagData.TaxonomyPredicate.TaxonomyEntry) {
|
||||
predicateText += ": " + tagData.TaxonomyPredicate.TaxonomyEntry[0].expanded;
|
||||
}
|
||||
|
||||
var $predicate = $('<div/>').append(
|
||||
$('<h3/>').css("margin-top", "5px").text('Tag info'),
|
||||
$('<p/>').css("margin-bottom", "5px").text(predicateText)
|
||||
);
|
||||
if (tagData.TaxonomyPredicate.description) {
|
||||
$predicate.append($('<p/>').css("margin-bottom", "5px").append(
|
||||
$('<strong/>').text('Description: '),
|
||||
$('<span/>').text(tagData.TaxonomyPredicate.description),
|
||||
));
|
||||
}
|
||||
if (tagData.TaxonomyPredicate.TaxonomyEntry && tagData.TaxonomyPredicate.TaxonomyEntry[0].numerical_value) {
|
||||
$predicate.append($('<p/>').css("margin-bottom", "5px").append(
|
||||
$('<strong/>').text('Numerical value: '),
|
||||
$('<span/>').text(tagData.TaxonomyPredicate.TaxonomyEntry[0].numerical_value),
|
||||
));
|
||||
}
|
||||
var $meta = $('<div/>').append(
|
||||
$('<h3/>').text('Taxonomy: ' + tagData.Taxonomy.namespace.toUpperCase()),
|
||||
$('<p/>').css("margin-bottom", "5px").append(
|
||||
$('<span/>').text(tagData.Taxonomy.description),
|
||||
)
|
||||
)
|
||||
return $('<div/>').append($predicate, $meta)
|
||||
}
|
||||
|
||||
var popoverDebounce = null;
|
||||
$(document.body).on({
|
||||
mouseover: function() {
|
||||
var $tag = $(this);
|
||||
popoverDebounce = setTimeout(function() {
|
||||
popoverDebounce = null;
|
||||
var tagId = $tag.data('tag-id');
|
||||
|
||||
fetchTagInfo(tagId, function (tagData) {
|
||||
if (tagData.TaxonomyPredicate === undefined) {
|
||||
return;
|
||||
}
|
||||
// Check if user cursor is still on tag
|
||||
if ($(':hover').last()[0] !== $tag[0]) {
|
||||
return;
|
||||
}
|
||||
$tag.popover({
|
||||
html: true,
|
||||
container: 'body',
|
||||
placement: 'top',
|
||||
template: '<div class="popover"><div class="arrow"></div><div class="popover-content"></div></div>',
|
||||
content: function () {
|
||||
return constructTaxonomyInfo(tagData);
|
||||
}
|
||||
}).popover('show');
|
||||
});
|
||||
}, 200);
|
||||
},
|
||||
mouseout: function() {
|
||||
if (popoverDebounce) {
|
||||
clearTimeout(popoverDebounce);
|
||||
popoverDebounce = null;
|
||||
}
|
||||
$(this).popover('destroy');
|
||||
}
|
||||
}, 'a.tag[data-tag-id]');
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue