cuckoosandbox / cuckoo

Cuckoo Sandbox is an automated dynamic malware analysis system
http://www.cuckoosandbox.org
Other
5.47k stars 1.7k forks source link

sqlalchemy database engine issue with mariadb #1522

Open geudrik opened 7 years ago

geudrik commented 7 years ago

Cuckoo==2.0.2

(Pdb) b cuckoo/core/database.py:453
-> raise CuckooDatabaseError(
(Pdb) self.engine
Engine(mysql://cuckoo:***@127.0.0.1:3306/cuckoo)
(Pdb) Base.metadata.create_all(self.engine)
*** OperationalError: (_mysql_exceptions.OperationalError) (1071, 'Specified key was too long; max key length is 767 bytes') [SQL: u'\nCREATE TABLE tags (\n\tid INTEGER NOT NULL AUTO_INCREMENT, \n\tname VARCHAR(255) NOT NULL, \n\tPRIMARY KEY (id), \n\tUNIQUE (name)\n)\n\n']
(Pdb) 

Fresh install, maria DB on Ubuntu 16.04. Happens when I try to start cuckoo or run clean

jbremer commented 7 years ago

What about regular MySQL?

geudrik commented 7 years ago

That did indeed fix the issue... which is weird. But 👍

jbremer commented 7 years ago

That's weird indeed, provided it's supposed to be a drop-in replacement. The exception doesn't make a lot of sense :-) I can see if we can do MariaDB database unit tests in the future though, along with a fix for whatever is the actual issue here of course.

geudrik commented 7 years ago

Agreed... so much for "drop in" if it's an engine issue. Let me know if you need me to test!

jbremer commented 7 years ago

Will keep the issue open for the moment as a reminder :-)

rholloway commented 7 years ago

This looks like it's more specific to MariaDB on Debian. On Debian installs it defaults to utf8mb4 character sets rather than latin1 (mysql and mariadb on other distros), which leads to key size issue on name.

https://mariadb.com/kb/en/mariadb/differences-in-mariadb-in-debian-and-ubuntu/

Cuckoo should probably just specify the character sets when creating the database and tables rather than rely on system defaults if expected to be latin1.

geudrik commented 7 years ago

Nice job hunting down the cause - I hadn't investigated after switching over to MySQL

HashBR commented 6 years ago

@rholloway this command fixed the problem that you figured out. ALTER DATABASE <database_name> CHARACTER SET = 'utf8' COLLATE ='utf8_bin'; `