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 mindev ruletype init to kick off a rule type #5228

Merged
merged 4 commits into from
Jan 13, 2025

Conversation

JAORMX
Copy link
Contributor

@JAORMX JAORMX commented Dec 19, 2024

Summary

This helps folks set up the basic skeleton for ruletype writing.

Fixes #(related issue)

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@JAORMX JAORMX requested a review from a team as a code owner December 19, 2024 12:58
@coveralls
Copy link

coveralls commented Dec 19, 2024

Coverage Status

coverage: 55.142% (+0.007%) from 55.135%
when pulling e0037ba on JAORMX:ruletype-scaffold
into a02f754 on mindersec:main.

@JAORMX JAORMX requested review from blkt and rdimitrov December 19, 2024 16:11
cmd/dev/app/rule_type/init.go Outdated Show resolved Hide resolved
cmd/dev/app/rule_type/init.go Outdated Show resolved Hide resolved
cmd/dev/app/rule_type/init.go Outdated Show resolved Hide resolved
cmd/dev/app/rule_type/init.go Outdated Show resolved Hide resolved
cmd/dev/app/rule_type/init.go Show resolved Hide resolved
cmd/dev/app/rule_type/init.go Outdated Show resolved Hide resolved
return initCmd
}

func initCmdRun(cmd *cobra.Command, args []string) error {
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about having this operate in a more "wizard" style in terms of prompting for missing data rather than people needing to figure out the flag arguments up front and then getting a file with a bunch of comments to fill in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure I see much value in that. There is one argument to figure out.

Copy link
Member

Choose a reason for hiding this comment

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

A wizard-type mode (or extra command-line flags) could fill out the commented sections of the template. For example, if we had a display_name, we could automatically create the RuleName based on the display name. We could also prompt for the critical fields like description, short_failure_message, and in_entity.

@JAORMX JAORMX force-pushed the ruletype-scaffold branch 2 times, most recently from 0623770 to e0037ba Compare January 7, 2025 07:53
@JAORMX JAORMX requested a review from evankanderson January 7, 2025 12:46
evankanderson
evankanderson previously approved these changes Jan 7, 2025
Copy link
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

Approving, but also explaining the wizard idea a bit more clearly.

I'm also still wondering whether Rego rule types should be able to have a top-level .rego file, so that it can work with language servers like Regal.

cmd/dev/app/rule_type/init.go Show resolved Hide resolved
return initCmd
}

func initCmdRun(cmd *cobra.Command, args []string) error {
Copy link
Member

Choose a reason for hiding this comment

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

A wizard-type mode (or extra command-line flags) could fill out the commented sections of the template. For example, if we had a display_name, we could automatically create the RuleName based on the display name. We could also prompt for the critical fields like description, short_failure_message, and in_entity.

JAORMX and others added 4 commits January 13, 2025 10:05
This helps folks set up the basic skeleton for ruletype writing.

Signed-off-by: Juan Antonio Osorio <[email protected]>
Signed-off-by: Juan Antonio Osorio <[email protected]>
Signed-off-by: Juan Antonio Osorio <[email protected]>
@JAORMX JAORMX force-pushed the ruletype-scaffold branch from bf35130 to d5a7798 Compare January 13, 2025 08:05
Copy link
Member

@rdimitrov rdimitrov left a comment

Choose a reason for hiding this comment

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

LGTM 👍 If we want we can add Evan's suggestions regarding the wizard-type UX as follow up PRs

@JAORMX JAORMX merged commit 2caea05 into mindersec:main Jan 13, 2025
26 checks passed
@JAORMX JAORMX deleted the ruletype-scaffold branch January 13, 2025 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants