saltstack/salt

[BUG] tls.create_csr doesn't check csr_path has a trailing slash before concatenating it

Open

#60,877 建立於 2021年9月13日

在 GitHub 查看
 (4 留言) (0 反應) (0 負責人)Python (13,710 star) (5,508 fork)batch import
Execution-Modulebugeffort-smallgood first issuehelp-wanted

描述

Description In log messages, salt.modules.tls uses csr_path in log messages without checking for a trailing slash, resulting in misleading log entries:

'Created Private Key: "/etc/ssl/MYCA/certsMY.HOSTNAME.key." '

(It also makes it appear that there's a trailing dot on the filename)

https://github.com/saltstack/salt/blob/v3003.3/salt/modules/tls.py#L1167 among other places. It probably affects other functions in this module too.

This only affects log messages, so it's not too important.

Setup

    result = __salt__['tls.create_csr'](ca_name,
                                        cacert_path=str(top_dir),
                                        csr_path=str(top_dir / ca_name / 'certs'),
                                        CN=minion_id, ...

Steps to Reproduce the behavior (Include debug logs if possible and relevant)

Call tls.create_csr with a csr_path which lacks a trailing slash.

Expected behavior Correct filename to appear in the log message.

Versions Report

Salt Version:
          Salt: 3003.3
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: unknown
      dateutil: 2.7.3
     docker-py: Not Installed
         gitdb: 2.0.5
     gitpython: 2.1.11
        Jinja2: 2.10
       libgit2: Not Installed
      M2Crypto: 0.31.0
          Mako: Not Installed
       msgpack: 0.5.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 2.6.1
  pycryptodome: 3.6.1
        pygit2: Not Installed
        Python: 3.7.3 (default, Jan 22 2021, 20:04:44)
  python-gnupg: Not Installed
        PyYAML: 3.13
         PyZMQ: 17.1.2
         smmap: 2.0.5
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.1
 
System Versions:
          dist: debian 10 buster
        locale: UTF-8
       machine: x86_64
       release: 4.19.0-17-cloud-amd64
        system: Linux
       version: Debian GNU/Linux 10 buster

貢獻者指南