saltstack / saltstack/salt

salt.modules.pip: Installing with the editable option does not validate local path correctly on Windows

Open
#55,097 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Confirmed Windows
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue

When specifying the editable option, the salt.modules.pip_state module checks the path that is passed in order to determine whether a local or remote path is specified. This is done by checking if the path begins with a "/" which can be incorrect on Windows.

salt.modules.pip.py:849

    if editable:
        egg_match = re.compile(r'(?:#|#.*?&)egg=([^&]*)')
        if isinstance(editable, six.string_types):
            editable = [e.strip() for e in editable.split(',')]

        for entry in editable:
            # Is the editable local?
            if not (entry == '.' or entry.startswith(('file://', '/'))):
                match = egg_match.search(entry)

                if not match or not match.group(1):
                    # Missing #egg=theEggName
                    raise CommandExecutionError(
                        'You must specify an egg for this editable'
                    )
            cmd.extend(['--editable', entry])

When the loop iterates through the list of editable paths, the entry is checked for "file://" and "/" in order to validate whether the editable is local or not. On windows, paths can begin with a letter followed by a ":".

Here's a regex that can probably be used to test for a valid windows path: ^[a-zA-Z]:\\[\\\S|*\S]?.*$. This appears exhaustive, but should probably be verified.

Setup

Install a salt-minion on windows.

Steps to Reproduce Issue
C> salt-call --local pip.install editable=C:/local-file-path`
Error running 'pip.install': You must specify an egg for this editable
Versions Report

Although the version here is 2019.2.0, it's in all versions as prior mentioned since commit 0bd2f6c06ee5196cde89271cc4752238539a29c9.

Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: 1.11.5
       cherrypy: 17.4.1
       dateutil: 2.7.5
      docker-py: Not Installed
          gitdb: 2.0.5
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: 1.6.1
       M2Crypto: Not Installed
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: 2.19
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:22:17) [MSC v.1500 32 bit (Intel)]
   python-gnupg: 0.4.3
         PyYAML: 3.13
          PyZMQ: 17.1.2
           RAET: Not Installed
          smmap: 2.0.5
        timelib: 0.2.4
        Tornado: 5.1.1
            ZMQ: 4.2.5
 
System Versions:
           dist:   
         locale: cp1252
        machine: AMD64
        release: 8
         system: Windows
        version: 8 6.2.9200 SP0 Multiprocessor Free

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading salt.modules.pip.py around line 849 and reproduce the reported salt-call command on Windows. Update the editable-path validation so a local Windows path such as C:/local-file-path is accepted without an egg, while remote editables still require one; verify the reported error no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.