{"action":"opened","issue":{"url":"https://api.github.com/repos/StackStorm/st2/issues/3077","repository_url":"https://api.github.com/repos/StackStorm/st2","labels_url":"https://api.github.com/repos/StackStorm/st2/issues/3077/labels{/name}","comments_url":"https://api.github.com/repos/StackStorm/st2/issues/3077/comments","events_url":"https://api.github.com/repos/StackStorm/st2/issues/3077/events","html_url":"https://github.com/StackStorm/st2/issues/3077","id":193035604,"number":3077,"title":"[st2reactor] Issue about no validation checking before dispatching trigger","user":{"login":"userlocalhost2000","id":469934,"avatar_url":"https://avatars.githubusercontent.com/u/469934?v=3","gravatar_id":"","url":"https://api.github.com/users/userlocalhost2000","html_url":"https://github.com/userlocalhost2000","followers_url":"https://api.github.com/users/userlocalhost2000/followers","following_url":"https://api.github.com/users/userlocalhost2000/following{/other_user}","gists_url":"https://api.github.com/users/userlocalhost2000/gists{/gist_id}","starred_url":"https://api.github.com/users/userlocalhost2000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/userlocalhost2000/subscriptions","organizations_url":"https://api.github.com/users/userlocalhost2000/orgs","repos_url":"https://api.github.com/users/userlocalhost2000/repos","events_url":"https://api.github.com/users/userlocalhost2000/events{/privacy}","received_events_url":"https://api.github.com/users/userlocalhost2000/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-02T05:08:39Z","updated_at":"2016-12-02T05:08:39Z","closed_at":null,"body":"The `dispatch` method on the `SensorService` class doens't check validation of `payload` argument which is passed to TriggerDispatcher with `payload_schema` of Trigger.\r\n\r\nSo a sensor can send a payload which is in violation of the `payload_schema` to a Trigger without warning or error, like following.\r\n\r\n```yaml\r\n---\r\nclass_name: 'TestSensor'\r\nentry_point: 'test.py'\r\ndescription: 'A test sensor'\r\npoll_interval: 5\r\n```\r\n\r\n```python\r\n### excerpt of test.py\r\nclass TestSensor(PollingSensor):\r\n    def poll(self):\r\n        payload = {\r\n            'hoge': [1,2,3],\r\n        }\r\n        self._sensor_service.dispatch(trigger=\"linux.file_watch.line\", payload=payload)\r\n...\r\n```\r\n\r\nThen we could conforme that this invalid payload could be get from the properties of `linux.file_watch.line` as below.\r\n\r\n```yaml\r\n---\r\nname: 'test-rule'\r\ndescription: 'A test rule'\r\nenabled: True\r\ntrigger:\r\n  type: linux.file_watch.line\r\n\r\n  action:\r\n    ref: 'core.local'\r\n    parameters:\r\n        cmd: 'echo {{trigger}} >> /tmp/test11'\r\n```\r\n\r\nAnd the output is here.\r\n\r\n```\r\n{hoge: [1, 2, 3]}\r\n{hoge: [1, 2, 3]}\r\n...\r\n```\r\n\r\n  I think the validation processing is needed to guarante that trigger output properties are based on `payload_schema` before dispatching Trigger.\r\n\r\nThank you."}}
{"actor":{"display_login":"userlocalhost2000"}}