-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: Added SSH Tunnel for Postgres #35449
feat: Added SSH Tunnel for Postgres #35449
Conversation
WalkthroughThe recent changes to the PostgreSQL plugin implement SSH tunneling, enabling secure connections to databases behind an SSH server. This update introduces new configuration options for SSH, expands validation for connection parameters, and enhances error handling, facilitating a seamless integration of these features for users needing secure access to production databases. Changes
Assessment against linked issues
Possibly related issues
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: 4
Outside diff range, codebase verification and nitpick comments (6)
app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1)
40-41
: Add Javadoc for the new constant.Consider adding a Javadoc comment to describe the purpose of this constant for better maintainability and readability.
/** * Error message for missing SSH port in the datasource configuration. */ public static final String DS_MISSING_SSH_PORT_ERROR_MSG = "Missing SSH port.";app/server/appsmith-plugins/postgresPlugin/src/main/resources/form.json (3)
15-29
: Ensure consistent naming for the connection method values.The values for the connection method options should be consistent. Consider using lowercase or uppercase for both options.
- "value": "STANDARD" + "value": "standard" ... - "value": "SSH" + "value": "ssh"
67-92
: Add a section name for the SSH configuration.For better readability and organization, consider adding a section name for the SSH configuration.
- { - "sectionName": null, + { + "sectionName": "SSH Configuration",
124-143
: Ensure consistent naming for the SSH-related fields.The placeholder text for the SSH username and SSH key fields should be consistent with other fields.
- "placeholderText": "Username", + "placeholderText": "SSH Username", ... - "placeholderText": "Password", + "placeholderText": "SSH Key",app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (2)
12-16
: Group SSH-related imports together.For better readability, group all SSH-related imports together.
+import com.appsmith.external.helpers.SSHUtils; ... +import com.appsmith.external.models.ConnectionContext;
Line range hint
313-330
: Improve readability of the endpoint identifier logic.The logic for constructing the endpoint identifier can be simplified for better readability.
- if (endpoints.size() > 0) { - String hostName = endpoints.get(0).getHost(); - Long port = endpoints.get(0).getPort(); - if (!isBlank(hostName)) { - identifier = hostName + "_" + ObjectUtils.defaultIfNull(port, DEFAULT_POSTGRES_PORT); - } - } + if (!endpoints.isEmpty()) { + Endpoint endpoint = endpoints.get(0); + String hostName = endpoint.getHost(); + Long port = endpoint.getPort(); + if (!isBlank(hostName)) { + identifier = hostName + "_" + ObjectUtils.defaultIfNull(port, DEFAULT_POSTGRES_PORT); + } + }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Commits
Files that changed from the base of the PR and between cbb4568 and 217ffc3aa7b0b1e9841b01016ed2f048cae7b20a.
Files selected for processing (4)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (7 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/resources/form.json (9 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresPluginTest.java (1 hunks)
Additional comments not posted (4)
app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresPluginTest.java (4)
1723-1744
: LGTM!The test case
testGetEndpointIdentifierForRateLimit_HostPresentPortAbsentSshEnabled_ReturnsCorrectString
is well-structured and correctly tests the expected behavior.
1746-1773
: LGTM!The test case
testGetEndpointIdentifierForRateLimit_HostPresentPortAbsentSshEnabledwithHostAndPort_ReturnsCorrectString
is well-structured and correctly tests the expected behavior.
1775-1801
: LGTM!The test case
testGetEndpointIdentifierForRateLimit_HostPresentPortAbsentSshEnabledwithHostAndNullPort_ReturnsCorrectString
is well-structured and correctly tests the expected behavior.
1803-1828
: LGTM!The test case
testGetEndpointIdentifierForRateLimit_EndpointAbsentSshEnabledwithHostAndNullPort_ReturnsCorrectString
is well-structured and correctly tests the expected behavior.
...erver/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java
Outdated
Show resolved
Hide resolved
...erver/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java
Outdated
Show resolved
Hide resolved
...erver/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java
Outdated
Show resolved
Hide resolved
217ffc3
to
8391d3c
Compare
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Commits
Files that changed from the base of the PR and between 217ffc3aa7b0b1e9841b01016ed2f048cae7b20a and 8391d3c.
Files selected for processing (4)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (7 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/resources/form.json (9 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresPluginTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java
- app/server/appsmith-plugins/postgresPlugin/src/main/resources/form.json
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresPluginTest.java
Additional comments not posted (1)
app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1)
40-41
: LGTM! The new error message is clear and concise.The added error message
DS_MISSING_SSH_PORT_ERROR_MSG
aligns well with the existing error messages.
@AnnaHariprasad5123 the server build is failing after pulling your changes. Can you check this. |
8391d3c
to
78d673e
Compare
Hi @NilanshBansal, Could you check it now. |
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (8 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/resources/form.json (9 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresPluginTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java
- app/server/appsmith-plugins/postgresPlugin/src/main/resources/form.json
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresPluginTest.java
Additional comments not posted (1)
app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1)
40-41
: Addition of SSH Port Error Message Approved.The new error message
DS_MISSING_SSH_PORT_ERROR_MSG
is a necessary addition for handling SSH tunneling errors. Ensure that this message is used wherever SSH port validation is performed.To confirm its usage, verify where this constant is referenced in the codebase.
Verification successful
SSH Port Error Message Usage Verified.
The error message
DS_MISSING_SSH_PORT_ERROR_MSG
is correctly referenced inPostgresPlugin.java
for handling validation errors related to missing SSH ports. This confirms its intended use in the codebase.
- File:
PostgresPlugin.java
- Line: Adds the error message to a list of invalids.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of DS_MISSING_SSH_PORT_ERROR_MSG in the codebase. # Test: Search for references to DS_MISSING_SSH_PORT_ERROR_MSG. Expect: Occurrences in validation logic. rg --type java 'DS_MISSING_SSH_PORT_ERROR_MSG'Length of output: 431
78d673e
to
2f95854
Compare
HI @NilanshBansal, Sorry for the mistake. Could you check it now. |
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (8 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/resources/form.json (9 hunks)
Files skipped from review as they are similar to previous changes (3)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java
- app/server/appsmith-plugins/postgresPlugin/src/main/resources/form.json
@AnnaHariprasad5123 spotless check is failing, can you run |
@AnnaHariprasad5123 also, is there any specific reason to do git force push? Can you also retain all the commits and just make new commits with the suggested changes. |
2f95854
to
bff288d
Compare
Because those are small changes so I am doing git amend and force push. From now, I will do new commits for every change. I will not repeat this again. |
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (8 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/resources/form.json (9 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresPluginTest.java (2 hunks)
Files skipped from review as they are similar to previous changes (3)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresPluginTest.java
Additional comments not posted (3)
app/server/appsmith-plugins/postgresPlugin/src/main/resources/form.json (3)
14-29
: Addition of "Connection method" is appropriate.The new "Connection method" field allows users to select between "Standard" and "SSH tunnel," aligning with the PR's objective to enhance security via SSH tunneling.
67-91
: SSH configuration fields are well-implemented.The SSH host address and port fields are conditionally displayed, enhancing the user experience by showing relevant fields based on the connection method.
122-143
: SSH authentication fields are correctly added.The SSH username and key fields are conditionally visible, which is essential for SSH tunneling configuration.
@AnnaHariprasad5123 cypress tests are failing on the shadow PR. Can you fix these. |
HI @NilanshBansal, Cypress tests are crashing in my system. I am unable to check it. Could you check it if possible. I didn't change any cypress tests file. I have checked with others also in my team. Cypress tests are crashing after sometime. Could you provide a suggestion or idea. |
@AnnaHariprasad5123 can you share the error screenshot that you are getting on running cypress locally? |
Hi @NilanshBansal, Good morning. Yes, I am running individual tests only. I’m encountering issues with the following tests:
|
/build-deploy-preview skip-tests=true |
Hi @NilanshBansal, We are not getting missing ssh port and ssh host value . Is this issue same for mysql plugin? Could you check mysql plugin once. I have checked in mysql ssh, so it is also getting as same : |
@AnnaHariprasad5123 I believe that is not concerned with the scope of this implementation. I will check it but it should be independent of our current implementation. |
|
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (24 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (2 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresDatasourceValidationTest.java (1 hunks)
Additional comments not posted (14)
app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1)
49-49
: LGTM!The new constant
DS_MISSING_PASSWORD_ERROR_MSG
is correctly defined and enhances error reporting.The code changes are approved.
app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresDatasourceValidationTest.java (10)
85-92
: LGTM!The test case
testErrorMessageOnEmptySSHHost
is correctly implemented and verifies the expected error message.The code changes are approved.
95-102
: LGTM!The test case
testErrorMessageOnBadSSHHost
is correctly implemented and verifies the expected error message.The code changes are approved.
105-111
: LGTM!The test case
testErrorMessageOnEmptySSHPort
is correctly implemented and verifies the expected behavior.The code changes are approved.
113-121
: LGTM!The test case
testErrorMessageOnEmptySSHUsername
is correctly implemented and verifies the expected error message.The code changes are approved.
125-131
: LGTM!The test case
testErrorMessageOnEmptySSHKey
is correctly implemented and verifies the expected error message.The code changes are approved.
133-145
: LGTM!The test case
testValidateDatasourceNullCredentials
is correctly implemented and verifies the expected error messages.The code changes are approved.
148-153
: LGTM!The test case
testValidateDatasourceMissingDBName
is correctly implemented and verifies the expected error message.The code changes are approved.
156-161
: LGTM!The test case
testValidateDatasourceNullEndpoint
is correctly implemented and verifies the expected error message.The code changes are approved.
164-169
: LGTM!The test case
testValidateDatasource_NullHost
is correctly implemented and verifies the expected error message.The code changes are approved.
172-177
: LGTM!The test case
testValidateDatasourceInvalidEndpoint
is correctly implemented and verifies the expected error message.The code changes are approved.
app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (3)
Line range hint
237-291
: LGTM!The method
executeParameterized
is correctly implemented and handles SSH connections appropriately.The code changes are approved.
Line range hint
312-329
: LGTM!The method
getEndpointIdentifierForRateLimit
is correctly implemented and includes SSH host in the identifier appropriately.The code changes are approved.
726-750
: LGTM!The method
validateDatasource
is correctly implemented and includes checks for SSH parameters appropriately.The code changes are approved.
@AnnaHariprasad5123 there are merge conflicts in this PR, can you please resolve them. |
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java (9 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresDatasourceValidationTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresDatasourceValidationTest.java
Additional comments not posted (1)
app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/exceptions/PostgresErrorMessages.java (1)
49-50
: LGTM!The new constant
DS_MISSING_PASSWORD_ERROR_MSG
is correctly implemented and follows the existing pattern in the file. It enhances error reporting for PostgreSQL connections.The code changes are approved.
@AnnaHariprasad5123 newly added server test is failing on the shadow PR here. |
Hi @NilanshBansal, check once and let me know if still having an issues.
|
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/SSHConnection.java (3 hunks)
- app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresPluginTest.java (3 hunks)
Additional comments not posted (11)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/SSHConnection.java (6)
28-28
: LGTM!The
host
field's annotation is correctly updated to includeFromRequest.class
.The code changes are approved.
31-31
: LGTM!The
port
field's annotation is correctly updated to includeFromRequest.class
.The code changes are approved.
34-34
: LGTM!The
endpoints
field's annotation is correctly updated to includeFromRequest.class
.The code changes are approved.
46-46
: LGTM!The
username
field's annotation is correctly updated to includeFromRequest.class
.The code changes are approved.
49-49
: LGTM!The
authType
field's annotation is correctly updated to includeFromRequest.class
.The code changes are approved.
52-52
: LGTM!The
privateKey
field's annotation is correctly updated to includeFromRequest.class
.The code changes are approved.
app/server/appsmith-plugins/postgresPlugin/src/test/java/com/external/plugins/PostgresPluginTest.java (5)
338-338
: LGTM!The assertion change enhances the clarity and specificity of the test's intent.
The code changes are approved.
1725-1745
: LGTM!The test case is correctly implemented to validate the behavior of the
getEndpointIdentifierForRateLimit
method when the host is set but the port is null, with SSH enabled.The code changes are approved.
1747-1774
: LGTM!The test case is correctly implemented to validate the behavior of the
getEndpointIdentifierForRateLimit
method when both the host and SSH proxy details are provided.The code changes are approved.
1776-1802
: LGTM!The test case is correctly implemented to validate the behavior of the
getEndpointIdentifierForRateLimit
method when the host is set but the port is null, with SSH enabled and SSH proxy details provided.The code changes are approved.
1804-1829
: LGTM!The test case is correctly implemented to validate the behavior of the
getEndpointIdentifierForRateLimit
method when no endpoints are defined but an SSH proxy is set.The code changes are approved.
/build-deploy-preview skip-tests=true |
Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/10608827308. |
Deploy-Preview-URL: https://ce-35449.dp.appsmith.com |
@AnnaHariprasad5123 the following cypress tests are failing. Can you please check and fix these if caused by your recent changes.
7350993.mp4
7350994.mp4 |
Hi @NilanshBansal, I fixed them. Check workflows once and let me know if issues still remain. |
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- app/client/cypress/e2e/Regression/ServerSide/Datasources/ConnectionErrors_Spec.ts (1 hunks)
- app/client/cypress/e2e/Regression/ServerSide/QueryPane/EmptyDataSource_spec.js (1 hunks)
Additional context used
Path-based instructions (2)
app/client/cypress/e2e/Regression/ServerSide/QueryPane/EmptyDataSource_spec.js (1)
Pattern
app/client/cypress/**/**.*
:app/client/cypress/e2e/Regression/ServerSide/Datasources/ConnectionErrors_Spec.ts (1)
Pattern
app/client/cypress/**/**.*
:
Additional comments not posted (2)
app/client/cypress/e2e/Regression/ServerSide/QueryPane/EmptyDataSource_spec.js (1)
26-26
: LGTM!The error message now includes "Missing password for authentication," which improves clarity.
The code changes are approved.
app/client/cypress/e2e/Regression/ServerSide/Datasources/ConnectionErrors_Spec.ts (1)
48-48
: LGTM!The error message now includes "Missing password for authentication," which simplifies the error handling logic.
The code changes are approved.
@AnnaHariprasad5123 Thanks for taking the time and contributing to Appsmith! We highly appreciate your effort in making Appsmith better ❤️ |
@appsmithorg/contributor-support
Hi @rohan-arthur
Fixes #30792
Video Demonstration
What's in this pr :
Screenshots :
Please review this pr. Let me know if any changes required.
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Tests