HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/renderers/__pycache__/nacl.cpython-310.pyc
o

�N�gG
�@sHdZddlZddlZddlZddlZe�e�ZdZ	dd�Z
d
dd	�ZdS)au
Renderer that will decrypt NACL ciphers

Any key in the SLS file can be an NACL cipher, and this renderer will decrypt it
before passing it off to Salt. This allows you to safely store secrets in
source control, in such a way that only your Salt master can decrypt them and
distribute them only to the minions that need them.

The typical use-case would be to use ciphers in your pillar data, and keep a
secret key on your master. You can put the public key in source control so that
developers can add new secrets quickly and easily.

This renderer requires the libsodium library binary and PyNacl >= 1.0


Setup
-----

To set things up, first generate a keypair. On the master, run the following:

.. code-block:: bash

    # salt-call --local nacl.keygen sk_file=/root/.nacl


Using encrypted pillar
----------------------

To encrypt secrets, copy the public key to your local machine and run:

.. code-block:: bash

    $ salt-call --local nacl.enc datatoenc pk_file=/root/.nacl.pub


To apply the renderer on a file-by-file basis add the following line to the
top of any pillar with nacl encrypted data in it:

.. code-block:: yaml

    #!yaml|nacl

Now with your renderer configured, you can include your ciphers in your pillar
data like so:

.. code-block:: yaml

    #!yaml|nacl

    a-secret: "NACL[MRN3cc+fmdxyQbz6WMF+jq1hKdU5X5BBI7OjK+atvHo1ll+w1gZ7XyWtZVfq9gK9rQaMfkDxmidJKwE0Mw==]"
�Nz^NACL\[(.*)\]$cKs�tjj�|�rt|��fi|��St|t�r1t�	t
|�dur/tdt�	t
|��d�fi|��S|St|t
�rK|��D]\}}t|fi|��||<q:|St|t�ret|�D]\}}t|fi|��||<qT|S|S)z�
    Recursively try to decrypt any object. If the object is a str, and it
    contains a valid NACLENC pretext, decrypt it, otherwise keep going until a
    string is found.
    Nznacl.dec�)�salt�utilsZstringioZis_readable�_decrypt_object�getvalue�
isinstance�str�re�search�
NACL_REGEXZ__salt__�group�dict�items�list�	enumerate)�obj�kwargs�key�value�r�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/renderers/nacl.pyr?s
"

r�base�cKst|fi|��S)za
    Decrypt the data to be rendered using the given nacl key or the one given
    in config
    )r)Z	nacl_dataZsaltenvZslsZarglinerrrr�renderXsr)rrr)�__doc__�loggingr	Z
salt.syspathsrZsalt.utils.stringio�	getLogger�__name__�logrrrrrrr�<module>s4