-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add primary key to brutforces table #7522
Comments
@artemis061 Also came across this issue using a MySQL HA cluster and mysql-router. You can also alter the database once MISP has initialised by issuing -
I'll create a pull request that updates - I don't see any other usages for when the bruteforces table is created except in the Postgresql table creation. I'm not sure if Postgresql would encounter the same issue, however, for consistency sake i should probably update INSTALL/POSTGRESQL-structure.sql and INSTALL/POSTGRESQL-data-initial.sql Your update looks correct. INSTALL/MYSQL.sql would be - CREATE TABLE IF NOT EXISTS `bruteforces` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ip` varchar(255) COLLATE utf8_bin NOT NULL,
`username` varchar(255) COLLATE utf8_bin NOT NULL,
`expire` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; also I think db_schema.json would need to be "bruteforces": [
{
"column_name": "id",
"is_nullable": "NO",
"data_type": "int",
"character_maximum_length": null,
"numeric_precision": "10",
"collation_name": null,
"column_type": "int(10) unsigned",
"column_default": null,
"extra": "auto_increment"
},
{
"column_name": "ip",
"is_nullable": "NO",
"data_type": "varchar",
"character_maximum_length": "255",
"numeric_precision": null,
"collation_name": "utf8mb3_bin",
"column_type": "varchar(255)",
"column_default": null,
"extra": ""
},
{
"column_name": "username",
"is_nullable": "NO",
"data_type": "varchar",
"character_maximum_length": "255",
"numeric_precision": null,
"collation_name": "utf8mb3_bin",
"column_type": "varchar(255)",
"column_default": null,
"extra": ""
},
{
"column_name": "expire",
"is_nullable": "NO",
"data_type": "datetime",
"character_maximum_length": null,
"numeric_precision": null,
"collation_name": null,
"column_type": "datetime",
"column_default": null,
"extra": ""
}
] In the Postgresql table creation INSTALL/POSTGRESQL-data-initial.sql would probably need to be - COPY public.bruteforces (id, ip, username, expire) FROM stdin; and INSTALL/POSTGRESQL-structure.sql CREATE TABLE public.bruteforces (
id serial PRIMARY KEY,
ip character varying(255) NOT NULL,
username character varying(255) NOT NULL,
expire timestamp with time zone NOT NULL
); Let me know if this looks correct and i'll submit a pull request. |
@c0dewhacker I concur with the changes for mysql, I am not much of a postgres developer and am not currently in a position to reattempt with your proposed changes. I'm good with it if you are! Thanks! |
Is your feature request related to a problem? Please describe.
I am currently working on creating a highly available MISP deployment with a distributed mysql database cluster. I was unable to login to the web ui after installing MISP due to the bruteforces table in the database not having a primary key.
Describe the solution you'd like
I would like an "official" primary key included in the MISP repository so that when I rebuild my docker images, they do not need additional SQL modifications.
Describe alternatives you've considered
Current code in MYSQL.sql:
My changes to get the mysql clustering working:
Additional context
My setup currently includes:
haproxy docker container load-balancing for 2 MISP servers running in docker (images custom built)
standalone redis server that both MISP servers communicate with (each MISP server is assigned a different database on the redis server)
1 mysql router directing traffic into the mysql cluster
3 mysql servers with HA clustering using innodb storage engine
The 2 MISP servers are configured to connect to the mysql cluster via the mysql router
The text was updated successfully, but these errors were encountered: