mirror of https://github.com/MISP/MISP
Merge branch '2.4' of github.com:MISP/MISP into 2.4
commit
a7761e2b7d
|
@ -1533,7 +1533,10 @@ class RestResponseComponent extends Component
|
||||||
$field['values'] = array_keys(ClassRegistry::init("Attribute")->categoryDefinitions);
|
$field['values'] = array_keys(ClassRegistry::init("Attribute")->categoryDefinitions);
|
||||||
}
|
}
|
||||||
private function __overwriteDistribution($scope, &$field) {
|
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) {
|
private function __overwriteTags($scope, &$field) {
|
||||||
$this->{$scope} = ClassRegistry::init("Tag");
|
$this->{$scope} = ClassRegistry::init("Tag");
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 04e8f468d9b789956adb1bea44fa108c4012229f
|
Subproject commit 3ededf3ddf92573e1037305859857418f73fdf25
|
|
@ -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) {
|
function changeTaxonomyRequiredState(checkbox) {
|
||||||
var checkbox_state = $(checkbox).is(":checked");
|
var checkbox_state = $(checkbox).is(":checked");
|
||||||
var taxonomy_id = $(checkbox).data('taxonomy-id');
|
var taxonomy_id = $(checkbox).data('taxonomy-id');
|
||||||
|
|
|
@ -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 allValidApis;
|
||||||
var fieldsConstraint;
|
var fieldsConstraint;
|
||||||
var querybuilderTool;
|
var querybuilderTool;
|
||||||
|
@ -87,7 +142,7 @@ function setApiInfoBox(isTyping) {
|
||||||
$('#ServerUrl').data('urlWithoutParam', selected_template);
|
$('#ServerUrl').data('urlWithoutParam', selected_template);
|
||||||
$('#ServerBody').val(allValidApis[selected_template].body);
|
$('#ServerBody').val(allValidApis[selected_template].body);
|
||||||
setApiInfoBox(false);
|
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 apiJson = allValidApis[url];
|
||||||
var filtersJson = fieldsConstraint[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 = [];
|
var filters = [];
|
||||||
for (var k in filtersJson) {
|
for (var k in filtersJson) {
|
||||||
if (filtersJson.hasOwnProperty(k)) {
|
if (filtersJson.hasOwnProperty(k)) {
|
||||||
|
@ -196,6 +260,11 @@ function updateQueryTool(url) {
|
||||||
};
|
};
|
||||||
mandatoryFields.forEach(function(mandatory) {
|
mandatoryFields.forEach(function(mandatory) {
|
||||||
var r = filtersJson[mandatory];
|
var r = filtersJson[mandatory];
|
||||||
|
var action = r.id.split('.')[1];
|
||||||
|
if (body[action] !== undefined) {
|
||||||
|
r.value = body[action];
|
||||||
|
delete body[action];
|
||||||
|
}
|
||||||
r.flags = {
|
r.flags = {
|
||||||
no_delete: true,
|
no_delete: true,
|
||||||
filter_readonly: 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
|
// add Params input field
|
||||||
var paramFields = apiJson.params;
|
var paramFields = apiJson.params;
|
||||||
$('#divAdditionalParamInput').remove();
|
$('#divAdditionalParamInput').remove();
|
||||||
|
|
Loading…
Reference in New Issue