Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Conversation

@allrob23
Copy link

@allrob23 allrob23 commented Apr 11, 2025

Proposed changes

  • Added CaseInsensitiveMixin to improve code reuse for case-insensitive value checking across Enum classes.
  • Applied the mixin to the Enuns StixCyberObservableTypes, IdentityTypes, ThreatActorTypes, LocationTypes, ContainerTypes, StixMetaTypes, and MultipleRefRelationship to remove duplicated has_value function logic.
  • Updated the logic in has_value to use a set (O(1) lookup) instead of a list (O(N) lookup) and added caching for lower_values to avoid recreating it on every call.

This change follows the DRY principle by centralizing case-insensitive checks in a single mixin, making the code cleaner and easier to maintain. It's not a major performance optimization, but it's a nice improvement. I’ve included a benchmark below to show the results.

Benchmark code and results:
code: https://gist.github.com/allrob23/03382afaffec1a31472ed6fa90fdeb52

Result
Original: 0.004698 seconds
Refactored: 0.000227 seconds

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@nino-filigran nino-filigran added the community use to identify PR from community label Apr 25, 2025
@nino-filigran
Copy link

Thanks @allrob23 for your contribution, we're going to look at it !

@aHenryJard aHenryJard self-assigned this Jun 20, 2025
@aHenryJard aHenryJard removed their assignment Sep 26, 2025
@CelineSebe
Copy link
Member

There is a conflit to resolve here.
Thanks in advance :)

@github-actions
Copy link

Thank you for your contribution, but we need you to sign your commits. Please see https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

@CelineSebe
Copy link
Member

Everything looks good :) However, we need the signature of the commit please.

@aHenryJard
Copy link
Member

Hello, this repository has been moved to client-python folder into https://github.com/OpenCTI-Platform/opencti.

All PR here in this repository will be closed, if you still need it, please reopen on https://github.com/OpenCTI-Platform/opencti

@aHenryJard aHenryJard closed this Nov 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community use to identify PR from community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants