Ejemplo n.º 1
0
def applyCocciOnFiles(cocci_files, config, c_files):

    cocci_tree_path = config.get('Cocci', 'cocci_path')
    project_tree_path = config.get('Projects', 'project_path')

    # check c_files
    list_files = ''
    for c_file in c_files:
        c_abspath = utils.checkCFile(project_tree_path, c_file)

        if c_abspath is not None:
            list_files = list_files + ' ' + project_tree_path + c_file
        else:
            print "%s is not an existing c file, escape" % c_file

    if not list_files == '':
    #
        for cocci_file in cocci_files:
            cocci_abspath = utils.checkCocciFile(cocci_tree_path, cocci_file)

            if cocci_abspath is not None:
                command_line = "spatch -sp_file " + cocci_abspath + ' ' + list_files
                subprocess.call(command_line, shell=True)
            else:
                print "%s is not an existing cocci file" % cocci_file
    #
    else:
        print "No existing C file. End of program"
        sys.exit(2)
Ejemplo n.º 2
0
def applyRulesOnProject(rules_file, config, project):

    cocci_tree_path = config.get('Cocci', 'cocci_path')
    project_tree_path = config.get('Projects', 'project_path')

    # Check Project
    _project = utils.checkProject(config, project)

    # Check Rules File
    rules_abspath = utils.checkRulesFile(_project, rules_file)

    if rules_abspath is None:
        print "Rules File %s does not exist. Aborting" % rules_file
        sys.exit(2)

    # Create list of cocci_files from rules_files
    cocci_files = []
    fd = open(rules_abspath, 'r')
    for line in fd:
        if not line.startswith('#'):
            cocci_files.append(line.strip())

    # Command line
    for cocci_file in cocci_files:
        cocci_abspath = utils.checkCocciFile(cocci_tree_path, cocci_file)
        print cocci_abspath
        if cocci_abspath is not None:
            command_line = "spatch -sp_file " + cocci_abspath + " -dir " + _project
            subprocess.call(command_line, shell=True)
        else:
            print "%s is not a cocci file" % cocci_file
Ejemplo n.º 3
0
def applyCocciOnProject(cocci_files, config, project):

    cocci_tree_path = config.get('Cocci', 'cocci_path')
    project_tree_path = config.get('Projects', 'project_path')

    _project = utils.checkProject(project_tree_path, project)

    for cocci_file in cocci_files:

        cocci_abspath = utils.checkCocciFile(cocci_tree_path, cocci_file)
        if cocci_abspath is not None:
             command_line = "spatch -sp_file " + cocci_abspath + " -dir " + _project
             subprocess.call(command_line, shell=True)
        else:
            print "%s is not a cocci file" % cocci_file