Browse files

libraries.core: Convert the port number to a string

Previously, when checking the port number against the regex, we
assumed that the port would always be a string.  When an integer
was passed to the check_port function it would blow up and fail
the chef-client run.

This change will convert the value passed to a string and then
attempt to run the regex against the value.

The offending value was passed like:

AFW.create_rule(node, 'Some rule', {
  'protocol' => 'tcp',
  'direction' => 'out',
  'user' => 'some_chump',
  'destination' => '',
  'dport' => 8080
  • Loading branch information...
1 parent 41e5535 commit 0633ddf2c91457a1378b2809ee00ef1f720cec89 Dan Tracy committed Jun 17, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 libraries/core.rb
@@ -194,7 +194,7 @@ def rule_validation(node, name, rule_params)
def check_port(port, name)
# check a (s|d)port against a regex
- unless port =~ PORT_VALID_REGEX
+ unless port.to_s =~ PORT_VALID_REGEX
raise ArgumentError, "Invalid Port '#{port}' in rule '#{name}'", caller
return true

0 comments on commit 0633ddf

Please sign in to comment.