Ejemplo n.º 1
0
def rewrite_report_engine(cocci):
    rtypes = Type.objects.filter(id=cocci.id + 10000)
    if len(rtypes) != 0:
        rtype = rtypes[0]

        einfo = []
        for efile in ExceptFile.objects.filter(type=rtype):
            einfo.append({"file": efile.file, "reason": efile.reason})

        fmt = CocciFormater(rtype.ptitle, rtype.pdesc, cocci.content, cocci.options, "", einfo)
        fmt.save(cocci.fullpath())
Ejemplo n.º 2
0
def rewrite_report_engine(cocci):
    rtypes = Type.objects.filter(id = cocci.id + 10000)
    if len(rtypes) != 0:
        rtype = rtypes[0]

        einfo = []
        for efile in ExceptFile.objects.filter(type = rtype):
            einfo.append({'file': efile.file, 'reason': efile.reason})

        fmt = CocciFormater(rtype.ptitle, rtype.pdesc, cocci.content,
                            cocci.options, '', einfo)
        fmt.save(cocci.fullpath())
Ejemplo n.º 3
0
def report_semantic_edit(request, cocci_id):
    if request.method == "POST":
        name = get_request_paramter(request, "name")
        title = get_request_paramter(request, "title")
        desc = get_request_paramter(request, "desc")
        content = get_request_paramter(request, "content")
        options = get_request_paramter(request, "options")

        if name is None or len(name) == 0:
            logevent("EDIT: coccinelle report semantic, ERROR: no name specified")
            return HttpResponse("EDIT ERROR: no semantic name specified")

        if title is None or len(title) == 0:
            logevent("EDIT: coccinelle report semantic, ERROR: no title specified")
            return HttpResponse("EDIT ERROR: no semantic title specified")

        if desc is None or len(desc) == 0:
            logevent("EDIT: coccinelle report semantic, ERROR: no desc specified")
            return HttpResponse("EDIT ERROR: no semantic desc specified")

        if content is None or len(content) == 0:
            logevent("EDIT: coccinelle report semantic, ERROR: no content specified")
            return HttpResponse("EDIT ERROR: no semantic content specified")

        if options is None:
            options = ""

        coccis = CocciReportEngine.objects.filter(id=cocci_id)
        if len(coccis) == 0:
            logevent("EDIT: coccinelle report semantic, ERROR: id %s does not exists" % cocci_id)
            return HttpResponse("EDIT ERROR: semantic id %s does not exists" % cocci_id)

        engine = coccis[0]
        ofname = engine.fullpath()
        fname = "%s.cocci" % name.strip()
        engine.file = fname
        engine.content = content
        engine.options = options.strip()

        rtype = Type.objects.get(id=engine.id + 10000)

        einfo = []
        for efile in ExceptFile.objects.filter(type=rtype):
            einfo.append({"file": efile.file, "reason": efile.reason})

        try:
            fmt = CocciFormater(title, desc, content, options, "", einfo)
            fmt.save(engine.fullpath())
            if ofname != engine.fullpath() and os.path.exists(ofname):
                os.unlink(ofname)
        except:
            logevent("EDIT: coccinelle report semantic, ERROR: can not write file %s" % engine.fullpath())
            return HttpResponse("EDIT ERROR: can not write file %s" % engine.fullpath())

        engine.save()

        rtype.name = name
        rtype.ptitle = title
        rtype.pdesc = desc
        rtype.save()

        logevent("EDIT: coccinelle report semantic, SUCCEED: type id %s" % rtype.id, True)
        return HttpResponse("EDIT: coccinelle semantic, SUCCEED: type id %s" % cocci_id)
    else:
        coccis = CocciReportEngine.objects.filter(id=cocci_id)
        if len(coccis) == 0:
            engine = None
            rtype = None
        else:
            engine = coccis[0]
            rtype = Type.objects.get(id=engine.id + 10000)
        context = RequestContext(request)
        context["cocci"] = engine
        context["type"] = rtype
        return render_to_response("engine/semanticedit.html", context)
