Esempio n. 1
0
 def POST(self):
     params = web.input()
     kw = {
         k: params[k].strip()
         for k in ("id", "name", "url", "info", "type", "level",
                   "description")
     }
     Vul.where(id=params.id.strip()).update(**kw)
     return jsonSuccess()
Esempio n. 2
0
    def GET(self):
        params = web.input()
        try:
            projectid = int(params.id)
        except (ValueError, AttributeError):
            raise web.internalerror("parameter error.")

        project = Project.getraw(projectid)
        if project:
            hosts = Host.where(project_id=projectid,tmp=0).getsraw()
            
            for host in hosts:
                host['vuls'] = Vul.where(host_id=host['id']).getsraw('name','url','info','type','level','description')
                host['comments'] = Comment.where(host_id=host['id']).getsraw('name','url','info','level','description')
                del host['id']
                del host['tmp']
                del host['project_id']
            project['hosts'] = hosts
            del project['id']

        projectName = "_".join(project['name'].split(" "))
        projectFile = os.path.join("static","tmp",projectName+".proj")

        try:
            with open(projectFile,'w') as fd:
                json.dump(project, fd)
        except IOError:
            raise web.internalerror("save imported project failed")
Esempio n. 3
0
    def GET(self):
        params = web.input()
        try:
            projectid = int(params.id)
        except (ValueError, AttributeError):
            raise web.internalerror("parameter error.")

        project = Project.getraw(projectid)
        if project:
            hosts = Host.where(project_id=projectid, tmp=0).getsraw()

            for host in hosts:
                host['vuls'] = Vul.where(host_id=host['id']).getsraw(
                    'name', 'url', 'info', 'type', 'level', 'description')
                host['comments'] = Comment.where(host_id=host['id']).getsraw(
                    'name', 'url', 'info', 'level', 'description')
                del host['id']
                del host['tmp']
                del host['project_id']
            project['hosts'] = hosts
            del project['id']

        projectName = "_".join(project['name'].split(" "))
        projectFile = os.path.join("static", "tmp", projectName + ".proj")

        try:
            with open(projectFile, 'w') as fd:
                json.dump(project, fd)
        except IOError:
            raise web.internalerror("save imported project failed")
Esempio n. 4
0
    def GET(self):
        params = web.input()
        if not params.id.strip().isdigit():
            raise web.internalerror("Parameter type error.")

        host = Host.get(params.id.strip())
        vuls = Vul.where(host_id=host.id).gets("id")
        for vul in vuls:
            vul.remove()

        comments = Comment.where(host_id=host.id).gets("id")
        for comment in comments:
            comment.remove()

        host.remove()

        return jsonSuccess()
Esempio n. 5
0
    def GET(self):
        params = web.input()
        if not params.id.strip().isdigit():
            raise web.internalerror("Parameter type error.")

        host = Host.get(params.id.strip())
        vuls = Vul.where(host_id=host.id).gets("id")
        for vul in vuls:
            vul.remove()

        comments = Comment.where(host_id=host.id).gets("id")
        for comment in comments:
            comment.remove()

        host.remove()

        return jsonSuccess()
Esempio n. 6
0
 def POST(self):
     params = web.input()
     kw = {k:params[k].strip() for k in ("id","name","url","info","type","level","description")}
     Vul.where(id=params.id.strip()).update(**kw)
     return jsonSuccess()
Esempio n. 7
0
 def GET(self):
     params = web.input()
     result = Vul.where(host_id=params.hostid.strip()).orderby(params.orderby.strip()).getsraw('id','name','level')
     return json.dumps(result)
Esempio n. 8
0
 def GET(self):
     params = web.input()
     result = Vul.where(host_id=params.hostid.strip()).orderby(
         params.orderby.strip()).getsraw('id', 'name', 'level')
     return json.dumps(result)