Ejemplo n.º 1
0
    sempath = os.path.join(args.path, "semantics")

    cfapp = CApplication(sempath, args.cfile)
    cfile = cfapp.get_cfile()

    if args.showcode:
        if args.open and args.violations:

            def pofilter(po):
                return not po.is_closed() or po.is_violated()

        elif args.open:

            def pofilter(po):
                return not po.is_closed()

        elif args.violations:

            def pofilter(po):
                return po.is_violated()

        else:

            def pofilter(po):
                return True

        print(RP.file_code_tostring(cfile, pofilter=pofilter, showinvs=True))

    print(RP.file_proofobligation_stats_tostring(cfile))
if __name__ == "__main__":

    args = parse()
    try:
        cpath = UF.get_juliet_testpath(args.cwe, args.test)
        UF.check_analysis_results(cpath)
    except UF.CHError as e:
        print(str(e.wrap()))
        exit(1)

    sempath = os.path.join(cpath, "semantics")

    try:
        cfapp = CApplication(sempath, args.cfile)
        cfile = cfapp.get_cfile()
    except UF.CHCFileNotFoundError as e:
        print(str(e.wrap()))
        exit(1)

    dc = ["deadcode"]

    if args.showcode:
        if args.open:
            print(
                RP.file_code_open_tostring(cfile,
                                           showinvs=args.showinvariants))
        else:
            print(RP.file_code_tostring(cfile, showinvs=args.showinvariants))

    print(RP.file_proofobligation_stats_tostring(cfile, extradsmethods=dc))
Ejemplo n.º 3
0
        UF.check_analysis_results(cpath)
    except UF.CHError as e:
        print(str(e.wrap()))
        exit(1)

    sempath = os.path.join(cpath, 'semantics')
    if not os.path.isdir(sempath):
        print(UP.semantics_not_found_err_msg(cpath))
        exit(1)

    try:
        cfapp = CApplication(sempath, args.cfile)
        cfile = cfapp.get_cfile()
    except UF.CFileNotFoundException as e:
        print(str(e.wrap()))
        exit(0)

    try:
        if args.showcode:
            if args.open:
                print(RP.file_code_open_tostring(cfile,
                                                 showinvs=args.showinvs))
            else:
                print(RP.file_code_tostring(cfile))

        print(RP.file_proofobligation_stats_tostring(cfile))
    except IndexedTableError as e:
        print('\n' + ('*' * 80) + '\nThe analysis results format has changed' +
              '\nYou may have to re-run the analysis first: ' + '\n' + e.msg +
              '\n' + ('*' * 80))