Skip to content

Commit

Permalink
Merge pull request #157 from nccgroup/bugfix/146-showall-bug
Browse files Browse the repository at this point in the history
Bugfix/146 showall bug
  • Loading branch information
Aboisier committed Feb 10, 2019
2 parents ef5c080 + 7add262 commit 730fa78
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<div id="services.cloudtrail.regions.id.trails.list" />
<div class="list-group" >
<div class="list-group-item">
<a href="#services.{{service_name}}.regions.id.{{resource_type}}">Show all <span class="badge float-right">XXX</span></a>
<a href="javascript:showRowWithItems('services.{{service_name}}.regions.id.{{resource_type}}')">Show all <span class="badge float-right">XXX</span></a>
</div>
</div>
{{#each items}}
<div class="list-group" id="services.{{../service_name}}.regions.{{@key}}.{{../resource_type}}.list">
<div class="list-group-item active">
<a href="#services.{{../service_name}}.regions.{{@key}}.{{../resource_type}}">{{@key}}</a>
<span class="float-right"><a href="javascript:hideRegion('services.{{../service_name}}.regions.{{@key}}.{{../resource_type}}.list')"><i class="fa fa-times-circle"></i></a></span>
<span class="float-right"><a href="javascript:hideList('services.{{../service_name}}.regions.{{@key}}.{{../resource_type}}.list')"><i class="fa fa-times-circle"></i></a></span>
</div>
<div class="list-group-item list-sub-element">
{{#each (lookup . ../resource_type)}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
<div id="services.{{service_name}}.regions.id.vpcs.id.{{resource_type}}.list">
<div class="list-group" >
<div class="list-group-item">
<a href="#services.{{service_name}}.regions.id.vpcs.id.{{resource_type}}">Show all <span class="badge float-right">{{get_value_at 'metadata' service_group service_name 'resources' resource_type 'count'}}</span></a>
<a href="javascript:showRowWithItems('services.{{service_name}}.regions.id.vpcs.id.{{resource_type}}')">
Show all <span class="badge float-right">{{get_value_at 'metadata' service_group service_name 'resources' resource_type 'count'}}</span>
</a>
</div>
</div>
{{#each items}}
<div class="list-group" id="services.{{../service_name}}.regions.{{@key}}.vpcs.id.{{../resource_type}}.list">
<div class="list-group-item active">
<a href="#services.{{../service_name}}.regions.{{@key}}.vpcs.id.{{../resource_type}}">{{@key}}</a>
<span class="float-right"><a href="javascript:hideRegion('services.{{../service_name}}.regions.{{@key}}.vpcs.id.{{../resource_type}}.list')"><i class="fa fa-times-circle"></i></a></span>
<span class="float-right"><a href="javascript:hideList('services.{{../service_name}}.regions.{{@key}}.vpcs.id.{{../resource_type}}.list')"><i class="fa fa-times-circle"></i></a></span>
</div>
{{#each vpcs}}
<div class="list-group-item list-sub-element" id="services.{{../../service_name}}.regions.{{@../key}}.vpcs.{{@key}}.{{../../resource_type}}.list">
Expand Down
105 changes: 19 additions & 86 deletions ScoutSuite/output/data/inc-scoutsuite/scoutsuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,35 +222,29 @@ function hideAll() {
*/
function showRow(path) {
path = path.replace(/.id./g, '\.[^.]+\.');
$('div').filter(function () {
return this.id.match(path + '.list')
}).show();
$('div').filter(function () {
return this.id.match(path + '.details')
}).show();
showList(path);
showDetails(path);
};


/**
* Hide list and details' containers for a given path
* @param path
*/
function hideRow(path) {
path = path.replace(/.id./g, '\.[^.]+\.');
function showList(path) {
$('div').filter(function () {
return this.id.match(path + '.list')
}).hide();
}).show();
}

function showDetails(path) {
$('div').filter(function () {
return this.id.match(path + '.details')
}).hide();
};
}).show();
}

function hideRegion(path) {
function hideList(path) {
$("[id='" + path + "']").hide();
path = path.replace('.list', '');
hideItems(path);
};


/**
* Show links and views for a given path
* @param path
Expand Down Expand Up @@ -373,11 +367,6 @@ function showSingleItem(id) {
$("[id='" + id + "']").show();
};

function toggleDetails(keyword, item) {
var id = '#' + keyword + '-' + item;
$(id).toggle();
};

/**
* Toggles between light and dark themes
*/
Expand Down Expand Up @@ -418,27 +407,6 @@ window.onunload = function() {
localStorage.setItem("theme_checkbox", document.getElementById("theme_checkbox").checked);
}

/**
* Update the navigation bar
* @param service
*/
function updateNavbar(service) {
$('[id*="dropdown"]').removeClass('active-dropdown');
$('#' + service + '_dropdown').addClass('active-dropdown');
$('[id*="dropdown"]').show();
};

function toggleVisibility(id) {
id1 = '#' + id;
$(id1).toggle()
id2 = '#bullet-' + id;
if ($(id1).is(":visible")) {
$(id2).html('<i class="fa fa-caret-square-o-down"></i>');
} else {
$(id2).html('<i class="fa fa-caret-square-o-right"></i>');
};
};

/**
*
* @param data
Expand Down Expand Up @@ -794,19 +762,6 @@ function show_main_dashboard() {
history.pushState("", document.title, window.location.pathname + window.location.search);
};

/**
* Show All Resources
* @param script_id
*/
function showAllResources(script_id) {
var path_array = script_id.split('.');
var selector = "[id^='" + path_array.shift() + "." + path_array.shift() + ".']"
for (p in path_array) {
$(selector).show();
selector = selector + "[id*='." + path_array[p] + "']";
};
};

/**
* Make title from resource path
* @param resource_path
Expand Down Expand Up @@ -1006,7 +961,6 @@ function lazy_loading(path) {
* @returns {*|string};
*/
function get_resource_path(path) {
var path_array = path.split('.');
if (path.endsWith('.items')) {
var resource_path = get_value_at(path.replace('items', 'display_path'));
if (resource_path == undefined) {
Expand All @@ -1019,7 +973,7 @@ function get_resource_path(path) {
// Resource path is not changed (this may break when using `back' button in browser)
var resource_path = current_resource_path;
} else {
var resource_path = path; // path_array[path_array.length-1];
var resource_path = path;
};
return resource_path;
};
Expand All @@ -1030,7 +984,7 @@ function get_resource_path(path) {
* @param title
* @returns {string};
*/
var make_title = function (title) {
function make_title (title) {
if (typeof(title) != "string") {
console.log("Error: received title " + title + " (string expected).");
return title.toString();
Expand Down Expand Up @@ -1085,7 +1039,7 @@ var make_title = function (title) {
* @param path
* @param cols
*/
var add_templates = function (group, service, section, resource_type, path, cols) {
function add_templates (group, service, section, resource_type, path, cols) {
if (cols == undefined) {
cols = 2;
};
Expand All @@ -1095,7 +1049,6 @@ var add_templates = function (group, service, section, resource_type, path, cols
};
};


/**
* Add resource templates
* @param group
Expand All @@ -1105,7 +1058,7 @@ var add_templates = function (group, service, section, resource_type, path, cols
* @param path
* @param suffix
*/
var add_template = function (group, service, section, resource_type, path, suffix) {
function add_template(group, service, section, resource_type, path, suffix) {
var template = document.createElement("script");
template.type = "text/x-handlebars-template";
template.id = path + "." + suffix + ".template";
Expand Down Expand Up @@ -1134,20 +1087,12 @@ var add_template = function (group, service, section, resource_type, path, suffi
};
};

var add_summary_template = function (path) {
var template = document.createElement("script");
template.type = "text/x-handlebars-template";
template.id = path + ".details.template";
template.innerHTML = "{{> " + partial_name + " service_name = '" + service + "' resource_type = '" + resource_type + "' partial_name = '" + path + "'}}";
$('body').append(template);
};

/**
* Rules generator
* @param group
* @param service
*/
var filter_rules = function (group, service) {
function filter_rules(group, service) {
if (service == undefined) {
$("[id*='rule-']").show();
} else {
Expand All @@ -1158,7 +1103,7 @@ var filter_rules = function (group, service) {
$("[id='" + id + "']").hide();
};

var download_configuration = function (configuration, name, prefix) {
function download_configuration(configuration, name, prefix) {

var uriContent = "data:text/json;charset=utf-8," + encodeURIComponent(prefix + JSON.stringify(configuration, null, 4));
var dlAnchorElem = document.getElementById('downloadAnchorElem');
Expand All @@ -1167,26 +1112,14 @@ var download_configuration = function (configuration, name, prefix) {
dlAnchorElem.click();
};

var download_exceptions = function () {
function download_exceptions() {
var url = window.location.pathname;
var profile_name = url.substring(url.lastIndexOf('/') + 1).replace('report-', '').replace('.html', '');
console.log(exceptions);
download_configuration(exceptions, 'exceptions-' + profile_name, 'exceptions = \n');
};

var show_element = function (element_id) {
$('#' + element_id).show();
};

var hide_element = function (element_id) {
$('#' + element_id).hide();
};

var toggle_element = function (element_id) {
$('#' + element_id).toggle();
};

var set_filter_url = function (region) {
function set_filter_url(region) {
tmp = location.hash.split('.');
tmp[3] = region;
location.hash = tmp.join('.');
Expand Down

0 comments on commit 730fa78

Please sign in to comment.