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

feat(wren-ui): Added FE Support for MySQL SSL Connection #1072

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ongdisheng
Copy link
Contributor

@ongdisheng ongdisheng commented Dec 29, 2024

Description

This PR introduces SSL connection handling for MySQL data source by adding a Select menu and an Upload component for Certificate Authority (CA) Certificate in the setup form. Meanwhile, existing logic has also been modified to include these fields when passing connection info to the engine. Fix #886

UI Screenshot

  1. When a client who requires SSL uploads the necessary CA certificate (VERIFY_CA), the connection succeeds:
  1. When a client who requires SSL attempts to connect without uploading CA certificate, the connection fails:

Summary by CodeRabbit

  • New Features

    • Added SSL configuration options for MySQL connections.
    • Introduced SSL mode selection (DISABLED, ENABLED, VERIFY_CA).
    • Implemented SSL certificate upload functionality for MySQL data sources.
  • Improvements

    • Enhanced security configuration for database connections.
    • Added more granular SSL certificate handling in the UI.
  • Documentation

    • Updated error messages for SSL certificate requirements.

Copy link
Contributor

coderabbitai bot commented Dec 29, 2024

Walkthrough

The pull request introduces comprehensive SSL configuration support for MySQL data sources across the Wren UI application. The changes span multiple files, adding new enumerations for SSL modes, updating connection information interfaces, and enhancing the MySQL properties component to support SSL certificate uploads. The modifications enable users to configure different SSL modes (DISABLED, ENABLED, VERIFY_CA) and upload SSL certificates when needed.

Changes

File Change Summary
wren-ui/src/apollo/server/types/sslMode.ts Added SSLMode enum with DISABLED, ENABLED, and VERIFY_CA modes
wren-ui/src/utils/enum/sslMode.ts Added SSL_MODE enum with matching SSL mode constants
wren-ui/src/apollo/server/repositories/projectRepository.ts Extended MYSQL_CONNECTION_INFO interface with sslMode and optional sslCA
wren-ui/src/apollo/server/dataSource.ts Updated MySQL data source to handle SSL configuration and sensitive properties
wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx Added SSL mode selection and certificate upload functionality
wren-ui/src/utils/error/dictionary.ts Added SSL certificate required error message

Assessment against linked issues

Objective Addressed Explanation
Add SSL configuration for MySQL
Support different SSL modes
Enable SSL certificate upload

Poem

🐰 A rabbit's tale of MySQL's SSL dance,
Certificates uploaded with careful glance,
Modes of security, VERIFY and ENABLED,
Connections now safer, no need to be troubled!
SSL magic sprinkled with coding delight 🔒


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ongdisheng
Copy link
Contributor Author

ongdisheng commented Dec 29, 2024

Hi, I’m exploring ways to allow users to select a file from their local system and display its absolute file path, instead of typing the path into the input box themselves. I’ve looked into the Ant Design Upload component, but it appears to only display the file name due to browser security restrictions. I’d greatly appreciate any suggestions or alternative approaches. Thank you! 😊

@ongdisheng ongdisheng closed this Dec 31, 2024
@wwwy3y3
Copy link
Member

wwwy3y3 commented Dec 31, 2024

hi @ongdisheng any reason you close this PR ? looks like a good contribution to me!

I'm thinking we should provide some options for users to pick instead of a Use SSL toggle. Just some quick thoughts:

SSL Mode
ref: https://dev.mysql.com/doc/refman/8.4/en/connection-options.html#option_general_ssl-mode

  • DISABLED: Establish an unencrypted connection.
  • REQUIRED: Establish an encrypted connection if the server supports encrypted connections. The connection attempt fails if an encrypted connection cannot be established.
  • VERIFY_CA: Like REQUIRED, but additionally verify the server Certificate Authority (CA) certificate against the configured CA certificates. The connection attempt fails if no valid matching CA certificates are found.

If users choose VERIFY_CA, we then show the upload inputs for them to upload CA.

cc @fredalai @andreashimin @onlyjackfrost chime in if you guys want.

I think you might want to work on some implementation on backend as well.

@ongdisheng ongdisheng reopened this Dec 31, 2024
@ongdisheng
Copy link
Contributor Author

Hi @wwwy3y3, thank you for the feedback! I closed the PR earlier as I felt the current implementation wasn't quite up to the mark. I’ve reopened it as a draft and will continue working on it 😊.

@ongdisheng ongdisheng force-pushed the issue-886 branch 2 times, most recently from 0b6a2d3 to 1ea9289 Compare January 3, 2025 14:39
@ongdisheng ongdisheng marked this pull request as ready for review January 3, 2025 15:02
@ongdisheng ongdisheng changed the title feat(wren-ui): Added support for MySQL SSL connection feat(wren-ui): Added FE Support for MySQL SSL Connection Jan 3, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (7)
wren-ui/src/apollo/server/types/index.ts (1)

7-7: Leverage strongly-typed imports for maintainability.

Exporting everything from ./sslMode is a valid approach for quick bundling. However, if the file grows, consider explicitly re-exporting only what's needed to maintain clarity and ensure only intended types or utilities are exposed.

wren-ui/src/utils/error/dictionary.ts (1)

52-54: Provide additional clarity for SSL certificate requirements.

The new SSL_CERT.REQUIRED message is straightforward. To further assist users, consider including details on valid file formats or maximum file sizes (if applicable). This can reduce confusion about acceptable certificate files during upload.

wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx (2)

13-63: Consider improving file upload error handling and applying optional chaining.
The UploadSSL component is well-structured, but there are points you might refine:

  1. Potential file-read failures: The readFileContent function does not handle errors. Consider adding reader.onerror to handle read failures gracefully.
  2. Optional chaining: Instead of using onChange && onChange(...) at lines 41 and 49, you can use optional chaining (onChange?.(...)) in TypeScript/modern JS for cleaner code.
  3. File size or type checks: If large or invalid files are a concern, consider validating them in the onUploadChange event.

Below is a suggested diff snippet for optional chaining:

-  onChange && onChange(fileContent);
+  onChange?.(fileContent);
-  onChange && onChange(undefined);
+  onChange?.(undefined);
🧰 Tools
🪛 Biome (1.9.4)

[error] 41-41: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 49-49: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


149-176: Enhance user guidance and default behaviors for SSL mode.

  1. User feedback: When users select a mode other than DISABLE, consider giving tooltips or descriptions to clarify what REQUIRE vs. VERIFY_CA does.
  2. Conditional display: The conditional rendering for sslCA is correct but ensure it matches any server constraints (e.g., do you also need a client certificate or key?).
  3. Preview uploaded file: If needed, allow users to confirm they uploaded the correct SSL certificate by showing a truncated snippet of file content or the file name.

Would you like help implementing additional user feedback or advanced upload validations?

wren-ui/src/apollo/server/dataSource.ts (1)

111-125: Verify base64 encoding and SSL property usage.
This block correctly includes sslMode and optionally base64-encodes sslCA before returning. A few considerations:

  • Condition checks: If you add more SSL-related fields (e.g., sslKey or sslCert) in the future, ensure consistent logic for each field.
  • Validate usage: Confirm that downstream code expects a base64 string for sslCA.
wren-ui/src/apollo/server/adaptors/tests/ibisAdaptor.test.ts (2)

48-49: Clarify SSL usage in test data.
You’ve specified sslMode: SSLMode.VERIFY_CA and sslCA: 'encrypted-certificate-string'. Make sure tests also cover other modes for completeness (e.g., SSLMode.DISABLE, SSLMode.REQUIRE).


191-202: Check for consistent property naming and transformations.
Here, you map sslCA to sslCA (base64-encoded). For uniformity, confirm that other SSL props (e.g., sslKey) follow a similar approach to keep your code symmetrical.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8933479 and 1ea9289.

📒 Files selected for processing (9)
  • wren-ui/src/apollo/server/adaptors/tests/ibisAdaptor.test.ts (3 hunks)
  • wren-ui/src/apollo/server/dataSource.ts (1 hunks)
  • wren-ui/src/apollo/server/repositories/projectRepository.ts (1 hunks)
  • wren-ui/src/apollo/server/types/index.ts (1 hunks)
  • wren-ui/src/apollo/server/types/sslMode.ts (1 hunks)
  • wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx (2 hunks)
  • wren-ui/src/utils/enum/index.ts (1 hunks)
  • wren-ui/src/utils/enum/sslMode.ts (1 hunks)
  • wren-ui/src/utils/error/dictionary.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • wren-ui/src/apollo/server/types/sslMode.ts
  • wren-ui/src/utils/enum/sslMode.ts
🧰 Additional context used
🪛 Biome (1.9.4)
wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx

[error] 41-41: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 49-49: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (6)
wren-ui/src/utils/enum/index.ts (1)

