Sensu-go: Validation does not work on strings with `==`

Created on 4 Sep 2019  路  2Comments  路  Source: sensu/sensu-go

Expected Behavior



I should be able to use a string with == in it and it still pass validation

Current Behavior


Adding a string with == results in validation failing. Consider the following:

  - API_TOKEN=bobsyouruncle==

Will cause validation to fail.

Steps to Reproduce (for bugs)


  1. See above
    2.
    3.
    4.

Context



Currently, I cannot use an API token with == in it as an env_var inside of my config.

bug

Most helpful comment

The issue needs to be fixed around there:
https://github.com/sensu/sensu-go/blob/a786ceeb603601f89a39276824de346b098ad5e4/api/core/v2/env_vars.go#L8-L17

This code claims that an environment variable is always of the form FOO=BAR; this is inaccurate, or at least misleading. There are no restrictions on the value of environment variables, and they are allowed to contain =s. See the relevant POSIX section.

All 2 comments

Our validation is a bit too strict, here's where it's failing: https://github.com/sensu/sensu-go/blob/a786ceeb603601f89a39276824de346b098ad5e4/api/core/v2/env_vars.go#L10-L12

We should probably simply split on the first occurrence of = and make sure we have two parts.

The issue needs to be fixed around there:
https://github.com/sensu/sensu-go/blob/a786ceeb603601f89a39276824de346b098ad5e4/api/core/v2/env_vars.go#L8-L17

This code claims that an environment variable is always of the form FOO=BAR; this is inaccurate, or at least misleading. There are no restrictions on the value of environment variables, and they are allowed to contain =s. See the relevant POSIX section.

Was this page helpful?
0 / 5 - 0 ratings