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

chore: shadow PR for external contribution #37106 [DO NOT MERGE] #37222

Draft
wants to merge 3 commits into
base: release
Choose a base branch
from

Conversation

NilanshBansal
Copy link
Contributor

@NilanshBansal NilanshBansal commented Nov 5, 2024

Description

Shadow PR for external contribution #37106
Corresponding EE PR: https://github.com/appsmithorg/appsmith-ee/pull/5487

Fixes #26723

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11694971406
Commit: 951e3f1
Cypress dashboard.
Tags: @tag.All
Spec:


Wed, 06 Nov 2024 02:20:17 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced TLS configuration options in the Redis plugin, allowing users to enable TLS and manage certificate uploads for secure connections.
    • Added a new section in the Redis configuration form for TLS settings, including options for enabling TLS, verifying certificates, and uploading necessary files.
  • Bug Fixes

    • Enhanced error handling for TLS configuration, providing clearer messages for missing certificates.
  • Tests

    • Expanded test coverage for TLS-related scenarios, ensuring robust validation of TLS settings in the Redis plugin.

Copy link
Contributor

coderabbitai bot commented Nov 5, 2024

Walkthrough

The pull request introduces enhancements to the Redis plugin by adding support for TLS (Transport Layer Security) configurations. A new TlsConfiguration class is created, and a corresponding field is added to the DatasourceConfiguration class. The Redis plugin methods are updated to handle TLS settings, including validation and pool creation logic. New error messages related to TLS are defined, and a configuration form is updated to include TLS options. Additionally, test cases are added to ensure proper validation of TLS settings.

Changes

File Change Summary
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/DatasourceConfiguration.java Added TlsConfiguration tlsConfiguration field.
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/TlsConfiguration.java Introduced TlsConfiguration class with various Boolean fields and file upload fields for TLS.
app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java Updated datasourceCreate and validateDatasource methods to handle TLS configurations.
app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/exceptions/RedisErrorMessages.java Added new error message constants for TLS-related errors.
app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/utils/RedisTLSManager.java Created RedisTLSManager class with methods for managing TLS connections.
app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/utils/RedisURIUtils.java Added REDIS_SSL_SCHEME constant and updated getURI method for TLS support.
app/server/appsmith-plugins/redisPlugin/src/main/resources/form.json Added "TLS Configuration" section with various TLS-related fields in the configuration form.
app/server/appsmith-plugins/redisPlugin/src/test/java/com/external/plugins/RedisPluginTest.java Added tests for validating TLS configurations and updated existing tests to include TLS logic.

Possibly related PRs

Suggested labels

skip-changelog, ok-to-test, Templates Product, Widgets & Accelerators Pod

Suggested reviewers

  • sneha122
  • ApekshaBhosale
  • sharat87
  • mohanarpit
  • abhvsn

🌟 In the world of code, a TLS tale unfolds,
With configurations added, and security bold.
Redis now dances in a secure embrace,
Validations and tests, all in their place.
So raise up your keyboards, let’s celebrate,
For safer connections, we’ll elevate! 🎉


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 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.

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.

@NilanshBansal NilanshBansal changed the title chore: shadow PR for external contribution 337106 chore: shadow PR for external contribution #37106 Nov 5, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Nov 5, 2024
@NilanshBansal NilanshBansal self-assigned this Nov 5, 2024
@github-actions github-actions bot added Enhancement New feature or request Integrations Product Issues related to a specific integration Inviting Contribution Issues that we would like contributions to Query & JS Pod Issues related to the query & JS Pod Redis Issues related to Redis labels Nov 5, 2024
@NilanshBansal NilanshBansal added the ok-to-test Required label for CI label Nov 5, 2024
@github-actions github-actions bot added Enhancement New feature or request and removed Enhancement New feature or request labels Nov 5, 2024
@NilanshBansal NilanshBansal changed the title chore: shadow PR for external contribution #37106 chore: shadow PR for external contribution #37106 [DO NOT MERGE] Nov 5, 2024
@github-actions github-actions bot added Enhancement New feature or request and removed Enhancement New feature or request labels Nov 5, 2024
@NilanshBansal NilanshBansal marked this pull request as draft November 5, 2024 09:29
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: 6

🧹 Outside diff range and nitpick comments (11)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/TlsConfiguration.java (2)

12-17: Add class-level documentation

