Repository navigation
Conversation
…th 7-day cookie persistence
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Lathiya50
left a comment
There was a problem hiding this comment.
🤖 CodeReviewAI
The pull request introduces a persistent session feature for user authentication, automatic PR review on push, and other improvements. The changes include updates to the .env.example file, package.json, and pnpm-lock.yaml. The risk score is 60 due to the introduction of new features and dependencies.
The pull request implements a persistent session feature for user authentication, including changes to the Prisma schema, sign-in and sign-up pages, and the dashboard repository page.
The pull request introduces a persistent session feature for user authentication with GitHub. It includes changes to the webhook verification process, repository management, and session configuration. The code is generally well-structured, but there are some minor issues and suggestions for improvement.
This pull request implements a persistent session feature for user authentication with GitHub. It introduces a new function to create a GitHub PR review and adds an auto-post feature for webhook-originated reviews. The code also includes a new service to register and manage repository webhooks. Overall, the changes are well-structured and follow good practices, but there are some potential issues and improvements to be made.
15 inline comment(s) posted, 1 skipped (outside diff range)
| @@ -2,7 +2,11 @@ APP_DOMAIN="app.example.com" | |||
| DATABASE_URL="postgresql://user:password@localhost:5432/mydatabase" # Replace with your actual database URL | |||
|
|
|||
There was a problem hiding this comment.
🟡 MEDIUM — security
The BETTER_AUTH_SECRET should be a strong secret key and not hardcoded in the .env.example file.
💡 Suggestion: Use environment variables or a secrets manager to store sensitive keys.
| # here to auto-register hooks and post reviews. For local dev, expose your | ||
| # server with a tunnel (e.g. cloudflared / ngrok) and use that URL; GitHub | ||
| # cannot reach http://localhost. | ||
| BETTER_AUTH_URL="https://app.example.com" |
There was a problem hiding this comment.
🟡 MEDIUM — security
The GH_WEBHOOK_SECRET should be a strong secret key and not hardcoded in the .env.example file.
💡 Suggestion: Use environment variables or a secrets manager to store sensitive keys.
| @@ -25,7 +25,7 @@ | |||
| "class-variance-authority": "^0.7.1", | |||
There was a problem hiding this comment.
⚪ LOW — style
The inngest version has been updated from 3.52.1 to 3.54.0.
💡 Suggestion: Ensure that the updated version is compatible with the existing codebase.
| @@ -5,10 +5,13 @@ An intelligent AI-powered code review platform that automatically analyzes GitHu | |||
| ## Features | |||
There was a problem hiding this comment.
⚪ LOW — style
The README.md file has been updated with new features and explanations.
💡 Suggestion: Review the updated content for accuracy and clarity.
| @@ -90,10 +90,29 @@ model Repository { | |||
| createdAt DateTime @default(now()) | |||
There was a problem hiding this comment.
🟡 MEDIUM — style
The new fields added to the Repository model should be documented with a description of their purpose.
💡 Suggestion: Add comments to explain the purpose of the new fields.
| * When no secret is available the request is allowed through (legacy behaviour | ||
| * for hooks configured before per-repo secrets existed). | ||
| */ | ||
| function verifySignature( |
There was a problem hiding this comment.
🟡 MEDIUM — performance
The verifySignature function is using crypto.timingSafeEqual which can be slow for large inputs. Consider using a faster alternative.
💡 Suggestion: Use a faster alternative like crypto.timingSafeEqual with a smaller input size or a different algorithm.
| @@ -33,6 +33,10 @@ export const auth = betterAuth({ | |||
| }, | |||
| }, | |||
There was a problem hiding this comment.
🟡 MEDIUM — security
The session configuration has a hardcoded session lifetime of 7 days. Consider making this configurable.
💡 Suggestion: Make the session lifetime configurable by adding an environment variable or a configuration option.
|
|
||
| /** | ||
| * Finds an existing repository webhook whose delivery URL matches `url`. | ||
| * Returns the hook id, or null if none is found / the lookup fails. |
There was a problem hiding this comment.
🟡 MEDIUM — performance
The findRepoWebhook function fetches all repository hooks and iterates over them to find a match. This could be inefficient if there are many hooks. Consider using a more efficient approach, such as using the hook.id in the URL to fetch a specific hook.
💡 Suggestion: Use a more efficient approach to find the repository webhook.
|
|
||
| if (!response.ok) return null; | ||
|
|
||
| const hooks = (await response.json()) as GitHubHook[]; |
There was a problem hiding this comment.
🟡 MEDIUM — security
The registerRepoWebhook function does not handle errors properly. If the webhook registration fails, it does not update the error message. Consider adding proper error handling to ensure that the error message is updated correctly.
💡 Suggestion: Add proper error handling to update the error message.
| @@ -32,7 +37,8 @@ export const reviewPR = inngest.createFunction( | |||
| }, | |||
| { event: "review/pr.requested" }, | |||
| async ({ event, step }) => { | |||
There was a problem hiding this comment.
🟡 MEDIUM — performance
The reviewPR function uses async/await to run the update-status-processing step. However, it does not handle errors properly. If the step fails, it does not update the error message. Consider adding proper error handling to ensure that the error message is updated correctly.
💡 Suggestion: Add proper error handling to update the error message.
Lathiya50
left a comment
There was a problem hiding this comment.
🤖 CodeReviewAI
The pull request implements a persistent session feature for user authentication, automatic PR review on push, and automatic webhook setup. It also updates the Inngest version to 3.54.0.
The pull request implements a persistent session feature for user authentication, adds webhook and automation settings for connected repositories, and updates the sign-in and sign-up pages to include a 'remember me' option.
Persistent session feature for user authentication with GitHub webhooks
This pull request implements a persistent session feature for user authentication with GitHub, enabling auto-posting of reviews back to the PR. The changes introduce a new function createGitHubPRReview and modify the reviewPR function to handle webhook-originated reviews. The code also includes a new service github.ts with functions for managing repository webhooks.
18 inline comment(s) posted, 2 skipped (outside diff range)
| @@ -0,0 +1,16 @@ | |||
| { | |||
There was a problem hiding this comment.
🟡 MEDIUM — security
The permissions in the settings file should be reviewed to ensure they are not too permissive.
💡 Suggestion: Review the permissions to ensure they are necessary and not too permissive.
|
|
||
| BETTER_AUTH_SECRET="supersecretkey" # Replace with a strong secret key | ||
| BETTER_AUTH_URL="https://app.example.com" # Base URL of your app | ||
| # Base URL of your app. MUST be a public HTTPS URL — GitHub delivers webhooks |
There was a problem hiding this comment.
🟡 MEDIUM — security
The BETTER_AUTH_SECRET should be a strong secret key and not hardcoded.
💡 Suggestion: Use an environment variable or a secrets manager to store the secret key.
|
|
||
| # Optional override for the GitHub webhook endpoint origin. If set, webhooks are | ||
| # registered against this URL instead of the app URL above. Use it in local dev | ||
| # to point GitHub at a public HTTPS tunnel (e.g. ngrok) while BETTER_AUTH_URL / |
There was a problem hiding this comment.
🟡 MEDIUM — security
The GH_WEBHOOK_SECRET should be a strong secret key and not hardcoded.
💡 Suggestion: Use an environment variable or a secrets manager to store the secret key.
| @@ -25,7 +25,7 @@ | |||
| "class-variance-authority": "^0.7.1", | |||
There was a problem hiding this comment.
⚪ LOW — style
The Inngest version has been updated to 3.54.0.
💡 Suggestion: Ensure that the updated version is compatible with the existing codebase.
| @@ -5,10 +5,13 @@ An intelligent AI-powered code review platform that automatically analyzes GitHu | |||
| ## Features | |||
There was a problem hiding this comment.
⚪ LOW — style
The features list has been updated to include automatic PR review on push and automatic webhook setup.
💡 Suggestion: Review the features list to ensure it is accurate and up-to-date.
| config?: { url?: string }; | ||
| } | ||
|
|
||
| const WEBHOOK_EVENTS = ["pull_request"] as const; |
There was a problem hiding this comment.
🟡 MEDIUM — security
The fetch function is used without a AbortController to handle potential network errors. Consider using AbortController to improve error handling.
💡 Suggestion: Use AbortController to handle potential network errors.
| repo: string, | ||
| url: string, | ||
| ): Promise<bigint | null> { | ||
| const response = await fetch( |
There was a problem hiding this comment.
🟡 MEDIUM — security
The fetch function is used without a AbortController to handle potential network errors. Consider using AbortController to improve error handling.
💡 Suggestion: Use AbortController to handle potential network errors.
|
|
||
| const hooks = (await response.json()) as GitHubHook[]; | ||
| const match = hooks.find((hook) => hook.config?.url === url); | ||
| return match ? BigInt(match.id) : null; |
There was a problem hiding this comment.
🟡 MEDIUM — security
The fetch function is used without a AbortController to handle potential network errors. Consider using AbortController to improve error handling.
💡 Suggestion: Use AbortController to handle potential network errors.
| @@ -121,6 +127,42 @@ export const reviewPR = inngest.createFunction( | |||
| }); | |||
There was a problem hiding this comment.
🟡 MEDIUM — performance
The db.review.update function is called multiple times in the reviewPR function. Consider batching updates to improve performance.
💡 Suggestion: Batch updates to improve performance.
| const result = await createGitHubPRReview( | ||
| accessToken, | ||
| owner, | ||
| repo, |
There was a problem hiding this comment.
🟡 MEDIUM — performance
The db.review.update function is called multiple times in the reviewPR function. Consider batching updates to improve performance.
💡 Suggestion: Batch updates to improve performance.
Lathiya50
left a comment
There was a problem hiding this comment.
🤖 CodeReviewAI
The pull request implements a persistent session feature for user authentication, including auto-review on push and automatic webhook setup. The changes include updates to the .env.example file, README.md, and package.json. The risk score is 60 due to potential security issues with the new features.
The pull request introduces a persistent session feature for user authentication, including changes to the Prisma schema, sign-in and sign-up pages, and the dashboard repos page. The changes aim to improve user experience and automate review and posting processes.
This pull request implements a persistent session feature for user authentication with GitHub. It introduces a new verifySignatureAgainstSecrets function to verify GitHub HMAC signatures against multiple secrets, including per-repo secrets. The code also includes improvements to the repositoryRouter and auth configurations. Overall, the changes enhance the security and functionality of the GitHub integration.
Persistent session feature for user authentication with GitHub.
This PR introduces a new feature to auto-post reviews back to GitHub for webhook-originated reviews.
However, there are some security concerns and code style issues that need to be addressed.
15 inline comment(s) posted, 1 skipped (outside diff range)
| @@ -2,16 +2,31 @@ APP_DOMAIN="app.example.com" | |||
| DATABASE_URL="postgresql://user:password@localhost:5432/mydatabase" # Replace with your actual database URL | |||
|
|
|||
There was a problem hiding this comment.
🟡 MEDIUM — security
The BETTER_AUTH_SECRET should be a strong secret key and not hardcoded in the .env.example file.
💡 Suggestion: Use environment variables or a secrets manager to store sensitive keys.
| # cannot reach http://localhost. | ||
| BETTER_AUTH_URL="https://app.example.com" | ||
| NEXT_PUBLIC_APP_URL="https://app.example.com" | ||
|
|
There was a problem hiding this comment.
🟡 MEDIUM — security
The GH_WEBHOOK_SECRET should be a strong secret key and not hardcoded in the .env.example file.
💡 Suggestion: Use environment variables or a secrets manager to store sensitive keys.
| @@ -25,7 +25,7 @@ | |||
| "class-variance-authority": "^0.7.1", | |||
There was a problem hiding this comment.
⚪ LOW — style
The inngest version has been updated from 3.52.1 to 3.54.0.
💡 Suggestion: Verify that the updated version is compatible with the existing codebase.
| @@ -90,10 +90,29 @@ model Repository { | |||
| createdAt DateTime @default(now()) | |||
There was a problem hiding this comment.
🟡 MEDIUM — style
The added fields and enums are not following a consistent naming convention.
💡 Suggestion: Use a consistent naming convention throughout the schema.
| @@ -5,7 +5,6 @@ import Link from "next/link"; | |||
| import { useRouter, useSearchParams } from "next/navigation"; | |||
There was a problem hiding this comment.
⚪ LOW — style
The removed import statement for Checkbox is not used anywhere in the file.
💡 Suggestion: Remove unused import statements to improve code readability.
| @@ -23,7 +23,11 @@ export const auth = betterAuth({ | |||
| github: { | |||
| clientId: process.env.GH_CLIENT_ID ?? "", | |||
| clientSecret: process.env.GH_CLIENT_SECRET ?? "", | |||
There was a problem hiding this comment.
🟡 MEDIUM — security
The auth configuration now includes the admin:repo_hook scope, which is required for creating and updating per-repo PR webhooks. However, this scope is not explicitly mentioned in the commit message or documentation.
💡 Suggestion: Add a note in the commit message or documentation to explain the addition of the admin:repo_hook scope.
| } | ||
|
|
||
| const WEBHOOK_EVENTS = ["pull_request"] as const; | ||
|
|
There was a problem hiding this comment.
🟠 HIGH — security
Insecure use of BigInt for hook ID. Consider using a safer approach.
💡 Suggestion: Use a safer approach to handle hook IDs, such as using a string or a number.
| repo: string, | ||
| url: string, | ||
| ): Promise<bigint | null> { | ||
| const response = await fetch( |
There was a problem hiding this comment.
🟡 MEDIUM — style
Consider using a more descriptive variable name instead of status.
💡 Suggestion: Use a more descriptive variable name to improve code readability.
| @@ -32,7 +37,8 @@ export const reviewPR = inngest.createFunction( | |||
| }, | |||
There was a problem hiding this comment.
🟡 MEDIUM — performance
Consider using a more efficient approach to update the review status.
💡 Suggestion: Use a more efficient approach to update the review status, such as using a single database query.
| const { reviewId, repositoryId, prNumber, userId, autoPost, postEvent } = | ||
| event.data; | ||
|
|
||
| await step.run("update-status-processing", async () => { |
There was a problem hiding this comment.
🟡 MEDIUM — style
Consider using a more consistent naming convention for function parameters.
💡 Suggestion: Use a more consistent naming convention for function parameters to improve code readability.
Lathiya50
left a comment
There was a problem hiding this comment.
🤖 CodeReviewAI
The pull request implements a persistent session feature for user authentication, including auto-review on push and automatic webhook setup. The changes include updates to the .env.example file, README.md, and package.json. The risk score is 60 due to potential security issues with the new features.
The pull request introduces a persistent session feature for user authentication, including changes to the Prisma schema, sign-in and sign-up pages, and the dashboard repos page. The changes aim to improve user experience and automate review and posting processes.
This pull request implements a persistent session feature for user authentication with GitHub. It introduces a new verifySignatureAgainstSecrets function to verify GitHub HMAC signatures against multiple secrets, including per-repo secrets. The code also includes improvements to the repositoryRouter and auth configurations. Overall, the changes enhance the security and functionality of the GitHub integration.
Persistent session feature for user authentication with GitHub.
This PR introduces a new feature to auto-post reviews back to GitHub for webhook-originated reviews.
However, there are some security concerns and code style issues that need to be addressed.
1 inline comment(s) posted
| @@ -2,16 +2,31 @@ APP_DOMAIN="app.example.com" | |||
| DATABASE_URL="postgresql://user:password@localhost:5432/mydatabase" # Replace with your actual database URL | |||
|
|
|||
There was a problem hiding this comment.
🟡 MEDIUM — security
The BETTER_AUTH_SECRET should be a strong secret key and not hardcoded in the .env.example file.
💡 Suggestion: Use environment variables or a secrets manager to store sensitive keys.
… derive legacy flags
…th 7-day cookie persistence