{"action":"closed","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/36961","repository_url":"https://api.github.com/repos/saltstack/salt","labels_url":"https://api.github.com/repos/saltstack/salt/issues/36961/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/36961/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/36961/events","html_url":"https://github.com/saltstack/salt/issues/36961","id":182676663,"number":36961,"title":"boto_secgroup assumes a string when checking ip_protocol validity when not tcp|udp|all|-1","user":{"login":"nullify005","id":13192879,"avatar_url":"https://avatars.githubusercontent.com/u/13192879?v=3","gravatar_id":"","url":"https://api.github.com/users/nullify005","html_url":"https://github.com/nullify005","followers_url":"https://api.github.com/users/nullify005/followers","following_url":"https://api.github.com/users/nullify005/following{/other_user}","gists_url":"https://api.github.com/users/nullify005/gists{/gist_id}","starred_url":"https://api.github.com/users/nullify005/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nullify005/subscriptions","organizations_url":"https://api.github.com/users/nullify005/orgs","repos_url":"https://api.github.com/users/nullify005/repos","events_url":"https://api.github.com/users/nullify005/events{/privacy}","received_events_url":"https://api.github.com/users/nullify005/received_events","type":"User","site_admin":false},"labels":[{"id":41387723,"url":"https://api.github.com/repos/saltstack/salt/labels/Bug","name":"Bug","color":"e11d21","default":false},{"id":41389957,"url":"https://api.github.com/repos/saltstack/salt/labels/Fixed%20Pending%20Verification","name":"Fixed Pending Verification","color":"d4c5f9","default":false},{"id":41388135,"url":"https://api.github.com/repos/saltstack/salt/labels/High%20Severity","name":"High Severity","color":"ff9143","default":false},{"id":194766324,"url":"https://api.github.com/repos/saltstack/salt/labels/P4","name":"P4","color":"031a39","default":false},{"id":220527153,"url":"https://api.github.com/repos/saltstack/salt/labels/RIoT","name":"RIoT","color":"fef2c0","default":false},{"id":41387450,"url":"https://api.github.com/repos/saltstack/salt/labels/State%20Module","name":"State Module","color":"006b75","default":false}],"state":"closed","locked":false,"assignee":{"login":"rallytime","id":6547906,"avatar_url":"https://avatars.githubusercontent.com/u/6547906?v=3","gravatar_id":"","url":"https://api.github.com/users/rallytime","html_url":"https://github.com/rallytime","followers_url":"https://api.github.com/users/rallytime/followers","following_url":"https://api.github.com/users/rallytime/following{/other_user}","gists_url":"https://api.github.com/users/rallytime/gists{/gist_id}","starred_url":"https://api.github.com/users/rallytime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rallytime/subscriptions","organizations_url":"https://api.github.com/users/rallytime/orgs","repos_url":"https://api.github.com/users/rallytime/repos","events_url":"https://api.github.com/users/rallytime/events{/privacy}","received_events_url":"https://api.github.com/users/rallytime/received_events","type":"User","site_admin":false},"assignees":[{"login":"rallytime","id":6547906,"avatar_url":"https://avatars.githubusercontent.com/u/6547906?v=3","gravatar_id":"","url":"https://api.github.com/users/rallytime","html_url":"https://github.com/rallytime","followers_url":"https://api.github.com/users/rallytime/followers","following_url":"https://api.github.com/users/rallytime/following{/other_user}","gists_url":"https://api.github.com/users/rallytime/gists{/gist_id}","starred_url":"https://api.github.com/users/rallytime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rallytime/subscriptions","organizations_url":"https://api.github.com/users/rallytime/orgs","repos_url":"https://api.github.com/users/rallytime/repos","events_url":"https://api.github.com/users/rallytime/events{/privacy}","received_events_url":"https://api.github.com/users/rallytime/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/saltstack/salt/milestones/93","html_url":"https://github.com/saltstack/salt/milestones/C%201","labels_url":"https://api.github.com/repos/saltstack/salt/milestones/93/labels","id":2014597,"number":93,"title":"C 1","description":"","creator":{"login":"meggiebot","id":12242451,"avatar_url":"https://avatars.githubusercontent.com/u/12242451?v=3","gravatar_id":"","url":"https://api.github.com/users/meggiebot","html_url":"https://github.com/meggiebot","followers_url":"https://api.github.com/users/meggiebot/followers","following_url":"https://api.github.com/users/meggiebot/following{/other_user}","gists_url":"https://api.github.com/users/meggiebot/gists{/gist_id}","starred_url":"https://api.github.com/users/meggiebot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meggiebot/subscriptions","organizations_url":"https://api.github.com/users/meggiebot/orgs","repos_url":"https://api.github.com/users/meggiebot/repos","events_url":"https://api.github.com/users/meggiebot/events{/privacy}","received_events_url":"https://api.github.com/users/meggiebot/received_events","type":"User","site_admin":false},"open_issues":36,"closed_issues":9,"state":"open","created_at":"2016-09-19T18:15:10Z","updated_at":"2016-11-06T23:23:25Z","due_on":"2016-11-25T00:00:00Z","closed_at":null},"comments":2,"created_at":"2016-10-13T01:59:51Z","updated_at":"2016-11-06T23:23:25Z","closed_at":"2016-11-06T23:23:25Z","body":"### Description of Issue\n\nWhen trying to create a secgroup using a numbered protocol the jinja renderer + sls appears to be calling boto_segroup.present with the ip_protocol as an int if the ip_protocol is clearly not a string (such as udp, tdp or all)\n\nThis has the effect of causing an exception when isdigit() is called on an int\n\nFor example:\n\n```\n----------\n          ID: secgroup out-all-ipsec\n    Function: boto_secgroup.present\n        Name: out-all-ipsec\n      Result: False\n     Comment: An exception occurred in this state: Traceback (most recent call last):\n                File \"lib/python2.7/site-packages/salt/state.py\", line 1733, in call\n                  **cdata['kwargs'])\n                File \"lib/python2.7/site-packages/salt/loader.py\", line 1652, in wrapper\n                  return f(*args, **kwargs)\n                File \"lib/python2.7/site-packages/salt/states/boto_secgroup.py\", line 196, in present\n                  keyid=keyid, profile=profile)\n                File \"lib/python2.7/site-packages/salt/states/boto_secgroup.py\", line 496, in _rules_egress_present\n                  rules_egress, sg['rules_egress']\n                File \"lib/python2.7/site-packages/salt/states/boto_secgroup.py\", line 335, in _get_rule_changes\n                  if ip_protocol not in supported_protocols and (not ip_protocol.isdigit() or int(ip_protocol) > 255):\n              AttributeError: 'int' object has no attribute 'isdigit'\n     Started: 12:40:45.978571\n    Duration: 1470.994 ms\n     Changes: \n```\n\nIf https://github.com/saltstack/salt/blob/v2016.3.3/salt/states/boto_secgroup.py#L329 is changed to cast ip_protocol to a string, then everything is fine & the state execution passes.\n\n```\n    for rule in rules:\n        try:\n            ip_protocol = str(rule.get('ip_protocol')) <--- HERE\n        except KeyError:\n            raise SaltInvocationError('ip_protocol, to_port, and from_port are'\n                                      ' required arguments for security group'\n                                      ' rules.')\n```\n\nI've tried quoting the ip_protocol numbers in the SLS with single & double quotes, but it's not working. I think the renderer or salt is seeing that it's an int & then passing it to the state / modules as an int instead of as a string (which is ideally what boto_secgroup wants)\n### Setup\n\nContrived sls example:\n\n```\nsecgroup out-all-ipsec:\n    boto_secgroup.present:\n        - name: out-all-ipsec\n        - description: Allow Output to IPSEC protocols to Anywhere\n        - rules: []\n        - rules_egress:\n            - ip_protocol: 50\n              from_port: -1\n              to_port: -1\n              cidr_ip:\n                  - 0.0.0.0/0\n            - ip_protocol: 51\n              from_port: -1\n              to_port: -1\n              cidr_ip:\n                  - 0.0.0.0/0\n            - ip_protocol: udp\n              from_port: 500\n              to_port: 500\n              cidr_ip:\n                  - 0.0.0.0/0\n            - ip_protocol: udp\n              from_port: 4500\n              to_port: 4500\n              cidr_ip:\n                  - 0.0.0.0/0\n        - tags:\n            saltmanaged: true\n        - region: TEH_REGION\n        - keyid: TEH_KEYID\n        - key: TEH_KEY\n        - vpc_name: TEH_VPC_NAME\n```\n### Steps to Reproduce Issue\n\nUse the above SLS with valid keys etc. & it will result in the aforementioned exception\n### Versions Report\n\n```\nSalt Version:\n           Salt: 2016.3.3\n\nDependency Versions:\n           cffi: Not Installed\n       cherrypy: Not Installed\n       dateutil: 2.5.3\n          gitdb: Not Installed\n      gitpython: Not Installed\n          ioflo: Not Installed\n         Jinja2: 2.8\n        libgit2: Not Installed\n        libnacl: Not Installed\n       M2Crypto: Not Installed\n           Mako: Not Installed\n   msgpack-pure: Not Installed\n msgpack-python: 0.4.8\n   mysql-python: Not Installed\n      pycparser: Not Installed\n       pycrypto: 2.6.1\n         pygit2: Not Installed\n         Python: 2.7.10 (default, Oct 23 2015, 19:19:21)\n   python-gnupg: Not Installed\n         PyYAML: 3.12\n          PyZMQ: 15.4.0\n           RAET: Not Installed\n          smmap: Not Installed\n        timelib: Not Installed\n        Tornado: 4.4.1\n            ZMQ: 4.1.5\n\nSystem Versions:\n           dist:   \n        machine: x86_64\n        release: 15.6.0\n         system: Darwin\n        version: 10.11.6 x86_64\n```\n"}}
{"actor":{"display_login":"cachedout"}}