Skip to content

Commit

Permalink
Code review: 213680043: Added more formatter tests for issue #99.
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Mar 27, 2015
1 parent 2c50469 commit 7f20a56
Show file tree
Hide file tree
Showing 29 changed files with 677 additions and 95 deletions.
16 changes: 9 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# Ignore back-up files.
# Files to ignore by git

# Back-up files
*~
*.swp

# Ignore compiled Python files.
# Generic auto-generated build files
*.pyc
*.pyo

# Don't include build related files.
# Specific auto-generated build files
/__pycache__
/build/
/dependencies/
/dist/
/build/

# And don't care about the 'egg'.
/plaso.egg-info

# Test files
.coverage
tests-coverage.txt

# And don't care about the temporary code review file if it exists.
# And don't care about the temporary code review file if it exists
._code_review_number
2 changes: 1 addition & 1 deletion config/dpkg/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ python-plaso (1.2.1-1) unstable; urgency=low

* Auto-generated

-- Log2Timeline <log2timeline-dev@googlegroups.com> Thu, 26 Mar 2015 07:16:12 +0100
-- Log2Timeline <log2timeline-dev@googlegroups.com> Fri, 27 Mar 2015 13:44:09 +0100
2 changes: 1 addition & 1 deletion plaso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__version__ = '1.2.1'

VERSION_DEV = True
VERSION_DATE = '20150326'
VERSION_DATE = '20150327'


def GetVersion():
Expand Down
2 changes: 1 addition & 1 deletion plaso/formatters/bsm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Formatter for Basic Security Module binary files."""
"""The Basic Security Module (BSM) binary files event formatter."""

from plaso.formatters import interface
from plaso.formatters import manager
Expand Down
57 changes: 57 additions & 0 deletions plaso/formatters/bsm_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tests for the Basic Security Module (BSM) binary files event formatter."""

import unittest

from plaso.formatters import bsm
from plaso.formatters import test_lib


class BSMFormatterTest(test_lib.EventFormatterTestCase):
"""Tests for the BSM log entry event formatter."""

def testInitialization(self):
"""Tests the initialization."""
event_formatter = bsm.BSMFormatter()
self.assertNotEqual(event_formatter, None)

def testGetFormatStringAttributeNames(self):
"""Tests the GetFormatStringAttributeNames function."""
event_formatter = bsm.BSMFormatter()

expected_attribute_names = [
u'event_type',
u'extra_tokens']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)

# TODO: add test for GetMessages.


class MacBSMFormatterTest(test_lib.EventFormatterTestCase):
"""Tests for the Mac OS X BSM log entry event formatter."""

def testInitialization(self):
"""Tests the initialization."""
event_formatter = bsm.MacBSMFormatter()
self.assertNotEqual(event_formatter, None)

def testGetFormatStringAttributeNames(self):
"""Tests the GetFormatStringAttributeNames function."""
event_formatter = bsm.MacBSMFormatter()

expected_attribute_names = [
u'event_type',
u'return_value',
u'extra_tokens']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)

# TODO: add test for GetMessages.


if __name__ == '__main__':
unittest.main()
10 changes: 8 additions & 2 deletions plaso/formatters/chrome_extension_activity_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ def testGetFormatStringAttributeNames(self):
chrome_extension_activity.ChromeExtensionActivityEventFormatter())

expected_attribute_names = [
u'extension_id', u'action_type', u'activity_id', u'page_url',
u'page_title', u'api_name', u'args', u'other']
u'extension_id',
u'action_type',
u'activity_id',
u'page_url',
u'page_title',
u'api_name',
u'args',
u'other']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)
Expand Down
12 changes: 6 additions & 6 deletions plaso/formatters/ipod_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def testGetFormatStringAttributeNames(self):
event_formatter = ipod.IPodDeviceFormatter()

expected_attribute_names = [
u'device_id',
u'device_class',
u'family_id',
u'use_count',
u'serial_number',
u'imei']
u'device_id',
u'device_class',
u'family_id',
u'use_count',
u'serial_number',
u'imei']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)
Expand Down
6 changes: 3 additions & 3 deletions plaso/formatters/java_idx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def testGetFormatStringAttributeNames(self):
event_formatter = java_idx.JavaIDXFormatter()

expected_attribute_names = [
u'idx_version',
u'ip_address',
u'url']
u'idx_version',
u'ip_address',
u'url']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)
Expand Down
10 changes: 5 additions & 5 deletions plaso/formatters/mac_appfirewall_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def testGetFormatStringAttributeNames(self):
event_formatter = mac_appfirewall.MacAppFirewallLogFormatter()

expected_attribute_names = [
u'computer_name',
u'agent',
u'status',
u'process_name',
u'action']
u'computer_name',
u'agent',
u'status',
u'process_name',
u'action']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)
Expand Down
8 changes: 4 additions & 4 deletions plaso/formatters/mac_document_versions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def testGetFormatStringAttributeNames(self):
event_formatter = mac_document_versions.MacDocumentVersionsFormatter()

expected_attribute_names = [
u'name',
u'path',
u'version_path',
u'user_sid']
u'name',
u'path',
u'version_path',
u'user_sid']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)
Expand Down
14 changes: 7 additions & 7 deletions plaso/formatters/mac_keychain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def testGetFormatStringAttributeNames(self):
event_formatter = mac_keychain.KeychainApplicationRecordFormatter()

