Skip to content
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

fix: [misp-core] MySQL HA DB Schema Fix for bruteforces table #9090

Open
wants to merge 1 commit into
base: 2.4
Choose a base branch
from

Conversation

c0dewhacker
Copy link

@c0dewhacker c0dewhacker commented May 22, 2023

What does it do?

If it fixes an existing issue - fixes #7522

A Stack trace occurs when logging into a MISP instance that utilises a MySQL Cluster HA setup. In order to be compliant with group replication Group Replication Requirements the bruteforces table must have a primary key. It is the only table in the schema that does not conform to this requirement.

Can be checked in the current 2.4 branch in the database with the following query -

SELECT tables.table_schema , tables.table_name , tables.engine
FROM information_schema.tables
LEFT JOIN (
   SELECT table_schema , table_name
   FROM information_schema.statistics
   GROUP BY table_schema, table_name, index_name HAVING
     SUM( case when non_unique = 0 and nullable != 'YES' then 1 else 0 end ) = count(*) ) puks
 ON tables.table_schema = puks.table_schema and tables.table_name = puks.table_name
 WHERE puks.table_name is null
   AND tables.table_type = 'BASE TABLE' AND Engine="InnoDB";

Results in

+--------------+-------------+--------+
| TABLE_SCHEMA | TABLE_NAME  | ENGINE |
+--------------+-------------+--------+
| misp         | bruteforces | InnoDB |
+--------------+-------------+--------+

In addition, due to the changes in db_schema.json. I also updated the relevant table structure in Postgresql related files.

Questions

  • Does it require a DB change?
  • Are you using it in production?
  • Does it require a change in the API (PyMISP for example)?

@adulau adulau requested a review from iglocska June 1, 2023 12:45
@c0dewhacker
Copy link
Author

Looks like it's failing in the pymisp repository test. Due to a DB schema version. Db schema 108 != 109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add primary key to brutforces table
1 participant