Beispiel #1
0
 def update(self, pipeline_set=None):
     """Update this object in database.
     Args:
         pipeline_set: (Opt.) A dictionnary with custom values. If None (default) use model attributes.
     """
     apiclient = APIClient.getInstance()
     if pipeline_set is None:
         apiclient.update(
             "defects", ObjectId(self._id), {
                 "ip": self.ip,
                 "title": self.title,
                 "port": self.port,
                 "proto": self.proto,
                 "notes": self.notes,
                 "ease": self.ease,
                 "impact": self.impact,
                 "risk": self.risk,
                 "redactor": self.redactor,
                 "type": list(self.mtype),
                 "proofs": self.proofs,
                 "infos": self.infos,
                 "index": int(self.index)
             })
     else:
         apiclient.update("defects", ObjectId(self._id), pipeline_set)
Beispiel #2
0
 def delete(self):
     """
     Delete the defect represented by this model in database.
     """
     ret = self._id
     apiclient = APIClient.getInstance()
     apiclient.delete("defects", ret)
Beispiel #3
0
 def getTools(self):
     """Return port assigned tools as a list of mongo fetched defects dict
     Returns:
         list of tool raw mongo data dictionnaries
     """
     apiclient = APIClient.getInstance()
     return apiclient.find("tools", {"wave": self.wave, "$or": [{"lvl": "network"}, {"lvl": "domain"}], "scope": self.scope})
Beispiel #4
0
 def removeProof(self, ind):
     """Removes the proof file at given proof index
     """
     apiclient = APIClient.getInstance()
     filename = self.proofs[ind]
     ret = apiclient.rmProof(self._id, filename)
     del self.proofs[ind]
     return ret
Beispiel #5
0
 def delete(self):
     """
     Delete the Scope represented by this model in database.
     Also delete the tools associated with this scope
     Also remove this scope from ips in_scopes attributes
     """
     # deleting tool with scope lvl
     apiclient = APIClient.getInstance()
     apiclient.delete("scopes", ObjectId(self._id))
Beispiel #6
0
 def uploadProof(self, proof_local_path):
     """Upload the given proof file to the server
     Args:
         proof_local_path: a path to a local proof file
     Returns:
         the basename of the file 
     """
     apiclient = APIClient.getInstance()
     apiclient.putProof(self._id, proof_local_path)
     return os.path.basename(proof_local_path)
Beispiel #7
0
 def update(self, pipeline_set=None):
     """Update this object in database.
     Args:
         pipeline_set: (Opt.) A dictionnary with custom values. If None (default) use model attributes.
     """
     apiclient = APIClient.getInstance()
     if pipeline_set is None:
         apiclient.update("scopes", ObjectId(self._id), {"notes": self.notes, "tags": self.tags})
     else:
         apiclient.update("scopes", ObjectId(self._id), pipeline_set)