[V3 Mongo] Unescaped username/password #2079

Closed
opened 2018-09-02 03:46:58 +02:00 by Zephyrkul · 1 comment
Zephyrkul commented 2018-09-02 03:46:58 +02:00 (Migrated from github.com)

Other bugs

What were you trying to do?

redbot <instance> to start the instance after setting up mongodb with authentication. Using the latest V3/Develop build.

What were you expecting to happen?

redbot asks for token / prefix and begins.

What actually happened?

This traceback (clicky)

Traceback (most recent call last):
  File "/home/zephyrkul/.pyenv/versions/red/bin/redbot", line 11, in <module>
    load_entry_point('Red-DiscordBot==3.0.0b20', 'console_scripts', 'redbot')()
  File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/__main__.py", line 131, in main
    red = Red(cli_flags=cli_flags, description=description, pm_help=None)
  File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/bot.py", line 42, in __init__
    self.db = Config.get_core_conf(force_registration=True)
  File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/config.py", line 579, in get_core_conf
    driver_name, "Core", "0", data_path_override=core_path, **driver_details
  File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/drivers/__init__.py", line 32, in get_driver
    return Mongo(*args, **kwargs)
  File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/drivers/red_mongo.py", line 35, in __init__
    _initialize(**kwargs)
  File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/drivers/red_mongo.py", line 23, in _initialize
    _conn = motor.motor_asyncio.AsyncIOMotorClient(url)
  File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/motor/core.py", line 141, in __init__
    delegate = self.__delegate_class__(*args, **kwargs)
  File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/pymongo/mongo_client.py", line 494, in __init__
    res = uri_parser.parse_uri(entity, port, warn=True)
  File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/pymongo/uri_parser.py", line 379, in parse_uri
    user, passwd = parse_userinfo(userinfo)
  File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/pymongo/uri_parser.py", line 97, in parse_userinfo
    "RFC 3986, use %s()." % quote_fn)
pymongo.errors.InvalidURI: Username and password must be escaped according to RFC 3986, use urllib.parse.quote_plus().

How can we reproduce this issue?

Setup a mongo user with a username / password with URL-unsafe characters and run redbot-setup, then run redbot <instance>.

Small note

Opening a Python interpreter and running quote_plus on my username / password and passing the percent-encoded strings to redbot-setup fixed it on my end.

# Other bugs <!-- Did you find a bug with something other than a command? Fill out the following: --> #### What were you trying to do? `redbot <instance>` to start the instance after setting up mongodb with authentication. Using the latest V3/Develop build. #### What were you expecting to happen? redbot asks for token / prefix and begins. #### What actually happened? <details><summary>This traceback (clicky)</summary><p> ```python Traceback (most recent call last): File "/home/zephyrkul/.pyenv/versions/red/bin/redbot", line 11, in <module> load_entry_point('Red-DiscordBot==3.0.0b20', 'console_scripts', 'redbot')() File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/__main__.py", line 131, in main red = Red(cli_flags=cli_flags, description=description, pm_help=None) File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/bot.py", line 42, in __init__ self.db = Config.get_core_conf(force_registration=True) File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/config.py", line 579, in get_core_conf driver_name, "Core", "0", data_path_override=core_path, **driver_details File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/drivers/__init__.py", line 32, in get_driver return Mongo(*args, **kwargs) File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/drivers/red_mongo.py", line 35, in __init__ _initialize(**kwargs) File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/drivers/red_mongo.py", line 23, in _initialize _conn = motor.motor_asyncio.AsyncIOMotorClient(url) File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/motor/core.py", line 141, in __init__ delegate = self.__delegate_class__(*args, **kwargs) File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/pymongo/mongo_client.py", line 494, in __init__ res = uri_parser.parse_uri(entity, port, warn=True) File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/pymongo/uri_parser.py", line 379, in parse_uri user, passwd = parse_userinfo(userinfo) File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/pymongo/uri_parser.py", line 97, in parse_userinfo "RFC 3986, use %s()." % quote_fn) pymongo.errors.InvalidURI: Username and password must be escaped according to RFC 3986, use urllib.parse.quote_plus(). ``` </p></details> #### How can we reproduce this issue? Setup a mongo user with a username / password with URL-unsafe characters and run `redbot-setup`, then run `redbot <instance>`. #### Small note Opening a Python interpreter and running `quote_plus` on my username / password and passing the percent-encoded strings to `redbot-setup` fixed it on my end.
Tobotimus commented 2018-09-09 15:07:58 +02:00 (Migrated from github.com)

Resolved by #2111.

Resolved by #2111.
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#2079
No description provided.