-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cleaned venv from useless packages (#103) * Cleaned venv from useless packages * Added pytz required in celery_beat * fix * Updated CHANGELOG.md * Registered UserAdmin for authentication app in admin.py * Configuration panel (#104) * [refactor] Added enums in new costants.py file for "choices" fields in the models * [refactor] Added default config values in the django settings (certego.py file) * Added default configs in settings * Updated CHANGELOG.md * [test-view] Ignore alerts order for views return API * Fixed linters paths * Changed "null=True" to "blank=True" for Charfields * changes for flake8 linter * Revoed E231 flake8 rule for certego.py file * removed comment * Updated CHANGELOG.md * [CI] Updated to compose v2 * fix * Alerts fields utilities (#105) * Added method to get the alert name label, for tagging * Added ipython for develop * Added new fields in login_raw_data for more info about previous login * Updated CHANGELOG.md * Version 1.3.0 * Force one config object (#107) * Forced only 1 Config object presence * Set always Config.id=1 * Updated CHANGELOG.md * Fix alert name representation (#108) * Fixed alert.name representation enums * Cleaned enum * Set short_name to choose * Added forms for multiple choices array * fix * Added style in order to show the choices selected in django-admin multiple choices field Config.filtered_alerts_types * Added forms to handle multiple choice fields * Added constraints for multiple choices fields check * Fixed risk_score admin display * Added user.risk_Score choice constraint * Added timestamp representations for seconds * Fixed enums * Added test migration in order to convert data in Alert with the new Alert.name "shorter version" * Fix * Included again E231 flake8 rule, but removed in some code lines with: # noqa: E231 * Fixes * Added config.ignored_ISPs list field * Fixed Rabbit url * Added null=True for Config list fields * Completed test * Updated CHANGELOG.md * Version 1.3.1 * Updated some Python dapendencies (#110) * Updated some Python dapendencies * fix * Version 1.3.1 fixed
- Loading branch information
Showing
24 changed files
with
619 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,3 @@ ignore = | |
exclude = | ||
*/migrations/*, | ||
Dockerfile | ||
|
||
per-file-ignores = | ||
# imported but unused | ||
certego.py: E231 |
15 changes: 7 additions & 8 deletions
15
.github/configurations/python_linters/requirements-linters.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
black==22.3.0 | ||
isort==5.12.0 | ||
flake8==5.0.4 | ||
flake8-django==1.1.5 | ||
pylint==2.14.3 | ||
pylint-django==2.5.3 | ||
bandit==1.7.4 | ||
autoflake==1.7.7 | ||
autoflake==2.3.1 | ||
bandit==1.7.9 | ||
black==24.8.0 | ||
flake8==7.1.1 | ||
isort==5.13.2 | ||
pylint==3.2.6 | ||
pylint-django==2.5.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from django import forms | ||
from django.contrib.postgres.forms import SimpleArrayField | ||
|
||
from .constants import AlertDetectionType, AlertFilterType, UserRiskScoreType | ||
from .models import Alert, Config, TaskSettings, User, UsersIP | ||
|
||
|
||
class MultiChoiceArrayWidget(forms.SelectMultiple): | ||
"""Widget for user-friendly interface for ArrayField with multiple choices""" | ||
|
||
def __init__(self, choices, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.choices = choices | ||
|
||
def render(self, name, value, attrs=None, renderer=None): | ||
if value is None: | ||
value = [] | ||
elif not isinstance(value, list): | ||
value = [value] | ||
return super().render(name, value, attrs, renderer) | ||
|
||
|
||
class MultiChoiceArrayField(SimpleArrayField): | ||
"""Personalized field for ArrayField that supports multiple choices""" | ||
|
||
def __init__(self, base_field, choices, *args, **kwargs): | ||
self.widget = MultiChoiceArrayWidget(choices=choices) | ||
super().__init__(base_field, *args, **kwargs) | ||
|
||
def prepare_value(self, value): | ||
if value is None: | ||
return [] | ||
return value | ||
|
||
|
||
class ShortLabelChoiceField(forms.ChoiceField): | ||
"""ChoiceField personalized in order to show the short_value as label on DjangoValue""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
choices = kwargs.pop("choices", []) | ||
formatted_choices = [(value, value) for value, _ in choices] | ||
super().__init__(*args, choices=formatted_choices, **kwargs) | ||
|
||
|
||
class UserAdminForm(forms.ModelForm): | ||
risk_score = ShortLabelChoiceField(choices=UserRiskScoreType.choices) | ||
|
||
class Meta: | ||
model = User | ||
fields = "__all__" | ||
|
||
|
||
class AlertAdminForm(forms.ModelForm): | ||
name = ShortLabelChoiceField(choices=AlertDetectionType.choices) | ||
filter_type = ShortLabelChoiceField(choices=AlertFilterType.choices) | ||
|
||
class Meta: | ||
model = Alert | ||
fields = "__all__" | ||
|
||
|
||
class ConfigAdminForm(forms.ModelForm): | ||
filtered_alerts_types = MultiChoiceArrayField( | ||
base_field=forms.CharField(), | ||
choices=AlertDetectionType.choices, | ||
required=False, | ||
help_text="Hold down “Control”, or “Command” on a Mac, to select more than one.", | ||
) | ||
alert_minimum_risk_score = ShortLabelChoiceField(choices=UserRiskScoreType.choices) | ||
|
||
class Meta: | ||
model = Config | ||
fields = "__all__" | ||
|
||
class Media: | ||
css = { | ||
"all": ("css/custom_admin.css",), | ||
} |
Oops, something went wrong.