Ejemplo n.º 4
0
def report_semantic_edit(request, cocci_id):
    if request.method == "POST":
        name = get_request_paramter(request, 'name')
        title = get_request_paramter(request, 'title')
        desc = get_request_paramter(request, 'desc')
        content = get_request_paramter(request, 'content')
        options = get_request_paramter(request, 'options')

        if name is None or len(name) == 0:
            logevent("EDIT: coccinelle report semantic, ERROR: no name specified")
            return HttpResponse('EDIT ERROR: no semantic name specified')
    
        if title is None or len(title) == 0:
            logevent("EDIT: coccinelle report semantic, ERROR: no title specified")
            return HttpResponse('EDIT ERROR: no semantic title specified')
    
        if desc is None or len(desc) == 0:
            logevent("EDIT: coccinelle report semantic, ERROR: no desc specified")
            return HttpResponse('EDIT ERROR: no semantic desc specified')
    
        if content is None or len(content) == 0:
            logevent("EDIT: coccinelle report semantic, ERROR: no content specified")
            return HttpResponse('EDIT ERROR: no semantic content specified')

        if options is None:
            options = ''

        coccis = CocciReportEngine.objects.filter(id = cocci_id)
        if len(coccis) == 0:
            logevent("EDIT: coccinelle report semantic, ERROR: id %s does not exists" % cocci_id)
            return HttpResponse('EDIT ERROR: semantic id %s does not exists' % cocci_id)

        engine = coccis[0]
        ofname = engine.fullpath()
        fname = '%s.cocci' % name.strip()
        engine.file = fname
        engine.content = content
        engine.options = options.strip()

        rtype = Type.objects.get(id = engine.id + 10000)

        einfo = []
        for efile in ExceptFile.objects.filter(type = rtype):
            einfo.append({'file': efile.file, 'reason': efile.reason})

        try:
            fmt = CocciFormater(title, desc, content, options, '', einfo)
            fmt.save(engine.fullpath())
            if ofname != engine.fullpath() and os.path.exists(ofname):
                os.unlink(ofname)
        except:
            logevent("EDIT: coccinelle report semantic, ERROR: can not write file %s" % engine.fullpath())
            return HttpResponse('EDIT ERROR: can not write file %s' % engine.fullpath())

        engine.save()
    
        rtype.name = name
        rtype.ptitle = title
        rtype.pdesc = desc
        rtype.save()

        logevent("EDIT: coccinelle report semantic, SUCCEED: type id %s" % rtype.id, True)
        return HttpResponse('EDIT: coccinelle semantic, SUCCEED: type id %s' % cocci_id)
    else:
        coccis = CocciReportEngine.objects.filter(id = cocci_id)
        if len(coccis) == 0:
            engine = None
            rtype = None
        else:
            engine = coccis[0]
            rtype = Type.objects.get(id = engine.id + 10000)
        context = RequestContext(request)
        context['cocci'] = engine
        context['type'] = rtype
        return render_to_response("engine/semanticedit.html", context)
Ejemplo n.º 5
0
def semantic_edit(request, cocci_id):
    if request.method == "POST":
        name = get_request_paramter(request, 'name')
        title = get_request_paramter(request, 'title')
        desc = get_request_paramter(request, 'desc')
        content = get_request_paramter(request, 'content')
        options = get_request_paramter(request, 'options')
        fixed = get_request_paramter(request, 'fixed')

        if name is None or len(name) == 0:
            logevent("EDIT: coccinelle semantic, ERROR: no name specified")
            return HttpResponse('EDIT ERROR: no semantic name specified')
    
        if title is None or len(title) == 0:
            logevent("EDIT: coccinelle semantic, ERROR: no title specified")
            return HttpResponse('EDIT ERROR: no semantic title specified')
    
        if desc is None or len(desc) == 0:
            logevent("EDIT: coccinelle semantic, ERROR: no desc specified")
            return HttpResponse('EDIT ERROR: no semantic desc specified')
    
        if content is None or len(content) == 0:
            logevent("EDIT: coccinelle semantic, ERROR: no content specified")
            return HttpResponse('EDIT ERROR: no semantic content specified')

        if options is None:
            options = ''

        if fixed is None:
            fixed = ''

        coccis = CocciPatchEngine.objects.filter(id = cocci_id)
        if len(coccis) == 0:
            logevent("EDIT: coccinelle semantic, ERROR: id %s does not exists" % cocci_id)
            return HttpResponse('EDIT ERROR: semantic id %s does not exists' % cocci_id)

        engine = coccis[0]
        ofname = engine.fullpath()
        fname = '%s.cocci' % name.strip()
        engine.file = fname
        engine.content = content
        engine.options = options.strip()
        engine.fixed = fixed.strip()

        rtype = Type.objects.get(id = engine.id + 3000)

        einfo = []
        for efile in ExceptFile.objects.filter(type = rtype):
            einfo.append({'file': efile.file, 'reason': efile.reason})

        try:
            fmt = CocciFormater(title, desc, content, options, fixed, einfo)
            fmt.save(engine.fullpath())
            if ofname != engine.fullpath() and os.path.exists(ofname):
                os.unlink(ofname)
        except:
            logevent("EDIT: coccinelle semantic, ERROR: can not write file %s" % engine.fullpath())
            return HttpResponse('EDIT ERROR: can not write file %s' % engine.fullpath())

        engine.save()

        rtype.name = name
        rtype.ptitle = title
        rtype.pdesc = desc
        rtype.save()

        logevent("EDIT: coccinelle semantic, SUCCEED: type id %s" % rtype.id, True)
        return HttpResponse('EDIT: coccinelle semantic, SUCCEED: type id %s' % cocci_id)
    else:
        coccis = CocciPatchEngine.objects.filter(id = cocci_id)
        if len(coccis) == 0:
            engine = None
            rtype = None
        else:
            engine = coccis[0]
            rtype = Type.objects.get(id = engine.id + 3000)
        context = RequestContext(request)
        context['cocci'] = engine
        context['type'] = rtype
        return render_to_response("engine/semanticedit.html", context)