salt icon indicating copy to clipboard operation
salt copied to clipboard

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

Open iaingeorgeson opened this issue 4 years ago • 2 comments

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 --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
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

iaingeorgeson avatar Sep 13 '21 20:09 iaingeorgeson

Can I tackle this? I am new to contributing in open source but this looks like a good start!

juanpi19 avatar May 30 '22 04:05 juanpi19

I am currently working on this.

huyta55 avatar Sep 21 '22 18:09 huyta55