{"action":"created","comment":{"url":"https://api.github.com/repos/codice/ddf/pulls/comments/93141633","pull_request_review_id":13663238,"id":93141633,"diff_hunk":"@@ -0,0 +1,200 @@\n+/**\n+ * Copyright (c) Codice Foundation\n+ * <p>\n+ * This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser\n+ * General Public License as published by the Free Software Foundation, either version 3 of the\n+ * License, or any later version.\n+ * <p>\n+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\n+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ * Lesser General Public License for more details. A copy of the GNU Lesser General Public License\n+ * is distributed along with this program and can be found at\n+ * <http://www.gnu.org/licenses/lgpl.html>.\n+ */\n+package org.codice.ddf.catalog.security;\n+\n+import java.io.Serializable;\n+import java.net.URI;\n+import java.util.List;\n+import java.util.Map;\n+\n+import org.apache.commons.lang3.StringUtils;\n+import org.opengis.filter.Filter;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import ddf.catalog.CatalogFramework;\n+import ddf.catalog.data.Metacard;\n+import ddf.catalog.data.Result;\n+import ddf.catalog.federation.FederationException;\n+import ddf.catalog.filter.FilterBuilder;\n+import ddf.catalog.operation.Query;\n+import ddf.catalog.operation.QueryRequest;\n+import ddf.catalog.operation.QueryResponse;\n+import ddf.catalog.operation.ResourceRequest;\n+import ddf.catalog.operation.ResourceResponse;\n+import ddf.catalog.operation.impl.QueryImpl;\n+import ddf.catalog.operation.impl.QueryRequestImpl;\n+import ddf.catalog.plugin.PolicyPlugin;\n+import ddf.catalog.plugin.PolicyResponse;\n+import ddf.catalog.plugin.StopProcessingException;\n+import ddf.catalog.plugin.impl.PolicyResponseImpl;\n+import ddf.catalog.source.SourceUnavailableException;\n+import ddf.catalog.source.UnsupportedQueryException;\n+import ddf.security.permission.Permissions;\n+\n+/**\n+ * Restricts how resource URIs are updated and created.\n+ * There are security risk to allowing users to update URIs as well as allowing users to\n+ * pass in a URI when the metacard is created.\n+ */\n+public class ResourceUriPolicy implements PolicyPlugin {\n+\n+    private static final Logger LOGGER = LoggerFactory.getLogger(ResourceUriPolicy.class);\n+\n+    private String[] createPermissions;\n+\n+    private String[] updatePermissions;\n+\n+    private CatalogFramework catalogFramework;\n+\n+    private FilterBuilder filterBuilder;\n+\n+    @Override\n+    public PolicyResponse processPreCreate(Metacard input, Map<String, Serializable> properties)\n+            throws StopProcessingException {\n+\n+        if (input.getResourceURI() != null && StringUtils.isNotEmpty(input.getResourceURI()","path":"catalog/security/catalog-security-resourceplugin/src/main/java/org/codice/ddf/catalog/security/ResourceUriPolicy.java","position":67,"original_position":67,"commit_id":"5ce1ddbed83e1e43a519bcdccc9557430a519341","original_commit_id":"5ce1ddbed83e1e43a519bcdccc9557430a519341","user":{"login":"clockard","id":5248090,"avatar_url":"https://avatars.githubusercontent.com/u/5248090?v=3","gravatar_id":"","url":"https://api.github.com/users/clockard","html_url":"https://github.com/clockard","followers_url":"https://api.github.com/users/clockard/followers","following_url":"https://api.github.com/users/clockard/following{/other_user}","gists_url":"https://api.github.com/users/clockard/gists{/gist_id}","starred_url":"https://api.github.com/users/clockard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clockard/subscriptions","organizations_url":"https://api.github.com/users/clockard/orgs","repos_url":"https://api.github.com/users/clockard/repos","events_url":"https://api.github.com/users/clockard/events{/privacy}","received_events_url":"https://api.github.com/users/clockard/received_events","type":"User","site_admin":false},"body":"For all each of the PolicyPlugin methods you are going to want to check if the request is local. If the change is not local then I don't think this plugin needs to do anything. `Requests.isLocal(properties) ` should return true if it is a local request.","created_at":"2016-12-19T23:20:24Z","updated_at":"2016-12-19T23:23:30Z","html_url":"https://github.com/codice/ddf/pull/1499#discussion_r93141633","pull_request_url":"https://api.github.com/repos/codice/ddf/pulls/1499","_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments/93141633"},"html":{"href":"https://github.com/codice/ddf/pull/1499#discussion_r93141633"},"pull_request":{"href":"https://api.github.com/repos/codice/ddf/pulls/1499"}}},"pull_request":{"url":"https://api.github.com/repos/codice/ddf/pulls/1499","id":98004886,"html_url":"https://github.com/codice/ddf/pull/1499","diff_url":"https://github.com/codice/ddf/pull/1499.diff","patch_url":"https://github.com/codice/ddf/pull/1499.patch","issue_url":"https://api.github.com/repos/codice/ddf/issues/1499","number":1499,"state":"open","locked":false,"title":"DDF-2639 Restrict access to updating or creating resource URIs on metacards","user":{"login":"ahoffer","id":133284,"avatar_url":"https://avatars.githubusercontent.com/u/133284?v=3","gravatar_id":"","url":"https://api.github.com/users/ahoffer","html_url":"https://github.com/ahoffer","followers_url":"https://api.github.com/users/ahoffer/followers","following_url":"https://api.github.com/users/ahoffer/following{/other_user}","gists_url":"https://api.github.com/users/ahoffer/gists{/gist_id}","starred_url":"https://api.github.com/users/ahoffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahoffer/subscriptions","organizations_url":"https://api.github.com/users/ahoffer/orgs","repos_url":"https://api.github.com/users/ahoffer/repos","events_url":"https://api.github.com/users/ahoffer/events{/privacy}","received_events_url":"https://api.github.com/users/ahoffer/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\nAllow administrators to allow privileged users to update metacard resource URI or add a resource URI when creating a metacard. \r\n#### Who is reviewing it (please choose AT LEAST two reviewers that need to approve the PR before it can get merged)?\r\n@brendan-hofmann @mweser @emanns95 @spearskw\r\n#### Select at least one member from relevant component team(s) from below (at least one component team member needs to approve the PR).\r\n[Build](https://github.com/orgs/codice/teams/build)\r\n@stustison \r\n#### Choose 2 committers to review/merge the PR (please choose ONLY two committers from below, delete the rest).\r\n@figliold\r\n@stustison\r\n#### How should this be tested? (List steps with links to updated documentation)\r\nIt has been manually tested. \r\n#### Any background context you want to provide?\r\nNo.\r\n#### What are the relevant tickets?\r\n[](https://codice.atlassian.net/browse/)\r\n#### Screenshots (if appropriate)\r\n#### Checklist:\r\n- [x] Documentation Updated\r\n- [x] Change Log Updated\r\n- [x] Update / Add Unit Tests\r\n- [x] Update / Add Integration Tests\r\n","created_at":"2016-12-14T18:06:15Z","updated_at":"2016-12-19T23:23:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b6b39861b19fbd25e12a5083f2077619d0548cf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/codice/ddf/pulls/1499/commits","review_comments_url":"https://api.github.com/repos/codice/ddf/pulls/1499/comments","review_comment_url":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codice/ddf/issues/1499/comments","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/5ce1ddbed83e1e43a519bcdccc9557430a519341","head":{"label":"ahoffer:DDF-2639_","ref":"DDF-2639_","sha":"5ce1ddbed83e1e43a519bcdccc9557430a519341","user":{"login":"ahoffer","id":133284,"avatar_url":"https://avatars.githubusercontent.com/u/133284?v=3","gravatar_id":"","url":"https://api.github.com/users/ahoffer","html_url":"https://github.com/ahoffer","followers_url":"https://api.github.com/users/ahoffer/followers","following_url":"https://api.github.com/users/ahoffer/following{/other_user}","gists_url":"https://api.github.com/users/ahoffer/gists{/gist_id}","starred_url":"https://api.github.com/users/ahoffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahoffer/subscriptions","organizations_url":"https://api.github.com/users/ahoffer/orgs","repos_url":"https://api.github.com/users/ahoffer/repos","events_url":"https://api.github.com/users/ahoffer/events{/privacy}","received_events_url":"https://api.github.com/users/ahoffer/received_events","type":"User","site_admin":false},"repo":{"id":42614877,"name":"ddf","full_name":"ahoffer/ddf","owner":{"login":"ahoffer","id":133284,"avatar_url":"https://avatars.githubusercontent.com/u/133284?v=3","gravatar_id":"","url":"https://api.github.com/users/ahoffer","html_url":"https://github.com/ahoffer","followers_url":"https://api.github.com/users/ahoffer/followers","following_url":"https://api.github.com/users/ahoffer/following{/other_user}","gists_url":"https://api.github.com/users/ahoffer/gists{/gist_id}","starred_url":"https://api.github.com/users/ahoffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahoffer/subscriptions","organizations_url":"https://api.github.com/users/ahoffer/orgs","repos_url":"https://api.github.com/users/ahoffer/repos","events_url":"https://api.github.com/users/ahoffer/events{/privacy}","received_events_url":"https://api.github.com/users/ahoffer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ahoffer/ddf","description":"The Distributed Data Framework - Distribution, SDK, and Test","fork":true,"url":"https://api.github.com/repos/ahoffer/ddf","forks_url":"https://api.github.com/repos/ahoffer/ddf/forks","keys_url":"https://api.github.com/repos/ahoffer/ddf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ahoffer/ddf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ahoffer/ddf/teams","hooks_url":"https://api.github.com/repos/ahoffer/ddf/hooks","issue_events_url":"https://api.github.com/repos/ahoffer/ddf/issues/events{/number}","events_url":"https://api.github.com/repos/ahoffer/ddf/events","assignees_url":"https://api.github.com/repos/ahoffer/ddf/assignees{/user}","branches_url":"https://api.github.com/repos/ahoffer/ddf/branches{/branch}","tags_url":"https://api.github.com/repos/ahoffer/ddf/tags","blobs_url":"https://api.github.com/repos/ahoffer/ddf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ahoffer/ddf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ahoffer/ddf/git/refs{/sha}","trees_url":"https://api.github.com/repos/ahoffer/ddf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ahoffer/ddf/statuses/{sha}","languages_url":"https://api.github.com/repos/ahoffer/ddf/languages","stargazers_url":"https://api.github.com/repos/ahoffer/ddf/stargazers","contributors_url":"https://api.github.com/repos/ahoffer/ddf/contributors","subscribers_url":"https://api.github.com/repos/ahoffer/ddf/subscribers","subscription_url":"https://api.github.com/repos/ahoffer/ddf/subscription","commits_url":"https://api.github.com/repos/ahoffer/ddf/commits{/sha}","git_commits_url":"https://api.github.com/repos/ahoffer/ddf/git/commits{/sha}","comments_url":"https://api.github.com/repos/ahoffer/ddf/comments{/number}","issue_comment_url":"https://api.github.com/repos/ahoffer/ddf/issues/comments{/number}","contents_url":"https://api.github.com/repos/ahoffer/ddf/contents/{+path}","compare_url":"https://api.github.com/repos/ahoffer/ddf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ahoffer/ddf/merges","archive_url":"https://api.github.com/repos/ahoffer/ddf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ahoffer/ddf/downloads","issues_url":"https://api.github.com/repos/ahoffer/ddf/issues{/number}","pulls_url":"https://api.github.com/repos/ahoffer/ddf/pulls{/number}","milestones_url":"https://api.github.com/repos/ahoffer/ddf/milestones{/number}","notifications_url":"https://api.github.com/repos/ahoffer/ddf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ahoffer/ddf/labels{/name}","releases_url":"https://api.github.com/repos/ahoffer/ddf/releases{/id}","deployments_url":"https://api.github.com/repos/ahoffer/ddf/deployments","created_at":"2015-09-16T21:39:29Z","updated_at":"2016-01-12T21:13:31Z","pushed_at":"2016-12-19T19:48:58Z","git_url":"git://github.com/ahoffer/ddf.git","ssh_url":"git@github.com:ahoffer/ddf.git","clone_url":"https://github.com/ahoffer/ddf.git","svn_url":"https://github.com/ahoffer/ddf","homepage":"","size":148549,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"codice:master","ref":"master","sha":"33f5e7d3cc019304edc3285be8858d0b1341e8fc","user":{"login":"codice","id":2386734,"avatar_url":"https://avatars.githubusercontent.com/u/2386734?v=3","gravatar_id":"","url":"https://api.github.com/users/codice","html_url":"https://github.com/codice","followers_url":"https://api.github.com/users/codice/followers","following_url":"https://api.github.com/users/codice/following{/other_user}","gists_url":"https://api.github.com/users/codice/gists{/gist_id}","starred_url":"https://api.github.com/users/codice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codice/subscriptions","organizations_url":"https://api.github.com/users/codice/orgs","repos_url":"https://api.github.com/users/codice/repos","events_url":"https://api.github.com/users/codice/events{/privacy}","received_events_url":"https://api.github.com/users/codice/received_events","type":"Organization","site_admin":false},"repo":{"id":15173563,"name":"ddf","full_name":"codice/ddf","owner":{"login":"codice","id":2386734,"avatar_url":"https://avatars.githubusercontent.com/u/2386734?v=3","gravatar_id":"","url":"https://api.github.com/users/codice","html_url":"https://github.com/codice","followers_url":"https://api.github.com/users/codice/followers","following_url":"https://api.github.com/users/codice/following{/other_user}","gists_url":"https://api.github.com/users/codice/gists{/gist_id}","starred_url":"https://api.github.com/users/codice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codice/subscriptions","organizations_url":"https://api.github.com/users/codice/orgs","repos_url":"https://api.github.com/users/codice/repos","events_url":"https://api.github.com/users/codice/events{/privacy}","received_events_url":"https://api.github.com/users/codice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codice/ddf","description":"Distributed Data Framework - an open source, modular integration framework.","fork":false,"url":"https://api.github.com/repos/codice/ddf","forks_url":"https://api.github.com/repos/codice/ddf/forks","keys_url":"https://api.github.com/repos/codice/ddf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codice/ddf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codice/ddf/teams","hooks_url":"https://api.github.com/repos/codice/ddf/hooks","issue_events_url":"https://api.github.com/repos/codice/ddf/issues/events{/number}","events_url":"https://api.github.com/repos/codice/ddf/events","assignees_url":"https://api.github.com/repos/codice/ddf/assignees{/user}","branches_url":"https://api.github.com/repos/codice/ddf/branches{/branch}","tags_url":"https://api.github.com/repos/codice/ddf/tags","blobs_url":"https://api.github.com/repos/codice/ddf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codice/ddf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codice/ddf/git/refs{/sha}","trees_url":"https://api.github.com/repos/codice/ddf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/{sha}","languages_url":"https://api.github.com/repos/codice/ddf/languages","stargazers_url":"https://api.github.com/repos/codice/ddf/stargazers","contributors_url":"https://api.github.com/repos/codice/ddf/contributors","subscribers_url":"https://api.github.com/repos/codice/ddf/subscribers","subscription_url":"https://api.github.com/repos/codice/ddf/subscription","commits_url":"https://api.github.com/repos/codice/ddf/commits{/sha}","git_commits_url":"https://api.github.com/repos/codice/ddf/git/commits{/sha}","comments_url":"https://api.github.com/repos/codice/ddf/comments{/number}","issue_comment_url":"https://api.github.com/repos/codice/ddf/issues/comments{/number}","contents_url":"https://api.github.com/repos/codice/ddf/contents/{+path}","compare_url":"https://api.github.com/repos/codice/ddf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codice/ddf/merges","archive_url":"https://api.github.com/repos/codice/ddf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codice/ddf/downloads","issues_url":"https://api.github.com/repos/codice/ddf/issues{/number}","pulls_url":"https://api.github.com/repos/codice/ddf/pulls{/number}","milestones_url":"https://api.github.com/repos/codice/ddf/milestones{/number}","notifications_url":"https://api.github.com/repos/codice/ddf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codice/ddf/labels{/name}","releases_url":"https://api.github.com/repos/codice/ddf/releases{/id}","deployments_url":"https://api.github.com/repos/codice/ddf/deployments","created_at":"2013-12-13T20:38:28Z","updated_at":"2016-12-18T16:45:55Z","pushed_at":"2016-12-19T23:20:39Z","git_url":"git://github.com/codice/ddf.git","ssh_url":"git@github.com:codice/ddf.git","clone_url":"https://github.com/codice/ddf.git","svn_url":"https://github.com/codice/ddf","homepage":"http://ddf.codice.org","size":294799,"stargazers_count":52,"watchers_count":52,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":99,"mirror_url":null,"open_issues_count":18,"forks":99,"open_issues":18,"watchers":52,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/1499"},"html":{"href":"https://github.com/codice/ddf/pull/1499"},"issue":{"href":"https://api.github.com/repos/codice/ddf/issues/1499"},"comments":{"href":"https://api.github.com/repos/codice/ddf/issues/1499/comments"},"review_comments":{"href":"https://api.github.com/repos/codice/ddf/pulls/1499/comments"},"review_comment":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codice/ddf/pulls/1499/commits"},"statuses":{"href":"https://api.github.com/repos/codice/ddf/statuses/5ce1ddbed83e1e43a519bcdccc9557430a519341"}}}}
{"actor":{"display_login":"clockard"}}