@@ -60,10 +60,10 @@ class BasicBlockMatch:
60
60
class BindiffFile (object ):
61
61
def __init__ (self , file : Path | str , permission : str = "ro" ):
62
62
self ._file = file
63
-
63
+
64
64
# Open database
65
65
self .db = sqlite3 .connect (f"file:{ file } ?mode={ permission } " , uri = True )
66
-
66
+
67
67
# Global variables
68
68
self .similarity = None
69
69
self .confidence = None
@@ -281,26 +281,29 @@ def create(filename: str, primary: str, secondary: str, version: str, desc: str,
281
281
conn .execute ("""INSERT INTO file (filename, exefilename, hash) VALUES (:filename, :name, :hash)""" ,
282
282
{"filename" : str (file1 ), "name" : file1 .name , "hash" : hash1 })
283
283
284
+
284
285
# Save secondary
285
286
file2 = Path (secondary )
286
287
hash2 = hashlib .sha256 (file2 .read_bytes ()).hexdigest () if file2 .exists () else ""
287
288
conn .execute ("""INSERT INTO file (filename, exefilename, hash) VALUES (:filename, :name, :hash)""" ,
288
289
{"filename" : str (file2 ), "name" : file2 .name , "hash" : hash2 })
289
-
290
+
290
291
conn .execute (
291
292
"""
292
- INSERT INTO metadata (version, file1, file2, description, created, similarity, confidence)
293
- VALUES (:version, 1, 2, :desc, :created, :similarity, :confidence)
293
+ INSERT INTO metadata (version, file1, file2, description, created, modified, similarity, confidence)
294
+ VALUES (:version, 1, 2, :desc, :created, :modified, : similarity, :confidence)
294
295
""" ,
295
296
{
296
297
"version" : version ,
297
298
"desc" : desc ,
298
299
"created" : datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ),
300
+ "modified" :datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ), # modified has to be filled so initialize it to the creation time
299
301
"similarity" : similarity ,
300
302
"confidence" : confidence
301
303
}
302
304
)
303
-
305
+
306
+ db .commit ()
304
307
db .close ()
305
308
return BindiffFile (filename , permission = "rw" )
306
309
0 commit comments