Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Auth: Add input validation for instance URL #3156
Auth: Add input validation for instance URL #3156
Changes from 1 commit
4c9c37a
8410754
7711472
dc3e994
075b903
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abeatrix this does not look to be catching the old format. Does everyone uses the new token format only? Can we include the ones from this list? cc:@willdollman @shivasurya
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dcomas @willdollman @shivasurya Thanks for the link! Would it be safe to assume anything without a
.
in the URL is an invalid URL?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broadly no (e.g.
http://localhost
) and slight concern that some edge case customer will have a crazy dns setup that this would break.What about ensuring the url matches this:
([.]|^https?:\/\/)
Matches anything containg a dot or anything starting with
https?://
Matches:
Doesn't match:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm making the assumption that we automatically add the missing https:// if a user enters a url without a prefix (
sourcegraph.com
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(what Will is proposing) LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@willdollman yea i added the check before we add the
https://
prefix:cody/vscode/src/services/AuthProvider.ts
Lines 463 to 465 in 7711472
But that's a good callout, I'll make sure to include those cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just updated the regex for catching token:
Sourcegraph Access Token (v3):
![image](https://private-user-images.githubusercontent.com/68532117/304509485-7256ff4f-710a-4438-87a9-63d83d60e17c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI0NTE1MDEsIm5iZiI6MTcyMjQ1MTIwMSwicGF0aCI6Ii82ODUzMjExNy8zMDQ1MDk0ODUtNzI1NmZmNGYtNzEwYS00NDM4LTg3YTktNjNkODNkNjBlMTdjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMxVDE4NDAwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWExY2FhYTc5MzI1NGUwNzU1Y2YxNTllZjYyMTNmZGIxMzhkMDY1YWI4ZTlhOGQ4NjNmZTZmZmIxNjFiNjNhYTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.miZTfuoIRPkNtRh_KOs00Fxkhom4wkJjhcbS-ModsWI)
Sourcegraph Access Token (v2, deprecated):
![image](https://private-user-images.githubusercontent.com/68532117/304509503-3cdb4056-20a0-4efb-9fde-4b2dd3bc1036.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI0NTE1MDEsIm5iZiI6MTcyMjQ1MTIwMSwicGF0aCI6Ii82ODUzMjExNy8zMDQ1MDk1MDMtM2NkYjQwNTYtMjBhMC00ZWZiLTlmZGUtNGIyZGQzYmMxMDM2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMxVDE4NDAwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUxN2UzMGI3NzI5YjlmMzIwNGUzM2RkZTM3NjQyOTYxY2FhYmE0YzE5YzFhZDkwMDFlZTgyZDZlZTVhZDhhZjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.qo3LkF98VuKg1hnrpaMbjREvlKVmBk4iWlG9zMXRG0Y)
Sourcegraph Access Token (v1, deprecated):
![image](https://private-user-images.githubusercontent.com/68532117/304509544-8592c52e-0666-4848-8c46-b454a9f14115.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI0NTE1MDEsIm5iZiI6MTcyMjQ1MTIwMSwicGF0aCI6Ii82ODUzMjExNy8zMDQ1MDk1NDQtODU5MmM1MmUtMDY2Ni00ODQ4LThjNDYtYjQ1NGE5ZjE0MTE1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMxVDE4NDAwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM4NjdmODIwZTA3ODg4OWU2ZWI4Y2Q3OGVhM2JiMWE4M2M3NDc3ZmE5OTdiYTIwOTFiYmRjMGVkNDNhNDJiNGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.wXhE76Rffr3rhxnOyIHzmLuAvzNQIFJbWS5xYWkGnJ0)
Catch tokens with http prefix:
Also updated the check to ensure the URL must starts with
![image](https://private-user-images.githubusercontent.com/68532117/304515609-72cf15ed-5f13-4e3b-b23f-84fd3ddb5759.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI0NTE1MDEsIm5iZiI6MTcyMjQ1MTIwMSwicGF0aCI6Ii82ODUzMjExNy8zMDQ1MTU2MDktNzJjZjE1ZWQtNWYxMy00ZTNiLWIyM2YtODRmZDNkZGI1NzU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMxVDE4NDAwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZlNGM2MTE0ZGU3YjhjMzU5YTdjNzVmMjEzYmQwYzVjYWI3YjczNWY2NGIzNzY0ZTkwODczN2QyNDI1YmRjMTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.JVLNvy62jyS9GRzvUwO9yyl9NbwtOheBOD0g7KhsujI)
![image](https://private-user-images.githubusercontent.com/68532117/304515752-c1ab3526-e095-48ec-9fd3-7f17bd3a5bec.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI0NTE1MDEsIm5iZiI6MTcyMjQ1MTIwMSwicGF0aCI6Ii82ODUzMjExNy8zMDQ1MTU3NTItYzFhYjM1MjYtZTA5NS00OGVjLTlmZDMtN2YxN2JkM2E1YmVjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMxVDE4NDAwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk3YWQ5MDQ2OTcwMzg1NWZjNzhiYWMxYTFhZWE0NDg2M2JmY2E0MTUxMTliNTEyMTY0MDU4ZWVlNDFkNTMzYTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.JdJiHJYYxnvLMyQOcDCAfYrzly5yEO_7r3cf_lS2ZsY)
![image](https://private-user-images.githubusercontent.com/68532117/304515796-9b0f3bc0-73d7-4b1c-98b0-2cbff2d633e4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI0NTE1MDEsIm5iZiI6MTcyMjQ1MTIwMSwicGF0aCI6Ii82ODUzMjExNy8zMDQ1MTU3OTYtOWIwZjNiYzAtNzNkNy00YjFjLTk4YjAtMmNiZmYyZDYzM2U0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMxVDE4NDAwMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU4YjM1NWMwMzA3MzA4NjUzOTlkYTJiOTk4MDNhYjBmZThhYzkyMGYyZmRkNzk2M2JhNDVhNTAwNWNjOTRhMDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.2Ame7UNDZJkJIVeBg-mN1E_HcgeUpjAN7zBzr_RQblY)
http
to reduce confusion: