{"action":"created","comment":{"url":"https://api.github.com/repos/cossacklabs/acra/pulls/comments/177761981","pull_request_review_id":107685016,"id":177761981,"diff_hunk":"@@ -0,0 +1,106 @@\n+package firewall\n+\n+import (\n+\t\"errors\"\n+\t\"github.com/xwb1989/sqlparser\"\n+\t\"gopkg.in/yaml.v2\"\n+\t\"github.com/cossacklabs/acra/firewall/handlers\"\n+)\n+\n+const BlacklistConfigStr = \"blacklist\"\n+const WhitelistConfigStr = \"whitelist\"\n+\n+var ErrQuerySyntaxError = errors.New(\"fail to parse specified query\")\n+var ErrStructureSyntaxError = errors.New(\"fail to parse specified structure\")\n+\n+type FirewallConfig struct {\n+\tHandlers []struct {\n+\t\tHandler string\n+\t\tQueries []string\n+\t\tTables  []string\n+\t\tRules   []string\n+\t}\n+}\n+\n+func (firewall *Firewall) SetFirewallConfiguration(configuration []byte) error {\n+\n+\terr := updateFirewall(firewall, configuration)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\treturn nil\n+}\n+\n+func updateFirewall(firewall *Firewall, configuration []byte) error {\n+\n+\tvar firewallConfiguration FirewallConfig\n+\n+\terr := yaml.Unmarshal(configuration, &firewallConfiguration)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\t//fmt.Println(firewallConfiguration)\n+\n+\tvar firewallCheckers []QueryHandlerInterface\n+\tfor _, handlerConfiguration := range firewallConfiguration.Handlers {\n+\t\tswitch handlerConfiguration.Handler{\n+\t\tcase WhitelistConfigStr:\n+\t\t\twhitelistHandler := &handlers.WhitelistHandler{}\n+\n+\t\t\twhitelistHandler.AddQueries(handlerConfiguration.Queries)","path":"firewall/firewall_configuration_provider.go","position":52,"original_position":52,"commit_id":"c2333ec7f981cb18c99853dfb63d1ec58e750a32","original_commit_id":"c2333ec7f981cb18c99853dfb63d1ec58e750a32","user":{"login":"Lagovas","id":6237700,"avatar_url":"https://avatars3.githubusercontent.com/u/6237700?v=4","gravatar_id":"","url":"https://api.github.com/users/Lagovas","html_url":"https://github.com/Lagovas","followers_url":"https://api.github.com/users/Lagovas/followers","following_url":"https://api.github.com/users/Lagovas/following{/other_user}","gists_url":"https://api.github.com/users/Lagovas/gists{/gist_id}","starred_url":"https://api.github.com/users/Lagovas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lagovas/subscriptions","organizations_url":"https://api.github.com/users/Lagovas/orgs","repos_url":"https://api.github.com/users/Lagovas/repos","events_url":"https://api.github.com/users/Lagovas/events{/privacy}","received_events_url":"https://api.github.com/users/Lagovas/received_events","type":"User","site_admin":false},"body":"better to check input params in AddQueries and return error here. Then we can drop extra function `testConfigurationSyntax` that in a future will grow with each new handler type or rules","created_at":"2018-03-28T14:08:39Z","updated_at":"2018-03-28T14:23:52Z","html_url":"https://github.com/cossacklabs/acra/pull/138#discussion_r177761981","pull_request_url":"https://api.github.com/repos/cossacklabs/acra/pulls/138","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/cossacklabs/acra/pulls/comments/177761981"},"html":{"href":"https://github.com/cossacklabs/acra/pull/138#discussion_r177761981"},"pull_request":{"href":"https://api.github.com/repos/cossacklabs/acra/pulls/138"}}},"pull_request":{"url":"https://api.github.com/repos/cossacklabs/acra/pulls/138","id":177990062,"html_url":"https://github.com/cossacklabs/acra/pull/138","diff_url":"https://github.com/cossacklabs/acra/pull/138.diff","patch_url":"https://github.com/cossacklabs/acra/pull/138.patch","issue_url":"https://api.github.com/repos/cossacklabs/acra/issues/138","number":138,"state":"open","locked":false,"title":"Updating firewall","user":{"login":"storojs72","id":20335747,"avatar_url":"https://avatars1.githubusercontent.com/u/20335747?v=4","gravatar_id":"","url":"https://api.github.com/users/storojs72","html_url":"https://github.com/storojs72","followers_url":"https://api.github.com/users/storojs72/followers","following_url":"https://api.github.com/users/storojs72/following{/other_user}","gists_url":"https://api.github.com/users/storojs72/gists{/gist_id}","starred_url":"https://api.github.com/users/storojs72/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storojs72/subscriptions","organizations_url":"https://api.github.com/users/storojs72/orgs","repos_url":"https://api.github.com/users/storojs72/repos","events_url":"https://api.github.com/users/storojs72/events{/privacy}","received_events_url":"https://api.github.com/users/storojs72/received_events","type":"User","site_admin":false},"body":"Add ability to configure firewall from configuration file","created_at":"2018-03-28T10:11:21Z","updated_at":"2018-03-28T14:23:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a889c18835a093acef5bb274e5dfde124324a27f","assignee":null,"assignees":[],"requested_reviewers":[{"login":"mozhmike","id":12601551,"avatar_url":"https://avatars3.githubusercontent.com/u/12601551?v=4","gravatar_id":"","url":"https://api.github.com/users/mozhmike","html_url":"https://github.com/mozhmike","followers_url":"https://api.github.com/users/mozhmike/followers","following_url":"https://api.github.com/users/mozhmike/following{/other_user}","gists_url":"https://api.github.com/users/mozhmike/gists{/gist_id}","starred_url":"https://api.github.com/users/mozhmike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozhmike/subscriptions","organizations_url":"https://api.github.com/users/mozhmike/orgs","repos_url":"https://api.github.com/users/mozhmike/repos","events_url":"https://api.github.com/users/mozhmike/events{/privacy}","received_events_url":"https://api.github.com/users/mozhmike/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":861780996,"url":"https://api.github.com/repos/cossacklabs/acra/labels/firewall","name":"firewall","color":"31bc5f","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/cossacklabs/acra/pulls/138/commits","review_comments_url":"https://api.github.com/repos/cossacklabs/acra/pulls/138/comments","review_comment_url":"https://api.github.com/repos/cossacklabs/acra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cossacklabs/acra/issues/138/comments","statuses_url":"https://api.github.com/repos/cossacklabs/acra/statuses/c2333ec7f981cb18c99853dfb63d1ec58e750a32","head":{"label":"storojs72:master","ref":"master","sha":"c2333ec7f981cb18c99853dfb63d1ec58e750a32","user":{"login":"storojs72","id":20335747,"avatar_url":"https://avatars1.githubusercontent.com/u/20335747?v=4","gravatar_id":"","url":"https://api.github.com/users/storojs72","html_url":"https://github.com/storojs72","followers_url":"https://api.github.com/users/storojs72/followers","following_url":"https://api.github.com/users/storojs72/following{/other_user}","gists_url":"https://api.github.com/users/storojs72/gists{/gist_id}","starred_url":"https://api.github.com/users/storojs72/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storojs72/subscriptions","organizations_url":"https://api.github.com/users/storojs72/orgs","repos_url":"https://api.github.com/users/storojs72/repos","events_url":"https://api.github.com/users/storojs72/events{/privacy}","received_events_url":"https://api.github.com/users/storojs72/received_events","type":"User","site_admin":false},"repo":{"id":96852242,"name":"acra","full_name":"storojs72/acra","owner":{"login":"storojs72","id":20335747,"avatar_url":"https://avatars1.githubusercontent.com/u/20335747?v=4","gravatar_id":"","url":"https://api.github.com/users/storojs72","html_url":"https://github.com/storojs72","followers_url":"https://api.github.com/users/storojs72/followers","following_url":"https://api.github.com/users/storojs72/following{/other_user}","gists_url":"https://api.github.com/users/storojs72/gists{/gist_id}","starred_url":"https://api.github.com/users/storojs72/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storojs72/subscriptions","organizations_url":"https://api.github.com/users/storojs72/orgs","repos_url":"https://api.github.com/users/storojs72/repos","events_url":"https://api.github.com/users/storojs72/events{/privacy}","received_events_url":"https://api.github.com/users/storojs72/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/storojs72/acra","description":"Acra database protection suite","fork":true,"url":"https://api.github.com/repos/storojs72/acra","forks_url":"https://api.github.com/repos/storojs72/acra/forks","keys_url":"https://api.github.com/repos/storojs72/acra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/storojs72/acra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/storojs72/acra/teams","hooks_url":"https://api.github.com/repos/storojs72/acra/hooks","issue_events_url":"https://api.github.com/repos/storojs72/acra/issues/events{/number}","events_url":"https://api.github.com/repos/storojs72/acra/events","assignees_url":"https://api.github.com/repos/storojs72/acra/assignees{/user}","branches_url":"https://api.github.com/repos/storojs72/acra/branches{/branch}","tags_url":"https://api.github.com/repos/storojs72/acra/tags","blobs_url":"https://api.github.com/repos/storojs72/acra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/storojs72/acra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/storojs72/acra/git/refs{/sha}","trees_url":"https://api.github.com/repos/storojs72/acra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/storojs72/acra/statuses/{sha}","languages_url":"https://api.github.com/repos/storojs72/acra/languages","stargazers_url":"https://api.github.com/repos/storojs72/acra/stargazers","contributors_url":"https://api.github.com/repos/storojs72/acra/contributors","subscribers_url":"https://api.github.com/repos/storojs72/acra/subscribers","subscription_url":"https://api.github.com/repos/storojs72/acra/subscription","commits_url":"https://api.github.com/repos/storojs72/acra/commits{/sha}","git_commits_url":"https://api.github.com/repos/storojs72/acra/git/commits{/sha}","comments_url":"https://api.github.com/repos/storojs72/acra/comments{/number}","issue_comment_url":"https://api.github.com/repos/storojs72/acra/issues/comments{/number}","contents_url":"https://api.github.com/repos/storojs72/acra/contents/{+path}","compare_url":"https://api.github.com/repos/storojs72/acra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/storojs72/acra/merges","archive_url":"https://api.github.com/repos/storojs72/acra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/storojs72/acra/downloads","issues_url":"https://api.github.com/repos/storojs72/acra/issues{/number}","pulls_url":"https://api.github.com/repos/storojs72/acra/pulls{/number}","milestones_url":"https://api.github.com/repos/storojs72/acra/milestones{/number}","notifications_url":"https://api.github.com/repos/storojs72/acra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/storojs72/acra/labels{/name}","releases_url":"https://api.github.com/repos/storojs72/acra/releases{/id}","deployments_url":"https://api.github.com/repos/storojs72/acra/deployments","created_at":"2017-07-11T04:56:33Z","updated_at":"2018-03-28T13:42:42Z","pushed_at":"2018-03-28T13:42:41Z","git_url":"git://github.com/storojs72/acra.git","ssh_url":"git@github.com:storojs72/acra.git","clone_url":"https://github.com/storojs72/acra.git","svn_url":"https://github.com/storojs72/acra","homepage":"https://www.cossacklabs.com/acra/","size":646,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cossacklabs:master","ref":"master","sha":"41ce469a21d35e93d92d728252efb4a54389acc3","user":{"login":"cossacklabs","id":11052315,"avatar_url":"https://avatars1.githubusercontent.com/u/11052315?v=4","gravatar_id":"","url":"https://api.github.com/users/cossacklabs","html_url":"https://github.com/cossacklabs","followers_url":"https://api.github.com/users/cossacklabs/followers","following_url":"https://api.github.com/users/cossacklabs/following{/other_user}","gists_url":"https://api.github.com/users/cossacklabs/gists{/gist_id}","starred_url":"https://api.github.com/users/cossacklabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cossacklabs/subscriptions","organizations_url":"https://api.github.com/users/cossacklabs/orgs","repos_url":"https://api.github.com/users/cossacklabs/repos","events_url":"https://api.github.com/users/cossacklabs/events{/privacy}","received_events_url":"https://api.github.com/users/cossacklabs/received_events","type":"Organization","site_admin":false},"repo":{"id":73724173,"name":"acra","full_name":"cossacklabs/acra","owner":{"login":"cossacklabs","id":11052315,"avatar_url":"https://avatars1.githubusercontent.com/u/11052315?v=4","gravatar_id":"","url":"https://api.github.com/users/cossacklabs","html_url":"https://github.com/cossacklabs","followers_url":"https://api.github.com/users/cossacklabs/followers","following_url":"https://api.github.com/users/cossacklabs/following{/other_user}","gists_url":"https://api.github.com/users/cossacklabs/gists{/gist_id}","starred_url":"https://api.github.com/users/cossacklabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cossacklabs/subscriptions","organizations_url":"https://api.github.com/users/cossacklabs/orgs","repos_url":"https://api.github.com/users/cossacklabs/repos","events_url":"https://api.github.com/users/cossacklabs/events{/privacy}","received_events_url":"https://api.github.com/users/cossacklabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cossacklabs/acra","description":"Acra database protection suite","fork":false,"url":"https://api.github.com/repos/cossacklabs/acra","forks_url":"https://api.github.com/repos/cossacklabs/acra/forks","keys_url":"https://api.github.com/repos/cossacklabs/acra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cossacklabs/acra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cossacklabs/acra/teams","hooks_url":"https://api.github.com/repos/cossacklabs/acra/hooks","issue_events_url":"https://api.github.com/repos/cossacklabs/acra/issues/events{/number}","events_url":"https://api.github.com/repos/cossacklabs/acra/events","assignees_url":"https://api.github.com/repos/cossacklabs/acra/assignees{/user}","branches_url":"https://api.github.com/repos/cossacklabs/acra/branches{/branch}","tags_url":"https://api.github.com/repos/cossacklabs/acra/tags","blobs_url":"https://api.github.com/repos/cossacklabs/acra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cossacklabs/acra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cossacklabs/acra/git/refs{/sha}","trees_url":"https://api.github.com/repos/cossacklabs/acra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cossacklabs/acra/statuses/{sha}","languages_url":"https://api.github.com/repos/cossacklabs/acra/languages","stargazers_url":"https://api.github.com/repos/cossacklabs/acra/stargazers","contributors_url":"https://api.github.com/repos/cossacklabs/acra/contributors","subscribers_url":"https://api.github.com/repos/cossacklabs/acra/subscribers","subscription_url":"https://api.github.com/repos/cossacklabs/acra/subscription","commits_url":"https://api.github.com/repos/cossacklabs/acra/commits{/sha}","git_commits_url":"https://api.github.com/repos/cossacklabs/acra/git/commits{/sha}","comments_url":"https://api.github.com/repos/cossacklabs/acra/comments{/number}","issue_comment_url":"https://api.github.com/repos/cossacklabs/acra/issues/comments{/number}","contents_url":"https://api.github.com/repos/cossacklabs/acra/contents/{+path}","compare_url":"https://api.github.com/repos/cossacklabs/acra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cossacklabs/acra/merges","archive_url":"https://api.github.com/repos/cossacklabs/acra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cossacklabs/acra/downloads","issues_url":"https://api.github.com/repos/cossacklabs/acra/issues{/number}","pulls_url":"https://api.github.com/repos/cossacklabs/acra/pulls{/number}","milestones_url":"https://api.github.com/repos/cossacklabs/acra/milestones{/number}","notifications_url":"https://api.github.com/repos/cossacklabs/acra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cossacklabs/acra/labels{/name}","releases_url":"https://api.github.com/repos/cossacklabs/acra/releases{/id}","deployments_url":"https://api.github.com/repos/cossacklabs/acra/deployments","created_at":"2016-11-14T16:23:25Z","updated_at":"2018-03-28T10:52:07Z","pushed_at":"2018-03-28T13:42:42Z","git_url":"git://github.com/cossacklabs/acra.git","ssh_url":"git@github.com:cossacklabs/acra.git","clone_url":"https://github.com/cossacklabs/acra.git","svn_url":"https://github.com/cossacklabs/acra","homepage":"https://www.cossacklabs.com/acra/","size":768,"stargazers_count":261,"watchers_count":261,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":13,"open_issues":11,"watchers":261,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cossacklabs/acra/pulls/138"},"html":{"href":"https://github.com/cossacklabs/acra/pull/138"},"issue":{"href":"https://api.github.com/repos/cossacklabs/acra/issues/138"},"comments":{"href":"https://api.github.com/repos/cossacklabs/acra/issues/138/comments"},"review_comments":{"href":"https://api.github.com/repos/cossacklabs/acra/pulls/138/comments"},"review_comment":{"href":"https://api.github.com/repos/cossacklabs/acra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cossacklabs/acra/pulls/138/commits"},"statuses":{"href":"https://api.github.com/repos/cossacklabs/acra/statuses/c2333ec7f981cb18c99853dfb63d1ec58e750a32"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Lagovas"}}