StamusNetworks / scirius

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

Compilation from source gives strange layout #177

Open KoffieNu opened 5 years ago

KoffieNu commented 5 years ago

Hi, I'me attempting to get scirius running on CentOS 7.5 and although I managed to get something up and running, the user interface is not working as expected. I'm not experienced in application development (especially node.js application), so I don't exclude me messing up somewhere, but I find it strange that the hunt interface is wirking as expected, but the main page and administration isn't. The system where it's supposed to land is an isolated, unconnected, system, so I expected the method of getting it there could be the cause. Just tested it on a connected, Debian, system, and I get the same results. Systems:

Method of deployment:

  1. get code from github
  2. follow manual https://scirius.readthedocs.io/en/latest/installation-ce.html#installing-scirius-ce
  3. do pip download on gatherer, move python install on target system from webbased directory --no-index, find-links,...
  4. npm install modules as described
  5. Get missing dependencies with in both main and hunt dir: npm list --depth=9999 2>&1 | awk '/^npm ERR! missing:/ { print $4 }' | awk -F'@' '{ print $1 }' | sort -u | xargs npm install
  6. npm run build in hunt dir
  7. tar complete scirius dir, move to target, unpack
  8. configure as described in manual

Expected result:

Result found:

I get the same result on both systems, the Debian and the CentOS system. Screenshots are taken from Debian with the 3.2.0 version. (current state of the master tree last pull today about 13:00 UTC)

Browser used:

Versions tested:

All environments and versions give the same issue, so I'm concluding that it's either the code or me messing up on the deployment. (kinda expecting the latter, pevma on irc channel SELKS asked me to post an issue) When it's me, I'm overlooking something in the manual (did the webpack) or a step is missing which is logical for node.js developers.

pevma commented 5 years ago

Does anything happen if you clear the full browser cache on Chrome/FF ? for IE I know it could be tricky.

KoffieNu commented 5 years ago

Nop, nothing, not even clearing all user settings. Looks like the index page gets another header then the hunt page.

jorgenbele commented 5 years ago

Are you sure you have setup STATIC_ROOT correctly? I had the same problem but fixed it by adding the following to local_settings.py (in the root directory of the project). Replace 'static' with the directory the static files are stored if you don't store them in the directory 'static'.

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
KoffieNu commented 5 years ago

The difference between the scirius and hunt environment I can think of is that the hunt page needs an additional run of the build script after npm installs the modules. It looks like that build.js run ties all the code and loose npm modules into 1 nice package. I'm trying to compare the layout with the debian iso and there the 3.1.0 version looks like I expect it to. On the Debian iso it's running in gunicorn.

KoffieNu commented 5 years ago

@jorgenbele Thanks for the tip, the index page looks a bit better. BTW should the local_settings.py be in / (relative of the scirius project) or the scirius subdir? (same level as hunt) BTW administration intrerface is still missing all it's layout... at least I have a kind of a clue in which direction to look.

jorgenbele commented 5 years ago

@KoffieNu Np. It should be in / (root of the scirius project).

Potrik98 commented 5 years ago

The value of STATIC_ROOT can be any valid directory on your system to which you have write access. After setting the value to something reasonable like basedir /static as @jorgenbele suggested, you must run

python manage.py collectstatic

This will copy all static files to the right directory on the format that it expects Make sure you have already build the static files with

~$ webpack

and

~$ cd hunt
~/hunt$ npm run build
pevma commented 5 years ago

It seems we need a doc update in the case - correct ?

-- Regards, Peter Manev

On 2 Jul 2019, at 10:19, Potrik98 notifications@github.com wrote:

The value of STATIC_ROOT can be any valid directory on your system to which you have write access. After setting the value to something reasonable like basedir /static as @jorgenbele suggested, you must run

python manage.py collectstatic This will copy all static files to the right directory on the format that it expects Make sure you have already build the static files with

~$ webpack and

~$ cd hunt ~/hunt$ npm run build — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Potrik98 commented 5 years ago

That would probably be wise.

149 adds a default value to STATIC_ROOT, but

python manage.py collectstatic

would have to be run regardless.

It seems we need a doc update in the case - correct ? -- Regards, Peter Manev On 2 Jul 2019, at 10:19, Potrik98 @.***> wrote: The value of STATIC_ROOT can be any valid directory on your system to which you have write access. After setting the value to something reasonable like basedir /static as @jorgenbele suggested, you must run python manage.py collectstatic This will copy all static files to the right directory on the format that it expects Make sure you have already build the static files with ~$ webpack and ~$ cd hunt ~/hunt$ npm run build — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Potrik98 commented 5 years ago

See #179

KoffieNu commented 5 years ago

I just noticed I get errors in npm install due to missing bdist_wheel command. package python-wheel is a dependency. It's probably a package recommended by either python-dev or python-pip. However, when someone has the lines below in apt.conf, they won't get installed on a debian system.

APT::Install-Recommends "0";
APT::Install-Suggests "0";

CentOS doesn't have the dependency.

pevma commented 5 years ago

Do you mind doing a pull request to adjust the install instructions to the scirius-3.1.0 tag ?

Potrik98 commented 5 years ago

Do you mind doing a pull request to adjust the install instructions to the scirius-3.1.0 tag ?

I don't quite understand. Could you explain how this is different from what I did in #179 ?

pevma commented 5 years ago

No - that's what i had in mind.Thanks!

KoffieNu commented 5 years ago

I added the local_config.py (changed the BASE_DIR to os.path.dirname(file)so static ends up in the project dir, not outside it), the index page looks a tad better, but still the top bar doesn't respond and rules subdir is missing it's style sheet (css). The Hunt section had it's own build, rules doesn't. Should rules build be triggered from something in the root dir? (or by a tool that I'm missing?) Could it be that the layout is a problem when one of the backend components isn't configured correctly?

The result I get: https://jan.huijsmans.nu/tmp/scirius/Scirius_3.2.0_on_CentOS.png The result I hope to get (layout wise to start): https://jan.huijsmans.nu/tmp/scirius/Scirius_3.1.0_on_Selks_Debian.png

KoffieNu commented 5 years ago

I finally managed to build a working scirius. The main requirement is Debian Stretch. Didn't manage to get something looking as expected with Debian Buster or CentOS 7.

After build, you can tar the tree on Debian and untar on CentOS (and do the pip install) and it'll look as expected and I hope it'll work as well. Needs to be tested.

pevma commented 5 years ago

Thank you for your feedback ! What problems / errs did you encounter in Buster ?

-- Regards, Peter Manev

On 19 Jul 2019, at 15:23, Jan Huijsmans notifications@github.com wrote:

I finally managed to build a working scirius. The main requirement is Debian Stretch. Didn't manage to get something looking as expected with Debian Buster or CentOS 7.

After build, you can tar the tree on Debian and untar on CentOS (and do the pip install) and it'll look as expected and I hope it'll work as well. Needs to be tested.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

KoffieNu commented 4 years ago

Sorry for the late response. I was getting the same issues with buster as with compilation on CentOS, layout 'strange' due to some dependencies missing or getting nodejs modules that weren't compatible with the code.

Looks like the build of scirius (long ago) relied on Stretch and defaults of the npm/pip packages. I have to admit we abandoned the route to have scirius 'compiled' on Debian and then used on CentOS and switched to evaluating the EE version to see if that would help.