Skip to content
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

Add __hash__ function to SigmaLevel & SigmaStatus #204

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

kelnage
Copy link
Contributor

@kelnage kelnage commented Mar 26, 2024

By implementing __eq__ but not __hash__, the SigmaLevel enum can no longer be used as the key of a dictionary (see the second paragraph of this Python documentation (1)). The code for the ATT&CK framework integration was however using it in this way (2), and this was leading to runtime errors in sigma-cli. This PR adds in an implementation of __hash__ to allow it to continue to be used as such, and similarly for SigmaStatus.

  1. https://docs.python.org/3.1/reference/datamodel.html#object.__hash__
  2. https://github.com/SigmaHQ/sigma-cli/blob/main/sigma/analyze/attack.py#L19

By implementing __eq__ but not __hash__, the `SigmaLevel` enum can no
longer be used as the key of a dictionary (see the second paragraph
of this Python documentation (1)). The code for the ATT&CK framework
integration was however using it in this way (2), and this was leading
to runtime errors in `sigma-cli`. This PR adds in an implementation of
__hash__ to allow it to continue to be used as such, and similarly for
`SigmaStatus`.

1. https://docs.python.org/3.1/reference/datamodel.html#object.__hash__
2. https://github.com/SigmaHQ/sigma-cli/blob/main/sigma/analyze/attack.py#L19
@thomaspatzke thomaspatzke merged commit cece15b into SigmaHQ:main Mar 26, 2024
12 checks passed
@kelnage kelnage deleted the sigma-level-hash-fn branch March 27, 2024 10:05
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