[V3 Repo Manager] Sanitize Repo.url #2774

Closed
Zephyrkul wants to merge 2 commits from patch-3 into V3/develop
Zephyrkul commented 2019-06-16 23:16:26 +02:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

If URL basic auth is present in a repo's URL, remove it.

### Type - [ ] Bugfix - [X] Enhancement - [ ] New feature ### Description of the changes If URL basic auth is present in a repo's URL, remove it.
tekulvw (Migrated from github.com) reviewed 2019-06-16 23:16:26 +02:00
mikeshardmind (Migrated from github.com) requested changes 2019-06-24 08:45:58 +02:00
mikeshardmind (Migrated from github.com) left a comment

This is an API change to do like this. Add a sanitized url property instead of changing the attribute to a property.

Use that in the places which grab it and present it in client.

This is an API change to do like this. Add a sanitized url property instead of changing the attribute to a property. Use that in the places which grab it and present it in client.
Zephyrkul commented 2019-06-25 04:27:02 +02:00 (Migrated from github.com)

I think this API change is worth it. I don't think Repo should potentially expose URL auth through its public attributes, nor should future code changes have to remember to specifically call the sanitized version. Auth like this should be only for backend and not exposed to public attributes. If this does actually break something in the backend of downloader, feel free to let me know.

I think this API change is worth it. I don't think Repo should potentially expose URL auth through its public attributes, nor should future code changes have to remember to specifically call the sanitized version. Auth like this should be only for backend and not exposed to public attributes. If this does actually break something in the backend of downloader, feel free to let me know.
Tobotimus commented 2019-06-25 06:49:09 +02:00 (Migrated from github.com)

I'm with Zeph here... Besides, this API is undocumented and should only be used internally. We Red developers really need to settle on what APIs we consider public and shouldn't be broken in micro releases, and which APIs are flexible. Because the more we consider public, the harder everything is to improve. The costs of considering it public often far outweigh the benifits - I think this is an example of that.

I'm with Zeph here... Besides, this API is undocumented and should only be used internally. We Red developers really need to settle on what APIs we consider public and shouldn't be broken in micro releases, and which APIs are flexible. Because the more we consider public, the harder everything is to improve. The costs of considering it public often far outweigh the benifits - I think this is an example of that.
Tobotimus commented 2019-06-25 06:58:00 +02:00 (Migrated from github.com)

I don't think Downloader functions were documented for the benefit of 3rd party devs. I think the documentation was put there to help core developers maintain and improve Downloader, but it managed to end up on RTD anyway. I'd really like to reconsider the APIs we show on RTD and consider public in the next minor release, and perhaps move the docs to a new "Red Developer Docs", or even just leave them as comments in the code. Other candidates for this would be things like the drivers for config, and some parts of data manager and cog manager.

I don't think Downloader functions were documented for the benefit of 3rd party devs. I think the documentation was put there to help core developers maintain and improve Downloader, but it managed to end up on RTD anyway. I'd really like to reconsider the APIs we show on RTD and consider public in the next minor release, and perhaps move the docs to a new "Red Developer Docs", or even just leave them as comments in the code. Other candidates for this would be things like the drivers for config, and some parts of data manager and cog manager.
mikeshardmind commented 2019-06-25 11:15:02 +02:00 (Migrated from github.com)

For better or for worse right now, this is a documented part of the API.

It's also possible someone is currently using this part of the API to build something which gets info about added repos which we do not. Changing this would would break something like that.

I don't think it's a hard ask for developers to use the correct attributes, especially if we document them, so I don't think it's worth changing a documented API to do this.

For better or for worse right now, this *is* a documented part of the API. It's also possible someone is currently using this part of the API to build something which gets info about added repos which we do not. Changing this would would break something like that. I don't think it's a hard ask for developers to use the correct attributes, especially if we document them, so I don't think it's worth changing a documented API to do this.
Tobotimus commented 2019-06-25 11:35:44 +02:00 (Migrated from github.com)

I know the Repo class is documented, the url attribute is not though