expected_attribute_names = [
u'entry_name',
u'account_name']
u'entry_name',
u'account_name']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)
Expand All @@ -43,11 +43,11 @@ def testGetFormatStringAttributeNames(self):
event_formatter = mac_keychain.KeychainInternetRecordFormatter()

expected_attribute_names = [
u'entry_name',
u'account_name',
u'where',
u'protocol',
u'type_protocol']
u'entry_name',
u'account_name',
u'where',
u'protocol',
u'type_protocol']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)
Expand Down
10 changes: 5 additions & 5 deletions plaso/formatters/mac_securityd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def testGetFormatStringAttributeNames(self):
event_formatter = mac_securityd.MacSecuritydLogFormatter()

expected_attribute_names = [
u'sender',
u'sender_pid',
u'level',
u'facility',
u'message']
u'sender',
u'sender_pid',
u'level',
u'facility',
u'message']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)
Expand Down
4 changes: 2 additions & 2 deletions plaso/formatters/mac_wifi.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
"""Formatter for Mac wifi.log file."""
"""The Mac OS X wifi.log file event formatter."""

from plaso.formatters import interface
from plaso.formatters import manager


class MacWifiLogFormatter(interface.ConditionalEventFormatter):
"""Formatter for Mac Wifi file."""
"""Formatter for a wifi.log file event."""

DATA_TYPE = 'mac:wifilog:line'

Expand Down
36 changes: 36 additions & 0 deletions plaso/formatters/mac_wifi_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tests for the Mac OS X wifi.log file event formatter."""

import unittest

from plaso.formatters import mac_wifi
from plaso.formatters import test_lib


class MacWifiLogFormatterTest(test_lib.EventFormatterTestCase):
"""Tests for the wifi.log file event formatter."""

def testInitialization(self):
"""Tests the initialization."""
event_formatter = mac_wifi.MacWifiLogFormatter()
self.assertNotEqual(event_formatter, None)

def testGetFormatStringAttributeNames(self):
"""Tests the GetFormatStringAttributeNames function."""
event_formatter = mac_wifi.MacWifiLogFormatter()

expected_attribute_names = [
u'action',
u'user',
u'function',
u'text']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)

# TODO: add test for GetMessages.


if __name__ == '__main__':
unittest.main()
12 changes: 6 additions & 6 deletions plaso/formatters/mackeeper_cache_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def testGetFormatStringAttributeNames(self):
event_formatter = mackeeper_cache.MacKeeperCacheFormatter()

expected_attribute_names = [
u'description',
u'event_type',
u'text',
u'url',
u'record_id',
u'room']
u'description',
u'event_type',
u'text',
u'url',
u'record_id',
u'room']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)
Expand Down
22 changes: 15 additions & 7 deletions plaso/formatters/mcafeeav.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# -*- coding: utf-8 -*-
"""Formatter for the McAfee AV Logs files."""
"""The McAfee AV Logs file event formatter."""

from plaso.formatters import interface
from plaso.formatters import manager


class McafeeAccessProtectionLogEventFormatter(interface.EventFormatter):
"""Class that formats the McAfee Access Protection Log events."""
class McafeeAccessProtectionLogEventFormatter(
interface.ConditionalEventFormatter):
"""Formatter for a McAfee Access Protection Log event."""

DATA_TYPE = 'av:mcafee:accessprotectionlog'

# The format string.
FORMAT_STRING = (u'File Name: {filename} User: {username} {trigger_location} '
u'{status} {rule} {action}')
FORMAT_STRING_SHORT = u'{filename} {action}'
FORMAT_STRING_PIECES = [
u'File Name: {filename}',
u'User: {username}',
u'{trigger_location}',
u'{status}',
u'{rule}',
u'{action}']

FORMAT_STRING_SHORT_PIECES = [
u'{filename}',
u'{action}']

SOURCE_LONG = 'McAfee Access Protection Log'
SOURCE_SHORT = 'LOG'
Expand Down
39 changes: 39 additions & 0 deletions plaso/formatters/mcafeeav_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tests for the McAfee AV Logs file event formatter."""

import unittest

from plaso.formatters import mcafeeav
from plaso.formatters import test_lib


class McafeeAccessProtectionLogEventFormatterTest(
test_lib.EventFormatterTestCase):
"""Tests for the McAfee Access Protection Log event formatter."""

def testInitialization(self):
"""Tests the initialization."""
event_formatter = mcafeeav.McafeeAccessProtectionLogEventFormatter()
self.assertNotEqual(event_formatter, None)

def testGetFormatStringAttributeNames(self):
"""Tests the GetFormatStringAttributeNames function."""
event_formatter = mcafeeav.McafeeAccessProtectionLogEventFormatter()

expected_attribute_names = [
u'filename',
u'username',
u'trigger_location',
u'status',
u'rule',
u'action']

self._TestGetFormatStringAttributeNames(
event_formatter, expected_attribute_names)

# TODO: add test for GetMessages.


if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion plaso/formatters/msie_webcache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Formatters for the MSIE WebCache ESE database events."""
"""The MSIE WebCache ESE database event formatters."""

from plaso.formatters import interface
from plaso.formatters import manager
Expand Down
Loading

0 comments on commit 7f20a56

Please sign in to comment.