-
Notifications
You must be signed in to change notification settings - Fork 289
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
to_type helper's handling of numbers is too loose #582
Comments
This is related to issue #682 to use Puppet v4's data types. We should enforce data types for certain values while respecting data types such as a string that looks like an integer, instead of transforming them. |
@cwjohnston Does Sensu have a need for integers to be cast as strings or to allow an integer with a leading zero? |
So, current situation, after migration to puppet 4 parameters validation, is that when integers are passed as strings they are accepted and should not be converted. |
@cwjohnston We need your guidance on what the right thing to do is regarding numbers. @threadwaste why would you have a number that begins with zero? |
@ghoneycutt Sensu implements what we call strong configuration validation, meaning Sensu will refuse to start if it determines configuration is invalid. This extends to a number of configuration attributes where integer values are required, e.g. port numbers, check intervals and keepalive or timeout thresholds. This strong validation does not extend to custom client or check attributes.
I'm not aware of any case where an attribute requires both an integer value and a leading zero.
I'm fine with this in principle. For example, the When we're looking at |
Thanks @cwjohnston ! @alvagante does this provide enough info to proceed? |
@ghoneycutt definitively, thank you @cwjohnston
|
@alvagante Seems like this is down a path, already. But, for context, identifiers like an AWS account number in the client's custom configuration where the intended target type is a string. While I don't have concrete examples of other cases, I could imagine similar types of inputs to say, handlers and checks. |
So, commit 636b3a8 removes integer validation and conversion of the keys of the custom parameter hash in sensu_client_config and should avoid cases like the ones mentioned in this issue. |
Description of problem
Tried to pass a numerical identifier with leading zeroes (e.g. "012345") through client_custom.
The identifier was converted to an integer, lost its leading zeroes, and stored as a JSON number.
The identifier would retain its leading zeroes, and be stored as a JSON string.
Anything else to add that you think will be helpful?
I'm trying to understand this helper better. The original commit suggests its tied to several type checks inside Sensu, which I'm guessing pose a problem when facts are used as parameter values. A quick
ag
of the source shows only a couple of these type checks present in HEAD for very specific values.Similarly, the use of #to_type in this module is inconsistent. For example, the sensu_client_config type calls it for keepalive, but not safe_mode.
I have two branches of this local that deal with this. One uses more specific matchers for numeric types, the other simply removes the calling #to_type over value for the client_custom parameter. Happy to PR one, but figured I'd seek clarification and input on direction first.
The text was updated successfully, but these errors were encountered: