reuse existing sketch if name is given - #3868
cvandeplas wants to merge 24 commits into
Conversation
…s/timesketch into feature_sketch_by_name
jkppr
left a comment
There was a problem hiding this comment.
Thanks for the contribution and following up on the earlier PR. This is the first round of review.
|
Please also ensure pylint & black are happy. You can run this in your dev setup: |
|
Thanks @jkppr for the input. I think I've incorporated it in this update. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to target sketches by name in the Timesketch importer client, including handling duplicate sketch names through various strategies (newest, oldest, or interactive selection). It adds supporting client API methods, properties (created_at, creator), tests, and documentation. The review feedback recommends restricting the --sketch-strategy argument using argparse choices, adhering to the style guide by using f-strings instead of .format(), and improving the robustness of the interactive CLI prompt by validating user-selected sketch IDs.
|
linting fixed |
What existing problem does this PR solve?
timesketch_importer.pyrecreates new sketches when asketch_nameis given, instead of reusing the existing sketch.What new feature is being introduced with this PR?
Reuse of an existing sketch when a name is given. If the sketch does not exist, create a new one with that name (original behaviour).
This is a reworked version of #3626, addressing all review feedback from @jkppr and @jaegeral.
Changes
api_client/python/timesketch_api_client/client.py: Addedget_sketches_by_name()method to theTimesketchApiclass, returning a list of matching sketches. Conflict resolution (duplicates) is the caller'''s responsibility.api_client/python/timesketch_api_client/sketch.py: Addedcreated_atandcreatorproperties to theSketchclass.importer_client/python/tools/timesketch_importer.py: Uses the new API method and adds a--sketch-strategyflag (ask/newest/oldest) to handle duplicate sketch names.docs/guides/user/upload-data.md: Documented the new--sketch-nameand--sketch-strategyflags.Design decisions
get_sketches_by_name()is a generic operation useful beyond the importer, so it belongs inTimesketchApi.KeyErrorif none are found. Callers decide how to resolve duplicates.--sketch-strategyflag for automation. In interactive mode (defaultask), the user is prompted to select. For automated pipelines,newestoroldestcan be passed to avoid interactive prompts.Checks
get_sketches_by_name,created_at,creator, duplicate handling, case sensitivity)Closing issues
closes #3625