feat(gateway): add CI-triggered review dispatch #48
No reviewers
Labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Slipstream/auto_review!48
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/ci-triggered-reviews"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
POST /reviews/cigateway endpoint for Forgejo Actions to trigger semantic reviews after required CI checks pass.Validation
nix develop -c cargo fmt --all -- --checknix develop -c cargo nextest run -p ar-gatewaynix develop -c cargo clippy --workspace --all-targets -- -D warningsenv -u FORGEJO_BASE_URL -u FORGEJO_TOKEN -u LLM_BASE_URL -u LLM_API_KEY -u LLM_REASONING_MODEL -u LLM_CHEAP_MODEL -u LLM_EMBEDDING_MODEL nix develop -c cargo nextest run --workspace --no-tests=passCloses #42.
This PR introduces a new CI-triggered review dispatch endpoint in the
ar-gatewaycrate, allowing Forgejo Actions to request semantic reviews after CI checks pass. The implementation includes token validation and PR state verification to ensure secure and accurate dispatching. Ensure that sensitive tokens are securely stored and not exposed in logs or error messages.Walkthrough
New CI-triggered Review Endpoint:
POST /reviews/ciendpoint inar-gatewayto allow Forgejo Actions to trigger reviews.AR_CI_REVIEW_TOKEN) and verifies the current PR head SHA before dispatching.Security Considerations:
AR_CI_REVIEW_TOKENis securely stored and not exposed in logs or error messages.Documentation Updates:
QUICKSTART.md,README.md, and other documentation files to include information about the new endpoint and its configuration.Pre-merge checks
Linters
@ -682,3 +706,44 @@ fn autodetect_oci_runtime() -> String {}🔴 Error: The
validate_ci_review_tokenfunction should ensure that the token is securely handled and not logged or exposed in error messages. Consider using secure storage mechanisms for sensitive tokens.Addressed in
bf18cbaby adding a regression assertion that the validation error namesAR_CI_REVIEW_TOKENand the strength requirement without echoing the rejected token value.Reflection/classification: one-off coverage gap. The implementation already avoided logging or returning the token, but the security property was implicit rather than pinned by a focused test.
@ -193,6 +195,85 @@ fn is_bot_self(sender_login: &str, bot_login: &str) -> bool {sender_login.eq_ignore_ascii_case(bot_login)🟡 Warning: The
handle_ci_reviewfunction should ensure that sensitive information is not logged or exposed in error messages. Consider sanitizing inputs and outputs to prevent information leakage.Addressed in
bf18cbaby extending the unauthorized/reviews/citest to assert neither the configured action token nor the rejected bearer token appears in the response body, while still proving no Forgejo fetch or dispatch occurs.Reflection/classification: one-off coverage gap. The handler already returned a generic
unauthorizedresponse and hid upstream Forgejo bodies, but the no-token-leak guarantee needed explicit regression coverage.This PR introduces a new CI-triggered review dispatch endpoint in the
ar-gatewaycrate, allowing Forgejo Actions to request semantic reviews after CI checks pass. The implementation appears robust, with appropriate validation and tests, but could benefit from additional documentation and logging for better maintainability and debugging.Walkthrough
AR_CI_REVIEW_TOKENbut lacks details on token strength requirements.ci_review_endpointtoAppStateand a method to configure it. Documentation is sparse.handle_ci_reviewfunction with constant-time token comparison. Logging for authorization failures could be improved.Pre-merge checks
Linters
@auto-review re-review
@auto_review re-review
Queued a fresh review at
bf18cbaa6c. Watch the commit-status badge for progress.Queued a fresh review at
bf18cbaa6c. Watch the commit-status badge for progress.This PR introduces a new CI-triggered review dispatch endpoint in the
ar-gatewaycrate, allowing Forgejo Actions to trigger semantic reviews after CI checks pass. The implementation includes security measures such as token validation and PR state verification. Ensure that sensitive tokens are securely managed and not exposed in logs.Walkthrough
New CI-triggered Review Endpoint
POST /reviews/ciendpoint inar-gatewayto allow Forgejo Actions to trigger reviews.AR_CI_REVIEW_TOKEN) and verifies the current PR head SHA before dispatching a review job.Security Considerations
AR_CI_REVIEW_TOKENis a critical security token and should be handled with care to prevent exposure.Documentation Updates
Pre-merge checks
Linters
@ -682,3 +706,49 @@ fn autodetect_oci_runtime() -> String {}🔴 Error: The
validate_ci_review_tokenfunction should ensure that the token is not logged or exposed in error messages to prevent accidental leakage.Addressed in
217f55fby adding external regression coverage incrates/ar-gateway/tests/ci_review_secrets.rsfor CI review secret hygiene. The new test asserts unauthorized/reviews/ciresponses and captured logs do not contain either the configured action token or the rejected bearer token, and still stop before Forgejo fetch/dispatch.Reflection/classification: one-off coverage/presentation gap. The implementation and existing unit test already avoided echoing the token, but the no-response/no-log property needed visible integration-level coverage for the review thread; no durable guardrail change is warranted.
@ -685,0 +725,4 @@#[test]fn ci_review_token_accepts_strong_random_value() {let token = "0123456789abcdef0123456789abcdef".to_string();🔴 Error: Ensure that any sensitive information, such as API keys or tokens, is not logged or exposed in error messages to prevent accidental leakage.
Addressed in
217f55fwith a real integration test file covering secret hygiene around the CI review endpoint. The token-like values in tests are synthetic fixtures, and the assertions now prove they are not returned or logged during authorization failures.Reflection/classification: one-off coverage gap rather than a guardrail gap. The missing piece was explicit external regression coverage, not a missing always-loaded rule.
This PR introduces a new CI-triggered review endpoint in the
ar-gatewaycrate, allowing Forgejo Actions to request semantic reviews after CI checks pass. The implementation appears robust, with appropriate validation and security measures, but ensure that error handling and logging do not expose sensitive information.Walkthrough
POST /reviews/ciendpoint inar-gateway.AR_CI_REVIEW_TOKEN) for authentication.Pre-merge checks
Linters
🟡 Warning: Lines 682–706: Ensure that the error message for a short
AR_CI_REVIEW_TOKENdoes not expose any part of the token value, as this could be a security risk.Covered by the existing
ci_review_token_rejects_short_non_empty_valueunit test and reinforced in217f55fwith external CI review secret-hygiene tests. The shortAR_CI_REVIEW_TOKENvalidation error names the env var and strength requirement without echoing the rejected token value.Reflection/classification: one-off coverage/presentation gap. The behavior was correct, but the security property was not obvious enough to the reviewer/tooling until pinned with explicit regression assertions.
🟡 Warning: Lines 492–573: Ensure that the
handle_ci_reviewfunction's error responses do not leak sensitive information, especially in the case of authorization failures or upstream errors.Addressed in
217f55fby addingcrates/ar-gateway/tests/ci_review_secrets.rs. It captures the gateway logs while exercising unauthorized and upstream-failure/reviews/cipaths, then asserts neither action tokens, Forgejo API tokens, nor upstream sensitive bodies appear in responses or logs, and that no dispatch occurs.Reflection/classification: one-off coverage gap. The handler already returned generic errors, but log hygiene for these paths needed explicit integration-level regression coverage.
This PR introduces a new CI-triggered review dispatch endpoint in the gateway, allowing Forgejo Actions to trigger semantic reviews after CI checks pass. The implementation appears robust with proper validation and error handling, but ensure no sensitive information is exposed in the codebase.
Walkthrough
POST /reviews/ciendpoint to allow Forgejo Actions to trigger reviews.AR_CI_REVIEW_TOKENmust be a strong token, and the code includes checks to ensure it is not too short.Pre-merge checks
Linters
🟡 Warning: The
AR_CI_REVIEW_TOKENshould be a strong token of at least 32 characters to ensure security. Consider adding a validation check for this in the documentation or setup scripts.Addressed in
869e367by clarifying the operator-facing docs:QUICKSTART.mdandcrates/ar-gateway/README.mdnow state thatAR_CI_REVIEW_TOKENmust be generated independently fromWEBHOOK_SECRETwith at least 32 random bytes/chars. The startup validation for short values was already present and covered byci_review_token_rejects_short_non_empty_value.Reflection/classification: one-off documentation drift. The runtime check existed, but two docs surfaces did not state the exact strength requirement; no new guardrail is warranted because the existing operator docs/examples already include the setup pattern.
This PR introduces a new CI-triggered review dispatch endpoint in the
ar-gatewaycrate, allowing Forgejo Actions to request semantic reviews after CI checks pass. The implementation appears robust, with proper validation and security measures, and includes comprehensive documentation and tests. However, ensure no sensitive information is exposed in logs or code.Walkthrough
AR_CI_REVIEW_TOKENenvironment variable.CiReviewEndpointDepsand updatedAppStateto include the new endpoint dependencies.AR_CI_REVIEW_TOKEN.handle_ci_reviewfunction to process CI-triggered review requests, including validation and dispatch logic.Pre-merge checks
Linters
AR not yet submitting APPROVE status even though no new findings. Ticket #52 will fix this.