<commit_before>import angr
import argparse
from angrutils import *
from os import remove
import sys

# imports for converting dot graph to json graph
import networkx as nx
from networkx.readwrite import json_graph


def generateCFG(binary, analysisType = 'Fast'):
    # Create the angr project for the binary
    project = angr.Project(binary, auto_load_libs = False)

    # Create the Control Flow Graph in Fast or Accurate mode.
    if (analysisType == 'Fast'):
        cfg = project.analyses.CFG()
    elif (analysisType == 'Accurate'):#
        cfg = project.analyses.CFGAccurate()
    else:
        return

    # output the cfg in dot format
    outputFileName = binary
    plot_cfg(cfg, outputFileName, asminst=True, remove_imports=True, remove_path_terminator=True, format='dot')

    # convert the output graph from angr to json format
    graph_json = _dot_to_json(outputFileName + '.dot')

    # delete the dot file generated by angrutils plot_cfg
    remove(outputFileName + '.dot')<commit_msg>remove unused imports<commit_after>import angr
from angrutils import *
from os import remove

# imports for converting dot graph to json graph
import networkx as nx
from networkx.readwrite import json_graph


def generateCFG(binary, analysisType = 'Fast'):
    # Create the angr project for the binary
    project = angr.Project(binary, auto_load_libs = False)

    # Create the Control Flow Graph in Fast or Accurate mode.
    if (analysisType == 'Fast'):
        cfg = project.analyses.CFG()
    elif (analysisType == 'Accurate'):#
        cfg = project.analyses.CFGAccurate()
    else:
        return

    # output the cfg in dot format
    outputFileName = binary
    plot_cfg(cfg, outputFileName, asminst=True, remove_imports=True, remove_path_terminator=True, format='dot')

    # convert the output graph from angr to json format
    graph_json = _dot_to_json(outputFileName + '.dot')

    # delete the dot file generated by angrutils plot_cfg
    remove(outputFileName + '.dot')
{'fraction_non_alphanumeric': 0.07835258663987946, 'fraction_numerical': 0.0, 'mean_word_length': 3.7315914489311166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3142967', 'n_tokens_mistral': 580, 'n_tokens_neox': 553, 'n_words': 201}