Esempio n. 1
0
    def __init__(self, parent_id=None):
        self._name          = ""
        self._id = None
        self._parent_id = parent_id
        self._parent = None

        self.owner          = api.getLoggedUser()
        self._metadata      = Metadata(self.owner)

        # indicates if object was owned somehow
        # we could use this property to put a different color on the GUI
        self._is_owned      = False

        # a custom description given by the user
        # this can be used to explain the purpose of the object
        self.description    = ""

        self.publicattrs = {'Description':'description',
                            'Name':'getName','Owned':'isOwned'
                            }

        self.publicattrsrefs = {'Description': '_description',
                            'Name': '_name','Owned': '_is_owned'
                            }

        self._updatePublicAttributes()

        #TODO: I think notes and vulns should be a dict
        self._notes = {}
        self._vulns = {}
        self._creds = {}
        self.evidences = []

        self.updates = []
Esempio n. 2
0
    def __init__(self):
        self._name          = ""
        self._id            = None
        self._parent        = None
        
        self.owner          = api.getLoggedUser()
        self._metadata      = Metadata(self.owner)
        self._metadataHistory = MetadataHistory()

        
        # this flag is used to determine if the object is an instance that is
        # inside the ModelController or is just a copy of an existing ModelObject
        # that can be used without worrying about changes affecting the real object
        self.is_copy       = False
        
        # indicates if object was owned somehow
        # we could use this property to put a different color on the GUI
        self._is_owned      = False

        # a custom description given by the user
        # this can be used to explain the purpose of the object
        self.description    = ""

        #IMPORTANT: this must be used in each object that inherits from this class
        # DO NOT REDEFINE THIS, JUST ADD ENTRIES IN ORDER NOT TO LOOSE INHERITED ATTRS
        # this attribute lists all values that can be shown in the gui, or
        # can be accessed from outside. This is done to do things more generic and
        # dynamic. The object that needs to use this should check if the element
        # in the attribute list is callable or not
        # To use this attributes list something like this should be done
        # >>> for attrDesc, attrName in m_object.publicattrs.iteritems():
        # >>>     attr_ref = m_object.__getattribute__(attrName)
        # >>>     if callable(attr_ref):
        # >>>         info = attr_ref()
        # >>>     else:
        # >>>         info = attr_ref
        # the dictionary key is the description of the attribute that is like a
        # display name to be used if needed to show in a GUI for example
        # and the value is the attribute name, that can be the name of an attribute,
        # a method or a property, that is why it needs to be checked with callable()

        self.publicattrs = {'Description':'description',
                            'Name':'getName','Owned':'isOwned',
                            #'Vulnerabilities' : 'vulnsCount',
                            #'Notes' : 'notesCount',
                            #'Creds' : 'credsCount'}
                            }

        self.publicattrsrefs = {'Description': '_description',
                            'Name': '_name','Owned': '_is_owned',
                            #'Vulnerabilities' : '_vulns',
                            #'Notes' :'_notes',
                            #'Creds' :'_creds'} 
                            }

        self._updatePublicAttributes()

        #TODO: I think notes and vulns should be a dict
        self._notes = {}
        self._vulns = {}
        self._creds = {}
        self.evidences = []

        self.updates = []