I know the `Repo` class is documented, the `url` attribute is not though
mikeshardmind commented 2019-06-25 11:41:12 +02:00 (Migrated from github.com)

Even so, I'd still disagree with changing this. It's not that we don't want the URL accessible outside the class, but that we don't want to leak secrets. Add a clean_url property which has this functionality, and we've now mirrored other similar in use APIs in a more clear manner.

All this does is make someone have to follow around some code to see why this is done this way, as neither of these are now documented, and we would be using both (even if only internally)

Even so, I'd still disagree with changing this. It's not that we don't want the URL accessible outside the class, but that we don't want to leak secrets. Add a `clean_url` property which has this functionality, and we've now mirrored other similar in use APIs in a more clear manner. All this does is make someone have to follow around some code to see why this is done this way, as neither of these are now documented, and we would be using both (even if only internally)
mikeshardmind commented 2019-06-25 11:43:57 +02:00 (Migrated from github.com)

(and such a change should probably include documenting both, the currently existing one with a note to note that it's unsafe to send to discord and a ref to clean_url for such)

(and such a change should probably include documenting both, the currently existing one with a note to note that it's unsafe to send to discord and a ref to `clean_url` for such)
Zephyrkul commented 2019-06-25 22:39:43 +02:00 (Migrated from github.com)

I will close this PR in favor of such an approach by a different PR, then.

I will close this PR in favor of such an approach by a different PR, then.
Zephyrkul commented 2019-06-30 19:50:43 +02:00 (Migrated from github.com)

If I may ask... is there any particular reason we want this unsanitized URL available as a public API? Do any core cogs use it outside of the Repo class? Would these cogs require the auth? Should we allow access to the auth to 3rd party cogs if we're keeping this as part of the API? Is there any reason these cogs would need the unsanitized URL over the sanitized URL, and if so, is there any reason that they wouldn't just use the Repo class itself and let it handle the unsanitized URL? Is it worth the risk of malicious 3rd party code?

If I may ask... is there any particular reason we *want* this unsanitized URL available as a public API? Do any core cogs use it outside of the Repo class? Would these cogs require the auth? Should we allow access to the auth to 3rd party cogs if we're keeping this as part of the API? Is there any reason these cogs would need the unsanitized URL over the sanitized URL, and if so, is there any reason that they wouldn't just use the Repo class itself and let it handle the unsanitized URL? Is it worth the risk of malicious 3rd party code?
mikeshardmind commented 2019-06-30 20:01:11 +02:00 (Migrated from github.com)

I thought my last comments on this were pretty clear, but I guess I'll clear it up.

Having a ._url and .url, neither of which are documented and both would need to be used is not okay, even from just an internal maintaining perspective.

Names should be meaningful.

As for changing the API here to not allow it to be accessed externally, I'm actually not in favor of it. I see no good reason to hide access to it.

Is it worth the risk of malicious 3rd party code?

If you load code, the assumption is you trust the code to do what it is supposed to. Hiding this attribute doesn't remove the ability for malicious code someone loaded to use it, it just creates more things which aren't documented. There's no such thing as private in python, it's only private by convention.

On the other hand, to prevent it from being accidentally leaked to discord, creating a .clean_url property (and documenting it, and the .url attribute) creates more maintainable code, and helps with pieces of code which communicate with users in discord.

I thought my last comments on this were pretty clear, but I guess I'll clear it up. Having a `._url` and `.url`, neither of which are documented and both would need to be used is not okay, even from just an internal maintaining perspective. Names should be meaningful. As for changing the API here to not allow it to be accessed externally, I'm actually not in favor of it. I see no good reason to hide access to it. > Is it worth the risk of malicious 3rd party code? If you load code, the assumption is you trust the code to do what it is supposed to. Hiding this attribute doesn't remove the ability for malicious code someone loaded to use it, it just creates more things which aren't documented. There's no such thing as private in python, it's only private by convention. On the other hand, to prevent it from being accidentally leaked to discord, creating a `.clean_url` property (and documenting it, and the `.url` attribute) creates more maintainable code, and helps with pieces of code which communicate with users in discord.

Pull request closed

Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!2774
No description provided.