-
-
Notifications
You must be signed in to change notification settings - Fork 729
Add the sha256 digest to the deployment image reference #1673
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
Conversation
|
WalkthroughThis pull request refines the deployment finalization process in the web application's deployment service. It modifies the Prisma query to retrieve only specific fields (status, id, version, externalBuildData) and introduces robust error handling to validate external build data. A new function, Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Deployment Caller
participant FDS as FinalizeDeploymentV2Service
participant EX as extractImageDigest Function
participant DB as Database (Prisma)
Caller->>FDS: Call finalize deployment
FDS->>DB: Query deployment data (select status, id, version, externalBuildData)
DB-->>FDS: Return deployment data
FDS->>FDS: Validate externalBuildData
alt Valid externalBuildData
FDS->>EX: Extract image digest from imageReference
EX-->>FDS: Return image digest
FDS->>FDS: Construct fullImage (with digest)
FDS->>DB: Finalize deployment with fullImage
else Invalid externalBuildData
FDS-->>Caller: Throw ServiceValidationError
end
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
apps/webapp/app/v3/services/finalizeDeploymentV2.server.tsOops! Something went wrong! :( ESLint: 8.45.0 ESLint couldn't find the config "custom" to extend from. Please check that the name of the config is correct. The config "custom" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. ✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 3
🧹 Nitpick comments (1)
apps/webapp/app/v3/services/finalizeDeploymentV2.server.ts (1)
144-156
: EnhanceextractImageDigest
function for robustnessThe current implementation may not handle all edge cases. Using a regular expression can improve reliability in extracting the digest from the image reference.
Apply this diff to improve the function:
function extractImageDigest(image: string) { - const digestIndex = image.lastIndexOf("@"); - - if (digestIndex === -1) { - return; - } - - return image.substring(digestIndex + 1); + const match = image.match(/@(?<digest>sha256:[a-f0-9]{64})$/); + return match?.groups?.digest; }Consider adding unit tests to validate this function with various image reference formats.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/webapp/app/v3/services/finalizeDeploymentV2.server.ts
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: units / 🧪 Unit Tests
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- GitHub Check: typecheck / typecheck
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
apps/webapp/app/v3/services/finalizeDeploymentV2.server.ts (2)
31-35
: Query optimization withselect
clause looks goodReplacing the
include
clause with aselect
clause to explicitly retrieve fields enhances query performance by fetching only the necessary data.
90-91
:⚠️ Potential issueValidate
body.imageReference
to prevent security risksExtracting the digest from
body.imageReference
without validation may introduce security vulnerabilities if the input is manipulated. Ensure thatbody.imageReference
is properly validated and corresponds to the expected image.Consider verifying that the extracted digest matches the digest of the pushed image to ensure integrity.
Summary by CodeRabbit