Skip to content

Commit

Permalink
Fixed environment settings (#67)
Browse files Browse the repository at this point in the history
* Fixed elasticsearch env variable

* Fixed shared task name
  • Loading branch information
Lorygold authored Sep 25, 2023
1 parent c8390ff commit d5ef625
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Or download the application directly from the [Docker Hub](https://hub.docker.co

After that, there are two ways of running BuffaLogs, depending on your system configurations:
* if you already have an elastic cluster:
* set the address of the host into the `CERTEGO_BUFFALOGS_ELASTICSEARCH` variable in the `buffalogs.env` file
* set the address of the host into the `CERTEGO_ELASTICSEARCH` variable in the `buffalogs.env` file
* launch ` docker-compose up -d` to run the containers
* if you have no hosts with Elasticsearch installed on it, you can run it directly with Buffalogs:
* run `docker-compose -f docker-compose.yaml -f docker-compose.elastic.yaml up -d` in order to execute all the containers, included Elasticsearch and Kibana
Expand Down
4 changes: 2 additions & 2 deletions buffalogs/buffalogs/settings/certego.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

if CERTEGO_BUFFALOGS_ENVIRONMENT == ENVIRONMENT_DOCKER:

CERTEGO_BUFFALOGS_ELASTICSEARCH = os.environ.get("CERTEGO_BUFFALOGS_ELASTICSEARCH", "http://elasticsearch:9200/")
CERTEGO_ELASTICSEARCH = os.environ.get("CERTEGO_ELASTICSEARCH", "http://elasticsearch:9200/")
CERTEGO_BUFFALOGS_DB_HOSTNAME = "postgres"
CERTEGO_DEBUG = False
CERTEGO_BUFFALOGS_STATIC_ROOT = "/var/www/static/"
Expand All @@ -27,7 +27,7 @@
CERTEGO_BUFFALOGS_RABBITMQ_URI = f"amqp://guest:guest@{CERTEGO_BUFFALOGS_RABBITMQ_HOST}/"

elif CERTEGO_BUFFALOGS_ENVIRONMENT == ENVIRONMENT_DEBUG:
CERTEGO_BUFFALOGS_ELASTICSEARCH = os.environ.get("CERTEGO_BUFFALOGS_ELASTICSEARCH", "http://localhost:9200/")
CERTEGO_ELASTICSEARCH = os.environ.get("CERTEGO_ELASTICSEARCH", "http://localhost:9200/")
CERTEGO_BUFFALOGS_DB_HOSTNAME = "localhost"
CERTEGO_DEBUG = True
CERTEGO_BUFFALOGS_STATIC_ROOT = "impossible_travel/static/"
Expand Down
4 changes: 2 additions & 2 deletions buffalogs/impossible_travel/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def clear_models_periodically():
UsersIP.objects.filter(updated__lte=delete_ip_time).delete()


@shared_task(name="UpdateRiskLevelTask")
@shared_task(name="BuffaLogsUpdateRiskLevelTask")
def update_risk_level():
"""Update users risk level depending on how many alerts were triggered"""
clear_models_periodically()
Expand Down Expand Up @@ -218,7 +218,7 @@ def exec_process_logs(start_date, end_date):
"""
logger.info(f"Starting at:{start_date} Finishing at:{end_date}")
config, op_result = Config.objects.get_or_create()
connections.create_connection(hosts=settings.CERTEGO_BUFFALOGS_ELASTICSEARCH, timeout=90, verify_certs=False)
connections.create_connection(hosts=settings.CERTEGO_ELASTICSEARCH, timeout=90, verify_certs=False)
s = (
Search(index=settings.CERTEGO_BUFFALOGS_ELASTIC_INDEX)
.filter("range", **{"@timestamp": {"gte": start_date, "lt": end_date}})
Expand Down
2 changes: 1 addition & 1 deletion buffalogs/impossible_travel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def get_users(request):
def get_all_logins(request, pk_user):
context = []
count = 0
connections.create_connection(hosts=[settings.CERTEGO_BUFFALOGS_ELASTICSEARCH], timeout=90)
connections.create_connection(hosts=[settings.CERTEGO_ELASTICSEARCH], timeout=90)
end_date = timezone.now()
start_date = end_date + timedelta(days=-365)
user_obj = User.objects.filter(id=pk_user)
Expand Down
2 changes: 1 addition & 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.1.1
Version: 1.2.0
Summary: A Django app to detect anomaly logins.
Home-page: UNKNOWN
Author: Lorena Goldoni
Expand Down

0 comments on commit d5ef625

Please sign in to comment.