{"action":"created","issue":{"url":"https://api.github.com/repos/kontena/kontena/issues/2324","repository_url":"https://api.github.com/repos/kontena/kontena","labels_url":"https://api.github.com/repos/kontena/kontena/issues/2324/labels{/name}","comments_url":"https://api.github.com/repos/kontena/kontena/issues/2324/comments","events_url":"https://api.github.com/repos/kontena/kontena/issues/2324/events","html_url":"https://github.com/kontena/kontena/issues/2324","id":228968380,"number":2324,"title":"Server string validations do not reject newlines","user":{"login":"SpComb","id":3950373,"avatar_url":"https://avatars1.githubusercontent.com/u/3950373?v=3","gravatar_id":"","url":"https://api.github.com/users/SpComb","html_url":"https://github.com/SpComb","followers_url":"https://api.github.com/users/SpComb/followers","following_url":"https://api.github.com/users/SpComb/following{/other_user}","gists_url":"https://api.github.com/users/SpComb/gists{/gist_id}","starred_url":"https://api.github.com/users/SpComb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpComb/subscriptions","organizations_url":"https://api.github.com/users/SpComb/orgs","repos_url":"https://api.github.com/users/SpComb/repos","events_url":"https://api.github.com/users/SpComb/events{/privacy}","received_events_url":"https://api.github.com/users/SpComb/received_events","type":"User","site_admin":false},"labels":[{"id":190601900,"url":"https://api.github.com/repos/kontena/kontena/labels/bug","name":"bug","color":"fc2929","default":true},{"id":213547662,"url":"https://api.github.com/repos/kontena/kontena/labels/server","name":"server","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-16T09:27:05Z","updated_at":"2017-05-16T10:09:48Z","closed_at":null,"body":"The server validations that create new named objects `GridServices::Create`, `Stacks::Create`, `Volumes::Create`  typically use a regexp to validate the name:\r\n\r\n```ruby\r\n      string :name, matches: /^(?!-)(\\w|-)+$/ # do not allow \"-\" as a first character\r\n```\r\n\r\nHowever, the use of `^` as an anchor does not match the beginning of the string, it matches the beginning of a line. This means that the name can contain a newline, and any arbitrary garbage, provided that least one \"line\" is a valid name. This allows names like:\r\n\r\n* `kontena service deploy $'redis\\ntest'`\r\n* `kontena service create $'redis\\n{}test--<>' redis`\r\n* `kontena service create $'redis\\n☃' redis`\r\n\r\n#### `DEBUG=api kontena service create $'redis\\ntest' redis`\r\n```\r\n[API Client Request]: POST http://localhost:9292/v1/grids/development/services | Headers: {Accept: application/json, Content-Type: application/json, Authorization: Bearer}  | Body: \r\n{\"name\":\"redis\\ntest\",\"image\":\"redis:latest\",\"stateful\":false,\"secrets\":[],\"privileged\":false,\"log_opts\":{}}\r\n[API Client Response]: Headers: {Content-Type: application/json}  | Status: 201 | Body: \r\n{\"id\":\"development/null/redis\\ntest\",\"created_at\":\"2017-05-16T09:21:59.031Z\",\"updated_at\":\"2017-05-16T09:21:59.031Z\",\"image\":\"redis:latest\",\"affinity\":[],\"name\":\"redis\\ntest\",\"stateful\":false,\"user\":null,\"instances\":1,\"cmd\":null,\"entrypoint\":null,\"net\":\"bridge\",\"dns\":\"redis\\ntest.development.kontena.local\",\"ports\":[],\"env\":[],\"secrets\":[],\"memory\":null,\"memory_swap\":null,\"cpu_shares\":null,\"volumes\":[],\"volumes_from\":[],\"cap_add\":[],\"cap_drop\":[],\"state\":\"initialized\",\"grid\":{\"id\":\"development\"},\"stack\":{\"id\":\"development/null\",\"name\":\"null\"},\"links\":[],\"log_driver\":null,\"log_opts\":{},\"strategy\":\"ha\",\"deploy_opts\":{\"_id\":{\"$oid\":\"591ac4b7de357847e2000002\"},\"interval\":null,\"min_health\":0.8,\"wait_for_port\":null},\"pid\":null,\"instance_counts\":{\"total\":0,\"running\":0},\"hooks\":[],\"revision\":1,\"stack_revision\":null}\r\n [done] Creating redis\r\ntest service      \r\n```\r\n\r\n#### `kontena service ls`\r\n```\r\nNAME                                                         INSTANCES  STATEFUL STATE      EXPOSED PORTS                                     \r\n⊝ redis\r\ntest                                                 0 / 1      no       initialized                                                   \r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/kontena/kontena/issues/comments/301736991","html_url":"https://github.com/kontena/kontena/issues/2324#issuecomment-301736991","issue_url":"https://api.github.com/repos/kontena/kontena/issues/2324","id":301736991,"user":{"login":"SpComb","id":3950373,"avatar_url":"https://avatars1.githubusercontent.com/u/3950373?v=3","gravatar_id":"","url":"https://api.github.com/users/SpComb","html_url":"https://github.com/SpComb","followers_url":"https://api.github.com/users/SpComb/followers","following_url":"https://api.github.com/users/SpComb/following{/other_user}","gists_url":"https://api.github.com/users/SpComb/gists{/gist_id}","starred_url":"https://api.github.com/users/SpComb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpComb/subscriptions","organizations_url":"https://api.github.com/users/SpComb/orgs","repos_url":"https://api.github.com/users/SpComb/repos","events_url":"https://api.github.com/users/SpComb/events{/privacy}","received_events_url":"https://api.github.com/users/SpComb/received_events","type":"User","site_admin":false},"created_at":"2017-05-16T10:09:48Z","updated_at":"2017-05-16T10:09:48Z","body":"Good news is that the Kontena Cloud -integration seems to be unicode-safe\r\n\r\n![2017-05-16-122922_822x273_scrot](https://cloud.githubusercontent.com/assets/3950373/26101190/ed11cee0-3a38-11e7-92ba-edf18837c00a.png)\r\n"}}
{"actor":{"display_login":"SpComb"}}