Skip to content

Commit

Permalink
Removed host attribute from Chrome event (log2timeline#1575) (log2tim…
Browse files Browse the repository at this point in the history
  • Loading branch information
chimau authored and Onager committed Mar 2, 2018
1 parent 843ca40 commit 895e249
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 29 deletions.
1 change: 0 additions & 1 deletion plaso/formatters/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class ChromePageVisitedFormatter(interface.ConditionalEventFormatter):
'{url}',
'({title})',
'[count: {typed_count}]',
'Host: {host}',
'Visit from: {from_visit}',
'Visit Source: [{visit_source}]',
'Type: [{page_transition}]',
Expand Down
23 changes: 0 additions & 23 deletions plaso/parsers/sqlite_plugins/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class ChromeHistoryPageVisitedEventData(events.EventData):
Attributes:
from_visit (str): URL where the visit originated from.
hostname (str): visited hostname.
page_transition_type (int): type of transitions between pages.
title (str): title of the visited page.
typed_count (int): number of characters of the URL that were typed.
Expand All @@ -61,7 +60,6 @@ def __init__(self):
super(ChromeHistoryPageVisitedEventData, self).__init__(
data_type=self.DATA_TYPE)
self.from_visit = None
self.host = None
self.page_transition_type = None
self.title = None
self.typed_count = None
Expand All @@ -82,25 +80,6 @@ class BaseGoogleChromeHistoryPlugin(interface.SQLitePlugin):
# https://cs.chromium.org/chromium/src/ui/base/page_transition_types.h?l=108
_PAGE_TRANSITION_CORE_MASK = 0xff

def _GetHostname(self, url):
"""Retrieves the hostname from a full URL.
Args:
url (str): full URL.
Returns:
str: hostname or full URL if hostname could not be retrieved.
"""
if url.startswith('http') or url.startswith('ftp'):
_, _, uri = url.partition('//')
hostname, _, _ = uri.partition('/')
return hostname

if url.startswith('about') or url.startswith('chrome'):
hostname, _, _ = url.partition('/')
return hostname

return url

def _GetUrl(self, url, cache, database):
"""Retrieves an URL from a reference to an entry in the from_visit table.
Expand Down Expand Up @@ -177,11 +156,9 @@ def ParseLastVisitedRow(

visit_identifier = self._GetRowValue(query_hash, row, 'visit_id')
from_visit = self._GetRowValue(query_hash, row, 'from_visit')
url = self._GetRowValue(query_hash, row, 'url')

event_data = ChromeHistoryPageVisitedEventData()
event_data.from_visit = self._GetUrl(from_visit, cache, database)
event_data.host = self._GetHostname(url)
event_data.offset = self._GetRowValue(query_hash, row, 'id')
event_data.query = query
event_data.page_transition_type = (
Expand Down
1 change: 0 additions & 1 deletion tests/formatters/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def testGetFormatStringAttributeNames(self):
'url',
'title',
'typed_count',
'host',
'from_visit',
'visit_source',
'page_transition',
Expand Down
5 changes: 1 addition & 4 deletions tests/parsers/sqlite_plugins/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def testProcess(self):
self.assertEqual(event.title, expected_title)

expected_message = (
'{0:s} ({1:s}) [count: 0] Host: start.ubuntu.com '
'{0:s} ({1:s}) [count: 0] '
'Visit Source: [SOURCE_FIREFOX_IMPORTED] Type: [LINK - User clicked '
'a link] (URL not typed directly - no typed count)').format(
expected_url, expected_title)
Expand Down Expand Up @@ -109,7 +109,6 @@ def testProcess57(self):
expected_message = (
'{0:s} '
'[count: 0] '
'Host: raw.githubusercontent.com '
'Type: [START_PAGE - The start page of the browser] '
'(URL not typed directly - no typed count)').format(expected_url)
expected_short_message = '{0:s}...'.format(expected_url[:77])
Expand Down Expand Up @@ -169,7 +168,6 @@ def testProcess58(self):
expected_message = (
'{0:s} '
'[count: 0] '
'Host: raw.githubusercontent.com '
'Type: [START_PAGE - The start page of the browser] '
'(URL not typed directly - no typed count)').format(expected_url)
expected_short_message = '{0:s}...'.format(expected_url[:77])
Expand Down Expand Up @@ -229,7 +227,6 @@ def testProcess59(self):
expected_message = (
'{0:s} '
'[count: 0] '
'Host: raw.githubusercontent.com '
'Type: [START_PAGE - The start page of the browser] '
'(URL not typed directly - no typed count)').format(expected_url)
expected_short_message = '{0:s}...'.format(expected_url[:77])
Expand Down

0 comments on commit 895e249

Please sign in to comment.