StamusNetworks / SELKS

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

Update of source is not working🐞🐋 <title> #469

Open nvmike opened 5 months ago

nvmike commented 5 months ago

Is there an existing issue for this?

Current Behavior

When trying to update sources - error coming: bulk_create() prohibited to prevent data loss due to unsaved related object 'flowbit'.

Environment:

Request Method: POST Request URL: https://192.168.251.128/suricata/update

Django Version: 3.2.25 Python Version: 3.9.19 Installed Applications: ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_tables2', 'bootstrap3', 'dbbackup', 'viz', 'rules', 'scirius', 'suricata', 'accounts', 'rest_framework', 'rest_framework.authtoken', 'django_filters', 'webpack_loader', 'revproxy') Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'scirius.loginrequired.LoginRequiredMiddleware', 'scirius.utils.TimezoneMiddleware', 'csp.middleware.CSPMiddleware', 'scirius.utils.CustomCSPMiddleware', 'django_cprofile_middleware.middleware.ProfilerMiddleware']

Traceback (most recent call last): File "/root/.local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/root/.local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) File "/root/.local/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view return view_func(request, *args, *kwargs) File "/opt/scirius/suricata/views.py", line 164, in update suri.ruleset.update() File "/opt/scirius/rules/models.py", line 3389, in update source.update() File "/usr/local/lib/python3.9/contextlib.py", line 79, in inner return func(args, kwds) File "/opt/scirius/rules/models.py", line 1316, in update self._handle_file(f) File "/opt/scirius/rules/models.py", line 1414, in _handle_file self.handle_rules_in_tar(_file) File "/opt/scirius/rules/models.py", line 1171, in handle_rules_in_tar self.get_categories() File "/opt/scirius/rules/models.py", line 1080, in get_categories category.get_rules( File "/opt/scirius/rules/models.py", line 2357, in get_rules Flowbit.set.through.objects.bulk_create(flowbits["added"]["through_set"]) File "/root/.local/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/root/.local/lib/python3.9/site-packages/django/db/models/query.py", line 498, in bulk_create self._prepare_for_bulk_create(objs) File "/root/.local/lib/python3.9/site-packages/django/db/models/query.py", line 461, in _prepare_for_bulk_create obj._prepare_related_fields_for_save(operation_name='bulk_create') File "/root/.local/lib/python3.9/site-packages/django/db/models/base.py", line 945, in _prepare_related_fields_for_save raise ValueError(

Exception Type: ValueError at /suricata/update Exception Value: bulk_create() prohibited to prevent data loss due to unsaved related object 'flowbit'.

Expected Behavior

No response

Steps To Reproduce

No response

Docker version

Docker version 26.1.4, build 5650f9b

Docker version

Docker Compose version v2.16.0

OS Version

Ubuntu 24.04 LTS

Content of the environnement File

COMPOSE_PROJECT_NAME=selks INTERFACES= -i ens192 SCIRIUS_DEBUG=True NGINX_EXEC=nginx-debug SCIRIUS_SECRET_KEY=Dq9UjepRagjejLWePNUNpi6b6MjDNKY9vKcNr6iVGeo PWD=${PWD}

Version of SELKS

commit 2fc53910bead2d6057f20d82b62826ba48234097 (HEAD -> master, origin/master, origin/HEAD) Merge: a030b9a 16fc908 Author: Eric Leblond eleblond@stamus-networks.com Date: Mon Sep 11 08:35:37 2023 +0000

Merge branch 'Arkime-fix-v1' into 'master'

Add oui file for Arkime

See merge request devel/SELKS!5

Anything else?

ValueError at /suricata/update

bulk_create() prohibited to prevent data loss due to unsaved related object 'flowbit'.
Request Method: | POST -- | -- https://192.168.251.128/suricata/update 3.2.25 ValueError bulk_create() prohibited to prevent data loss due to unsaved related object 'flowbit'. /root/.local/lib/python3.9/site-packages/django/db/models/base.py, line 945, in _prepare_related_fields_for_save /usr/local/bin/python 3.9.19 ['/opt/scirius', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/root/.local/lib/python3.9/site-packages', '/usr/local/lib/python3.9/site-packages']
inguy24 commented 4 months ago

Same error on fresh install of 22.04 LTS and SELKS via docker.

nvmike commented 4 months ago

Hi Yesterday I decide to start from scratch: I did remove all my containers and images - Git pull - and reinstall. Then it did work.

inguy24 commented 4 months ago

Hmmm i just did this on a fresh install too. I will try it again... Did you change any configuration when you tried reinstalling?

pevma commented 4 months ago

It seems you are running the previous version of SELKS? You should be on https://github.com/StamusNetworks/SELKS/commits/master/ (aka SELKS 10 currently), form the original issue opening it seems the commits you are on now are (older SELKS) :

Merge branch 'Arkime-fix-v1' into 'master'
Add oui file for Arkime
See merge request devel/SELKS!5