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 more cortex queries #371

Merged
merged 6 commits into from
Dec 4, 2024

Conversation

Anko59
Copy link
Contributor

@Anko59 Anko59 commented Nov 26, 2024

No description provided.

@Anko59 Anko59 force-pushed the 369-add-more-cortex-queries branch 3 times, most recently from 43b02cc to fb1a0e3 Compare November 26, 2024 15:16
@Anko59 Anko59 force-pushed the 369-add-more-cortex-queries branch from fb1a0e3 to 15a52a5 Compare November 26, 2024 15:18
@Kamforka
Copy link
Collaborator

I'll take a closer look but on the high level it seems fine!
Maybe one thing that is not ideal is the simple return types.
Probably we can define some more advanced type hints for those?

@Kamforka Kamforka self-requested a review November 26, 2024 18:11
@Kamforka Kamforka added category:enhancement 2.x changelog:added changelog label for new features. labels Nov 26, 2024
@Kamforka Kamforka added this to the 2.0.0b8 milestone Nov 26, 2024
@Anko59
Copy link
Contributor Author

Anko59 commented Nov 27, 2024

Thanks for the review,

I applied the changes that you suggested. I added cortex types for the objects returned by the API and added the range parameter to the list_analyzers function. I did not find any other missing parameter.

I used python 3.9+ typing (dict and list instead of Dict and List). It was already like this in the cortex.py, though I noticed most of the repo still uses pre 3.9 typing.

To better match the documentation, "responder action" and "analyzer job" could be renamed "cortex action" and "cortex job", but I think the first ones are easier to understand.

@Anko59 Anko59 requested a review from Kamforka November 28, 2024 09:51
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.94%. Comparing base (da08ad3) to head (514fd55).

Files with missing lines Patch % Lines
thehive4py/endpoints/cortex.py 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #371      +/-   ##
==========================================
- Coverage   93.08%   92.94%   -0.15%     
==========================================
  Files          27       27              
  Lines         738      751      +13     
==========================================
+ Hits          687      698      +11     
- Misses         51       53       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Kamforka
Copy link
Collaborator

I applied the changes that you suggested. I added cortex types for the objects returned by the API and added the range parameter to the list_analyzers function. I did not find any other missing parameter.

Nice, great job so far!

I used python 3.9+ typing (dict and list instead of Dict and List). It was already like this in the cortex.py, though I noticed most of the repo still uses pre 3.9 typing.

Unfortunately we still support 3.8, so can you please fall back to typing.List and typing.Dict where necessary? I plan to drop support 2025Q1.

To better match the documentation, "responder action" and "analyzer job" could be renamed "cortex action" and "cortex job", but I think the first ones are easier to understand.

I agree with the naming convention, more to the point than cortex action and job!

My last point to this PR would be the missing integration tests. Unfortunately we don't have a Cortex instance configured yet, so we cannot test all the endpoints, but probably we can add some dummy test for the list_analyzers and list_responders methods, would you like to give it a try?

@Anko59 Anko59 requested a review from Kamforka December 2, 2024 09:31
@Anko59
Copy link
Contributor Author

Anko59 commented Dec 2, 2024

I implemented the changes you suggested.
The tests are really dummy, as there are no responders or analyzers on the test instance, some of the test code is never reached. I don't know how to add responders or analyzers using the API. I will try to document myself.

@Kamforka
Copy link
Collaborator

Kamforka commented Dec 2, 2024

I implemented the changes you suggested. The tests are really dummy, as there are no responders or analyzers on the test instance, some of the test code is never reached. I don't know how to add responders or analyzers using the API. I will try to document myself.

First of all thank you very much for the changes, great job just as before!!!

To reply to your dummy test concern, unfortunately this is the best we can do at the moment as we don't yet have a live Cortex instance behind the integrator instance of TheHive, so we will always get back empty responder and analyzer lists, but that's okay for now. TheHive cannot create/define analyzers nor responders.

Additionally I added some simplification ideas to your tests, if you implement those I think we are done with this PR.

@Anko59 Anko59 requested a review from Kamforka December 3, 2024 08:46
@Kamforka Kamforka self-requested a review December 4, 2024 09:48
@Kamforka
Copy link
Collaborator

Kamforka commented Dec 4, 2024

Thank you for your coop, nice one!

@Kamforka Kamforka merged commit 570066e into TheHive-Project:main Dec 4, 2024
11 checks passed
@Kamforka Kamforka linked an issue Jan 12, 2025 that may be closed by this pull request
@Kamforka Kamforka added the changelog:changed changelog label for changes in existing functionality label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x category:enhancement changelog:added changelog label for new features. changelog:changed changelog label for changes in existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for more cortex queries
2 participants