-
Notifications
You must be signed in to change notification settings - Fork 29
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
Detect and Process Policy Files into SemConv Registry + Generic Diagnostic Reporting #153
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #153 +/- ##
=======================================
- Coverage 75.2% 75.0% -0.2%
=======================================
Files 45 43 -2
Lines 2704 2729 +25
=======================================
+ Hits 2034 2049 +15
- Misses 670 680 +10 ☔ View full report in Codecov by Sentry. |
A few thoughts:
With corresponding |
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.
So far this looks really good. There's a LOT to this so it took a while for me to sort through it all.
Have one major question around what installation of weaver looks like with these diagnostic templates, but otherwise just a lot of nits / cleanups.
@jsuereth My goal in an upcoming PR is to embed the default templates within the binary to avoid depending on an external directory. However, a user will still be able to create an external directory to (re)define templates as they wish. We could even imagine an init command to initialize this directory with the default content. |
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.
Ok to merge as long as we consider the template issue a blocker for release.
Main updates
This PR introduces several enhancements:
Policy Enforcement: It detects policy files (
.rego
) embedded in semantic convention registries and uses the policy engine to enforce all found policies. In this PR, only thebefore_resolution
policy stage is supported.Enhanced Error Reporting: All
WeaverError
instances are now extended to support Miette diagnostics, enabling rich annotations and improved error reporting. This extension is utilized by the diagnostic message rendering process described below.Generic Diagnostic Message Output: A new mechanism for outputting diagnostic messages in various formats is introduced, including ANSI-compatible text, JSON, and
gh_workflow_command
. Users can create new formats by adding a Jinja template, which will be used to render diagnostic messages in the new format.Centralized Error Processing and Exit Code Determination: All errors and diagnostic messages are now processed and rendered in the main function, which also determines the exit code.
The ANSI template renders policy violations in a specific way, while all other diagnostic messages are rendered using the Miette "graphical" renderer.
Below are the newly supported parameters that can be used to configure the diagnostic rendering process:
Other minor updates/improvements
assert_cmd
to test the command line.Future PRs
after_resolution
policy stage.