From 9dd01fb91da46c95f2f20540c2148a2f1ec4c38b Mon Sep 17 00:00:00 2001 From: Elias Bachaalany Date: Mon, 31 Jul 2023 09:04:46 -0700 Subject: [PATCH] Updated the snippet manager documentation I blame ChatGPT Code interpreter ;) --- snippet_manager/.temp/gpt4-prompt-readme.txt | 54 -------------------- snippet_manager/README.md | 10 ++-- snippet_manager/snippetmanager.py | 1 + 3 files changed, 5 insertions(+), 60 deletions(-) delete mode 100644 snippet_manager/.temp/gpt4-prompt-readme.txt diff --git a/snippet_manager/.temp/gpt4-prompt-readme.txt b/snippet_manager/.temp/gpt4-prompt-readme.txt deleted file mode 100644 index 0600254..0000000 --- a/snippet_manager/.temp/gpt4-prompt-readme.txt +++ /dev/null @@ -1,54 +0,0 @@ -Please generate a professional README.md file, for the snipper manager IDA Pro plugin. - -Here are the functionality that this plugin provides. -Also create a simple (empty/template) section for "INSTALLATION" instructions that I will fill in later: - -def save_snippets(output_folder=''): - """ - Save snippets to a specified output folder. If no folder is specified, - the function uses the current directory by default. - - Args: - output_folder (str): The folder where the snippets will be saved. - Defaults to current directory if not specified. - - Returns: - Result of the operation performed by the save_to_folder method. - """ - return _sm.save_to_folder(output_folder) - -def load_snippets(input_folder=''): - """ - Load snippets from a specified input folder. If no folder is specified, - the function uses the current directory by default. - - Args: - input_folder (str): The folder from where the snippets will be loaded. - Defaults to current directory if not specified. - - Returns: - Result of the operation performed by the load_from_folder method. - """ - return _sm.load_from_folder(input_folder) - -def delete_snippets(): - """ - Delete all existing snippets. - - Returns: - Result of the operation performed by the delete_all method. - """ - return _sm.delete_all() - -ext.snippets = idaapi.object_t( - save=save_snippets, - load=load_snippets, - delete=delete_snippets, -) - -At the end, give me a download link for the README.md file. -Do not show me the contents, instead directly emit to the file to be downloaded. -Add an "Examples" section illustrating the usage of the exported extension calls. - -Basically, to emit the README.md file that I should download, just use the code interpreter to write a whole large string of the contents (as you will generate it). - diff --git a/snippet_manager/README.md b/snippet_manager/README.md index f7dd6b2..b878ddd 100644 --- a/snippet_manager/README.md +++ b/snippet_manager/README.md @@ -6,10 +6,10 @@ This plugin for IDA provides a set of functionality for importing, exporting or Type the following functions from IDA's CLI or just call them directly from Python: -- `idaapi.ext.save_snippets(output_folder='')`: Save snippets to a specified output folder. -- `idaapi.ext.load_snippets(input_folder='')`: Load snippets from a specified input folder. -- `idaapi.ext.delete_snippets()`: Delete all existing snippets. -- `idaapi.ext.man`: Direct access to the snippet manager object. +- `idaapi.ext.snippets.save(output_folder='')`: Save snippets to a specified output folder. +- `idaapi.ext.snippets.load(input_folder='')`: Load snippets from a specified input folder. +- `idaapi.ext.snippets.delete()`: Delete all existing snippets. +- `idaapi.ext.snippets.man`: Direct access to the snippet manager object. By default, if no input or output folders are specified, then the plugin will default to the `os.path.join(os.path.dirname(idc.get_idb_path()), '.snippets')` folder. @@ -23,8 +23,6 @@ Alternatively, for example on Windows, just make a symbolic link directly: C:\Projects\ida-qscripts\snippet_manager>mklink c:\ida\plugins\snippetmanager.py %cd%\snippetmanager.py ``` -_(Just for fun, I provided the [ChatGPT-4/Code Interpreter prompt](.temp/gpt4-prompt-readme.txt) used to bootstrap this readme file)_ - ## Very important Due to the IDA UI's caching of snippets in memory, changes will not be immediately visible. Therefore, upon executing any of the functions, it is obligatory to close, save, and then reopen the database manually in order to observe the modifications. \ No newline at end of file diff --git a/snippet_manager/snippetmanager.py b/snippet_manager/snippetmanager.py index 89c1049..7081f72 100644 --- a/snippet_manager/snippetmanager.py +++ b/snippet_manager/snippetmanager.py @@ -240,6 +240,7 @@ def run(self, _): - save snippets: idaapi.ext.snippets.save() - load snippets: idaapi.ext.snippets.load() - delete snippets: idaapi.ext.snippets.delete() + - access the snippet manager object: idaapi.ext.snippets.man """) return 0