{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/comments/211284995","pull_request_review_id":147660765,"id":211284995,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTI4NDk5NQ==","diff_hunk":"@@ -0,0 +1,132 @@\n+# Copyright 2018 The Forseti Security Authors. All rights reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain 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, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\"\"\"Tests for BigqueryScanner.\"\"\"\n+\n+import collections\n+import json\n+import unittest\n+import mock\n+\n+from tests.scanner.test_data import fake_bigquery_scanner_data as fbsd\n+from tests.unittest_utils import ForsetiTestCase\n+from google.cloud.forseti.common.gcp_type import resource as resource_mod\n+from google.cloud.forseti.scanner.scanners import bigquery_scanner\n+\n+\n+def _mock_gcp_resource_iter(_, resource_type):\n+    \"\"\"Creates a list of GCP resource mocks retrieved by the scanner.\"\"\"\n+    resources = []\n+    if resource_type != 'dataset_policy':\n+        raise ValueError(\n+            'unexpected resource type: got %s, want dataset_policy',\n+            resource_type,\n+        )\n+\n+    Resource = collections.namedtuple(\n+        'Resource',\n+        # fields based on required fields from Resource in dao.py.\n+        ['full_name', 'type', 'name', 'parent_type_name', 'parent',\n+         'data'],\n+    )\n+\n+    for resource in fbsd.BIGQUERY_DATA:\n+        proj = Resource(\n+            full_name=resource['full_project_name'],\n+            type='project',\n+            name='projects/' + resource['project_id'],\n+            parent_type_name='',\n+            parent=None,\n+            data='',\n+        )\n+\n+        dataset= Resource(\n+            full_name=resource['full_name'],","path":"tests/scanner/scanners/bigquery_scanner_test.py","position":54,"original_position":54,"commit_id":"014dacb813b123838a95356bfbb13504ac273b70","original_commit_id":"014dacb813b123838a95356bfbb13504ac273b70","user":{"login":"dufton","id":18620887,"node_id":"MDQ6VXNlcjE4NjIwODg3","avatar_url":"https://avatars1.githubusercontent.com/u/18620887?v=4","gravatar_id":"","url":"https://api.github.com/users/dufton","html_url":"https://github.com/dufton","followers_url":"https://api.github.com/users/dufton/followers","following_url":"https://api.github.com/users/dufton/following{/other_user}","gists_url":"https://api.github.com/users/dufton/gists{/gist_id}","starred_url":"https://api.github.com/users/dufton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dufton/subscriptions","organizations_url":"https://api.github.com/users/dufton/orgs","repos_url":"https://api.github.com/users/dufton/repos","events_url":"https://api.github.com/users/dufton/events{/privacy}","received_events_url":"https://api.github.com/users/dufton/received_events","type":"User","site_admin":false},"body":"This full_name is the name of the dataset_policy. Trim the end off: '/'.join(full_name.split('/')[:-3]) + '/'\r\n","created_at":"2018-08-20T14:35:06Z","updated_at":"2018-08-20T14:43:00Z","html_url":"https://github.com/GoogleCloudPlatform/forseti-security/pull/1884#discussion_r211284995","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/1884","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/comments/211284995"},"html":{"href":"https://github.com/GoogleCloudPlatform/forseti-security/pull/1884#discussion_r211284995"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/1884"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/1884","id":208038954,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA4MDM4OTU0","html_url":"https://github.com/GoogleCloudPlatform/forseti-security/pull/1884","diff_url":"https://github.com/GoogleCloudPlatform/forseti-security/pull/1884.diff","patch_url":"https://github.com/GoogleCloudPlatform/forseti-security/pull/1884.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/issues/1884","number":1884,"state":"open","locked":false,"title":"[Fixes #1865] Fix bigquery scanner to respect resources","user":{"login":"umairidris","id":5559279,"node_id":"MDQ6VXNlcjU1NTkyNzk=","avatar_url":"https://avatars1.githubusercontent.com/u/5559279?v=4","gravatar_id":"","url":"https://api.github.com/users/umairidris","html_url":"https://github.com/umairidris","followers_url":"https://api.github.com/users/umairidris/followers","following_url":"https://api.github.com/users/umairidris/following{/other_user}","gists_url":"https://api.github.com/users/umairidris/gists{/gist_id}","starred_url":"https://api.github.com/users/umairidris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umairidris/subscriptions","organizations_url":"https://api.github.com/users/umairidris/orgs","repos_url":"https://api.github.com/users/umairidris/repos","events_url":"https://api.github.com/users/umairidris/events{/privacy}","received_events_url":"https://api.github.com/users/umairidris/received_events","type":"User","site_admin":false},"body":"Prior to this change, the bigquery scanner would match rules against all resources, even if it did not apply.\r\n\r\nFor example, a rule set on organization 'foo' would be incorrectly matched against a bigquery dataset under organization 'bar'.","created_at":"2018-08-13T16:50:00Z","updated_at":"2018-08-20T14:43:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"299817ee54741661fb87d59197edaf56fd5230b0","assignee":null,"assignees":[],"requested_reviewers":[{"login":"joecheuk","id":5330393,"node_id":"MDQ6VXNlcjUzMzAzOTM=","avatar_url":"https://avatars2.githubusercontent.com/u/5330393?v=4","gravatar_id":"","url":"https://api.github.com/users/joecheuk","html_url":"https://github.com/joecheuk","followers_url":"https://api.github.com/users/joecheuk/followers","following_url":"https://api.github.com/users/joecheuk/following{/other_user}","gists_url":"https://api.github.com/users/joecheuk/gists{/gist_id}","starred_url":"https://api.github.com/users/joecheuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joecheuk/subscriptions","organizations_url":"https://api.github.com/users/joecheuk/orgs","repos_url":"https://api.github.com/users/joecheuk/repos","events_url":"https://api.github.com/users/joecheuk/events{/privacy}","received_events_url":"https://api.github.com/users/joecheuk/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":658852504,"node_id":"MDU6TGFiZWw2NTg4NTI1MDQ=","url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/labels/cla:%20yes","name":"cla: yes","color":"ededed","default":false},{"id":769538991,"node_id":"MDU6TGFiZWw3Njk1Mzg5OTE=","url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/labels/status:%20in-progress","name":"status: in-progress","color":"1d76db","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/1884/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/1884/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/issues/1884/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/statuses/014dacb813b123838a95356bfbb13504ac273b70","head":{"label":"umairidris:bq-resource","ref":"bq-resource","sha":"014dacb813b123838a95356bfbb13504ac273b70","user":{"login":"umairidris","id":5559279,"node_id":"MDQ6VXNlcjU1NTkyNzk=","avatar_url":"https://avatars1.githubusercontent.com/u/5559279?v=4","gravatar_id":"","url":"https://api.github.com/users/umairidris","html_url":"https://github.com/umairidris","followers_url":"https://api.github.com/users/umairidris/followers","following_url":"https://api.github.com/users/umairidris/following{/other_user}","gists_url":"https://api.github.com/users/umairidris/gists{/gist_id}","starred_url":"https://api.github.com/users/umairidris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umairidris/subscriptions","organizations_url":"https://api.github.com/users/umairidris/orgs","repos_url":"https://api.github.com/users/umairidris/repos","events_url":"https://api.github.com/users/umairidris/events{/privacy}","received_events_url":"https://api.github.com/users/umairidris/received_events","type":"User","site_admin":false},"repo":{"id":143443269,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM0NDMyNjk=","name":"forseti-security","full_name":"umairidris/forseti-security","owner":{"login":"umairidris","id":5559279,"node_id":"MDQ6VXNlcjU1NTkyNzk=","avatar_url":"https://avatars1.githubusercontent.com/u/5559279?v=4","gravatar_id":"","url":"https://api.github.com/users/umairidris","html_url":"https://github.com/umairidris","followers_url":"https://api.github.com/users/umairidris/followers","following_url":"https://api.github.com/users/umairidris/following{/other_user}","gists_url":"https://api.github.com/users/umairidris/gists{/gist_id}","starred_url":"https://api.github.com/users/umairidris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umairidris/subscriptions","organizations_url":"https://api.github.com/users/umairidris/orgs","repos_url":"https://api.github.com/users/umairidris/repos","events_url":"https://api.github.com/users/umairidris/events{/privacy}","received_events_url":"https://api.github.com/users/umairidris/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/umairidris/forseti-security","description":"Forseti Security","fork":true,"url":"https://api.github.com/repos/umairidris/forseti-security","forks_url":"https://api.github.com/repos/umairidris/forseti-security/forks","keys_url":"https://api.github.com/repos/umairidris/forseti-security/keys{/key_id}","collaborators_url":"https://api.github.com/repos/umairidris/forseti-security/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/umairidris/forseti-security/teams","hooks_url":"https://api.github.com/repos/umairidris/forseti-security/hooks","issue_events_url":"https://api.github.com/repos/umairidris/forseti-security/issues/events{/number}","events_url":"https://api.github.com/repos/umairidris/forseti-security/events","assignees_url":"https://api.github.com/repos/umairidris/forseti-security/assignees{/user}","branches_url":"https://api.github.com/repos/umairidris/forseti-security/branches{/branch}","tags_url":"https://api.github.com/repos/umairidris/forseti-security/tags","blobs_url":"https://api.github.com/repos/umairidris/forseti-security/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/umairidris/forseti-security/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/umairidris/forseti-security/git/refs{/sha}","trees_url":"https://api.github.com/repos/umairidris/forseti-security/git/trees{/sha}","statuses_url":"https://api.github.com/repos/umairidris/forseti-security/statuses/{sha}","languages_url":"https://api.github.com/repos/umairidris/forseti-security/languages","stargazers_url":"https://api.github.com/repos/umairidris/forseti-security/stargazers","contributors_url":"https://api.github.com/repos/umairidris/forseti-security/contributors","subscribers_url":"https://api.github.com/repos/umairidris/forseti-security/subscribers","subscription_url":"https://api.github.com/repos/umairidris/forseti-security/subscription","commits_url":"https://api.github.com/repos/umairidris/forseti-security/commits{/sha}","git_commits_url":"https://api.github.com/repos/umairidris/forseti-security/git/commits{/sha}","comments_url":"https://api.github.com/repos/umairidris/forseti-security/comments{/number}","issue_comment_url":"https://api.github.com/repos/umairidris/forseti-security/issues/comments{/number}","contents_url":"https://api.github.com/repos/umairidris/forseti-security/contents/{+path}","compare_url":"https://api.github.com/repos/umairidris/forseti-security/compare/{base}...{head}","merges_url":"https://api.github.com/repos/umairidris/forseti-security/merges","archive_url":"https://api.github.com/repos/umairidris/forseti-security/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/umairidris/forseti-security/downloads","issues_url":"https://api.github.com/repos/umairidris/forseti-security/issues{/number}","pulls_url":"https://api.github.com/repos/umairidris/forseti-security/pulls{/number}","milestones_url":"https://api.github.com/repos/umairidris/forseti-security/milestones{/number}","notifications_url":"https://api.github.com/repos/umairidris/forseti-security/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/umairidris/forseti-security/labels{/name}","releases_url":"https://api.github.com/repos/umairidris/forseti-security/releases{/id}","deployments_url":"https://api.github.com/repos/umairidris/forseti-security/deployments","created_at":"2018-08-03T15:21:38Z","updated_at":"2018-08-09T15:33:49Z","pushed_at":"2018-08-16T19:59:21Z","git_url":"git://github.com/umairidris/forseti-security.git","ssh_url":"git@github.com:umairidris/forseti-security.git","clone_url":"https://github.com/umairidris/forseti-security.git","svn_url":"https://github.com/umairidris/forseti-security","homepage":"https://forsetisecurity.org","size":27306,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"GoogleCloudPlatform:dev","ref":"dev","sha":"705dc31f53f712396b315f36e8ee1bd30df5f82d","user":{"login":"GoogleCloudPlatform","id":2810941,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4MTA5NDE=","avatar_url":"https://avatars0.githubusercontent.com/u/2810941?v=4","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":82210080,"node_id":"MDEwOlJlcG9zaXRvcnk4MjIxMDA4MA==","name":"forseti-security","full_name":"GoogleCloudPlatform/forseti-security","owner":{"login":"GoogleCloudPlatform","id":2810941,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4MTA5NDE=","avatar_url":"https://avatars0.githubusercontent.com/u/2810941?v=4","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/forseti-security","description":"Forseti Security","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/deployments","created_at":"2017-02-16T18:01:26Z","updated_at":"2018-08-20T11:29:43Z","pushed_at":"2018-08-20T05:10:54Z","git_url":"git://github.com/GoogleCloudPlatform/forseti-security.git","ssh_url":"git@github.com:GoogleCloudPlatform/forseti-security.git","clone_url":"https://github.com/GoogleCloudPlatform/forseti-security.git","svn_url":"https://github.com/GoogleCloudPlatform/forseti-security","homepage":"https://forsetisecurity.org","size":27605,"stargazers_count":343,"watchers_count":343,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":113,"mirror_url":null,"archived":false,"open_issues_count":237,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":113,"open_issues":237,"watchers":343,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/1884"},"html":{"href":"https://github.com/GoogleCloudPlatform/forseti-security/pull/1884"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/issues/1884"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/issues/1884/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/1884/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/pulls/1884/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/forseti-security/statuses/014dacb813b123838a95356bfbb13504ac273b70"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"dufton"}}