ValueError when env variable password contains hash
See original GitHub issueIssue description
When a password passed through an env variable contains a hash (e.g. ab#cd
), a ValueError
is raised when calling pipenv install
. The error is not raised when the username also contains a hash.
Expected result
Just install the dependencies if the credentials are valid.
Actual result
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
using sources: [{'url': 'https://pypi.org/simple', 'verify_ssl': True, 'name': 'pypi'}, {'url': 'https://user:pass#word@simudyne.jfrog.io/simudyne/api/pypi/simudyne-pypi/simple', 'verify_ssl': True, 'name': 'simudyne_pypi'}]
Using pip: -i https://pypi.org/simple --extra-index-url https://user:pass#word@simudyne.jfrog.io/simudyne/api/pypi/simudyne-pypi/simple
ROUND 1
Current constraints:
ipykernel
simudyne
Finding the best candidates:
Traceback (most recent call last):
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 101, in <module>
main()
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 90, in main
system=system,
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 73, in resolve
allow_global=system,
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/utils.py", line 422, in resolve_deps
req_dir=req_dir,
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/utils.py", line 302, in actually_resolve_deps
results = resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS)
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
has_changed, best_matches = self._resolve_one_round()
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 198, in _resolve_one_round
best_matches = {self.get_best_match(ireq) for ireq in constraints}
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 198, in <setcomp>
best_matches = {self.get_best_match(ireq) for ireq in constraints}
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 263, in get_best_match
best_match = self.repository.find_best_match(ireq, prereleases=self.prereleases)
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 165, in find_best_match
all_candidates = clean_requires_python(self.find_all_candidates(ireq.name))
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 153, in find_all_candidates
candidates = self.finder.find_all_candidates(req_name)
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/index.py", line 458, in find_all_candidates
(Link(url) for url in dep_url_loc),
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/index.py", line 460, in <listcomp>
if self._validate_secure_origin(logger, link)
File "/home/simudyne/.local/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/index.py", line 341, in _validate_secure_origin
origin = (parsed.scheme, parsed.hostname, parsed.port)
File "/home/simudyne/anaconda3/lib/python3.6/urllib/parse.py", line 167, in port
port = int(port, 10)
ValueError: invalid literal for int() with base 10: 'pass'
Steps to replicate
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[[source]]
url = "https://${USER}:${PASSWORD}@simudyne.jfrog.io/simudyne/api/pypi/simudyne-pypi/simple"
verify_ssl = true
name = "simudyne_pypi"
[packages]
ipykernel = "*"
simudyne = {version = "*", index = "simudyne_pypi"}
This raises the ValueError
:
export USER="user"
export PASSWORD="pass#word"
pipenv install
This doesn’t raise the ValueError
:
export USER="user"
export PASSWORD="password"
pipenv install
This doesn’t raise the ValueError
:
export USER="us#er"
export PASSWORD="pass#word"
pipenv install
$ pipenv --support
Pipenv version: '2018.10.13'
Pipenv location: '/home/simudyne/.local/lib/python3.6/site-packages/pipenv'
Python location: '/home/simudyne/anaconda3/bin/python3'
Python installations found:
3.6.6
:/usr/bin/python3.6
3.6.6
:/usr/bin/python3.6m
2.7.15rc1
:/usr/bin/python2.7
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '3.6.4',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'CPython',
'platform_release': '4.15.0-36-generic',
'platform_system': 'Linux',
'platform_version': '#39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018',
'python_full_version': '3.6.4',
'python_version': '3.6',
'sys_platform': 'linux'}
System environment variables:
CLUTTER_IM_MODULE
SIMUDYNE_PASSWORD
LS_COLORS
LESSCLOSE
XDG_MENU_PREFIX
LANG
GDM_LANG
DISPLAY
OLDPWD
GTK2_MODULES
COLORTERM
XDG_VTNR
PASSWORD
SSH_AUTH_SOCK
MANDATORY_PATH
XDG_SESSION_ID
XDG_GREETER_DATA_DIR
USER
DESKTOP_SESSION
QT4_IM_MODULE
TEXTDOMAINDIR
GNOME_TERMINAL_SCREEN
DEFAULTS_PATH
QT_QPA_PLATFORMTHEME
PWD
HOME
TEXTDOMAIN
SSH_AGENT_PID
QT_ACCESSIBILITY
XDG_SESSION_TYPE
XDG_DATA_DIRS
XDG_SESSION_DESKTOP
GJS_DEBUG_OUTPUT
GTK_MODULES
TERM
SHELL
VTE_VERSION
XDG_SEAT_PATH
QT_IM_MODULE
XMODIFIERS
IM_CONFIG_PHASE
XDG_CURRENT_DESKTOP
GPG_AGENT_INFO
GNOME_TERMINAL_SERVICE
XDG_SEAT
SHLVL
LANGUAGE
GDMSESSION
GNOME_DESKTOP_SESSION_ID
LOGNAME
DBUS_SESSION_BUS_ADDRESS
XDG_RUNTIME_DIR
XAUTHORITY
XDG_SESSION_PATH
XDG_CONFIG_DIRS
PATH
AAA_BBB
GJS_DEBUG_TOPICS
SESSION_MANAGER
SIMUDYNE_USER
LESSOPEN
GTK_IM_MODULE
_
PYTHONDONTWRITEBYTECODE
PIP_SHIMS_BASE_MODULE
PIP_PYTHON_PATH
Pipenv–specific environment variables:
Debug–specific environment variables:
PATH
:/home/simudyne/anaconda3/bin:/home/simudyne/bin:/home/simudyne/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
SHELL
:/bin/bash
LANG
:en_GB.UTF-8
PWD
:/home/simudyne/Documents/python-client-app-example
Contents of Pipfile
(‘/home/simudyne/Documents/python-client-app-example/Pipfile’):
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[[source]]
url = "https://${USER}:${PASSWORD}@simudyne.jfrog.io/simudyne/api/pypi/simudyne-pypi/simple"
verify_ssl = true
name = "simudyne_pypi"
[packages]
ipykernel = "*"
simudyne = {version = "*", index = "simudyne_pypi"}
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Why am Getting a "ValueError: Your API ID or Hash cannot ...
So... in my python script i have: import os import asyncio import requests from telethon import TelegramClient TELEGRAM_POSTING_API_HASH = os.
Read more >passlib.exc - Exceptions and warnings
Error raised if a password can't be hashed / verified for various reasons. This exception derives from the builtin ValueError . May be...
Read more >cron is truncating environment variables containing a hash
I export my environment variables with env >> /etc/environment to expose them to my cron jobs. However one of my environment variables, ...
Read more >Password management in Django
Most password hashes include a salt along with their password hash in order to protect against rainbow table attacks. The salt itself is...
Read more >Using Environment Variables in Python for App Configuration ...
Environment variables have the additional benefit of abstracting from ... and a default value can't be provided, e.g. a database password.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, I guess I failed to make myself understood. I was trying to agree with you that an automatically encoded field needs to be specified in a dedicated field 😃
yup