def checkDomainFit(cls, waveName, domain): """ Check if a found domain belongs to one of the scope of the given wave. Args: waveName: The wave id (name) you want to search for a validating scope domain: The found domain. Returns: boolean """ # Checking settings for domain check. settings = Settings() # get the domain ip so we can search for it in ipv4 range scopes. domainIp = Utils.performLookUp(domain) mongoInstance = MongoCalendar.getInstance() scopesOfWave = mongoInstance.find("scopes", {"wave": waveName}) for scopeOfWave in scopesOfWave: scopeIsANetworkIp = Utils.isNetworkIp(scopeOfWave["scope"]) if scopeIsANetworkIp: if settings.db_settings.get("include_domains_with_ip_in_scope", False): if Ip.checkIpScope(scopeOfWave["scope"], domainIp): return True else: # If scope is domain # check if we include subdomains if settings.db_settings.get("include_all_domains", False): return True else: splitted_domain = domain.split(".") # Assuring to check only if there is a domain before the tld (.com, .fr ... ) topDomainExists = len(splitted_domain) > 2 if topDomainExists: if settings.db_settings.get( "include_domains_with_topdomain_in_scope", False): if splitted_domain[1:] == scopeOfWave[ "scope"].split("."): return True if settings.db_settings.get( "include_domains_with_ip_in_scope", False): inRangeDomainIp = Utils.performLookUp( scopeOfWave["scope"]) if str(inRangeDomainIp) == str(domainIp): return True return False
def __init__(self, parent): """ Initialise the application Args: parent: The main tk window. """ # Lexic: # view frame : the frame in the tab that will hold forms. # Tree view : the tree on the left of the window. # frame tree view : a frame around the tree view (useful to attach a scrollbar to a treeview) # canvas : a canvas object (useful to attach a scrollbar to a frame) # paned : a Paned widget is used to separate two other widgets and display a one over the other if desired # Used to separate the treeview frame and view frame. self.parent = parent # parent tkinter window # already read notifications from previous notification reading iteration self.old_notifs = [] self.notifications_timers = None tk.Tk.report_callback_exception = self.show_error self.setStyle() # HISTORY : Main view and command where historically in the same view; # This results in lots of widget here with a confusing naming style ttk.Frame.__init__(self, parent) #### core components (Tab menu on the left objects)#### self.settings = Settings() self.settingViewFrame = None self.scanManager = None # Loaded when clicking on it if linux only self.scanViewFrame = None self.main_tab_img = ImageTk.PhotoImage( Image.open(Utils.getIconDir()+"tab_main.png")) self.commands_tab_img = ImageTk.PhotoImage( Image.open(Utils.getIconDir()+"tab_commands.png")) self.scan_tab_img = ImageTk.PhotoImage( Image.open(Utils.getIconDir()+"tab_scan.png")) self.settings_tab_img = ImageTk.PhotoImage( Image.open(Utils.getIconDir()+"tab_settings.png")) self.initModules() #### MAIN VIEW #### self.openedViewFrameId = None self.mainPageFrame = None self.paned = None self.canvasMain = None self.viewframe = None self.frameTw = None self.treevw = None self.myscrollbarMain = None #### COMMAND VIEW #### self.commandsPageFrame = None self.commandPaned = None self.commandsFrameTw = None self.canvas = None self.commandsViewFrame = None self.myscrollbarCommand = None self.commandsTreevw = None #### SEARCH BAR #### # boolean set to true when the main tree view is displaying search results self.searchMode = False self.searchBar = None # the search bar component self.btnHelp = None # help button on the right of the search bar self.photo = None # the ? image self.helpFrame = None # the floating help frame poping when the button is pressed # Connect to database and choose database to open abandon = False mongoInstance = MongoCalendar.getInstance() while not mongoInstance.isUserConnected() and not abandon: abandon = self.promptForConnection() is None if not abandon: mongoInstance.attach(self) self.initUI() # Will trigger promptForCalendarOpen when tab will be opened else: self.onClosing() try: parent.destroy() except tk.TclError: pass