Skip to content
Permalink
Browse files

Moved pylintrc file, fixed some linter errors (#250)

  • Loading branch information
Onager authored and aarontp committed Sep 17, 2018
1 parent 97a437d commit 45d6b4602c3455c05e40f1615012f48dbb8f9bc8
File renamed without changes.
@@ -24,6 +24,7 @@


class TestTurbiniaConfig(unittest.TestCase):
"""Tests for the Turbinia configuration module."""

@classmethod
def setUpClass(cls):
@@ -48,6 +49,7 @@ def setUp(self):

@classmethod
def tearDownClass(cls):
"""Called after tests in the class have been run."""
config.CONFIGPATH = cls.CONFIGPATH_SAVE
config.CONFIGFILES = cls.CONFIGFILES_SAVE
config.CONFIGVARS = cls.CONFIGVARS_SAVE
@@ -59,9 +61,14 @@ def tearDown(self):
[delattr(config, a) for a in dir(config) if a not in self.config_attrs]
config.CONFIG = None

def WriteConfig(self, data):
def WriteConfig(self, text):
"""Helper to write text to a configuration file.
Args:
text (str): data to write to the file.
"""
with open(self.config_file, 'w') as config_file:
config_file.write(data)
config_file.write(text)

def testBasicConfig(self):
"""Test out a basic config."""
@@ -281,16 +281,6 @@ def GetSourceString(self):
class GoogleComputeInstance(GoogleComputeBaseResource):
"""Class representing a Google Compute Engine virtual machine."""

def __init__(self, project, zone, name):
"""Initialize the virtual machine object.
Args:
project: Cloud project for the instance (instance of GoogleCloudProject).
zone: What zone the instance is in.
name: Name of the instance.
"""
super(GoogleComputeInstance, self).__init__(project, zone, name)

def GetOperation(self):
"""Get API operation object for the virtual machine.
@@ -360,16 +350,6 @@ def DetachDisk(self, disk):
class GoogleComputeDisk(GoogleComputeBaseResource):
"""Class representing a Compute Engine disk."""

def __init__(self, project, zone, name):
"""Initialize the disk object.
Args:
project: Cloud project for the disk (instance of GoogleCloudProject).
zone: What zone the disk is in.
name: Name of the disk.
"""
super(GoogleComputeDisk, self).__init__(project, zone, name)

def GetOperation(self):
"""Get API operation object for the disk.
@@ -421,12 +421,14 @@ def get_boot_disk(self):
"""Get the virtual machine boot disk.
Returns:
Disk object (instance of GoogleComputeDisk).
Disk object (instance of GoogleComputeDisk) or None if no disk can be
found.
"""
for disk in self.get_value('disks'):
if disk['boot']:
disk_name = disk['source'].split('/')[-1]
return self.project.get_disk(disk_name=disk_name)
return None

def get_disk(self, disk_name):
"""Gets a disk attached to this virtual machine disk by name.
@@ -629,7 +631,7 @@ def start_analysis_vm(project, vm_name, zone, boot_disk_size, attach_disk=None):
"""
project = GoogleCloudProject(project, default_zone=zone)
analysis_vm, created = project.get_or_create_analysis_vm(
vm_name, boot_disk_size)
vm_name, boot_disk_size)
if attach_disk:
analysis_vm.attach_disk(attach_disk)
return analysis_vm, created
@@ -16,9 +16,9 @@

from __future__ import unicode_literals

import mock
import unittest

import mock
import six

from turbinia.lib import libcloudforensics
@@ -57,10 +57,10 @@ def run(self, evidence, result):

output_evidence.local_path = output_file_path
cmd = 'grep -E -b -n -f {0:s} {1:s} > {2:s}'.format(
patterns_file_path, evidence.local_path, output_file_path)
patterns_file_path, evidence.local_path, output_file_path)

result.log('Running [{0:s}]'.format(cmd))
self.execute(
cmd, result, new_evidence=[output_evidence], close=True, shell=True)
cmd, result, new_evidence=[output_evidence], close=True, shell=True)

return result
@@ -72,12 +72,12 @@ def analyse_sshd_config(self, config):
"""
findings = []
permit_root_login_re = re.compile(
'^\s*PermitRootLogin\s*(yes|prohibit-password|without-password)',
r'^\s*PermitRootLogin\s*(yes|prohibit-password|without-password)',
re.IGNORECASE | re.MULTILINE)
password_authentication_re = re.compile(
'^\s*PasswordAuthentication[\s"]*No', re.IGNORECASE | re.MULTILINE)
r'^\s*PasswordAuthentication[\s"]*No', re.IGNORECASE | re.MULTILINE)
permit_empty_passwords_re = re.compile(
'^\s*PermitEmptyPasswords[\s"]*Yes', re.IGNORECASE | re.MULTILINE)
r'^\s*PermitEmptyPasswords[\s"]*Yes', re.IGNORECASE | re.MULTILINE)

if re.search(permit_root_login_re, config):
findings.append('\tRoot login enabled.')
@@ -23,6 +23,8 @@


class SSHDAnalysisTaskTest(unittest.TestCase):
"""test for the SSHD analysis task."""

SSH_INSECURE_EVERYTHING = """PermitRootLogin Yes
PasswordAuthentication yes
PermitEmptyPasswords Yes
@@ -23,6 +23,8 @@


class TomcatAnalysisTaskTest(unittest.TestCase):
"""Test for the Tomcat Task."""

TOMCAT_PASSWORD_FILE = """<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
@@ -31,21 +33,26 @@ class TomcatAnalysisTaskTest(unittest.TestCase):
<user username="both" password="tomcat" roles="tomcat,role1"/>
</tomcat-users>"""

# pylint: disable=line-too-long
TOMCAT_PASSWORD_FILE_REPORT = """Tomcat found (2 hits):
Tomcat user: <user username="tomcat" password="tomcat" roles="tomcat"/>
Tomcat user: <user username="both" password="tomcat" roles="tomcat,role1"/>"""

# pylint: disable=line-too-long
TOMCAT_APP_DEPLOY_LOG = r"""21-Mar-2017 19:21:08.140 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\MyAwesomeApp.war
10-Sep-2012 11:41:12.283 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /opt/apache-tomcat-8.0.32/webapps/badboy.war"""

# pylint: disable=line-too-long
TOMCAT_APP_DEPLOY_LOG_REPORT = r"""Tomcat found (2 hits):
Tomcat App Deployed: 21-Mar-2017 19:21:08.140 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\MyAwesomeApp.war
Tomcat App Deployed: 10-Sep-2012 11:41:12.283 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /opt/apache-tomcat-8.0.32/webapps/badboy.war"""

# pylint: disable=line-too-long
TOMCAT_ACCESS_LOG = """1.2.3.4 - - [12/Apr/2018:14:01:08 -0100] "GET /manager/html HTTP/1.1" 401 2001
1.2.3.4 - admin [12/Apr/2018:14:01:09 -0100] "GET /manager/html HTTP/1.1" 200 22130
1.2.3.4 - admin [12/Apr/2018:14:01:39 -0100] "POST /manager/html/upload?org.apache.catalina.filters.CSRF_NONCE=1ABCDEFGKLMONPQRSTIRQKD240384739 HTTP/1.1" 200 27809"""

# pylint: disable=line-too-long
TOMCAT_ACCESS_LOG_REPORT = """Tomcat found (1 hits):
Tomcat Management: 1.2.3.4 - admin [12/Apr/2018:14:01:39 -0100] "POST /manager/html/upload?org.apache.catalina.filters.CSRF_NONCE=1ABCDEFGKLMONPQRSTIRQKD240384739 HTTP/1.1" 200 27809"""

@@ -52,8 +52,14 @@ def setUp(self):
self.result.output_dir = self.base_output_dir

def tearDown(self):
[os.remove(f) for f in self.remove_files if os.path.exists(f)]
[os.rmdir(d) for d in self.remove_dirs if os.path.exists(d)]
for remove_file in self.remove_files:
if os.path.exists(remove_file):
os.remove(remove_file)

for directory in self.remove_dirs:
if os.path.exists(directory):
os.rmdir(directory)

os.rmdir(self.base_output_dir)

def setResults(self, setup=None, run=None, validate_result=None):

0 comments on commit 45d6b46

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