This security-sensitive configuration class should have proper JavaDoc explaining its purpose and usage.

+/**
+ * Configuration class for TLS/SSL settings used in secure connections.
+ * This class encapsulates all TLS-related settings including certificate management
+ * and client authentication options.
+ */
 @Getter
 @Setter

12-17: Consider making the configuration immutable

For security-sensitive configurations, consider making the class immutable by:

  1. Removing @Setter
  2. Using final fields
  3. Using a builder pattern for construction
 @Getter
-@Setter
 @ToString
-@NoArgsConstructor
-@AllArgsConstructor
+@Builder
+@RequiredArgsConstructor
 public class TlsConfiguration {
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/DatasourceConfiguration.java (1)

37-39: Consider adding migration documentation.

Since this adds a new field to a configuration class, it would be helpful to document any required database schema updates or migration steps.

app/server/appsmith-plugins/redisPlugin/src/main/resources/form.json (2)

97-129: Consider adding validation for certificate/key pair

While the client authentication fields are properly configured with conditional visibility and encryption, consider adding validation to ensure both client certificate and key are provided when client authentication is enabled.

 {
   "label": "Upload Client Certificate",
   "configProperty": "datasourceConfiguration.tlsConfiguration.clientCertificateFile",
   "controlType": "FILE_PICKER",
   "encrypted": true,
+  "required": {
+    "path": "datasourceConfiguration.tlsConfiguration.requiresClientAuth",
+    "comparison": "EQUALS",
+    "value": true
+  },
   "hidden": {
     "path": "datasourceConfiguration.tlsConfiguration.requiresClientAuth",
     "comparison": "EQUALS",
     "value": false
   }
 }

87-96: Consider adding file type validation for CA certificate

For better user experience and security, consider adding file type validation for the CA certificate upload.

 {
   "label": "Upload CA Certificate",
   "configProperty": "datasourceConfiguration.tlsConfiguration.caCertificateFile",
   "controlType": "FILE_PICKER",
   "encrypted": true,
+  "allowedFileTypes": [".pem", ".crt", ".cer"],
   "hidden": {
     "path": "datasourceConfiguration.tlsConfiguration.tlsEnabled",
     "comparison": "NOT_EQUALS",
     "value": true
   }
 }
app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/utils/RedisTLSManager.java (4)

43-43: Specify TLS protocol version explicitly

Consider specifying the TLS protocol version explicitly by using "TLSv1.2" or "TLSv1.3" instead of "TLS" to ensure you're using the desired version and to enhance security.


120-130: Use a secure library to handle private key parsing

Manually parsing the private key by stripping headers and decoding can be error-prone and might not handle all key formats. Consider using a robust library like Bouncy Castle's PEMParser to load and parse PEM-formatted private keys securely and reliably.

🧰 Tools
🪛 Gitleaks

122-123: Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.

(private-key)


40-42: Enhance exception handling for null TLS configuration flags

Throwing IllegalArgumentException with a generic message may not provide enough context for debugging. Consider creating a custom exception or providing more detailed messages to help pinpoint configuration issues.


115-117: Ensure proper resource management for SSL resources

While the SSLContext, SSLSocketFactory, and related resources are managed by the JVM, it's good practice to verify that any created resources are appropriately released or closed if necessary to prevent potential memory leaks.

app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java (1)

266-275: Add unit tests for TLS handling

Consider adding unit tests for the new TLS configurations in both datasourceCreate and validateDatasource methods to ensure all scenarios are properly tested.

Also applies to: 313-339

app/server/appsmith-plugins/redisPlugin/src/test/java/com/external/plugins/RedisPluginTest.java (1)

177-181: Refactor duplicated TLS configuration setup in test methods

The TLS configuration setup code is duplicated across multiple test methods. Consider extracting it into a helper method to reduce code duplication and enhance maintainability.

Also applies to: 191-195, 205-209, 219-225

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6660bd9 and 951e3f1.

📒 Files selected for processing (8)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/DatasourceConfiguration.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/TlsConfiguration.java (1 hunks)
  • app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java (4 hunks)
  • app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/exceptions/RedisErrorMessages.java (1 hunks)
  • app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/utils/RedisTLSManager.java (1 hunks)
  • app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/utils/RedisURIUtils.java (1 hunks)
  • app/server/appsmith-plugins/redisPlugin/src/main/resources/form.json (1 hunks)
  • app/server/appsmith-plugins/redisPlugin/src/test/java/com/external/plugins/RedisPluginTest.java (9 hunks)
🧰 Additional context used
🪛 Gitleaks
app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/utils/RedisTLSManager.java

122-123: Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.

(private-key)

🔇 Additional comments (9)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/DatasourceConfiguration.java (1)

37-39: LGTM! The TLS configuration field is well-placed and properly annotated.

The addition follows the established pattern in the class with appropriate JSON view annotations for serialization control.

Let's verify the TlsConfiguration class existence and structure:

✅ Verification successful

TLS configuration field is properly integrated and used correctly

The verification confirms:

  • TlsConfiguration class exists in the same package with proper structure
  • Field is actively used in Redis plugin for TLS support
  • Implementation follows consistent patterns with proper JSON view annotations
  • Integration is complete with proper usage in RedisPlugin, RedisURIUtils, and RedisTLSManager
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify TlsConfiguration class exists and has expected structure
ast-grep --pattern 'class TlsConfiguration {
  $$$
}'

Length of output: 55


Script:

#!/bin/bash
# Let's try to find the TlsConfiguration class using ripgrep
rg "class TlsConfiguration" -A 5

# Also search for any references to TlsConfiguration to understand its location
rg "TlsConfiguration" --type java

Length of output: 5471

app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/exceptions/RedisErrorMessages.java (2)

33-37: LGTM! Well-organized section header

The section header follows the established pattern in the file and clearly separates TLS-related error messages.


39-46: Error messages are clear and actionable

The error messages are well-structured and provide clear guidance to users about what's missing in their TLS configuration. Each message specifies both the problem and the required action.

Let's verify the consistency of these error messages with their usage:

✅ Verification successful

Error messages are properly integrated with validation logic

The error messages are correctly used in the Redis plugin's validation logic (RedisPlugin.java) to handle TLS configuration issues. The messages are also properly tested in RedisPluginTest.java to verify the validation behavior.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of these error messages in validation logic
rg "CA_CERTIFICATE_MISSING_ERROR_MSG|TLS_CLIENT_AUTH_ENABLED_BUT_CLIENT_CERTIFICATE_MISSING_ERROR_MSG|TLS_CLIENT_AUTH_ENABLED_BUT_CLIENT_KEY_MISSING_ERROR_MSG" -A 2

Length of output: 4372

app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/utils/RedisURIUtils.java (1)

16-17: LGTM! Correct Redis SSL scheme constant.

The REDIS_SSL_SCHEME constant correctly uses "rediss://" as per Redis protocol specifications.

app/server/appsmith-plugins/redisPlugin/src/main/resources/form.json (3)

61-65: LGTM: Section structure is well-defined

The TLS Configuration section is properly structured with a unique ID and follows the existing form pattern.


69-74: LGTM: TLS enable toggle is properly configured

The TLS enable checkbox is well-implemented with appropriate default value (false) and clear labeling.


75-96: Verify the conditional visibility logic for certificate fields

The certificate verification fields are properly encrypted and conditionally displayed. However, we should verify that the visibility conditions work as expected in the UI.

✅ Verification successful

Conditional visibility logic for TLS fields is correctly implemented

The form schema shows a well-structured and consistent implementation of conditional visibility:

  • TLS certificate verification and CA certificate upload are correctly hidden when TLS is disabled
  • Client certificate and key fields are properly hidden when client authentication is disabled
  • All visibility conditions use appropriate comparison operators and paths
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that these visibility conditions are consistently implemented in the frontend
rg -A 2 "tlsConfiguration.tlsEnabled" app/client/src/

Length of output: 53


Script:

#!/bin/bash
# Let's search for the form configuration in the frontend
rg -g "*.{ts,tsx}" "tlsEnabled.*verifyTlsCertificate" app/client/src/

# Also search for any TLS configuration handling
rg -g "*.{ts,tsx}" "tlsConfiguration" app/client/src/

# Check if there are any form configurations related to Redis TLS
rg -g "*.{ts,tsx}" "Redis.*TLS" app/client/src/

# Look for any Redis plugin form handling
fd -e ts -e tsx -e json . | xargs rg "redisPlugin.*form"

Length of output: 234


Script:

#!/bin/bash
# Let's check the form schema structure in the plugin
cat app/server/appsmith-plugins/redisPlugin/src/main/resources/form.json

# Look for any form-related files in the Redis plugin
fd -e json . app/server/appsmith-plugins/redisPlugin/

# Check if there are any editor configurations
rg -g "*.{ts,tsx,json}" "datasourceConfiguration.*hidden" 

Length of output: 4815

app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java (1)

313-339: TLS configuration validation looks good

The added validation logic for TLS configurations in the validateDatasource method appropriately checks for the necessary certificates and keys when TLS is enabled.

app/server/appsmith-plugins/redisPlugin/src/test/java/com/external/plugins/RedisPluginTest.java (1)

174-229: New TLS validation tests are comprehensive

The added test cases effectively cover various TLS configuration scenarios, ensuring robust validation.

Comment on lines +19 to +20
@JsonView({Views.Public.class, FromRequest.class})
Boolean tlsEnabled;
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 using primitive boolean with default values

The Boolean wrapper classes can be null, which might lead to NPEs. For configuration flags, it's better to use primitive boolean with default values.

-    Boolean tlsEnabled;
+    boolean tlsEnabled = false;

-    Boolean verifyTlsCertificate;
+    boolean verifyTlsCertificate = true;

-    Boolean requiresClientAuth;
+    boolean requiresClientAuth = false;

Also applies to: 22-23, 28-29

Comment on lines +25 to +26
@JsonView({Views.Public.class, FromRequest.class})
UploadedFile caCertificateFile;
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 validation for certificate files

The certificate and key files should have validation constraints to ensure they're provided when required and have appropriate content types.

+    @javax.validation.constraints.NotNull(message = "CA certificate is required when TLS verification is enabled", 
+        groups = TlsEnabledValidationGroup.class)
     @JsonView({Views.Public.class, FromRequest.class})
     UploadedFile caCertificateFile;

+    @javax.validation.constraints.NotNull(message = "Client certificate is required when client auth is enabled",
+        groups = ClientAuthEnabledValidationGroup.class)
     @JsonView({Views.Public.class, FromRequest.class})
     UploadedFile clientCertificateFile;

+    @javax.validation.constraints.NotNull(message = "Client key is required when client auth is enabled",
+        groups = ClientAuthEnabledValidationGroup.class)
     @JsonView({Views.Public.class, FromRequest.class})
     UploadedFile clientKeyFile;

Also applies to: 31-35

Comment on lines +20 to +26

if (datasourceConfiguration.getTlsConfiguration() != null
&& datasourceConfiguration.getTlsConfiguration().getTlsEnabled()) {
builder.append(REDIS_SSL_SCHEME);
} else {
builder.append(REDIS_SCHEME);
}
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 null check for datasourceConfiguration parameter.

While the logic for TLS scheme selection is correct, consider adding a null check for the datasourceConfiguration parameter to prevent potential NullPointerException.

 public static URI getURI(DatasourceConfiguration datasourceConfiguration) throws URISyntaxException {
+    if (datasourceConfiguration == null) {
+        throw new IllegalArgumentException("DatasourceConfiguration cannot be null");
+    }
     StringBuilder builder = new StringBuilder();
 
     if (datasourceConfiguration.getTlsConfiguration() != null
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (datasourceConfiguration.getTlsConfiguration() != null
&& datasourceConfiguration.getTlsConfiguration().getTlsEnabled()) {
builder.append(REDIS_SSL_SCHEME);
} else {
builder.append(REDIS_SCHEME);
}
if (datasourceConfiguration == null) {
throw new IllegalArgumentException("DatasourceConfiguration cannot be null");
}
if (datasourceConfiguration.getTlsConfiguration() != null
&& datasourceConfiguration.getTlsConfiguration().getTlsEnabled()) {
builder.append(REDIS_SSL_SCHEME);
} else {
builder.append(REDIS_SCHEME);
}

Comment on lines +92 to +105
trustManagers = new TrustManager[] {
new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}

@Override
public void checkClientTrusted(X509Certificate[] certs, String authType) {}

@Override
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review the implications of trusting all server certificates

When verifyTlsCertificate is set to false, the custom TrustManager trusts all server certificates without verification. This can pose significant security risks, such as man-in-the-middle attacks. Please ensure that this behavior is acceptable for your use case and consider adding warnings or documentation to inform users.

Comment on lines +266 to +275
if (datasourceConfiguration.getTlsConfiguration() != null
&& !datasourceConfiguration
.getTlsConfiguration()
.getTlsEnabled()) {
JedisPool jedisPool = new JedisPool(poolConfig, uri, timeout);
log.debug(Thread.currentThread().getName() + ": Created Jedis pool.");
return jedisPool;
} else {
return createJedisPoolWithTLS(poolConfig, uri, timeout, datasourceConfiguration);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review TLS configuration logic in datasourceCreate method

The condition in your if statement might not correctly handle cases where tlsConfiguration is null. Currently, if tlsConfiguration is null, the code defaults to creating a Jedis pool with TLS, which may not be intended. Consider revising the condition to ensure that TLS is enabled only when explicitly configured.

Apply this diff to correct the logic:

-if (datasourceConfiguration.getTlsConfiguration() != null
-        && !datasourceConfiguration
-                .getTlsConfiguration()
-                .getTlsEnabled()) {
-    JedisPool jedisPool = new JedisPool(poolConfig, uri, timeout);
-    log.debug(Thread.currentThread().getName() + ": Created Jedis pool.");
-    return jedisPool;
-} else {
+if (datasourceConfiguration.getTlsConfiguration() != null
+        && datasourceConfiguration
+                .getTlsConfiguration()
+                .getTlsEnabled()) {
+    return createJedisPoolWithTLS(poolConfig, uri, timeout, datasourceConfiguration);
+} else {
+    JedisPool jedisPool = new JedisPool(poolConfig, uri, timeout);
+    log.debug(Thread.currentThread().getName() + ": Created Jedis pool.");
+    return jedisPool;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (datasourceConfiguration.getTlsConfiguration() != null
&& !datasourceConfiguration
.getTlsConfiguration()
.getTlsEnabled()) {
JedisPool jedisPool = new JedisPool(poolConfig, uri, timeout);
log.debug(Thread.currentThread().getName() + ": Created Jedis pool.");
return jedisPool;
} else {
return createJedisPoolWithTLS(poolConfig, uri, timeout, datasourceConfiguration);
}
if (datasourceConfiguration.getTlsConfiguration() != null
&& datasourceConfiguration
.getTlsConfiguration()
.getTlsEnabled()) {
return createJedisPoolWithTLS(poolConfig, uri, timeout, datasourceConfiguration);
} else {
JedisPool jedisPool = new JedisPool(poolConfig, uri, timeout);
log.debug(Thread.currentThread().getName() + ": Created Jedis pool.");
return jedisPool;
}

Comment on lines +60 to +64
private TlsConfiguration addTLSConfiguration(DatasourceConfiguration datasourceConfiguration) {
TlsConfiguration tlsConfiguration = new TlsConfiguration();
tlsConfiguration.setTlsEnabled(false);
return tlsConfiguration;
}
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

Remove unused parameter in addTLSConfiguration method

The parameter DatasourceConfiguration datasourceConfiguration in the addTLSConfiguration method is unused. Consider removing it to improve code clarity.

Apply this diff to remove the unused parameter:

-private TlsConfiguration addTLSConfiguration(DatasourceConfiguration datasourceConfiguration) {
+private TlsConfiguration addTLSConfiguration() {
    TlsConfiguration tlsConfiguration = new TlsConfiguration();
    tlsConfiguration.setTlsEnabled(false);
    return tlsConfiguration;
}

Update the method calls accordingly:

-datasourceConfiguration.setTlsConfiguration(addTLSConfiguration(datasourceConfiguration));
+datasourceConfiguration.setTlsConfiguration(addTLSConfiguration());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private TlsConfiguration addTLSConfiguration(DatasourceConfiguration datasourceConfiguration) {
TlsConfiguration tlsConfiguration = new TlsConfiguration();
tlsConfiguration.setTlsEnabled(false);
return tlsConfiguration;
}
private TlsConfiguration addTLSConfiguration() {
TlsConfiguration tlsConfiguration = new TlsConfiguration();
tlsConfiguration.setTlsEnabled(false);
return tlsConfiguration;
}

@NilanshBansal NilanshBansal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Nov 6, 2024
@github-actions github-actions bot added the Enhancement New feature or request label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Integrations Product Issues related to a specific integration Inviting Contribution Issues that we would like contributions to ok-to-test Required label for CI Query & JS Pod Issues related to the query & JS Pod Redis Issues related to Redis skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Support for connecting via TLS to a managed Redis database
2 participants