Example #1
0
    def updateFecha_fin(self, id):
        conn = ConexionDB()
        cur = conn.conn.cursor()

        update = "UPDATE pentest SET fecha_fin = statement_timestamp() WHERE id = %s"
        cur.execute(update, (id, ))
        conn.conn.commit()

        cur.close()
        conn.desconectar()
Example #2
0
    def getLastRecord(self):
        conn = ConexionDB()
        cur = conn.conn.cursor()
        query = "SELECT id, url_ip, fecha_ini, fecha_fin, riesgo_general FROM pentest ORDER BY id DESC LIMIT 1"
        cur.execute(query)
        row = cur.fetchone()

        cur.close()
        conn.desconectar()
        return row
Example #3
0
    def getById(self, idd):
        conn = ConexionDB()
        cur = conn.conn.cursor()

        query = "SELECT id, url_ip, fecha_ini, fecha_fin, riesgo_general FROM pentest WHERE id = %s"
        cur.execute(query, (idd, ))
        row = cur.fetchone()

        cur.close()
        conn.desconectar()
        return row
Example #4
0
    def insert(self, objDetalle):
        conn = ConexionDB()
        cur = conn.conn.cursor()

        insert = "INSERT INTO detalle (id_pentest, id_prueba, id_riesgoc, riesgo, resultado, recomendacion) VALUES (%s, %s, %s, %s, %s, %s)"
        cur.execute(insert, (objDetalle.id_pentest, objDetalle.id_prueba,
                             objDetalle.id_riesgoc, objDetalle.riesgo,
                             objDetalle.resultado, objDetalle.recomendacion))
        conn.conn.commit()

        cur.close()
        conn.desconectar()
Example #5
0
    def getTechImpact(self, codigo):
        conn = ConexionDB()
        cur = conn.conn.cursor()

        query = "SELECT riesgo_imptecnico FROM prueba WHERE codigo = %s"
        cur.execute(query, (codigo, ))
        row = cur.fetchone()

        cur.close()
        conn.desconectar()

        return row
Example #6
0
    def getLikelihood(self, codigo):
        conn = ConexionDB()
        cur = conn.conn.cursor()

        query = "SELECT riesgo_probabilidad FROM prueba WHERE codigo = %s"
        cur.execute(query, (codigo, ))
        row = cur.fetchone()

        cur.close()
        conn.desconectar()

        return row
Example #7
0
    def getResultado(self, otg, id_pentest):
        conn = ConexionDB()
        cur = conn.conn.cursor()

        # query = """SELECT p.resultado FROM (SELECT id_prueba, resultado FROM detalle WHERE id_prueba = (SELECT id FROM prueba WHERE codigo = %s) AND id_pentest = %s) p"""
        query = "SELECT d.resultado FROM (SELECT id, codigo from prueba where codigo = %s) p INNER JOIN detalle d ON p.id=d.id_prueba WHERE id_pentest = %s"
        cur.execute(query, (otg, id_pentest))
        row = cur.fetchone()

        cur.close()
        conn.desconectar()

        return row
Example #8
0
    def updateRiesgo_general(self, id):
        conn = ConexionDB()
        cur = conn.conn.cursor()

        update = "UPDATE pentest SET riesgo_general = (SELECT AVG(riesgo) FROM detalle WHERE id_pentest = %s) WHERE id = %s"
        cur.execute(update, (
            id,
            id,
        ))
        conn.conn.commit()

        cur.close()
        conn.desconectar()
Example #9
0
    def getById(self, idd):
        conn = ConexionDB()
        cur = conn.conn.cursor()

        query = "SELECT id, id_pentest, id_prueba, riesgo, resultado, recomendacion FROM detalle WHERE id = %s"
        cur.execute(query, (idd))
        row = cur.fetchone()

        cur.close()
        conn.desconectar()
        if row is not None:
            return Detalle(row[0], row[1], row[2], row[3], row[4], row[5])
        else:
            return None
Example #10
0
    def getAll(self):
        objs = list()

        conn = ConexionDB()
        cur = conn.conn.cursor()
        query = "SELECT id, url_ip, fecha_ini, fecha_fin, riesgo_general FROM pentest"
        cur.execute(query)
        rows = cur.fetchall()
        cur.close()
        conn.desconectar()

        for p in rows:
            objs.append(Pentest(p[0], p[1], p[2], p[3], p[4]))
        return objs
    def getByName(self, nombre):
        conn = ConexionDB()
        cur = conn.conn.cursor()

        query = "SELECT id, nombre FROM riesgo_cualitativo WHERE nombre = %s"
        cur.execute(query, (nombre, ))
        row = cur.fetchone()

        cur.close()
        conn.desconectar()
        if row is not None:
            return Riesgo_Cualitativo(row[0], row[1])
        else:
            return None
Example #12
0
    def getByCodigo(self, codigo):
        conn = ConexionDB()
        cur = conn.conn.cursor()

        query = "SELECT id, codigo, nombre, descripcion, objetivo, id_subcategoria FROM prueba WHERE codigo = %s"
        cur.execute(query, (codigo, ))
        row = cur.fetchone()

        cur.close()
        conn.desconectar()
        if row is not None:
            return Prueba(row[0], row[1], row[2], row[3], row[4], row[5])
        else:
            return None