-
Notifications
You must be signed in to change notification settings - Fork 2
Replace a list of allowed fields with a list of blocked fields #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace a list of allowed fields with a list of blocked fields #217
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the field restrictions by replacing the previous allowed fields terminology with blocked fields, ensuring consistency across environment variables, settings, serializers, and model mixins.
- Changed environment variable names and configuration keys in project/settings.py and docker environment files
- Renamed properties and methods in serializers and model mixins to use "blocked" instead of "allowed" and adjusted corresponding logic
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| project/settings.py | Updated environment variable names and config settings |
| ngen/serializers/common/mixins.py | Renamed property and modified read-only field logic |
| ngen/serializers/case.py | Renamed methods and updated error validation to reflect new terminology |
| ngen/models/common/mixins.py | Renamed property and adjusted field change check logic |
| docker/.env/ngen.base.env | Updated environment variables to use new "BLOCKED_FIELDS_*" naming |
ngen/models/common/mixins.py
Outdated
| @property | ||
| def allowed_fields(self) -> bool: | ||
| key = f"ALLOWED_FIELDS_BLOCKED_{self.__class__.__name__.upper()}" | ||
| def blocked_fields(self) -> bool: |
Copilot
AI
May 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property 'blocked_fields' returns a list of values but is annotated with a bool return type. Consider updating the type annotation (e.g., to List[str]) to accurately reflect its return type.
|
|
||
| ALLOWED_FIELDS_BLOCKED_CASE=parent,state,tlp | ||
| ALLOWED_FIELDS_BLOCKED_EVENT=parent,case,tlp | ||
| BLOCKED_FIELDS_CASE= |
Copilot
AI
May 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable 'BLOCKED_FIELDS_CASE' is now empty, which may unintentionally result in an empty blocked fields list (or a list containing an empty string) when split. Please verify if this change is intentional and adjust the value if necessary.
| BLOCKED_FIELDS_CASE= | |
| BLOCKED_FIELDS_CASE=none |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the field restriction logic in the ngen project by replacing the "allowed fields" terminology with "blocked fields" throughout the codebase.
- Updated environment variables and configuration keys in project settings and Docker files.
- Renamed properties and methods in model mixins and serializers to adopt the new "blocked_fields" naming convention.
- Modified the utility function clean_list to filter additional empty values.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| project/settings.py | Updated configuration keys to use BLOCKED_FIELDS_* instead of ALLOWED_FIELDS_BLOCKED_* |
| ngen/utils.py | Changed clean_list implementation to filter out additional empty values |
| ngen/serializers/common/mixins.py | Updated serializer mixin to use blocked_fields to determine read-only fields |
| ngen/serializers/case.py | Renamed methods from allowed_fields to blocked_fields and updated exception handling |
| ngen/models/common/mixins.py | Renamed property from allowed_fields to blocked_fields and adjusted related methods |
| docker/.env/ngen.base.env | Renamed environment variable keys to use BLOCKED_FIELDS_* |
Comments suppressed due to low confidence (1)
ngen/utils.py:66
- [nitpick] Ensure that filtering out empty lists, dictionaries, and tuples in addition to None and empty strings is the intended behavior for cleaning the input list.
return [item for item in input_list if item not in (None, "", [], {}, ())]
| @staticmethod | ||
| def allowed_fields(): | ||
| return config.ALLOWED_FIELDS_BLOCKED_EVENT.split(",") | ||
| def blocked_fields(): |
Copilot
AI
May 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding the @staticmethod decorator to the 'blocked_fields' methods if they do not rely on instance state, to maintain consistent static method usage.
* Feature/tanstackquery2 (#212) * Moved changes * Update frontend/src/views/user/components/TableUsers.jsx Co-authored-by: Copilot <[email protected]> * Update frontend/src/views/tanstackquery/UserComponent.jsx Co-authored-by: Copilot <[email protected]> * Update frontend/src/views/tanstackquery/EventComponent.jsx Co-authored-by: Copilot <[email protected]> * Event component only retrieves a single event, adding it to the cache --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Mateo Durante <[email protected]> * hotfix/send_affected_email_with_bcc_to_team * hotfix/email_bcc_contacts_as_list * fix/dependencies * fix pip dependencies * Feature/kintun frontend (#216) * Kintun frontend integration. Retests table, with send and refresh functionality. * Remove console log from refresh function and enhance error handling during event analysis deletion * Analyzer mappings views created and modified api service * Update frontend/src/api/services/analyzerMapping.jsx Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Agustin Paturlanne <[email protected]> Co-authored-by: Agustin Paturlanne <[email protected]> Co-authored-by: Copilot <[email protected]> * disable TEAM_EMAIL_PRIORITY to always send intern email * fix typo config * Replace a list of allowed fields with a list of blocked fields (#217) * Replace a list of allowed fields with a list of blocked fields * better clean list * add types to constance fields * fix/possible_none_fields * fix none value split * add about view to api and frontend (#218) * add about view to api and frontend * add TAG and TAG_RAW to workflow variables --------- Co-authored-by: Bar <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Agustin Paturlanne <[email protected]> Co-authored-by: Agustin Paturlanne <[email protected]>
This pull request refactors the handling of field restrictions in the
ngenproject by replacing the terminology of "allowed fields" with "blocked fields" for better clarity and consistency. The key changes include updates to environment variables, configuration settings, and method/property names across various files.Refactoring of field restriction terminology:
Environment variables and configuration settings:
docker/.env/ngen.base.envto useBLOCKED_FIELDS_*instead ofALLOWED_FIELDS_BLOCKED_*. ([docker/.env/ngen.base.envL55-R59](https://github.com/CERTUNLP/ngen/pull/217/files#diff-6709acacd301c0c80eed34b1b27eca4585a4dbc96e6d2e8f6176db61e39623afL55-R59))project/settings.pyto reflect the new naming convention. ([project/settings.pyL348-R361](https://github.com/CERTUNLP/ngen/pull/217/files#diff-25e4824b66759633b73f6971463e7d0f84a3f8563d999460250b9a7db52098bcL348-R361))Model mixins (
ngen/models/common/mixins.py):allowed_fieldsproperty toblocked_fieldsand updated its logic to use the new configuration keys. ([ngen/models/common/mixins.pyL144-R145](https://github.com/CERTUNLP/ngen/pull/217/files#diff-2ce14d1b359c7af0778fe5a8ceb1acca0a8ea86e4dbcc077b2ef4aaedc864e4bL144-R145))check_allowed_fieldsmethod to check againstblocked_fieldsinstead ofallowed_fields. ([ngen/models/common/mixins.pyL239-R242](https://github.com/CERTUNLP/ngen/pull/217/files#diff-2ce14d1b359c7af0778fe5a8ceb1acca0a8ea86e4dbcc077b2ef4aaedc864e4bL239-R242))Serializers (
ngen/serializers/case.py):allowed_fieldsmethods toblocked_fieldsin multiple serializers, includingEventSerializerReducedandCaseSerializerReduced. ([[1]](https://github.com/CERTUNLP/ngen/pull/217/files#diff-0cd1cda8a2e0687350989b4b01d1699fb17b38a25af2fc352cf29f88ee3ae1c4L189-R190),[[2]](https://github.com/CERTUNLP/ngen/pull/217/files#diff-0cd1cda8a2e0687350989b4b01d1699fb17b38a25af2fc352cf29f88ee3ae1c4L370-R371),[[3]](https://github.com/CERTUNLP/ngen/pull/217/files#diff-0cd1cda8a2e0687350989b4b01d1699fb17b38a25af2fc352cf29f88ee3ae1c4L298-R299))validatemethod to useBLOCKED_FIELDS_EXCEPTIONfor exception handling. ([ngen/serializers/case.pyL148-R148](https://github.com/CERTUNLP/ngen/pull/217/files#diff-0cd1cda8a2e0687350989b4b01d1699fb17b38a25af2fc352cf29f88ee3ae1c4L148-R148))Serializer mixins (
ngen/serializers/common/mixins.py):get_extra_kwargsmethod to useblocked_fieldsinstead ofallowed_fieldswhen determining read-only fields. ([ngen/serializers/common/mixins.pyL115-R119](https://github.com/CERTUNLP/ngen/pull/217/files#diff-8cce39e8854556d91d624311377afdb9a56b3e3c834a02a6ade34941a57ffda6L115-R119))