Skip to content
Permalink
Browse files

Corrected MacOSFSEvents definition and changes to validator (#365)

  • Loading branch information...
joachimmetz committed Nov 6, 2019
1 parent 5b5f6e4 commit 817cbea03212c1dcf3b4d19c5ac283889cd72696
Showing with 26 additions and 5 deletions.
  1. +13 −4 artifacts/source_type.py
  2. +1 −1 data/macos.yaml
  3. +12 −0 tests/source_type_test.py
@@ -134,10 +134,13 @@ def __init__(self, paths=None, separator='/'):
separator (Optional[str]): path segment separator.
Raises:
FormatError: when paths is not set.
FormatError: when paths is not set or not a list type.
"""
if not paths:
raise errors.FormatError('Missing directory value.')
raise errors.FormatError('Missing paths value.')

if not isinstance(paths, list):
raise errors.FormatError('Invalid paths value, not a list.')

super(DirectorySourceType, self).__init__()
self.paths = paths
@@ -169,11 +172,14 @@ def __init__(self, paths=None, separator='/'):
separator (Optional[str]): path segment separator.
Raises:
FormatError: when paths is not set.
FormatError: when paths is not set or not a list type.
"""
if not paths:
raise errors.FormatError('Missing paths value.')

if not isinstance(paths, list):
raise errors.FormatError('Invalid paths value, not a list.')

super(FileSourceType, self).__init__()
self.paths = paths
self.separator = separator
@@ -204,11 +210,14 @@ def __init__(self, paths=None, separator='/'):
separator (Optional[str]): path segment separator.
Raises:
FormatError: when paths is not set.
FormatError: when paths is not set or not a list type.
"""
if not paths:
raise errors.FormatError('Missing paths value.')

if not isinstance(paths, list):
raise errors.FormatError('Invalid paths value, not a list.')

super(PathSourceType, self).__init__()
self.paths = paths
self.separator = separator
@@ -1013,7 +1013,7 @@ name: MacOSFSEvents
doc: Mac OS X file system event log
sources:
- type: FILE
attributes: {paths: '/.fseventsd/*'}
attributes: {paths: ['/.fseventsd/*']}
labels: [Logs, System, Users]
supported_os: [Darwin]
urls:
@@ -60,6 +60,12 @@ def testInitialize(self):
source_type.FileSourceType(paths=['test'])
source_type.FileSourceType(paths=['test'], separator='\\')

with self.assertRaises(errors.FormatError):
source_type.FileSourceType()

with self.assertRaises(errors.FormatError):
source_type.FileSourceType(paths='test')


class PathSourceTypeTest(test_lib.BaseTestCase):
"""Class to test the paths source type."""
@@ -69,6 +75,12 @@ def testInitialize(self):
source_type.PathSourceType(paths=['test'])
source_type.PathSourceType(paths=['test'], separator='\\')

with self.assertRaises(errors.FormatError):
source_type.PathSourceType()

with self.assertRaises(errors.FormatError):
source_type.PathSourceType(paths='test')


class WindowsRegistryKeySourceTypeTest(test_lib.BaseTestCase):
"""Class to test the Windows Registry keys source type."""

0 comments on commit 817cbea

Please sign in to comment.
You can’t perform that action at this time.