infosec-intern / vscode-yara

VSCode extension for the YARA pattern matching language
MIT License
63 stars 14 forks source link

Configuration metadata #39

Closed infosec-intern closed 3 years ago

infosec-intern commented 3 years ago

Closes #23

ITAYC0HEN commented 3 years ago

HEy, I notice that there are no easy templates anymore (snippets). Any reason to remove the rich snippet that was here before? :) https://github.com/infosec-intern/vscode-yara/pull/30/commits/796702ef457e65e8ef148067c924e6ce6c8681b0

infosec-intern commented 3 years ago

@ITAYC0HEN the specific text templates were removed, but the capability still exists with the Snippet Provider. A lot of the text you added in that snippet was ported into the provider as default text with the option to provide default metadata as keywords via the extension's settings. For example, if you want to recreate the same metadata provided in your original snippet, the following configuration should work:

{
    "author": "",
    "date": "${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}",
    "hash": "",
    "reference": ""
}

I wrote a little wiki page for this specific feature here too: https://github.com/infosec-intern/vscode-yara/wiki/Snippets#rule-section-snippets

ITAYC0HEN commented 3 years ago

Sorry not sure I understood how it works. Couldn't make it happen. Should I edit some of this repo's files under ~/.vscode or somewhere else? I tried some things and couldn't bring them to work. Would you mind sharing a .diff file of some kind that I can apply to have the same metadata as in the previous snippet?

infosec-intern commented 3 years ago

Sure, here's my workspace settings with the metaEntries field filled out along with some screenshots to display the results

These are just placed in my yara-rules/.vscode/settings.json file: metaEntriesSettings

Here's the actual snippet text - what it should look like when attempting to complete a rule snippet. Similar text will also be autofilled when trying to complete a meta section snippet: ruleCompletion

And the resulting text with the author and date auto-filled (any snippet variables should work), and tabstops placed in the hash and reference keys because I left those values empty in the settings: ruleResult

One other thing about these is you can enable/disable any of these snippets, so if you prefer to create your own snippet with the same name instead of use this feature, you can disable any/all of the sections in the Settings menu: snippetToggles