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

Allow template in pull request alert comment #5192

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

eleftherias
Copy link
Contributor

Summary

Change the pull request alert comment parameter from a string to a template.
This allows us to set the comment to "{{ .EvalErrorDetails }}" which gets details from the evaluation error.

Ref #5120

Question

I'm undecided about how to structure the template params, whether it should be a nested eval object (.Eval.Error.Details) or a single string (.EvalErrorDetails). Let me know if you have a preference.

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

In a rule set the alert message to a template

  alert:
    type: pull_request_comment
    pull_request_comment:
      review_message: "{{ .EvalErrorDetails }}"

This is an example from the legacy Trusty rule using the pr comment alert:
Screenshot 2024-12-12 at 14 48 03

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.

@eleftherias eleftherias marked this pull request as ready for review December 12, 2024 13:53
@eleftherias eleftherias requested a review from a team as a code owner December 12, 2024 13:53
@coveralls
Copy link

Coverage Status

coverage: 55.356% (+0.01%) from 55.345%
when pulling 3df29a0 on eleftherias:pr-alert-comment-template
into b69d87d on mindersec:main.

@eleftherias eleftherias merged commit 59faada into mindersec:main Dec 13, 2024
24 of 26 checks passed
@eleftherias eleftherias deleted the pr-alert-comment-template branch December 13, 2024 08:54
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.

3 participants