{"action":"created","comment":{"url":"https://api.github.com/repos/google/turbinia/pulls/comments/98328947","pull_request_review_id":18971486,"id":98328947,"diff_hunk":"@@ -0,0 +1,325 @@\n+# Copyright 2016 Google Inc.\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+\n+# HACK: We need the log2timeline tool and it only exists as a script.\n+# TODO(aarontp): Fix hack\n+import sys\n+sys.path.append('/usr/bin')\n+\n+import argparse\n+import base64\n+import datetime\n+import httplib2\n+import os\n+import stat\n+import time\n+\n+import requests\n+import BeautifulSoup\n+import json\n+\n+# Google API\n+from googleapiclient import discovery\n+from googleapiclient import errors as google_errors\n+from googleapiclient import http as storage_http\n+from oauth2client import client as oauth2client\n+\n+# Plaso\n+import plaso\n+import log2timeline\n+\n+# Turbinia\n+from turbinia import config\n+\n+\n+def GetCurrentTimeUTC():\n+  return datetime.datetime.utcnow().strftime(u'%Y-%m-%dT%H:%M:%S+0000')\n+\n+\n+def IsBlockDevice(path):\n+  if not os.path.exists(path):\n+    return\n+  mode = os.stat(path).st_mode\n+  return stat.S_ISBLK(mode)\n+\n+\n+def WriteToStdOut(message):\n+  # TODO(aarontp): Convert to standard logging mechanism\n+  msg = u'{0:s} {1:s}\\n'.format(GetCurrentTimeUTC(), message)\n+  sys.stdout.write(msg)\n+  sys.stdout.flush()\n+\n+\n+def WriteToStdErr(message):\n+  msg = u'{0:s} {1:s}\\n'.format(GetCurrentTimeUTC(), message)\n+  sys.stderr.write(msg)\n+  sys.stderr.flush()\n+\n+\n+def CreateServiceClient(service):\n+  \"\"\"Creates an API client for talking to Google Cloud.\"\"\"\n+  WriteToStdOut(u'Create API client for service: {0:s}'.format(service))\n+  credentials = oauth2client.GoogleCredentials.get_application_default()\n+  http = httplib2.Http()\n+  credentials.authorize(http)\n+  return discovery.build(service, 'v1', http=http)\n+\n+\n+class TimesketchApiClient(object):\n+\n+  def __init__(self, server_ip, username, password):\n+    self.server_ip = server_ip\n+    self.host_url = u'https://{0:s}'.format(self.server_ip)\n+    self.session = self._CreateSession(username, password)\n+\n+  def _CreateSession(self, username, password):\n+    session = requests.Session()\n+    session.verify = False  # Depending on SSL cert is verifiable\n+\n+    # Get the CSRF token from the response\n+    response = session.get(self.host_url)\n+    soup = BeautifulSoup.BeautifulSoup(response.text)\n+    csrf_token = soup.find(id='csrf_token').get('value')\n+    session.headers.update({\n+        'x-csrftoken': csrf_token,\n+        'referer': self.server_ip\n+    })\n+\n+    # Do a POST to the login handler to set up the session cookies\n+    form_data = {u'username': username, u'password': password}\n+    session.post(u'{0:s}/login/'.format(self.host_url), data=form_data)\n+    return session\n+\n+  def CreateSketch(self, name, description):\n+    resource_url = u'{0:s}/api/v1/sketches/'.format(self.host_url)\n+    form_data = {u'name': name, u'description': description}\n+    response = self.session.post(resource_url, json=form_data)\n+    response_dict = response.json()\n+    sketch_id = response_dict[u'objects'][0]['id']\n+    return sketch_id\n+\n+  def UploadTimeline(self, timeline_name, plaso_storage_path):\n+    resource_url = u'{0:s}/api/v1/upload/'.format(self.host_url)\n+    files = {'file': open(plaso_storage_path, 'rb')}\n+    form_data = {u'name': timeline_name}\n+    response = self.session.post(resource_url, files=files, data=form_data)\n+    response_dict = response.json()\n+    index_id = response_dict[u'objects'][0]['id']\n+    return index_id\n+\n+  def AddTimelineToSketch(self, sketch_id, index_id):\n+    resource_url = u'{0:s}/api/v1/sketches/{0:d}/'.format(self.host_url,\n+                                                          sketch_id)\n+    form_data = {u'timelines': [index_id]}\n+    response = self.session.post(resource_url, json=form_data)\n+    response_dict = response.json()\n+    timeline_id = response_dict[u'objects'][0]['id']\n+    return timeline_id\n+\n+\n+class PlasoProcessor(object):\n+\n+  def __init__(self):\n+    config.LoadConfig()\n+\n+  def _WaitForOperation(self, client, operation):\n+    \"\"\"Wait for an operation to complete.\"\"\"\n+    WriteToStdOut(u'Waiting for operation to complete')\n+    while True:\n+      result = client.zoneOperations().get(project=config.PROJECT,\n+                                           zone=config.ZONE,\n+                                           operation=operation).execute()\n+      WriteToStdOut(u'Status: {0:s}'.format(result[u'status']))\n+      if result[u'status'] == u'DONE':\n+        if u'error' in result:\n+          WriteToStdErr(result)\n+          raise RuntimeError(result[u'error'][u'errors'][0][u'message'])\n+        return result\n+      time.sleep(1)\n+\n+  def _AttachDisk(self, client, disk):\n+    \"\"\"Attaches a persistent disk to the machine.\"\"\"","path":"tools/plaso_pubsub.py","position":152,"original_position":152,"commit_id":"96f688558b745bd4bd8be0eb397953fe86506957","original_commit_id":"96f688558b745bd4bd8be0eb397953fe86506957","user":{"login":"berggren","id":316362,"avatar_url":"https://avatars.githubusercontent.com/u/316362?v=3","gravatar_id":"","url":"https://api.github.com/users/berggren","html_url":"https://github.com/berggren","followers_url":"https://api.github.com/users/berggren/followers","following_url":"https://api.github.com/users/berggren/following{/other_user}","gists_url":"https://api.github.com/users/berggren/gists{/gist_id}","starred_url":"https://api.github.com/users/berggren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berggren/subscriptions","organizations_url":"https://api.github.com/users/berggren/orgs","repos_url":"https://api.github.com/users/berggren/repos","events_url":"https://api.github.com/users/berggren/events{/privacy}","received_events_url":"https://api.github.com/users/berggren/received_events","type":"User","site_admin":false},"body":"Add args","created_at":"2017-01-28T10:43:44Z","updated_at":"2017-01-28T10:52:18Z","html_url":"https://github.com/google/turbinia/pull/7#discussion_r98328947","pull_request_url":"https://api.github.com/repos/google/turbinia/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/google/turbinia/pulls/comments/98328947"},"html":{"href":"https://github.com/google/turbinia/pull/7#discussion_r98328947"},"pull_request":{"href":"https://api.github.com/repos/google/turbinia/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/google/turbinia/pulls/7","id":103414722,"html_url":"https://github.com/google/turbinia/pull/7","diff_url":"https://github.com/google/turbinia/pull/7.diff","patch_url":"https://github.com/google/turbinia/pull/7.patch","issue_url":"https://api.github.com/repos/google/turbinia/issues/7","number":7,"state":"open","locked":false,"title":"Initial plaso pubsub client code.","user":{"login":"aarontp","id":2667195,"avatar_url":"https://avatars.githubusercontent.com/u/2667195?v=3","gravatar_id":"","url":"https://api.github.com/users/aarontp","html_url":"https://github.com/aarontp","followers_url":"https://api.github.com/users/aarontp/followers","following_url":"https://api.github.com/users/aarontp/following{/other_user}","gists_url":"https://api.github.com/users/aarontp/gists{/gist_id}","starred_url":"https://api.github.com/users/aarontp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aarontp/subscriptions","organizations_url":"https://api.github.com/users/aarontp/orgs","repos_url":"https://api.github.com/users/aarontp/repos","events_url":"https://api.github.com/users/aarontp/events{/privacy}","received_events_url":"https://api.github.com/users/aarontp/received_events","type":"User","site_admin":false},"body":"This is adapted from jberggren's initial code.  Will stick it in this tools/ dir for now and will merge functionality into the turbinia/ dir as I go.","created_at":"2017-01-26T23:50:54Z","updated_at":"2017-01-28T10:52:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cda231288890e82b5eac888a040acce104ea38b5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/turbinia/pulls/7/commits","review_comments_url":"https://api.github.com/repos/google/turbinia/pulls/7/comments","review_comment_url":"https://api.github.com/repos/google/turbinia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/turbinia/issues/7/comments","statuses_url":"https://api.github.com/repos/google/turbinia/statuses/96f688558b745bd4bd8be0eb397953fe86506957","head":{"label":"aarontp:master","ref":"master","sha":"96f688558b745bd4bd8be0eb397953fe86506957","user":{"login":"aarontp","id":2667195,"avatar_url":"https://avatars.githubusercontent.com/u/2667195?v=3","gravatar_id":"","url":"https://api.github.com/users/aarontp","html_url":"https://github.com/aarontp","followers_url":"https://api.github.com/users/aarontp/followers","following_url":"https://api.github.com/users/aarontp/following{/other_user}","gists_url":"https://api.github.com/users/aarontp/gists{/gist_id}","starred_url":"https://api.github.com/users/aarontp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aarontp/subscriptions","organizations_url":"https://api.github.com/users/aarontp/orgs","repos_url":"https://api.github.com/users/aarontp/repos","events_url":"https://api.github.com/users/aarontp/events{/privacy}","received_events_url":"https://api.github.com/users/aarontp/received_events","type":"User","site_admin":false},"repo":{"id":68854185,"name":"turbinia","full_name":"aarontp/turbinia","owner":{"login":"aarontp","id":2667195,"avatar_url":"https://avatars.githubusercontent.com/u/2667195?v=3","gravatar_id":"","url":"https://api.github.com/users/aarontp","html_url":"https://github.com/aarontp","followers_url":"https://api.github.com/users/aarontp/followers","following_url":"https://api.github.com/users/aarontp/following{/other_user}","gists_url":"https://api.github.com/users/aarontp/gists{/gist_id}","starred_url":"https://api.github.com/users/aarontp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aarontp/subscriptions","organizations_url":"https://api.github.com/users/aarontp/orgs","repos_url":"https://api.github.com/users/aarontp/repos","events_url":"https://api.github.com/users/aarontp/events{/privacy}","received_events_url":"https://api.github.com/users/aarontp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aarontp/turbinia","description":null,"fork":true,"url":"https://api.github.com/repos/aarontp/turbinia","forks_url":"https://api.github.com/repos/aarontp/turbinia/forks","keys_url":"https://api.github.com/repos/aarontp/turbinia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aarontp/turbinia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aarontp/turbinia/teams","hooks_url":"https://api.github.com/repos/aarontp/turbinia/hooks","issue_events_url":"https://api.github.com/repos/aarontp/turbinia/issues/events{/number}","events_url":"https://api.github.com/repos/aarontp/turbinia/events","assignees_url":"https://api.github.com/repos/aarontp/turbinia/assignees{/user}","branches_url":"https://api.github.com/repos/aarontp/turbinia/branches{/branch}","tags_url":"https://api.github.com/repos/aarontp/turbinia/tags","blobs_url":"https://api.github.com/repos/aarontp/turbinia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aarontp/turbinia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aarontp/turbinia/git/refs{/sha}","trees_url":"https://api.github.com/repos/aarontp/turbinia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aarontp/turbinia/statuses/{sha}","languages_url":"https://api.github.com/repos/aarontp/turbinia/languages","stargazers_url":"https://api.github.com/repos/aarontp/turbinia/stargazers","contributors_url":"https://api.github.com/repos/aarontp/turbinia/contributors","subscribers_url":"https://api.github.com/repos/aarontp/turbinia/subscribers","subscription_url":"https://api.github.com/repos/aarontp/turbinia/subscription","commits_url":"https://api.github.com/repos/aarontp/turbinia/commits{/sha}","git_commits_url":"https://api.github.com/repos/aarontp/turbinia/git/commits{/sha}","comments_url":"https://api.github.com/repos/aarontp/turbinia/comments{/number}","issue_comment_url":"https://api.github.com/repos/aarontp/turbinia/issues/comments{/number}","contents_url":"https://api.github.com/repos/aarontp/turbinia/contents/{+path}","compare_url":"https://api.github.com/repos/aarontp/turbinia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aarontp/turbinia/merges","archive_url":"https://api.github.com/repos/aarontp/turbinia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aarontp/turbinia/downloads","issues_url":"https://api.github.com/repos/aarontp/turbinia/issues{/number}","pulls_url":"https://api.github.com/repos/aarontp/turbinia/pulls{/number}","milestones_url":"https://api.github.com/repos/aarontp/turbinia/milestones{/number}","notifications_url":"https://api.github.com/repos/aarontp/turbinia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aarontp/turbinia/labels{/name}","releases_url":"https://api.github.com/repos/aarontp/turbinia/releases{/id}","deployments_url":"https://api.github.com/repos/aarontp/turbinia/deployments","created_at":"2016-09-21T20:17:41Z","updated_at":"2016-09-21T20:17:42Z","pushed_at":"2017-01-27T02:12:56Z","git_url":"git://github.com/aarontp/turbinia.git","ssh_url":"git@github.com:aarontp/turbinia.git","clone_url":"https://github.com/aarontp/turbinia.git","svn_url":"https://github.com/aarontp/turbinia","homepage":null,"size":43,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":true,"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":"google:master","ref":"master","sha":"630786c8902e064b4fa1b61e9a603a8de9192e65","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":42533053,"name":"turbinia","full_name":"google/turbinia","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/turbinia","description":null,"fork":false,"url":"https://api.github.com/repos/google/turbinia","forks_url":"https://api.github.com/repos/google/turbinia/forks","keys_url":"https://api.github.com/repos/google/turbinia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/turbinia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/turbinia/teams","hooks_url":"https://api.github.com/repos/google/turbinia/hooks","issue_events_url":"https://api.github.com/repos/google/turbinia/issues/events{/number}","events_url":"https://api.github.com/repos/google/turbinia/events","assignees_url":"https://api.github.com/repos/google/turbinia/assignees{/user}","branches_url":"https://api.github.com/repos/google/turbinia/branches{/branch}","tags_url":"https://api.github.com/repos/google/turbinia/tags","blobs_url":"https://api.github.com/repos/google/turbinia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/turbinia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/turbinia/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/turbinia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/turbinia/statuses/{sha}","languages_url":"https://api.github.com/repos/google/turbinia/languages","stargazers_url":"https://api.github.com/repos/google/turbinia/stargazers","contributors_url":"https://api.github.com/repos/google/turbinia/contributors","subscribers_url":"https://api.github.com/repos/google/turbinia/subscribers","subscription_url":"https://api.github.com/repos/google/turbinia/subscription","commits_url":"https://api.github.com/repos/google/turbinia/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/turbinia/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/turbinia/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/turbinia/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/turbinia/contents/{+path}","compare_url":"https://api.github.com/repos/google/turbinia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/turbinia/merges","archive_url":"https://api.github.com/repos/google/turbinia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/turbinia/downloads","issues_url":"https://api.github.com/repos/google/turbinia/issues{/number}","pulls_url":"https://api.github.com/repos/google/turbinia/pulls{/number}","milestones_url":"https://api.github.com/repos/google/turbinia/milestones{/number}","notifications_url":"https://api.github.com/repos/google/turbinia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/turbinia/labels{/name}","releases_url":"https://api.github.com/repos/google/turbinia/releases{/id}","deployments_url":"https://api.github.com/repos/google/turbinia/deployments","created_at":"2015-09-15T16:50:40Z","updated_at":"2016-11-18T16:20:05Z","pushed_at":"2017-01-27T02:12:57Z","git_url":"git://github.com/google/turbinia.git","ssh_url":"git@github.com:google/turbinia.git","clone_url":"https://github.com/google/turbinia.git","svn_url":"https://github.com/google/turbinia","homepage":null,"size":38,"stargazers_count":20,"watchers_count":20,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/turbinia/pulls/7"},"html":{"href":"https://github.com/google/turbinia/pull/7"},"issue":{"href":"https://api.github.com/repos/google/turbinia/issues/7"},"comments":{"href":"https://api.github.com/repos/google/turbinia/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/google/turbinia/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/google/turbinia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/turbinia/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/google/turbinia/statuses/96f688558b745bd4bd8be0eb397953fe86506957"}}}}
{"actor":{"display_login":"berggren"}}