def fromDict(self, dict): self.id = dict["_id"] self.name = dict["name"] owned = True if dict["owned"].upper() == "TRUE" else False self.setOwned(owned) parent_id = dict["parent"] self.owner = dict["owner"] self._status = dict["status"] self._version = dict["version"] self.description = dict["description"] for u, p in dict["credentials"]: self.credentials.append((u, p)) for note in dict["notes"]: n = ModelObjectNote("") self.setParent(self) n.fromDict(note) self.addNote(n) for vuln in dict["vulnerabilities"]: v = ModelObjectVuln("") self.setParent(self) v.fromDict(vuln) self.addVuln(v) return True
def fromDict(self, dict): self.id = dict["id"] self.name = dict["name"] owned = True if dict["owned"].upper() == "TRUE" else False self.setOwned(owned) parent_id = dict["parent"] self.owner = dict["owner"] self._protocol = dict["protocol"] self._status = dict["status"] self._version = dict["version"] self.description = dict["description"] for port in dict["ports"]: self.addPort(int(port)) for interface in dict["interfaces"]: inter = Interface() inter.id = interface self.addInterface(inter) for application in dict["applications"]: app = HostApplication("") app.id = application self.addApplication(app) for cred in dict["creds"]: c = ModelObjectCred("") self.setParent(self) c.fromDict(cred) self.addCred(c) for note in dict["notes"]: n = ModelObjectNote("") self.setParent(self) n.fromDict(note) self.addNote(n) for vuln in dict["vulnerabilities"]: v = ModelObjectVuln("") self.setParent(self) v.fromDict(vuln) self.addVuln(v) return True
def fromDict(self, dict): dict.setdefault("") self.id = dict["_id"] self.name = dict["name"] owned = True if dict.get("owned", "").upper() == "TRUE" else False self.setOwned(owned) parent_id = dict["parent"] self.owner = dict["owner"] self.operating_system = dict["os"] self._default_gateway = dict["default_gateway"].split(",") self.description = dict["description"] self._metadata = Metadata("").fromDict(dict["metadata"]) self.categories = [] for category in dict["categories"]: self.categories.append(category) interfaces = dict["interfaces"] for id, interface in interfaces.items(): ints = Interface() ints.setParent(self) ints.fromDict(interface) self.addInterface(ints) applications = dict["applications"] for id, application in applications.items(): app = HostApplication("") app.setParent(self) app.fromDict(application) self.addApplication(app) for note in dict["notes"]: n = ModelObjectNote("") self.setParent(self) n.fromDict(note) self.addNote(n) for vuln in dict["vulnerabilities"]: v = ModelObjectVuln("") self.setParent(self) v.fromDict(vuln) self.addVuln(v) return True
def fromDict(self, dict): dict.setdefault("") self.id = dict["_id"] self.name = dict["name"] owned = True if dict.get("owned", "").upper() == "TRUE" else False self.setOwned(owned) parent_id = dict["parent"] self.owner = dict["owner"] self.operating_system = dict["os"] self._default_gateway = dict["default_gateway"].split(",") self.description = dict["description"] self._metadata = Metadata("").fromDict(dict["metadata"] ) self.categories = [] for category in dict["categories"]: self.categories.append(category) interfaces = dict["interfaces"] for id, interface in interfaces.items(): ints = Interface() ints.setParent(self) ints.fromDict(interface) self.addInterface(ints) applications = dict["applications"] for id, application in applications.items(): app = HostApplication("") app.setParent(self) app.fromDict(application) self.addApplication(app) for note in dict["notes"]: n = ModelObjectNote("") self.setParent(self) n.fromDict(note) self.addNote(n) for vuln in dict["vulnerabilities"]: v = ModelObjectVuln("") self.setParent(self) v.fromDict(vuln) self.addVuln(v) return True
def fromDict(self, dict): self.id = dict["_id"] self.name = dict["name"] owned = True if dict["owned"].upper() == "TRUE" else False self.setOwned(owned) parent_id = dict["parent"] self.owner = dict["owner"] self.mac = dict["mac"] self.network_segment = dict["network_segment"] self.description = dict["description"] for hostname in dict["hostnames"]: self.addHostname(hostname) self.ipv4.update(dict["ipv4"]) self.ipv6.update(dict["ipv6"]) self.amount_ports_opened = dict["ports"]["opened"] self.amount_ports_closed = dict["ports"]["closed"] self.amount_ports_filtered = dict["ports"]["filtered"] for srv in dict["services"]: service = Service("") service.setParent(self) service.fromDict(srv) self.addService(service) for note in dict["notes"]: n = ModelObjectNote("") self.setParent(self) n.fromDict(note) self.addNote(n) for vuln in dict["vulnerabilities"]: v = ModelObjectVuln("") self.setParent(self) v.fromDict(vuln) self.addVuln(v) return True