10-10: Centralize enum usage.

Similarly, re-exporting all from sslMode makes the enum easily accessible throughout the codebase. As the codebase evolves, ensure repeated or conflicting enum definitions are consolidated to maintain consistency.

wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx (2)

1-6: Ensure consistent import usage and check for unused imports.
These imports look fine for the newly introduced features, such as Upload and Ant Design icons. Verify that each imported item (e.g., Button, Select) is actually used in this file.


68-69: Ensure SSL mode state updates are fully validated.
The sslMode state and onSSLModeChange function are straightforward. Double-check that all form validations (e.g., required certificates on certain modes) are handled or triggered consistently in your parent form logic.

wren-ui/src/apollo/server/dataSource.ts (1)

105-105: Add an extra safeguard for sensitive properties.
By adding sslCA to sensitiveProps, you ensure that it will be encrypted at rest. Confirm that your logs or error outputs do not inadvertently display sslCA values in plaintext.

wren-ui/src/apollo/server/adaptors/tests/ibisAdaptor.test.ts (2)

9-9: Consolidate or differentiate imports as needed.
The new SSLMode import is straightforward. If multiple modules import the same enumerations, ensure they reference a shared location for consistency.


181-184: Consider verifying decryption fails gracefully if sslCA is invalid.
Currently, you mock decryption to always succeed with an sslCA string. Test how your code behaves if decryption fails or the certificate data is malformed.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (4)
wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx (4)

18-20: Prevent potential memory leaks in useEffect

The useEffect hook should clean up the file list state when the component unmounts.

 useEffect(() => {
   if (!value) setFileList([]);
+  return () => setFileList([]);
 }, [value]);

36-50: Improve error handling and use optional chaining

The callback handling in onUploadChange and onRemove could be improved with optional chaining and better error handling.

 const onUploadChange = (info) => {
   const { file, fileList } = info;
   if (fileList.length) {
     const uploadFile = fileList[0];
+    if (!file.originFileObj) {
+      console.error('File object is missing');
+      return;
+    }
     readFileContent(file.originFileObj, (fileContent: string) => {
-      onChange && onChange(fileContent);
+      onChange?.(fileContent);
     });
     setFileList([uploadFile]);
   }
 };

 const onRemove = () => {
   setFileList([]);
-  onChange && onChange(undefined);
+  onChange?.(undefined);
 };
🧰 Tools
🪛 Biome (1.9.4)

[error] 41-41: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 49-49: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


53-62: Enhance file type validation and user feedback

The current file type validation could be improved with more comprehensive checks and better user feedback.

 <Upload
   accept=".pem,.crt,.key"
   fileList={fileList}
   onChange={onUploadChange}
   onRemove={onRemove}
   maxCount={1}
+  beforeUpload={(file) => {
+    const isValidType = ['.pem', '.crt', '.key'].some(ext => 
+      file.name.toLowerCase().endsWith(ext)
+    );
+    if (!isValidType) {
+      message.error('Please upload a valid SSL certificate file');
+    }
+    return isValidType || Upload.LIST_IGNORE;
+  }}
 >
   <Button icon={<UploadOutlined />}>Click to upload SSL cert file</Button>
 </Upload>

68-69: Consider deriving SSL mode from Form.Item

Instead of maintaining a separate state for SSL mode, consider using Form's internal state management.

- const [sslMode, setSSLMode] = useState<string>(SSL_MODE.DISABLED);
- const onSSLModeChange = (value: string) => setSSLMode(value)
+ const [form] = Form.useForm();
+ const sslMode = Form.useWatch('sslMode', form) || SSL_MODE.DISABLED;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 226eee2 and 342b8c4.

📒 Files selected for processing (3)
  • wren-ui/src/apollo/server/types/sslMode.ts (1 hunks)
  • wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx (2 hunks)
  • wren-ui/src/utils/enum/sslMode.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx

[error] 41-41: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 49-49: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (1)
wren-ui/src/utils/enum/sslMode.ts (1)

1-5: Duplicate enum addressed in previous comment

