diff --git a/lib/constants.rb b/lib/constants.rb index 4288cc78a..65ca40b50 100644 --- a/lib/constants.rb +++ b/lib/constants.rb @@ -88,5 +88,13 @@ module Constants end + # The distributed engine codes + module DistributedEngine + + REQUESTER = 1 + PORTSCANNER = 2 + + end + end end diff --git a/lib/ui/panel/index.html b/lib/ui/panel/index.html index b9c0e694c..9f5fe5f10 100644 --- a/lib/ui/panel/index.html +++ b/lib/ui/panel/index.html @@ -12,6 +12,7 @@ <%= script_tag 'ux/StatusBar.js' %> <%= script_tag 'ui/panel/common.js' %> + <%= script_tag 'ui/panel/DistributedEngine.js' %> <%= script_tag 'ui/panel/PanelStatusBar.js' %> <%= script_tag 'ui/panel/tabs/ZombieTabMain.js' %> diff --git a/public/javascript/ui/panel/DistributedEngine.js b/public/javascript/ui/panel/DistributedEngine.js new file mode 100644 index 000000000..de0cc96df --- /dev/null +++ b/public/javascript/ui/panel/DistributedEngine.js @@ -0,0 +1,39 @@ +/* + * RULES TYPE + * - DOMAIN : DOMAIN www.zzz.com + * - EXTERNAL : EXTERNAL 123.456.789.123 + * - INTERNAL : INTERNAL 10.0.0.3 + */ +DistributedEngine = function() { + //defines the constant code to match with the backend ruby + this.CONSTANTS = { + 'requester' : 1, + 'portscanner' : 2 + }; + + /* + * Returns true of the hooked browser matches one of the rules and should be checked. + * @param: {Literal Object} the browser object. + * @param: {Literal Object} the rule set object. + * @return: {Boolean} true if matches, false if not. + */ + this.HookedBrowserMatchesRules = function(hooked_browser, rules) { + + }; + + /* + * Disable an existing rule in the framework. That function is called when the user + * unchecks a hooked browser. + * @param: {Integer} the id of the rule. + */ + this.DisableRule = function(rule_id) { + + }; + + /* + * Creates and sends a new rule to the backend. + */ + this.CreateNewRule = function() { + + }; +}; \ No newline at end of file diff --git a/public/javascript/ui/panel/ZombieTabs.js b/public/javascript/ui/panel/ZombieTabs.js index 36dbfcfa8..aa477e012 100644 --- a/public/javascript/ui/panel/ZombieTabs.js +++ b/public/javascript/ui/panel/ZombieTabs.js @@ -4,8 +4,15 @@ ZombieTabs = function(zombie_tree_list) { this.tree_items = new Array; //we store the list of trees in a correct array format for ExtJs - for(tree in zombie_tree_list) { - this.tree_items.push(zombie_tree_list[tree]); + for(tree_name in zombie_tree_list) { + var tree = zombie_tree_list[tree_name]; + + //set the tree as distributed if it's not the basic tree + if(tree_name != "basic") { + tree.tree_configuration["distributed"] = true; + } + + this.tree_items.push(tree); } /* diff --git a/public/javascript/ui/panel/ZombiesMgr.js b/public/javascript/ui/panel/ZombiesMgr.js index 321c83451..ae40e95b5 100644 --- a/public/javascript/ui/panel/ZombiesMgr.js +++ b/public/javascript/ui/panel/ZombiesMgr.js @@ -46,9 +46,11 @@ var ZombiesMgr = function(zombies_tree_lists) { for(var i in online_hooked_browsers) { var online_hooked_browser = this.zombieFactory(i, online_hooked_browsers); hooked_browsers_tree.addZombie(online_hooked_browser, true, ((tree_type != 'basic') ? true : false)); - //TODO: add the rules here } + //apply the rules to the tree + hooked_browsers_tree.applyRules(rules); + //expand the online hooked browser tree lists if(hooked_browsers_tree.online_hooked_browsers_treenode.childNodes.length > 0) { hooked_browsers_tree.online_hooked_browsers_treenode.expand(true); diff --git a/public/javascript/ui/panel/zombiesTreeList.js b/public/javascript/ui/panel/zombiesTreeList.js index 788837939..a81dad3ac 100644 --- a/public/javascript/ui/panel/zombiesTreeList.js +++ b/public/javascript/ui/panel/zombiesTreeList.js @@ -68,6 +68,10 @@ Ext.extend(zombiesTreeList, Ext.tree.TreePanel, { } mainPanel.activate(node.attributes.session); + }, + //update the set of rules when a checkbox is clicked + checkchange: function(node, checked) { + } }, @@ -188,7 +192,8 @@ Ext.extend(zombiesTreeList, Ext.tree.TreePanel, { sub_folder_node = new Ext.tree.TreeNode({ id: 'sub-folder-'+folder, text: folder, - checked: ((checkbox) ? false : null) + checked: ((checkbox) ? false : null), + type: this.tree_configuration["sub-branch"] }); mother_node.appendChild(sub_folder_node); @@ -246,5 +251,16 @@ Ext.extend(zombiesTreeList, Ext.tree.TreePanel, { } }, this); }, this); + }, + + /* + * Apply a new set of distributed engine rules to the nodes in the tree + * @param: {Literal Objects} the rules set. See the zombie manager. + */ + applyRules: function(rules) { + //we return if the tree is not distributed + if(!this.tree_configuration["distributed"]) return; + + //TODO } }); \ No newline at end of file