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

Adds Splunk interfaces #50

Merged
merged 2 commits into from
Nov 26, 2024
Merged

Adds Splunk interfaces #50

merged 2 commits into from
Nov 26, 2024

Conversation

markkasaboski
Copy link
Collaborator

No description provided.

@markkasaboski markkasaboski self-assigned this Nov 18, 2024
@markkasaboski markkasaboski force-pushed the mark/refactor-protocol branch 4 times, most recently from cf026dc to 461375d Compare November 19, 2024 14:59
@markkasaboski markkasaboski force-pushed the mark/refactor-protocol branch 2 times, most recently from d863cdc to 292f7c5 Compare November 21, 2024 17:03
@markkasaboski
Copy link
Collaborator Author

markkasaboski commented Nov 21, 2024

@aviau I see you approved my draft. I was still working on the refactoring portion of it. Can you have a look now and give me your thoughts before I keep moving forward with the tests? Thanks.

  • Refactored the cron_job_ingest_events.py code into a class
    -- This cleans things up by not having to pass dependencies all the way down through every function.
  • Refactored test_ingest_events.py to use fake objects instead of mocks.

Not done with testing yet. It's mostly there, but opening for review now.

@markkasaboski markkasaboski force-pushed the mark/refactor-protocol branch 11 times, most recently from ad612cd to 30902a0 Compare November 21, 2024 22:07
@markkasaboski markkasaboski marked this pull request as ready for review November 21, 2024 22:08
@markkasaboski markkasaboski requested a review from TyMarc November 21, 2024 22:16
@aviau
Copy link
Member

aviau commented Nov 22, 2024

Can you have a look now and give me your thoughts before I keep moving forward with the tests?

Sure! My first comment would be that this PR is pretty big already. There are multiple refactors at the same time:

  • Using interfaces
  • Creating a big FlareEventIngestor class

I think the simplicify of the previous design was nice. Now, the FlareEventIngestor will be hard to test atomically because it has a lot of dependencies. For example, testing get_storage_password_value now requires creating a whole FlareEventIngestor, but it only needs one of its properties.

Instead of creating this big class, you could create something like this:

def get_storage_password_value(
   storage: StoragePasswords,
   ...
 ):
    ...

When you attach a method to a class, this makes the method impossible to test without the class. You should question: does it really need to be attached to the class?

@markkasaboski
Copy link
Collaborator Author

markkasaboski commented Nov 22, 2024

Can you have a look now and give me your thoughts before I keep moving forward with the tests?

Sure! My first comment would be that this PR is pretty big already. There are multiple refactors at the same time:

  • Using interfaces
  • Creating a big FlareEventIngestor class

I think the simplicify of the previous design was nice. Now, the FlareEventIngestor will be hard to test atomically because it has a lot of dependencies. For example, testing get_storage_password_value now requires creating a whole FlareEventIngestor, but it only needs one of its properties.

Instead of creating this big class, you could create something like this:

def get_storage_password_value(
   storage: StoragePasswords,
   ...
 ):
    ...

When you attach a method to a class, this makes the method impossible to test without the class. You should question: does it really need to be attached to the class?

@aviau

The problem I see with the function above is that every function that we have in this file has to be passed its dependency which is either storage_passwords: StoragePasswords or kvstore: KVStoreCollections, which makes it rather messy. If it's in a class, every method can simply reference the class property where the dependency reside.

I dunno what this boils down to. Is this just a matter of personal preference or best practice? I can trash the class and go back.

Wanna/have time to pair up on it?

@aviau
Copy link
Member

aviau commented Nov 22, 2024

If it's in a class, every method can simply reference the class property where the dependency reside.

So you can do this:

class BigClass:
    def do_something(arg: str) -> None:
       # This just re-routes to the detached function, and is more "convenient" to use.
        return do_something(dependency=self.dependency, arg=arg)


def do_something(dependency, arg) -> None:
  # most of the implementation is here, and it has minimal dependencies
  ...

This way, you can test do_someting easily, without creating BigClass, and you stil get the "convenience" when you use BigClass.

@markkasaboski markkasaboski force-pushed the mark/refactor-protocol branch 2 times, most recently from 55f89b6 to 7e2c18c Compare November 26, 2024 14:33
Copy link
Contributor

@TyMarc TyMarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@markkasaboski markkasaboski merged commit cad1e39 into main Nov 26, 2024
2 checks passed
@markkasaboski markkasaboski deleted the mark/refactor-protocol branch November 26, 2024 15:41
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.

3 participants