Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mateodurante
Copy link
Contributor

This pull request refactors the handling of field restrictions in the ngen project 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:

    • Updated environment variables in docker/.env/ngen.base.env to use BLOCKED_FIELDS_* instead of ALLOWED_FIELDS_BLOCKED_*. ([docker/.env/ngen.base.envL55-R59](https://github.com/CERTUNLP/ngen/pull/217/files#diff-6709acacd301c0c80eed34b1b27eca4585a4dbc96e6d2e8f6176db61e39623afL55-R59))
    • Updated corresponding configuration settings in project/settings.py to 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):

    • Renamed the allowed_fields property to blocked_fields and 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))
    • Adjusted the check_allowed_fields method to check against blocked_fields instead of allowed_fields. ([ngen/models/common/mixins.pyL239-R242](https://github.com/CERTUNLP/ngen/pull/217/files#diff-2ce14d1b359c7af0778fe5a8ceb1acca0a8ea86e4dbcc077b2ef4aaedc864e4bL239-R242))
  • Serializers (ngen/serializers/case.py):

    • Renamed allowed_fields methods to blocked_fields in multiple serializers, including EventSerializerReduced and CaseSerializerReduced. ([[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))
    • Updated the validate method to use BLOCKED_FIELDS_EXCEPTION for 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):

    • Updated the get_extra_kwargs method to use blocked_fields instead of allowed_fields when determining read-only fields. ([ngen/serializers/common/mixins.pyL115-R119](https://github.com/CERTUNLP/ngen/pull/217/files#diff-8cce39e8854556d91d624311377afdb9a56b3e3c834a02a6ade34941a57ffda6L115-R119))

@mateodurante mateodurante requested a review from Copilot May 9, 2025 13:28
Copy link
Contributor

Copilot AI left a 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

@property
def allowed_fields(self) -> bool:
key = f"ALLOWED_FIELDS_BLOCKED_{self.__class__.__name__.upper()}"
def blocked_fields(self) -> bool:
Copy link

Copilot AI May 9, 2025

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.

Copilot uses AI. Check for mistakes.

ALLOWED_FIELDS_BLOCKED_CASE=parent,state,tlp
ALLOWED_FIELDS_BLOCKED_EVENT=parent,case,tlp
BLOCKED_FIELDS_CASE=
Copy link

Copilot AI May 9, 2025

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.

Suggested change
BLOCKED_FIELDS_CASE=
BLOCKED_FIELDS_CASE=none

Copilot uses AI. Check for mistakes.
@mateodurante mateodurante requested a review from Copilot May 9, 2025 14:50
Copy link
Contributor

Copilot AI left a 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():
Copy link

Copilot AI May 9, 2025

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.

Copilot uses AI. Check for mistakes.
@mateodurante mateodurante merged commit 97c5d3a into develop May 9, 2025
6 checks passed
mateodurante added a commit that referenced this pull request May 16, 2025
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants