Skip to content

Commit abd1fd1

Browse files
committed
Replace call to eval.
Replace call to eval for converting a string representation of a list of file names with ast.literal_eval(). eval will run any string as Python code so potentially can cause harm, ast.literal_eval() is safer.
1 parent 06ef2b9 commit abd1fd1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Python/71_Trust_But_Verify.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"import SimpleITK as sitk\n",
5555
"import pandas as pd\n",
5656
"import numpy as np\n",
57+
"import ast\n",
5758
"import os\n",
5859
"import sys\n",
5960
"import shutil\n",
@@ -735,7 +736,8 @@
735736
"outputs": [],
736737
"source": [
737738
"faux_volume_image_files = sitk.ReadImage(faux_series_volume_file_name)\n",
738-
"image_file_list = pd.read_csv(faux_series_file_list_name)[\"files\"].apply(eval).to_list()\n",
739+
"# convert string representation of list of file names to a list of file names\n",
740+
"image_file_list = pd.read_csv(faux_series_file_list_name)[\"files\"].apply(ast.literal_eval).tolist()\n",
739741
"\n",
740742
"image_selection_gui2 = ImageSelection(\n",
741743
" faux_volume_image_files,\n",

0 commit comments

Comments
 (0)