Comment on lines +1 to +5
export enum SSLMode {
DISABLED = 'disabled',
ENABLED = 'enabled',
VERIFY_CA = 'verify_ca',
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider consolidating duplicate SSL mode enums

There appears to be duplicate SSL mode enums in both apollo/server/types/sslMode.ts and utils/enum/sslMode.ts. Consider consolidating these into a single shared enum to maintain a single source of truth.

I can help propose a solution to consolidate these enums if you'd like.

Comment on lines +13 to +14
const UploadSSL = (props) => {
const { onChange, value } = props;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add TypeScript interface for component props

The UploadSSL component lacks a proper TypeScript interface for its props. This could lead to type-related issues.

Add a props interface:

interface UploadSSLProps {
  onChange?: (value: string | undefined) => void;
  value?: string;
}

const UploadSSL = (props: UploadSSLProps) => {

Comment on lines +149 to +176
<Form.Item label="SSL mode" name="sslMode" initialValue={SSL_MODE.DISABLED}>
<Select
style={{ width: 120 }}
onChange={onSSLModeChange}
disabled={isEditMode}
options={[
{ value: SSL_MODE.DISABLED, label: 'Disabled' },
{ value: SSL_MODE.ENABLED, label: 'Enabled' },
{ value: SSL_MODE.VERIFY_CA, label: 'Verify CA' },
]}
/>
</Form.Item>
{
sslMode === SSL_MODE.VERIFY_CA &&
<Form.Item
label="SSL CA file"
name="sslCA"
required
rules={[
{
required: true,
message: ERROR_TEXTS.CONNECTION.SSL_CERT.REQUIRED,
},
]}
>
<UploadSSL />
</Form.Item>
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

SSL configuration edit mode behavior needs to be consistent

The verification confirms that while SSL mode selection is disabled in edit mode, the SSL certificate upload remains enabled, creating an inconsistent user experience. The suggested changes in the review comment would improve both consistency and user guidance:

  • Disable both SSL mode selection and certificate upload in edit mode
  • Add tooltips to explain the disabled state
  • Keep the validation rules for when the form is in create mode
🔗 Analysis chain

Improve edit mode handling for SSL configuration

The current implementation disables SSL mode selection in edit mode but allows certificate changes. Consider making this behavior consistent.

Also, consider adding a tooltip to explain why SSL mode is disabled in edit mode.

 <Form.Item label="SSL mode" name="sslMode" initialValue={SSL_MODE.DISABLED}>
   <Select
     style={{ width: 120 }}
-    onChange={onSSLModeChange}
     disabled={isEditMode}
+    tooltip={isEditMode ? "SSL mode cannot be changed after connection is created" : undefined}
     options={[
       { value: SSL_MODE.DISABLED, label: 'Disabled' },
       { value: SSL_MODE.ENABLED, label: 'Enabled' },
       { value: SSL_MODE.VERIFY_CA, label: 'Verify CA' },
     ]}
   />
 </Form.Item>
 {
   sslMode === SSL_MODE.VERIFY_CA &&
   <Form.Item
     label="SSL CA file"
     name="sslCA"
     required
+    tooltip="Upload a valid CA certificate file (.pem, .crt, or .key)"
     rules={[
       {
         required: true,
         message: ERROR_TEXTS.CONNECTION.SSL_CERT.REQUIRED,
       },
     ]}
   >
-    <UploadSSL />
+    <UploadSSL disabled={isEditMode} />
   </Form.Item>
 }
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any existing implementations of edit mode handling for SSL
rg -A 5 "mode === FORM_MODE.EDIT.*ssl" .

Length of output: 42


Script:

#!/bin/bash
# Find form mode edit usages and SSL-related code
rg "FORM_MODE.EDIT" .
echo "---"
fd -e tsx -e ts "UploadSSL" .
echo "---"
rg "const.*SSL" .

Length of output: 1973

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx (4)

9-11: Add documentation for the Props interface

Consider adding JSDoc comments to document the Props interface, especially explaining the significance of the mode parameter and its impact on form behavior.

/**
 * Props for MySQLProperties component
 * @interface Props
 * @property {FORM_MODE} [mode] - Form mode that determines if fields are editable
 */
interface Props {
  mode?: FORM_MODE;
}

22-34: Improve file reading implementation

The file reading implementation could be enhanced for better error handling and type safety.

- const readFileContent = (file: any, callback: (value: string) => void) => {
+ const readFileContent = (file: File, callback: (value: string) => void) => {
   const reader = new FileReader();
+  reader.onerror = () => {
+    console.error('Error reading file:', reader.error);
+  };
   reader.onloadend = (_e) => {
     const result = reader.result;
-    if (result) {
+    if (typeof result === 'string') {
-      const fileContent = String(result);
-      callback(fileContent);
+      callback(result);
     }
   };
   reader.readAsText(file);
 };

36-50: Use optional chaining and improve type safety

Address the static analysis suggestions and improve type safety.

- const onUploadChange = (info) => {
+ const onUploadChange = (info: { file: UploadFile; fileList: UploadFile[] }) => {
   const { file, fileList } = info;
   if (fileList.length) {
     const uploadFile = fileList[0];
     readFileContent(file.originFileObj, (fileContent: string) => {
-      onChange && onChange(fileContent);
+      onChange?.(fileContent);
     });
     setFileList([uploadFile]);
   }
 };

 const onRemove = () => {
   setFileList([]);
-  onChange && onChange(undefined);
+  onChange?.(undefined);
 };
🧰 Tools
🪛 Biome (1.9.4)

[error] 41-41: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 49-49: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


149-160: Enhance SSL mode selection UX

Add tooltips to explain different SSL modes and why they might be disabled in edit mode.

 <Form.Item label="SSL mode" name="sslMode" initialValue={SSL_MODE.DISABLED}>
   <Select
     style={{ width: 120 }}
     onChange={onSSLModeChange}
     disabled={isEditMode}
+    tooltip={isEditMode ? "SSL mode cannot be changed after connection is created" : undefined}
     options={[
-      { value: SSL_MODE.DISABLED, label: 'Disabled' },
-      { value: SSL_MODE.ENABLED, label: 'Enabled' },
-      { value: SSL_MODE.VERIFY_CA, label: 'Verify CA' },
+      { 
+        value: SSL_MODE.DISABLED, 
+        label: 'Disabled',
+        title: 'No SSL encryption for connection'
+      },
+      { 
+        value: SSL_MODE.ENABLED, 
+        label: 'Enabled',
+        title: 'Use SSL encryption without certificate verification'
+      },
+      { 
+        value: SSL_MODE.VERIFY_CA, 
+        label: 'Verify CA',
+        title: 'Use SSL encryption with certificate verification'
+      },
     ]}
   />
 </Form.Item>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 342b8c4 and b121174.

📒 Files selected for processing (9)
  • wren-ui/src/apollo/server/adaptors/tests/ibisAdaptor.test.ts (3 hunks)
  • wren-ui/src/apollo/server/dataSource.ts (1 hunks)
  • wren-ui/src/apollo/server/repositories/projectRepository.ts (2 hunks)
  • wren-ui/src/apollo/server/types/index.ts (1 hunks)
  • wren-ui/src/apollo/server/types/sslMode.ts (1 hunks)
  • wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx (2 hunks)
  • wren-ui/src/utils/enum/index.ts (1 hunks)
  • wren-ui/src/utils/enum/sslMode.ts (1 hunks)
  • wren-ui/src/utils/error/dictionary.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • wren-ui/src/utils/enum/index.ts
  • wren-ui/src/apollo/server/types/index.ts
  • wren-ui/src/apollo/server/types/sslMode.ts
  • wren-ui/src/utils/enum/sslMode.ts
  • wren-ui/src/utils/error/dictionary.ts
  • wren-ui/src/apollo/server/repositories/projectRepository.ts
  • wren-ui/src/apollo/server/adaptors/tests/ibisAdaptor.test.ts
  • wren-ui/src/apollo/server/dataSource.ts
🧰 Additional context used
🪛 Biome (1.9.4)
wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx

[error] 41-41: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 49-49: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (2)
wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx (2)

13-14: Add TypeScript interface for UploadSSL props

The component lacks proper type definitions for its props.


161-176: 🛠️ Refactor suggestion

Improve SSL certificate upload validation and consistency

Add file type validation and maintain consistency with edit mode behavior.

 {
   sslMode === SSL_MODE.VERIFY_CA &&
   <Form.Item
     label="SSL CA file"
     name="sslCA"
     required
+    tooltip="Upload a valid CA certificate file (.pem, .crt, or .key)"
     rules={[
       {
         required: true,
         message: ERROR_TEXTS.CONNECTION.SSL_CERT.REQUIRED,
       },
+      {
+        validator: async (_rule, value) => {
+          if (value && !value.match(/^-----BEGIN CERTIFICATE-----/)) {
+            throw new Error('Invalid certificate format');
+          }
+        },
+      },
     ]}
   >
-    <UploadSSL />
+    <UploadSSL disabled={isEditMode} />
   </Form.Item>
 }

Likely invalid or redundant comment.

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.

MySQL SSL Connection Requirement for Data Source Configuration
2 participants