{"action":"created","comment":{"url":"https://api.github.com/repos/chef/chef-server/pulls/comments/30802471","id":30802471,"diff_hunk":"@@ -0,0 +1,94 @@\n+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil; fill-column: 92 -*-\n+%% ex: ts=4 sw=4 et\n+%% @author Mark  Mzyk <mm@chef.io>\n+%% Copyright 2015 Chef Software, Inc.\n+%%\n+%% This file is provided to you under the Apache License,\n+%% Version 2.0 (the \"License\"); you may not use this file\n+%% except in compliance with the License.  You may obtain\n+%% a copy of the License at\n+%%\n+%%   http://www.apache.org/licenses/LICENSE-2.0\n+%%\n+%% Unless required by applicable law or agreed to in writing,\n+%% software distributed under the License is distributed on an\n+%% \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+%% KIND, either express or implied.  See the License for the\n+%% specific language governing permissions and limitations\n+%% under the License.\n+%%\n+\n+-module(oc_chef_authz_acl_constraints).\n+\n+-ifdef(TEST).\n+-compile([export_all]).\n+-endif.\n+\n+-export([check_acl_constraints/4]).\n+\n+check_acl_constraints(AuthzId, Type, AclPerm, Ace) ->\n+  check_acl_constraints(AuthzId, Type, AclPerm, Ace, acl_checks()).\n+\n+check_acl_constraints(AuthzId, Type, AclPerm, Ace, AclChecks) ->\n+  case lists:filtermap(fun(Check) -> Check(AuthzId, Type, AclPerm, Ace) end, AclChecks) of\n+    [] ->\n+      ok;\n+    Failures ->\n+      Failures\n+  end.\n+\n+acl_checks() ->\n+  [\n+    fun check_admins_group_removal_from_grant_ace/4\n+  ].\n+\n+check_admins_group_removal_from_grant_ace(AuthzId, Type, AclPerm, NewAce) ->\n+  %% It is necessary to pull the current ace and compare to the new ace.\n+  %% This is because there are some groups that don't have the admin\n+  %% group by default, such as billing-admins. This will have the effect\n+  %% that if a group doesn't have the admin group, but then it is later added,\n+  %% the admin group will never be able to be removed.\n+  case AclPerm of\n+    <<\"grant\">> ->\n+      NewGroups = extract_acl_groups(AclPerm, NewAce),\n+      CurrentAce = oc_chef_authz_acl:fetch(Type, AuthzId),","path":"src/oc_erchef/apps/oc_chef_authz/src/oc_chef_authz_acl_constraints.erl","position":54,"original_position":54,"commit_id":"253f1fadbfa57e45dea0c7e620b822b7251be9c6","original_commit_id":"253f1fadbfa57e45dea0c7e620b822b7251be9c6","user":{"login":"stevendanna","id":852371,"avatar_url":"https://avatars.githubusercontent.com/u/852371?v=3","gravatar_id":"","url":"https://api.github.com/users/stevendanna","html_url":"https://github.com/stevendanna","followers_url":"https://api.github.com/users/stevendanna/followers","following_url":"https://api.github.com/users/stevendanna/following{/other_user}","gists_url":"https://api.github.com/users/stevendanna/gists{/gist_id}","starred_url":"https://api.github.com/users/stevendanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevendanna/subscriptions","organizations_url":"https://api.github.com/users/stevendanna/orgs","repos_url":"https://api.github.com/users/stevendanna/repos","events_url":"https://api.github.com/users/stevendanna/events{/privacy}","received_events_url":"https://api.github.com/users/stevendanna/received_events","type":"User","site_admin":false},"body":"This will make an extra bifrost call per ACL update.  Since ACL updates are rare, this is fine.  I wonder if this will be common enough to make it worth it to pass in the old document as an argument to the check functions rather than the AuthzID?","created_at":"2015-05-21T13:43:17Z","updated_at":"2015-05-21T13:43:17Z","html_url":"https://github.com/chef/chef-server/pull/248#discussion_r30802471","pull_request_url":"https://api.github.com/repos/chef/chef-server/pulls/248","_links":{"self":{"href":"https://api.github.com/repos/chef/chef-server/pulls/comments/30802471"},"html":{"href":"https://github.com/chef/chef-server/pull/248#discussion_r30802471"},"pull_request":{"href":"https://api.github.com/repos/chef/chef-server/pulls/248"}}},"pull_request":{"url":"https://api.github.com/repos/chef/chef-server/pulls/248","id":35168918,"html_url":"https://github.com/chef/chef-server/pull/248","diff_url":"https://github.com/chef/chef-server/pull/248.diff","patch_url":"https://github.com/chef/chef-server/pull/248.patch","issue_url":"https://api.github.com/repos/chef/chef-server/issues/248","number":248,"state":"open","locked":false,"title":"ACL Restrictions","user":{"login":"mmzyk","id":66784,"avatar_url":"https://avatars.githubusercontent.com/u/66784?v=3","gravatar_id":"","url":"https://api.github.com/users/mmzyk","html_url":"https://github.com/mmzyk","followers_url":"https://api.github.com/users/mmzyk/followers","following_url":"https://api.github.com/users/mmzyk/following{/other_user}","gists_url":"https://api.github.com/users/mmzyk/gists{/gist_id}","starred_url":"https://api.github.com/users/mmzyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmzyk/subscriptions","organizations_url":"https://api.github.com/users/mmzyk/orgs","repos_url":"https://api.github.com/users/mmzyk/repos","events_url":"https://api.github.com/users/mmzyk/events{/privacy}","received_events_url":"https://api.github.com/users/mmzyk/received_events","type":"User","site_admin":false},"body":"Add in stubb for performing acl integrity checks\r\n\r\nThis commit changes nothing about how the current code operates. However, it does add a new module and call to that module that gives a hook for performing acl integrity checks, such as if we are removing the admin group from the grant ace, which is something we desire not to be possible.\r\n\r\nThis branch is branched from https://github.com/chef/chef-server/pull/240.\r\n\r\nThe desire at this point is that both of these branches could be merged to master and would essential be no-ops as the desired functionality is built on top of these changes.","created_at":"2015-05-11T21:00:13Z","updated_at":"2015-05-21T13:43:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ae8798e515cdf3f06cba85746cd50fdaf6b986c1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/chef/chef-server/pulls/248/commits","review_comments_url":"https://api.github.com/repos/chef/chef-server/pulls/248/comments","review_comment_url":"https://api.github.com/repos/chef/chef-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chef/chef-server/issues/248/comments","statuses_url":"https://api.github.com/repos/chef/chef-server/statuses/253f1fadbfa57e45dea0c7e620b822b7251be9c6","head":{"label":"chef:mm/acl-restrictions","ref":"mm/acl-restrictions","sha":"253f1fadbfa57e45dea0c7e620b822b7251be9c6","user":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"repo":{"id":24732433,"name":"chef-server","full_name":"chef/chef-server","owner":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chef/chef-server","description":"The Chef Server ","fork":false,"url":"https://api.github.com/repos/chef/chef-server","forks_url":"https://api.github.com/repos/chef/chef-server/forks","keys_url":"https://api.github.com/repos/chef/chef-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chef/chef-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chef/chef-server/teams","hooks_url":"https://api.github.com/repos/chef/chef-server/hooks","issue_events_url":"https://api.github.com/repos/chef/chef-server/issues/events{/number}","events_url":"https://api.github.com/repos/chef/chef-server/events","assignees_url":"https://api.github.com/repos/chef/chef-server/assignees{/user}","branches_url":"https://api.github.com/repos/chef/chef-server/branches{/branch}","tags_url":"https://api.github.com/repos/chef/chef-server/tags","blobs_url":"https://api.github.com/repos/chef/chef-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chef/chef-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chef/chef-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/chef/chef-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chef/chef-server/statuses/{sha}","languages_url":"https://api.github.com/repos/chef/chef-server/languages","stargazers_url":"https://api.github.com/repos/chef/chef-server/stargazers","contributors_url":"https://api.github.com/repos/chef/chef-server/contributors","subscribers_url":"https://api.github.com/repos/chef/chef-server/subscribers","subscription_url":"https://api.github.com/repos/chef/chef-server/subscription","commits_url":"https://api.github.com/repos/chef/chef-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/chef/chef-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/chef/chef-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/chef/chef-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/chef/chef-server/contents/{+path}","compare_url":"https://api.github.com/repos/chef/chef-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chef/chef-server/merges","archive_url":"https://api.github.com/repos/chef/chef-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chef/chef-server/downloads","issues_url":"https://api.github.com/repos/chef/chef-server/issues{/number}","pulls_url":"https://api.github.com/repos/chef/chef-server/pulls{/number}","milestones_url":"https://api.github.com/repos/chef/chef-server/milestones{/number}","notifications_url":"https://api.github.com/repos/chef/chef-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chef/chef-server/labels{/name}","releases_url":"https://api.github.com/repos/chef/chef-server/releases{/id}","created_at":"2014-10-02T19:04:18Z","updated_at":"2015-05-19T14:10:15Z","pushed_at":"2015-05-21T13:42:20Z","git_url":"git://github.com/chef/chef-server.git","ssh_url":"git@github.com:chef/chef-server.git","clone_url":"https://github.com/chef/chef-server.git","svn_url":"https://github.com/chef/chef-server","homepage":"https://www.chef.io/chef/","size":13704,"stargazers_count":22,"watchers_count":22,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":165,"forks":9,"open_issues":165,"watchers":22,"default_branch":"master"}},"base":{"label":"chef:master","ref":"master","sha":"851eae8a9b6df2c224e0138feccf8e1176ef336f","user":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"repo":{"id":24732433,"name":"chef-server","full_name":"chef/chef-server","owner":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chef/chef-server","description":"The Chef Server ","fork":false,"url":"https://api.github.com/repos/chef/chef-server","forks_url":"https://api.github.com/repos/chef/chef-server/forks","keys_url":"https://api.github.com/repos/chef/chef-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chef/chef-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chef/chef-server/teams","hooks_url":"https://api.github.com/repos/chef/chef-server/hooks","issue_events_url":"https://api.github.com/repos/chef/chef-server/issues/events{/number}","events_url":"https://api.github.com/repos/chef/chef-server/events","assignees_url":"https://api.github.com/repos/chef/chef-server/assignees{/user}","branches_url":"https://api.github.com/repos/chef/chef-server/branches{/branch}","tags_url":"https://api.github.com/repos/chef/chef-server/tags","blobs_url":"https://api.github.com/repos/chef/chef-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chef/chef-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chef/chef-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/chef/chef-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chef/chef-server/statuses/{sha}","languages_url":"https://api.github.com/repos/chef/chef-server/languages","stargazers_url":"https://api.github.com/repos/chef/chef-server/stargazers","contributors_url":"https://api.github.com/repos/chef/chef-server/contributors","subscribers_url":"https://api.github.com/repos/chef/chef-server/subscribers","subscription_url":"https://api.github.com/repos/chef/chef-server/subscription","commits_url":"https://api.github.com/repos/chef/chef-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/chef/chef-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/chef/chef-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/chef/chef-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/chef/chef-server/contents/{+path}","compare_url":"https://api.github.com/repos/chef/chef-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chef/chef-server/merges","archive_url":"https://api.github.com/repos/chef/chef-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chef/chef-server/downloads","issues_url":"https://api.github.com/repos/chef/chef-server/issues{/number}","pulls_url":"https://api.github.com/repos/chef/chef-server/pulls{/number}","milestones_url":"https://api.github.com/repos/chef/chef-server/milestones{/number}","notifications_url":"https://api.github.com/repos/chef/chef-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chef/chef-server/labels{/name}","releases_url":"https://api.github.com/repos/chef/chef-server/releases{/id}","created_at":"2014-10-02T19:04:18Z","updated_at":"2015-05-19T14:10:15Z","pushed_at":"2015-05-21T13:42:20Z","git_url":"git://github.com/chef/chef-server.git","ssh_url":"git@github.com:chef/chef-server.git","clone_url":"https://github.com/chef/chef-server.git","svn_url":"https://github.com/chef/chef-server","homepage":"https://www.chef.io/chef/","size":13704,"stargazers_count":22,"watchers_count":22,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":165,"forks":9,"open_issues":165,"watchers":22,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chef/chef-server/pulls/248"},"html":{"href":"https://github.com/chef/chef-server/pull/248"},"issue":{"href":"https://api.github.com/repos/chef/chef-server/issues/248"},"comments":{"href":"https://api.github.com/repos/chef/chef-server/issues/248/comments"},"review_comments":{"href":"https://api.github.com/repos/chef/chef-server/pulls/248/comments"},"review_comment":{"href":"https://api.github.com/repos/chef/chef-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chef/chef-server/pulls/248/commits"},"statuses":{"href":"https://api.github.com/repos/chef/chef-server/statuses/253f1fadbfa57e45dea0c7e620b822b7251be9c6"}}}}