Skip to content

Commit a5926c5

Browse files
author
Roxane Cohen
committed
fix export
1 parent b10a03e commit a5926c5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

bindiff/file.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ class BasicBlockMatch:
6060
class BindiffFile(object):
6161
def __init__(self, file: Path | str, permission: str = "ro"):
6262
self._file = file
63-
63+
6464
# Open database
6565
self.db = sqlite3.connect(f"file:{file}?mode={permission}", uri=True)
66-
66+
6767
# Global variables
6868
self.similarity = None
6969
self.confidence = None
@@ -281,26 +281,29 @@ def create(filename: str, primary: str, secondary: str, version: str, desc: str,
281281
conn.execute("""INSERT INTO file (filename, exefilename, hash) VALUES (:filename, :name, :hash)""",
282282
{"filename": str(file1), "name": file1.name, "hash": hash1})
283283

284+
284285
# Save secondary
285286
file2 = Path(secondary)
286287
hash2 = hashlib.sha256(file2.read_bytes()).hexdigest() if file2.exists() else ""
287288
conn.execute("""INSERT INTO file (filename, exefilename, hash) VALUES (:filename, :name, :hash)""",
288289
{"filename": str(file2), "name": file2.name, "hash": hash2})
289-
290+
290291
conn.execute(
291292
"""
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)
294295
""",
295296
{
296297
"version": version,
297298
"desc": desc,
298299
"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
299301
"similarity": similarity,
300302
"confidence": confidence
301303
}
302304
)
303-
305+
306+
db.commit()
304307
db.close()
305308
return BindiffFile(filename, permission="rw")
306309

0 commit comments

Comments
 (0)