Merge branch '2.4' of github.com:MISP/MISP into 2.4

pull/4403/head
iglocska 2019-03-31 10:27:14 +02:00
commit a7761e2b7d
4 changed files with 91 additions and 52 deletions

View File

@ -1533,7 +1533,10 @@ class RestResponseComponent extends Component
$field['values'] = array_keys(ClassRegistry::init("Attribute")->categoryDefinitions);
}
private function __overwriteDistribution($scope, &$field) {
$field['values'] = array_keys(ClassRegistry::init("Attribute")->distributionLevels);
$field['values'] = array();
foreach(ClassRegistry::init("Attribute")->distributionLevels as $d => $text) {
$field['values'][] = array('label' => $text, 'value' => $d);
}
}
private function __overwriteTags($scope, &$field) {
$this->{$scope} = ClassRegistry::init("Tag");

@ -1 +1 @@
Subproject commit 04e8f468d9b789956adb1bea44fa108c4012229f
Subproject commit 3ededf3ddf92573e1037305859857418f73fdf25

View File

@ -4101,54 +4101,6 @@ function submit_feed_overlap_tool(feedId) {
});
}
function populate_rest_history(scope) {
if (scope === 'history') {
scope = '';
var container_class = 'history_queries';
} else {
scope = '1';
var container_class = 'bookmarked_queries';
}
$.get("/rest_client_history/index/" + scope, function(data) {
$('.' + container_class).html(data);
});
}
function loadRestClientHistory(k, data_container) {
$('#ServerMethod').val(data_container[k]['RestClientHistory']['http_method']);
$('#ServerUseFullPath').prop("checked", data_container[k]['RestClientHistory']['use_full_path']);
$('#ServerShowResult').prop("checked", data_container[k]['RestClientHistory']['show_result']);
$('#ServerSkipSslValidation').prop("checked", data_container[k]['RestClientHistory']['skip_ssl_validation']);
$('#ServerUrl').val(data_container[k]['RestClientHistory']['url']);
$('#ServerHeader').val(data_container[k]['RestClientHistory']['headers']);
$('#ServerBody').val(data_container[k]['RestClientHistory']['body']);
toggleRestClientBookmark();
}
function toggleRestClientBookmark() {
if ($('#ServerBookmark').prop("checked") == true) {
$('#bookmark-name').css('display', 'block');
} else {
$('#bookmark-name').css('display', 'none');
}
}
function removeRestClientHistoryItem(id) {
$.ajax({
data: '[]',
success:function (data, textStatus) {
populate_rest_history('bookmark');
populate_rest_history('history');
},
error:function() {
handleGenericAjaxResponse({'saved':false, 'errors':['Request failed due to an unexpected error.']});
},
type:"post",
cache: false,
url: '/rest_client_history/delete/' + id,
});
}
function changeTaxonomyRequiredState(checkbox) {
var checkbox_state = $(checkbox).is(":checked");
var taxonomy_id = $(checkbox).data('taxonomy-id');

View File

@ -31,6 +31,61 @@ function setApiInfoBox(isTyping) {
}
}
function loadRestClientHistory(k, data_container) {
$('#ServerMethod').val(data_container[k]['RestClientHistory']['http_method']);
$('#ServerUseFullPath').prop("checked", data_container[k]['RestClientHistory']['use_full_path']);
$('#ServerShowResult').prop("checked", data_container[k]['RestClientHistory']['show_result']);
$('#ServerSkipSslValidation').prop("checked", data_container[k]['RestClientHistory']['skip_ssl_validation']);
$('#ServerUrl').val(data_container[k]['RestClientHistory']['url']);
$('#ServerHeader').val(data_container[k]['RestClientHistory']['headers']);
toggleRestClientBookmark();
$('#ServerBody').val(data_container[k]['RestClientHistory']['body']);
$('#TemplateSelect').val(data_container[k]['RestClientHistory']['url']).trigger("chosen:updated");
updateQueryTool(data_container[k]['RestClientHistory']['url'], false);
$('#querybuilder').find('select').trigger('chosen:updated');
setApiInfoBox(false);
}
function populate_rest_history(scope) {
if (scope === 'history') {
scope = '';
var container_class = 'history_queries';
} else {
scope = '1';
var container_class = 'bookmarked_queries';
}
$.get("/rest_client_history/index/" + scope, function(data) {
$('.' + container_class).html(data);
});
}
function toggleRestClientBookmark() {
if ($('#ServerBookmark').prop("checked") == true) {
$('#bookmark-name').css('display', 'block');
} else {
$('#bookmark-name').css('display', 'none');
}
}
function removeRestClientHistoryItem(id) {
$.ajax({
data: '[]',
success:function (data, textStatus) {
populate_rest_history('bookmark');
populate_rest_history('history');
},
error:function() {
handleGenericAjaxResponse({'saved':false, 'errors':['Request failed due to an unexpected error.']});
},
type:"post",
cache: false,
url: '/rest_client_history/delete/' + id,
});
}
var allValidApis;
var fieldsConstraint;
var querybuilderTool;
@ -87,7 +142,7 @@ function setApiInfoBox(isTyping) {
$('#ServerUrl').data('urlWithoutParam', selected_template);
$('#ServerBody').val(allValidApis[selected_template].body);
setApiInfoBox(false);
updateQueryTool(selected_template);
updateQueryTool(selected_template, true);
}
});
@ -150,9 +205,18 @@ function setApiInfoBox(isTyping) {
});
function updateQueryTool(url) {
function updateQueryTool(url, isEmpty) {
var apiJson = allValidApis[url];
var filtersJson = fieldsConstraint[url];
isEmpty = isEmpty === undefined ? false : isEmpty;
var body = $('#ServerBody').val();
if (!isEmpty && body !== undefined && body.length > 0) {
body = JSON.parse(body);
} else {
body = {};
}
var filters = [];
for (var k in filtersJson) {
if (filtersJson.hasOwnProperty(k)) {
@ -196,6 +260,11 @@ function updateQueryTool(url) {
};
mandatoryFields.forEach(function(mandatory) {
var r = filtersJson[mandatory];
var action = r.id.split('.')[1];
if (body[action] !== undefined) {
r.value = body[action];
delete body[action];
}
r.flags = {
no_delete: true,
filter_readonly: true
@ -211,6 +280,21 @@ function updateQueryTool(url) {
};
}
Object.keys(body).forEach(function(k) {
var values = body[k];
if (Array.isArray(values)) {
values.forEach(function(value) {
var r = $.extend({}, filtersJson[k], true);
r.value = value;
rules.rules[0].rules.push(r);
});
} else {
var r = filtersJson[k];
r.value = values;
rules.rules[0].rules.push(r);
}
});
// add Params input field
var paramFields = apiJson.params;
$('#divAdditionalParamInput').remove();