From 947352bf4feea76de3c20f06d8995cd7ef955c83 Mon Sep 17 00:00:00 2001 From: Antoine Boisier-Michaud Date: Mon, 14 Jan 2019 16:03:49 -0500 Subject: [PATCH] Added resource path values to the data context --- .../output/data/inc-scoutsuite/scoutsuite.js | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ScoutSuite/output/data/inc-scoutsuite/scoutsuite.js b/ScoutSuite/output/data/inc-scoutsuite/scoutsuite.js index ff147953c..147d73b6f 100644 --- a/ScoutSuite/output/data/inc-scoutsuite/scoutsuite.js +++ b/ScoutSuite/output/data/inc-scoutsuite/scoutsuite.js @@ -573,6 +573,15 @@ function showObject() { for (var i = 0; i < path_length; i++) { data = data[path_array[i]]; }; + + // Adds the resource path values to the data context + for (var i = 0; i < path_length - 1; i += 2) { + if(i + 1 >= path_length) break; + + const resource_type = makeResourceTypeSingular(path_array[i]); + data[resource_type] = path_array[i + 1]; + } + // Filter if ... if (arguments.length > 1) { var attr_name = arguments[1]; @@ -587,12 +596,22 @@ function showObject() { } else { var resource_type = path_array[1] + '_' + path_array[path_length - 2]; }; - resource = resource_type.substring(0, resource_type.length - 1).replace(/\.?ie$/, "y"); + + + resource = makeResourceTypeSingular(resource_type); template = 'single_' + resource + '_template'; $('#overlay-details').html(window[template](data)); showPopup(); }; +/** + * Makes the resource type singular. + * @param {string} resource_type + */ +function makeResourceTypeSingular(resource_type) { + return resource_type.substring(0, resource_type.length - 1).replace(/\.?ie$/, "y"); +} + /** * * @param policy_id