Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CC-1227] Capability to provide environment variables from dashboard #317

Open
wants to merge 1 commit into
base: next-release
Choose a base branch
from

Conversation

jegasega
Copy link
Contributor

@jegasega jegasega commented Jan 31, 2018

Description of your patch

env_var cookbook update for checking environment variable name for unallowed characters and escaping special characters inside variable value.

Recommended Release Notes

None.

Estimated risk

Low

Components involved

env_vars cookbook

Description of testing done

See QA instructions

QA Instructions

  1. Create simple Ruby application. (https://github.com/engineyard/todo.git) can be used for this testing.
  2. Boot the environment with the latest V5 stack version. Environment should be run with following parameters:
  • Environment type - Single Instance.
  1. SSH to the instance.
  2. Add following lines to the /etc/chef/dna.json file after dh_key value:
                "environment_variables": [
                  {
                    "name": "MY_VAR_NAME",
                    "value": "VmFyaWFibGUgdmFsdWUgYCQoKQo="
                  }
                ]
  1. Run Chef PATH=/usr/local/ey_resin/bin:$PATH /home/ey/bin/chef-solo -j /etc/chef/dna.json -c /etc/chef/solo.rb
  2. Check /data/[YOUR APPLICATION NAME]/shared/config/env.cloud file. Ensure variable value characters are properly escaped.
  3. Change dna.json environment variable data to:
                "environment_variables": [
                  {
                    "name": "'MY_VAR_NAME",
                    "value": "VmFyaWFibGUgdmFsdWUgYCQoKQo="
                  }
                ]
  1. Run Chef PATH=/usr/local/ey_resin/bin:$PATH /home/ey/bin/chef-solo -j /etc/chef/dna.json -c /etc/chef/solo.rb
  2. Check /data/[YOUR APPLICATION NAME]/shared/config/env.cloud file. Ensure that no variables with invalid characters in variable name appeared.

@jfuechsl
Copy link
Contributor

This most likely needs to be ported to v6 as well.

Copy link
Contributor

@paulasaurus paulasaurus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails.

Test was done via dashboard environmental variables page, though results in the same DNA changes.

For multiline variables such as https://cloud.engineyard.com/app_deployments/110413/environment/environment_variables/593/edit the final env.cloud looks like:

export COMESTRI_HAPROXY_CERT="-----BEGIN CERTIFICATE-----^MMIIGsTCCBZmgAwIBAgIII7sCppK4rUcwDQYJKoZIhvcNAQELBQAwgbQxCzAJBgNV^MBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYD

rather than:

export COMESTRI_HAPROXY_CERT="-----BEGIN CERTIFICATE-----^M
MIIGsTCCBZmgAwIBAgIII7sCppK4rUcwDQYJKoZIhvcNAQELBQAwgbQxCzAJBgNV^M
BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRow^M

So new lines are removed, not sure how this would impact genuine environmental variables.

The bigger issue is that single line variables are removed completely: https://cloud.engineyard.com/app_deployments/110413/environment/environment_variables/773/edit which is "MY_VAR_NAME" "line1" or in the DNA:

"name": "MY_VAR_NAME",                                                                                                                                                                                         
"value": "bGluZTE="

Is export MY_VAR_NAME="" in the env.cloud file.

The dashboard environmental variables page actually rejected an incorrect name when testing. Do we still want to use this PR fix to reject variables should they ever be somehow injected directly into the DNA as per the testing steps here?

@jfuechsl jfuechsl self-assigned this Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants