Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to add function.csv to vul.tar.gz #5

Closed
darkskytechnology opened this issue May 12, 2021 · 2 comments
Closed

Need to add function.csv to vul.tar.gz #5

darkskytechnology opened this issue May 12, 2021 · 2 comments

Comments

@darkskytechnology
Copy link

$ python preprocess/vul_preprocess.py
...
FileNotFoundError: [Errno 2] No such file or directory: 'data/vul/function.csv'

Can you please add the csv file to the vulnerability data that can be downloaded directly?

@MCCTT
Copy link

MCCTT commented Jun 22, 2021

Changing lines 45:64 of vul_preprocess.py to:

def load_graphs(args):
    #csv_file = os.path.join(args.csv_dir, "function.csv")
    json_file = os.path.join(args.csv_dir, "function.json") 
    paths = []
    #df = pd.read_csv(csv_file, header=0, index_col=False)
    df = pd.read_json(json_file)
    id2sha = df.to_dict()['commit_id']
    id2tgt = df.to_dict()['target']
    idx = [str(i) for i in id2sha.keys()]

        
    #with open(os.path.join(args.file_list), "r") as f:
    #    idx = [str(i.strip()) for i in f.readlines()]

    for i in range(0, len(idx)):
        id = idx[i]
        path = os.path.join(args.asm_dir, str(id)+ "_" + id2sha[int(id)] + ".s")
        if os.path.isfile(path):
            paths.append(
                (i, path, id2tgt[int(id)]))

    graphs_asm = {}
    large_asm  = {}
    tgt_asm = {}

worked for me (the data is there is just a json instead of a csv)

@ChengFu0118
Copy link

Changing lines 45:64 of vul_preprocess.py to:

def load_graphs(args):
    #csv_file = os.path.join(args.csv_dir, "function.csv")
    json_file = os.path.join(args.csv_dir, "function.json") 
    paths = []
    #df = pd.read_csv(csv_file, header=0, index_col=False)
    df = pd.read_json(json_file)
    id2sha = df.to_dict()['commit_id']
    id2tgt = df.to_dict()['target']
    idx = [str(i) for i in id2sha.keys()]

        
    #with open(os.path.join(args.file_list), "r") as f:
    #    idx = [str(i.strip()) for i in f.readlines()]

    for i in range(0, len(idx)):
        id = idx[i]
        path = os.path.join(args.asm_dir, str(id)+ "_" + id2sha[int(id)] + ".s")
        if os.path.isfile(path):
            paths.append(
                (i, path, id2tgt[int(id)]))

    graphs_asm = {}
    large_asm  = {}
    tgt_asm = {}

worked for me (the data is there is just a json instead of a csv)

Thanks for the help! I will update the name of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants