StamusNetworks / SELKS

A Suricata based IDS/IPS/NSM distro
https://www.stamus-networks.com/open-source/#selks
GNU General Public License v3.0
1.45k stars 285 forks source link

Migrate Error #129

Open dsjkee opened 6 years ago

dsjkee commented 6 years ago

Hi guys. After launching /opt/selks/Scripts/Setup/selks-upgrade_stamus.sh for updating Scirius CE v1.2.4., I got some problem with scirius migration:

_262 static files symlinked to '/var/lib/scirius/static'. /usr/share/python/scirius/local/lib/python2.7/site-packages/requests/init.py:80: RequestsDependencyWarning: urllib3 (1.16) or chardet (3.0.4) doesn't match a supported version! RequestsDependencyWarning) Operations to perform: Apply all migrations: accounts, admin, auth, authtoken, contenttypes, rules, sessions, suricata Running migrations: Applying rules.0056_auto_20180223_0823...Traceback (most recent call last): File "bin/manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/core/management/init.py", line 364, in execute_from_command_line utility.execute() File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/core/management/init.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, cmd_options) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, *options) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle fake_initial=fake_initial, File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration state = migration.apply(state, schema_editor) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards self.code(from_state.apps, schema_editor) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/rules/migrations/0056_auto_20180223_0823.py", line 89, in migrate_transformations_data rt.save() File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/models/base.py", line 808, in save force_update=force_update, update_fields=update_fields) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/models/base.py", line 838, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/models/base.py", line 924, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/models/base.py", line 963, in _do_insert using=using, raw=raw) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(args, kwargs) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/models/query.py", line 1076, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1112, in execute_sql cursor.execute(sql, params) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/usr/share/python/scirius/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute return Database.Cursor.execute(self, query, params) django.db.utils.IntegrityError: UNIQUE constraint failed: rules_ruletransformation.ruleset_id, rules_ruletransformation.rule_transformation_id, rules_ruletransformation.key dpkg: error processing package scirius (--configure): subprocess installed post-installation script returned error exit status 1_

What does it means?

biolds commented 5 years ago

Hi,

The error says that you have 2 rule transformations conflicting. Since the version you're upgrading, rule transformations have been rewritten in Scirius, and safety checks have been added at the DB layer to prevent this case. To be more precise, one rule has a transformation in a ruleset to drop/reject/filestore, and this same rule has an other transformation in the same ruleset to reject.

The only way to fix it is to remove one of the conflicting rule in the sqlite database.