kloudlite / kl

Kloudlite CLI Client
GNU Affero General Public License v3.0
5 stars 1 forks source link

:lock: updated ssh client for insecure-ignore-host-key-use #175

Closed abdheshnayak closed 1 week ago

abdheshnayak commented 1 week ago

Summary by Sourcery

Fix the insecure host key usage by implementing a custom HostKeyCallback function to validate hostnames, and enhance the Println function to ensure proper string formatting and output.

Bug Fixes:

Enhancements:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

This pull request updates the SSH client to address the insecure-ignore-host-key-use issue. It introduces a new HostKeyCallback function for improved security and modifies the Println function for better string handling.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Implemented a custom HostKeyCallback function for SSH connections
  • Added a new HostKeyCallback function that uses regex to validate hostnames
  • The function only allows hostnames matching the pattern '*.local.khost.dev:port'
  • Replaced the insecure ssh.InsecureIgnoreHostKey() with the new HostKeyCallback
pkg/sshclient/ssh.go
Refactored the Println function for improved string handling
  • Replaced direct string concatenation with strings.Join for better performance
  • Implemented a closure to convert interface{} arguments to strings
  • Modified the output format to ensure proper spacing between arguments
pkg/functions/print.go

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).