예제 #1
0
def get_ppo_project_variant_totals(variant, cwe):
    variantfile = 'x' + variant
    ppoprojecttotals = {}  # project -> dm -> dmtotal
    spoprojecttotals = {}
    nosummary = []

    for p in get_juliet_projects(cwe):
        path = os.path.join(UF.get_juliet_path(), p)
        results = UF.read_project_summary_results(path)
        if results is None:
            nosummary.append(p)
            continue
        pd = results

        if variantfile in pd['fileresults']['ppos']:
            ppod = pd['fileresults']['ppos'][variantfile]
            if variantfile in pd['fileresults']['spos']:
                spod = pd['fileresults']['spos'][variantfile]
            else:
                spod = {}
            if not 'violated' in ppod:
                ppod['violated'] = 0
            if not 'violated' in spod:
                spod['violated'] = 0
            ppoprojecttotals[p] = ppod
            spoprojecttotals[p] = spod

        else:
            vfiles = get_variant_files(variant)
            if len(vfiles) > 0 and vfiles[0] in pd['fileresults']['ppos']:
                ppoprojecttotals[p] = {}
                spoprojecttotals[p] = {}
                for f in vfiles:
                    if f in pd['fileresults']['ppos']:
                        ppod = pd['fileresults']['ppos'][f]
                        if not 'violated' in ppod:
                            ppod['violated'] = 0
                        for dm in ppod:
                            if not dm in ppoprojecttotals[p]:
                                ppoprojecttotals[p][dm] = 0
                            ppoprojecttotals[p][dm] += ppod[dm]
                    if f in pd['fileresults']['spos']:
                        spod = pd['fileresults']['spos'][f]
                        if not 'violated' in spod:
                            spod['violated'] = 0
                        for dm in spod:
                            if not dm in spoprojecttotals[p]:
                                spoprojecttotals[p][dm] = 0
                            spoprojecttotals[p][dm] += spod[dm]
    return (ppoprojecttotals, spoprojecttotals, nosummary)
예제 #2
0
    colors = RP.histogramcolors

    ppodmtotals = {}  # dm -> totals list (per test)
    spodmtotals = {}  # dm -> totals list (per test)
    plotlegend = []
    for dm in dsmethods:
        ppodmtotals[dm] = []
    for dm in dsmethods:
        spodmtotals[dm] = []
    width = 0.67
    N = 0
    ptotals = []  # totals list   (per test)
    stotals = []  # totals list   (per test)

    for p in get_juliet_projects(cwe):
        path = os.path.join(UF.get_juliet_path(), p)
        results = UF.read_project_summary_results(path)
        if results is None:
            continue
        pd = results
        ppod = pd['tagresults']['ppos']  # ppotype -> dm -> count
        spod = pd['tagresults']['spos']  # ppotype -> dm -> count

        for t in ppod:
            if not 'violated' in ppod[t]: ppod[t]['violated'] = 0
        for t in spod:
            if not 'violated' in spod[t]: spod[t]['violated'] = 0

        for t in ppod:
            if not 'contract' in ppod[t]: ppod[t]['contract'] = 0
        for t in spod:
예제 #3
0
        ktpath = os.path.join(sempath, 'ktadvance')
        if os.path.isdir(ktpath):
            ktmodtime = os.path.getmtime(ktpath)
    scorefile = os.path.join(dname, 'summaryresults.json')
    if os.path.isfile(scorefile):
        scmodtime = os.path.getmtime(scorefile)
    return (ktmodtime, scmodtime)


if __name__ == '__main__':

    args = parse()
    cwerequested = 'all'
    if args.cwe is not None: cwerequested = args.cwe

    path = UF.get_juliet_path()

    result = {}

    if os.path.isdir(path):
        for d1 in os.listdir(path):
            if d1.startswith('CWE'):
                if not (cwerequested == 'all' or cwerequested == d1): continue
                fd1 = os.path.join(path, d1)
                for d2 in os.listdir(fd1):
                    fd2 = os.path.join(fd1, d2)
                    if os.path.isdir(fd2):
                        if d2.startswith('s0') or d2.startswith('s1'):
                            for d3 in os.listdir(fd2):
                                fd3 = os.path.join(fd2, d3)
                                if os.path.isdir(fd3):