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 JSON struct tags #39

Merged
merged 1 commit into from
Oct 17, 2023
Merged

Add JSON struct tags #39

merged 1 commit into from
Oct 17, 2023

Conversation

scudette
Copy link
Contributor

No description provided.


// Any non-standard fields will end up in here
AdditionalFields map[string]interface{} `yaml:",inline"`
AdditionalFields map[string]interface{} `yaml:",inline,omitempty" json:",inline,omitempty"`
Copy link
Owner

Choose a reason for hiding this comment

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

Unfortunately I don't think the "inline" keyword works for json (in the yaml package used here it outputs the values at the same level of nesting as the other struct fields)

What's the use case for json output? YAML output makes sense here so that you can programmatically edit rules and then marshal them out to valid Sigma rules again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Velociraptor emits all results in Json and we want to include the rule itself as part of the hit. Without the Json tags we get all the empty fields which just take up space.

Copy link
Owner

Choose a reason for hiding this comment

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

Makes sense 👍🏻

Copy link
Owner

Choose a reason for hiding this comment

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

Though I do wonder if you'd get better results converting YAML to JSON yourself e.g. like this https://github.com/ghodss/yaml/blob/d8423dcdf3440d0a5baffc6f90a11e4128545620/yaml.go#L104
That way you'd get support for things like inline

Anyway, doesn't hurt to have these tags so I'll merge


// Any non-standard fields will end up in here
AdditionalFields map[string]interface{} `yaml:",inline"`
AdditionalFields map[string]interface{} `yaml:",inline,omitempty" json:",inline,omitempty"`
Copy link
Owner

Choose a reason for hiding this comment

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

Though I do wonder if you'd get better results converting YAML to JSON yourself e.g. like this https://github.com/ghodss/yaml/blob/d8423dcdf3440d0a5baffc6f90a11e4128545620/yaml.go#L104
That way you'd get support for things like inline

Anyway, doesn't hurt to have these tags so I'll merge

@bradleyjkemp bradleyjkemp merged commit ee7ca3e into bradleyjkemp:main Oct 17, 2023
1 check passed
@scudette scudette deleted the json branch October 25, 2024 12:23
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.

2 participants