StamusNetworks / scirius

Scirius is a web application for Suricata ruleset management and threat hunting.
GNU General Public License v3.0
634 stars 150 forks source link

v1.1 - stable error when adding new source (os x) #43

Closed drew1kun closed 9 years ago

drew1kun commented 9 years ago

When adding new source and pressing "Submit" - getting this: untitled but when pressing "go back" browser button it says that this rule already exists (so it actually creates the rule and after that gives an error...

regit commented 9 years ago

Hi,

It is supposed to be fixed by https://github.com/StamusNetworks/scirius/commit/f8c5b8486e0ba6521b3bb6584293fb7838627ff7. From line number it seems you are not using the latest version. Can you check this please ?

drew1kun commented 9 years ago

sorry could you tell me how can I check? I'm new to git...

drew1kun commented 9 years ago

'About' tab says v1.1

regit commented 9 years ago

If you have run a 'git clone' to create the directory of sicirius, the run 'git pull' to update the source

drew1kun commented 9 years ago

Well after doing:

$ cd /usr/local/var/www/scirius
$ git pull

instead of "login page" I'm getting this: 1 I've tried it two times and seems like your last commits broke everything... lol Now I can't even use it))

regit commented 9 years ago

It did not break anything, you just need to migrate the db via django utilities :)

It will be direct with older django. On newer, a few commands may be needed.

drew1kun commented 9 years ago

but it didn't say to run "migrate"…

$ /usr/local/bin/python /usr/local/var/www/scirius/manage.py runserver
/usr/local/lib/python2.7/site-packages/django_tables2/tables.py:175: RemovedInDjango19Warning: SortedDict is deprecated and will be removed in Django 1.9.
  attrs["base_columns"] = SortedDict(parent_columns)

/usr/local/lib/python2.7/site-packages/django_tables2/tables.py:197: RemovedInDjango19Warning: SortedDict is deprecated and will be removed in Django 1.9.
  attrs["base_columns"].update(SortedDict(cols))

/usr/local/lib/python2.7/site-packages/django_tables2/tables.py:175: RemovedInDjango19Warning: SortedDict is deprecated and will be removed in Django 1.9.
  attrs["base_columns"] = SortedDict(parent_columns)

/usr/local/lib/python2.7/site-packages/django_tables2/tables.py:197: RemovedInDjango19Warning: SortedDict is deprecated and will be removed in Django 1.9.
  attrs["base_columns"].update(SortedDict(cols))

Performing system checks...

System check identified no issues (0 silenced).
August 05, 2015 - 17:35:58
Django version 1.8, using settings 'scirius.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
regit commented 9 years ago

Yes, git pull and now it should say it ;)

drew1kun commented 9 years ago

I ran migrate:

$ python manage.py migrate

and then restarted the server - got the same error in browser and this in the shell:

Quit the server with CONTROL-C.
[05/Aug/2015 17:40:40]"GET / HTTP/1.1" 302 0
/usr/local/lib/python2.7/site-packages/django_tables2/tables.py:178: RemovedInDjango19Warning: SortedDict is deprecated and will be removed in Django 1.9.
  extra = SortedDict()

[05/Aug/2015 17:40:40]"GET /accounts/login/ HTTP/1.1" 500 176421
regit commented 9 years ago

For info, till now only south based migration were commited. I've now added the migration for django > 1.7.

regit commented 9 years ago

During migrate you should see something like:

eric@ice-age2:~/git/stamus/scirius (master)$ python manage.py migrate
Operations to perform:
  Synchronize unmigrated apps: suricata, accounts, django_tables2, bootstrap3
  Apply all migrations: admin, rules, contenttypes, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying rules.0039_auto_20150805_1737... OK
drew1kun commented 9 years ago

so what should I do now?

$ git pull && python manage.py migrate

?

regit commented 9 years ago

yes, update the code, then run migration

drew1kun commented 9 years ago

done it and still got:

You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.

August 05, 2015 - 17:48:46
Django version 1.8, using settings 'scirius.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

done it two times

drew1kun commented 9 years ago

migration output:

$ python manage.py migrate
/usr/local/lib/python2.7/site-packages/django_tables2/tables.py:175: RemovedInDjango19Warning: SortedDict is deprecated and will be removed in Django 1.9.
  attrs["base_columns"] = SortedDict(parent_columns)

/usr/local/lib/python2.7/site-packages/django_tables2/tables.py:197: RemovedInDjango19Warning: SortedDict is deprecated and will be removed in Django 1.9.
  attrs["base_columns"].update(SortedDict(cols))

Operations to perform:
  Synchronize unmigrated apps: staticfiles, suricata, messages, accounts, django_tables2, revproxy, bootstrap3
  Apply all migrations: admin, rules, contenttypes, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying rules.0001_initial...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 221, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 110, in migrate
    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 147, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 115, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 59, in database_forwards
    schema_editor.create_model(model)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 282, in create_model
    self.execute(sql, params or None)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 107, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 316, in execute
    return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: table "rules_category" already exists
regit commented 9 years ago

OK, looks like starting from scratch (remove db file) would be the easier method as migration were not included for django > 1.6 :/

drew1kun commented 9 years ago

could you please be more precise what should I do step by step

regit commented 9 years ago

This procedure will loose your data:

rm db.sqlite3
python manage.py syncdb
python manage.py migrate
drew1kun commented 9 years ago

Ok. Seems like everything works now, so this should be closed but there are some troubles with VRT and Community rules and not only them... I'll explain here https://github.com/StamusNetworks/scirius/issues/38