Skip to content

Indentation handling for multiline encrypted values #49

@adamsilkcm

Description

@adamsilkcm

Current behavior:

When attemptnig to decrypt a value that is indented, the indentation is considered part of the block to handle and gets re-encrypted.
E.g.

---
nested:
  with:
    indentation: !vault |
      $ANSIBLE_VAULT;1.1;AES256
      66393664653066663837336333626666653233353164343332386439353830356238346538383963
      6331613230303632616665306230333430393862323737623664

Highlighting the last three lines and the toggling encryption produces something like this:

---
nested:
  with:
    indentation: !vault |
$ANSIBLE_VAULT;1.1;AES256
30383735633861383762613236356435303863396531376331623335303263313636633638373436
39636438363531393562353530616264613331316139326232316230383530376639636136336537
35363833636339326366613632343263636264346235343838663434313535656234393865306335
3065316662666563353364333337386138660

Desired behavior

Detect ANSIBLE_VAULT string to determine encryption or decryption, then strip leading whitespace from lines before decrypting.
Above actions would produce something like:

---
nested:
  with:
    indentation: !vault |
cleartext

Workarounds:

Manually dedenting before toggling works, just adds an extra chord between me and the cleartext.

Other notes:

Vault does not produce leading whitespace in its output, so there is no risk of removing information when removing leading whitespace.
Vault errors with Non-hexadecimal digit found ERROR when attempting to decrypt items with spaces in them.
Auto-indenting upon encryption not desired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions