Skip to content

Commit

Permalink
1.2.2 (#71)
Browse files Browse the repository at this point in the history
* Setup config (#70)

* Updated setup_config mgmt command

* Updated CHANGELOG.md

* Added cover

* Update README.md

* Managed values as a list

* Refactoring

* Removed comments

* buffalogs_1_2_2
  • Loading branch information
Lorygold authored Sep 28, 2023
1 parent 879c995 commit 5d66f65
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 72 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 1.2.x
### 1.2.2
#### Bugfix
* Updated setup_config management command in order to overwrite the configs
### 1.2.1
#### Bugfix
* Fixed Elasticsearch environment variable
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# BuffaLogs

<img src="docs/static/cover_buffalogs.png" width=750 height=400 alt="BuffaLogs"/>

BuffaLogs is an Open Source Django Project whose main purpose is to detect impossible travel logins.

In detail, it sends several types of alerts:
Expand Down Expand Up @@ -153,3 +155,6 @@ BuffaLogs is an Open Source project and was developed in order to allow enrichme

## Licence
This project is protected by the Apache Licence 2.0.


[def]: docs/
53 changes: 26 additions & 27 deletions buffalogs/impossible_travel/management/commands/setup_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,41 @@

logger = logging.getLogger()
IGNORED_USERS = ["N/A", "Not Available"]
IGNORED_IPS = [""]
IGNORED_IPS = ["127.0.0.1"]


class Command(BaseCommand):
help = "Command to setup configs in the Config model"
help = "Setup the Configs overwriting them"

def add_arguments(self, parser):
# Optional arguments
parser.add_argument("--ignored_users", nargs="?", action="append", default=[], help="List of users to filter and to not consider in the detection")
parser.add_argument("--ignored_ips", nargs="?", action="append", default=[], help="List of ips or subnets to not consider in the detection")
parser.add_argument("--allowed_countries", nargs="?", action="append", default=[], help="List of countries from which the logins are always allowed")
parser.add_argument("--vip_users", nargs="?", action="append", default=[], help="List of users to which pay particular attention")
parser.add_argument("--ignored_users", nargs="?", default=[], help="List of users to filter and to not consider in the detection")
parser.add_argument("--ignored_ips", nargs="?", default=[], help="List of ips or subnets to not consider in the detection")
parser.add_argument("--allowed_countries", nargs="?", default=[], help="List of countries from which the logins are always allowed")
parser.add_argument("--vip_users", nargs="?", default=[], help="List of users to which pay particular attention")

def handle(self, *args, **options):
"""Setup the configurations into the Config model"""
logger = logging.getLogger()
print(options)

if Config.objects.all().exists():
config_obj = Config.objects.all()[0]
else:
config_obj = Config.objects.create()
if not options["ignored_users"] and not options["ignored_ips"] and not options["allowed_countries"] and not options["vip_users"]:
# Setup default configs
Config.objects.update_or_create(ignored_users=IGNORED_USERS, ignored_ips=IGNORED_IPS)
# Set default values
config_obj.ignored_users = IGNORED_USERS
config_obj.ignored_ips = IGNORED_IPS
else:
if not Config.objects.exists():
Config.objects.create(
ignored_users=options["ignored_users"],
ignored_ips=options["ignored_ips"],
allowed_countries=options["allowed_countries"],
vip_users=["vip_users"],
)
self.stdout.write(
self.style.SUCCESS(
f"Configs set correctly:\
\nIgnored users: {options['ignored_users']}\
\nIgnored ips: {options['ignored_ips']}\
\nAllowed countries: {options['allowed_countries']}\
\nVip users: {options['vip_users']}"
)
)
else:
self.stdout.write(self.style.ERROR("Error: Configs already exist. Use the update_config or the clear_models commands"))
for opt in options:
if opt in ["ignored_users", "ignored_ips", "allowed_countries", "vip_users"]:
if not options[opt]:
setattr(config_obj, opt, [])
else:
setattr(config_obj, opt, options[opt].split(","))

config_obj.save()

logger.info(
f"Updated Config values - Ignored users: {config_obj.ignored_users}, Ignored IPs: {config_obj.ignored_ips}, Allowed countries: {config_obj.allowed_countries}, Vip users: {config_obj.vip_users}"
)
39 changes: 0 additions & 39 deletions buffalogs/impossible_travel/management/commands/update_config.py

This file was deleted.

1 change: 0 additions & 1 deletion buffalogs/impossible_travel/static/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ li a:link{
}
.sidebar-header::before{
content:"";
background-image: url("../images/header_backg.jpg");
opacity: 0.8;
position: absolute;
background-size: 100% 100%;
Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion django-buffalogs/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include LICENSE
include README.rst
recursive-include docs/static *
recursive-include impossible_travel/management *
recursive-include impossible_travel/modules *
recursive-exclude impossible_travel/dashboard *
recursive-exclude impossible_travel/tests *
recursive-exclude impossible_travel/tests *
2 changes: 2 additions & 0 deletions django-buffalogs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
BuffaLogs
=========

.. image:: docs/static/cover_buffalogs.png

BuffaLogs is a Django app whose main purpose is to detect anomaly logins.

Detaild documentation is in the ``docs/`` directory.
Expand Down
4 changes: 3 additions & 1 deletion django-buffalogs/buffalogs.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: buffalogs
Version: 1.2.1
Version: 1.2.2
Summary: A Django app to detect anomaly logins.
Home-page: UNKNOWN
Author: Lorena Goldoni
Expand All @@ -18,6 +18,8 @@ License-File: LICENSE.txt
BuffaLogs
=========

.. image:: docs/static/cover_buffalogs.png

BuffaLogs is a Django app whose main purpose is to detect anomaly logins.

Detaild documentation is in the ``docs/`` directory.
Expand Down
4 changes: 3 additions & 1 deletion django-buffalogs/buffalogs.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ README.rst
pyproject.toml
setup.cfg
setup.py
../docs/static/cover_buffalogs.png
buffalogs.egg-info/PKG-INFO
buffalogs.egg-info/SOURCES.txt
buffalogs.egg-info/dependency_links.txt
buffalogs.egg-info/requires.txt
buffalogs.egg-info/top_level.txt
docs/static/cover_buffalogs.png
impossible_travel/__init__.py
impossible_travel/admin.py
impossible_travel/apps.py
Expand All @@ -18,7 +20,7 @@ impossible_travel/views.py
impossible_travel/management/commands/clear_models.py
impossible_travel/management/commands/impossible_travel.py
impossible_travel/management/commands/setup_config.py
impossible_travel/management/commands/update_config.py
impossible_travel/management/commands/__pycache__/setup_config.cpython-310.pyc
impossible_travel/migrations/0001_initial.py
impossible_travel/migrations/0002_alert_updated.py
impossible_travel/migrations/0003_alter_alert_updated.py
Expand Down
Binary file added django-buffalogs/docs/static/cover_buffalogs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion django-buffalogs/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = buffalogs
version = 1.2.1
version = 1.2.2
description = A Django app to detect anomaly logins.
long_description = file: README.rst
author = Lorena Goldoni
Expand Down
Binary file added docs/static/cover_buffalogs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5d66f65

Please sign in to comment.