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

cider-connect improvements #3410

Merged
merged 2 commits into from
Aug 18, 2023
Merged

cider-connect improvements #3410

merged 2 commits into from
Aug 18, 2023

Conversation

vemv
Copy link
Member

@vemv vemv commented Aug 14, 2023

Cheers - V

@vemv vemv requested a review from bbatsov August 14, 2023 20:33
(if (eq system-type 'windows-nt)
port-string
(when (not (equal ""
(shell-command-to-string (concat "lsof -i:" port-string))))
Copy link
Contributor

Choose a reason for hiding this comment

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

I know the possibility of not having lsof installed on a Linux machine is low (maybe it comes by default in OSX, but that is not the case in every Linux distribution). But if it isn't installed, shell-command-to-string will return a non-empty string with an error similar to:

"/bin/bash: line 1: lsof: command not found
"

which will make the above code assume that port-string is a "alive", even if we couldn't check that it is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review!

I actually considered that.

If there's no lsof installed, the only reasonable option we have is to allow the port, instead of excluding it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't splicing arbitrary file contents into a shell command in this manner introduce some sort of vulnerability?

Not that I have a specific threat model in mind, but it might at least help to sanitize the input (eg. matching against a basic "^\\d+$" regexp)

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's do that, thanks!

Most of all it would seem a good way to ensure the command being run is reasonable (e.g. not an empty string or non-numeric contents)

@bbatsov
Copy link
Member

bbatsov commented Aug 18, 2023

The changes look good, but your branch has to be rebased on top of the current master branch due to merge conflicts.

@vemv vemv force-pushed the 3408--cider-connect-improvements branch from 9de86cf to 4b49255 Compare August 18, 2023 10:21
@vemv
Copy link
Member Author

vemv commented Aug 18, 2023

Thanks 🍻

@vemv vemv merged commit f14c8de into master Aug 18, 2023
26 checks passed
@vemv vemv deleted the 3408--cider-connect-improvements branch August 18, 2023 10:23
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.

cider-connect improvements
4 participants