Skip to content

Conversation

mcasimir
Copy link
Collaborator

@mcasimir mcasimir commented Mar 4, 2022

This came up from a chat with @mmarcon and requests by customers on slack. The gist of the change is:

  • We don't do semantic validations on save. Only well-formed strings are saved, ie. no pineapple, but users can save connections that would not work with the driver, like those missing passwords.
  • If a connection has been saved in the past then we will only update the lastUsed field instead of saving all the changes. NOTE: this replicates the behavior of the old connection form.
  • Unrelated: Changes the copy for TLS warnings to a more positive language.

Screenshot 2022-03-04 at 11 56 51

Screenshot 2022-03-04 at 11 57 00

Screenshot 2022-03-04 at 11 57 19

Screenshot 2022-03-04 at 12 57 33

@mcasimir mcasimir changed the title feat(connect-form): Allow saving invalid but well-formed strings COMPASS-4948 WIP: feat(connect-form): Allow saving invalid but well-formed strings COMPASS-4948 Mar 4, 2022
// if a connection has been saved already we only want to update the lastUsed
// attribute, otherwise we are going to save the entire connection info.
const connectionInfoToBeSaved =
(await connectionStorage.load(connectionInfo.id)) ?? connectionInfo;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to reload the entire connection here? Would it make sense to check for lastUsed instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we need to reload for the update, but we could do a check first, something like this?

const connectionInfoToBeSaved = connectionInfo.lastUsed && (await connectionStorage.load(connectionInfo.id)) ?? connectionInfo;

Copy link
Member

Choose a reason for hiding this comment

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

Ah gotcha we are reloading here to pull in the original state of the connection then so the changes that are currently there do not override. This is probably a nicer way to do it than keeping around a clone of the original state of the connection then, I think both have implications if a user is doing things in another window.

Copy link
Collaborator Author

@mcasimir mcasimir Mar 4, 2022

Choose a reason for hiding this comment

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

We are only replicating the old behavior here, i was surprised this is how the old connection model worked.

Copy link
Member

Choose a reason for hiding this comment

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

I think the suggestion I made for using lastUsed might not actually do anything then? Sorry!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah true, actually it would cause the entire thing to be saved on connect the first time, even if it was saved before, but just never used

Copy link
Collaborator Author

@mcasimir mcasimir Mar 7, 2022

Choose a reason for hiding this comment

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

Changed it back. Let's wait for @addaleax before merging, It would be great to have some feedback cause she wasn't fond of relaxing the validation too much. We can easily drop the looseValidation from ensureWellFormedConnectionString in case

Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

lgtm - do we want to show an indicator that there are unsaved changes similar to how the old form did? Or does the Save button functionality cover that now?
Screen Shot 2022-03-04 at 12 28 31 PM

@mcasimir mcasimir changed the title WIP: feat(connect-form): Allow saving invalid but well-formed strings COMPASS-4948 WIP: feat(connect-form): Allow saving invalid but well-formed strings Mar 8, 2022
warnings.push({
message:
'Disabling certificate validation is not recommended as it may create a security vulnerability',
message: `TLS/SSL certificate validation is disabled. For a more secure connection enable certificate validation if possible.`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I did like that this explicitly used the phrase “vulnerability”. Usually, that’s what it is, and “more secure connection” makes it sound like the connection still gives some security guarantees, which it effectively does not.

It’s nice to use positive language, but we should really push users towards never using these options.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mmarcon what's your opinion here? For this PR I can just keep the old copy and maybe do another one.

Copy link
Member

Choose a reason for hiding this comment

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

What if we said something like:

TLS/SSL certificate validation is disabled. If possible, enable certificate validation to avoid security vulnerabilities.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Going to merge this one and open another PR to discuss the copy for TLS

Copy link
Collaborator

@addaleax addaleax Mar 9, 2022

Choose a reason for hiding this comment

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

I think that’s fine, yeah.

(Think about how browsers do this – in both Chrome and Firefox you’ll need to go to an Advanced section and are only then presented with the option to actually go to the site. And here, this potentially affects our customer’s production databases, where the risk probably tends to be higher-impact than a person visiting a bad-HTTPS site.)

warnings.push({
message:
'Connecting without tls is not recommended as it may create a security vulnerability.',
'Connecting to a remote server without TLS/SSL is not recommended. For a more secure connection enable TLS/SSL if possible.',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto here

@mcasimir mcasimir changed the title WIP: feat(connect-form): Allow saving invalid but well-formed strings feat(connect-form): Allow saving invalid but well-formed strings Mar 9, 2022
@mcasimir mcasimir merged commit 183c26e into main Mar 9, 2022
@mcasimir mcasimir deleted the allow-saving-without-passwords branch March 9, 2022 16:54
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.

4 participants