ft-circleci-orbs / doppler-circleci-orb

A CircleCI orb to load secrets managed in Doppler into CircleCI projects as environment variables.
MIT License
0 stars 0 forks source link

Properly escape exports from the .env file using the jq @sh operator #20

Closed ob6160 closed 4 months ago

ob6160 commented 4 months ago

Summary

Fixes an issue with environment variable exports in the doppler-circleci-orb tool, where variables containing $$ (or other values that would be evaluated by the shell environment) were incorrectly evaluated as the process ID when using source .env to import the exports.

Details

This change implements a fix that utilises the built-in @sh filter in jq to escape each value properly and wraps entries in single quotes to prevent evaluation.

Docs for the filter state:

The input is escaped suitable for use in a command-line for a POSIX shell. If the input is an array, the output will be a series of space-separated strings.

Before

# Unexpectedly becomes "secret<Process ID>val" when sourced
export SECRET="secret$$val"

After

# Stays our expected value "secret$$val" when sourced
export SECRET='secret$$val'