opencti icon indicating copy to clipboard operation
opencti copied to clipboard

Initial Changes to support dynamic configurable required fields via settings --> customization

Open ParamConstructor opened this issue 1 year ago • 1 comments

Proposed changes

Modify system to support dynamic required fields using the existing capability per object type off the Admin console (setting--> customization). These fields that are required will be marked with a "*" star shown next to labels and result in a read error call out when not filled in/provided.

This change is implemented off the Analyses objects in this intial PR. The Related Issues section will cover where the change was not implemented and why on the Analyses --> External References section. On that area, the platform behavior for required field remains unchanged.

Related issues

  • External-Reference is not directly supported for this required fields change. Based on communication with the Filigran team - this field will require many complex relationships between mandatory attributes to fully implement

  • There are two translations unrelated to this PR but were corrected as part of the PR: The word "Let" was replaced with "Leave" in these two translations: - "Leave the field empty to grant all authenticated users" - "Leave the field empty to grant all users"

Checklist

  • [X] I consider the submitted work as finished
  • Note - there will be a second PR to apply these changes to the remainder of the platform forms/objects. Filigran requested that PR (https://github.com/OpenCTI-Platform/opencti/pull/5877) be decomposed into 2 PRs for ease of merging/review.
  • [X] I tested the code for its functionality
  • [X] (N/A - Existing test cases should work properly) I wrote test cases for the relevant uses case (coverage and e2e)
  • [ ] I added/update the relevant documentation (either on github or on notion)
  • [X] Where necessary I refactored code to improve the overall quality

Further comments

There will be an additional PR to adopt this change to the reset of the platform, after the PR is accepted. Some general notes on required fields.

  • Files requiring change have been determined by a search of the codebase for 'This field is required' and by limiting found files to ./*/.tsx. The exceptions are listed in these comments.

  • There are roughly 46 *.jsx files that need to be rewritten as *.tsx. That is considered outside tech debt and can be performed, as need, adopting this required fields implementation at that time.

  • ScaleConfiguration, StixCoreObjectFileExport - Do not currently store attribute configuration in GraphQL, so unable to manage required fields via useSchemaAttributes or useEntitySettings for these fields. [Tech Debt]

  • NotifierCreation and NotifierEdition - FORMIK errors were not reported back to user on these objects, unclear how to fix this issue, so not implemented on these objects.

  • CsvMapperForm appears to be a work in progress - this change has skipped that form for now.

  • SettingsMessages data objects need to be registered as InternalObjects within the opencti-platform/opencti-graphql/src/modules/attributes/internalObject-registrationAttributes.ts source. This is necessary for the useMandatorySchemaAttributes capability to work, so this has been skipped. [Tech Debt]

  • opencti-platform/opencti-front/src/private/components/common/files/FileImportMarkingSelectionPopup.tsx and opencti-platform/opencti-front/src/private/components/common/files/FreeTextUploader.tsx currently only support the field required setting of False

ParamConstructor avatar May 14 '24 19:05 ParamConstructor

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 66.06%. Comparing base (ff19cb5) to head (d31b409). Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6972   +/-   ##
=======================================
  Coverage   66.05%   66.06%           
=======================================
  Files         597      597           
  Lines       60913    60913           
  Branches     6202     6203    +1     
=======================================
+ Hits        40235    40241    +6     
+ Misses      20678    20672    -6     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 17 '24 17:05 codecov[bot]

A form has been forgotten in the StixCoreObjectOpinionsDialog.ts file. You can test it in a report by clicking on the button above the radar. image

frapuks avatar Sep 19 '24 09:09 frapuks