-
Notifications
You must be signed in to change notification settings - Fork 43
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
Validate rule type guidance
as markdown.
#4292
Conversation
Minder Vulnerability Report ✅Minder analyzed this PR and found it does not add any new vulnerable dependencies.
|
guidance
is valid markdown.guidance
as markdown.
Changes unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also cover `UpdateRuleType?
), | ||
) | ||
if err := md.Convert([]byte(crt.RuleType.Guidance), &bytes.Buffer{}); err != nil { | ||
return nil, status.Errorf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a user-facing issue? We have a UserVisibleError
wrapper that allows for this.
return nil, status.Errorf( | ||
codes.InvalidArgument, | ||
"invalid rule type definition: guidance too long", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a user-facing issue? We have a UserVisibleError wrapper that allows for this.
We're currently treating `guidance` as a plain string, storing it unmodified. This change introduces some controls ensuring that guidance is valid markdown before storing it in the database. Since any valid UTF-8 string is valid markdown, the check is a bit redundant at the moment and ensures that it is parseable and renderable as HTML. Additionally, we limit its size to 10kB, which is far more than enough given the current rule types have a `guidance` field shorter than 1kB. Fixes #4286
Thanks for catching that @JAORMX |
Summary
We're currently treating
guidance
as a plain string, storing it unmodified.This change introduces some controls ensuring that guidance is valid markdown before storing it in the database. Since any valid UTF-8 string is valid markdown, the check is a bit redundant at the moment and ensures that it is parseable and renderable as HTML.
Additionally, we limit its size to 10kB, which is far more than enough given the current rule types have a
guidance
field shorter than 1kB.Fixes #4286
Change Type
Testing
Manual tests.
Review Checklist: