delano / redis-dump

Redis to JSON and nack again
https://rubygems.org/gems/redis-dump
MIT License
825 stars 124 forks source link

Support rediss (redis+TLS) URLs #42

Open joey-squid opened 4 months ago

joey-squid commented 4 months ago

User description

redis-dump rediss://some-host Just Works.


PR Type

Enhancement


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
redis-dump
Add support for `rediss` (Redis over TLS) URLs in redis-dump

exe/redis-dump
  • Updated URI matching to support rediss scheme.
  • Ensured compatibility with both redis and rediss schemes.
  • +1/-1     
    redis-load
    Add support for `rediss` (Redis over TLS) URLs in redis-load

    exe/redis-load
  • Updated URI matching to support rediss scheme.
  • Ensured compatibility with both redis and rediss schemes.
  • +1/-1     

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codiumai-pr-agent-pro[bot] commented 4 months ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review: 2 ๐Ÿ”ต๐Ÿ”ตโšชโšชโšช
    ๐Ÿงช No relevant tests
    ๐Ÿ”’ No security concerns identified
    โšก Key issues to review

    Code Redundancy
    The logic to prepend 'redis://' to the URI if it does not match the pattern is duplicated in both 'redis-dump' and 'redis-load'. Consider abstracting this logic into a shared method to avoid code duplication and facilitate easier maintenance. Code Redundancy
    Similar to the issue in 'redis-dump', the logic to prepend 'redis://' to the URI if it does not match the pattern is duplicated here. Abstracting this logic into a shared method would improve code maintainability.
    codiumai-pr-agent-pro[bot] commented 4 months ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Modify the URI prefix logic to correctly handle both 'redis' and 'rediss' protocols ___ **To support both 'redis' and 'rediss' (Redis over SSL) protocols, ensure that the URI
    prefix is correctly set based on the existing protocol in obj.global.uri. Instead of
    always prepending 'redis://', check if 'rediss://' is required.** [exe/redis-dump [59]](https://github.com/delano/redis-dump/pull/42/files#diff-e73cdb060985c8491d2d4c6804a9a5e7c53940fcb2895687ea97f4b49e988419R59-R59) ```diff -obj.global.uri = 'redis://' << obj.global.uri unless obj.global.uri.match(/^rediss?:\/\//) +unless obj.global.uri.match(/^rediss?:\/\//) + obj.global.uri = obj.global.uri.start_with?('rediss://') ? 'rediss://' << obj.global.uri : 'redis://' << obj.global.uri +end ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: The suggestion correctly addresses the need to handle both 'redis' and 'rediss' protocols, ensuring the URI is properly formatted for secure and non-secure connections. This is a significant improvement for robustness.
    9
    Ensure correct URI formatting for both 'redis' and 'rediss' protocols ___ **To avoid potential issues with URI manipulation, refactor the code to prepend the
    correct protocol ('redis://' or 'rediss://') based on the existing URI. This ensures
    that the URI is correctly formatted for both secure and non-secure Redis
    connections.** [exe/redis-load [54]](https://github.com/delano/redis-dump/pull/42/files#diff-d77fd3d98200f0b57fef0fcd4bbfa0bf621fc79f51a4bf710363ffe37e16e0fdR54-R54) ```diff -obj.global.uri = 'redis://' << obj.global.uri unless obj.global.uri.match(/^rediss?:\/\//) +unless obj.global.uri.match(/^rediss?:\/\//) + obj.global.uri = obj.global.uri.start_with?('rediss://') ? 'rediss://' << obj.global.uri : 'redis://' << obj.global.uri +end ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: The suggestion ensures that the URI is correctly formatted for both secure and non-secure Redis connections, which is crucial for avoiding potential issues with URI manipulation. This enhances the reliability of the code.
    9
    joey-squid commented 4 months ago

    I'm not sure if the commit signing needs to be done by me or a maintainer. I don't have it set up and I'm on my way out the door on leave, so if I need to do anything I'm sorry but it won't happen until September. (Feel free to close this PR, make your own, whatever.)

    managedhostingsolution commented 1 month ago

    simple patch sed -i 's/redis:/rediss?:/g' "/var/lib/gems/3.1.0/gems/redis-dump-0.6.1/exe/redis-dump" and sed -i 's/redis:/rediss?:/g' "/var/lib/gems/3.1.0/gems/redis-dump-0.6.1/exe/redis-load"