Пример #1
0
    def __init__(self, config=None):
        config = config or {}

        self.proc = None
        self.st2stop = '/usr/bin/sudo /usr/bin/st2ctl stop'
        self.output = '/tmp/st2installer.log'
        self.lockfile = '/tmp/st2installer_lock'
        self.keypair = KeypairController()
        self.configname = "answers.json"
        self.hostname = ''
        self.config = None
        self.start_time = None
        self.runtime = None
        self.analytics_sent = False
        self.puppet_check_command = 'ps aux | grep "[p]uppet-apply"'
        self.gen_ssl = 'Self-signed'
        self.gen_ssh = 'Generated'
        self.version = None
        # we only support ssh-rsa key types
        self.ssh_key_type = 'ssh-rsa'

        config = config or conf.to_dict()

        version = config.get('app', {}).get('version', None)
        if version:
            self.version = version

        puppet_command = config.get('puppet', {}).get('command', None)
        if puppet_command:
            self.command = puppet_command
        else:
            self.command = os.path.join(SCRIPTS_DIR, 'run-puppet.sh')

        hieradata_path = config.get('puppet', {}).get('hieradata', None)
        if hieradata_path:
            self.path = hieradata_path
        else:
            self.path = "/opt/puppet/hieradata/"

        # TODO: Generate password when needed aka on demand
        password_length = 32
        password_chars = string.ascii_letters + string.digits
        self.password = ''.join([random.choice(password_chars) for n in xrange(password_length)])

        # Note, any command added here needs to be added to the workroom sudoers entry.
        # File can be found at
        # https://github.com/StackStorm/st2workroom/blob/master/modules/profile/manifests/st2server.pp#L513
        self.cleanup_chain = [
            "/usr/bin/sudo /bin/chmod 660 %s%s" % (self.path, self.configname),
            "/usr/bin/sudo /usr/sbin/service nginx restart",
            "/usr/bin/sudo /usr/bin/st2ctl reload --register-all",
            "/usr/bin/sudo /usr/sbin/service docker-hubot restart",
            "/usr/bin/sudo /usr/bin/st2 run st2.call_home",
        ]

        self.grant_access = "/usr/bin/sudo /bin/chmod 755 %s%s" % (self.path, self.configname)
Пример #2
0
    def __init__(self, config=None):

        self.proc = None
        self.st2stop = '/usr/bin/sudo /usr/bin/st2ctl stop'
        self.output = '/tmp/st2installer.log'
        self.lockfile = '/tmp/st2installer_lock'
        self.keypair = KeypairController()
        self.configname = "answers.json"
        self.hostname = ''
        self.config = None
        self.start_time = None
        self.runtime = None
        self.analytics_sent = False
        self.puppet_check_command = 'ps aux | grep "[p]uppet-apply"'
        self.gen_ssl = 'Self-signed'
        self.gen_ssh = 'Generated'
        self.version = None

        config = config or conf.to_dict()
        if 'app' in config and 'version' in config['app']:
            self.version = config['app']['version']
        if 'puppet' in config and 'command' in config['puppet']:
            self.command = config['puppet']['command']
        else:
            self.command = '/usr/bin/sudo ' + \
                           'FACTER_installer_running=true ' + \
                           'ENV=current_working_directory ' + \
                           'NOCOLOR=true /usr/bin/puprun'
        if 'puppet' in config and 'hieradata' in config['puppet']:
            self.path = config['puppet']['hieradata']
        else:
            self.path = "/opt/puppet/hieradata/"

        password_length = 32
        password_chars = string.ascii_letters + string.digits
        self.password = ''.join(
            [random.choice(password_chars) for n in xrange(password_length)])

        # Note, any command added here needs to be added to the workroom sudoers entry.
        # File can be found at
        # https://github.com/StackStorm/st2workroom/blob/master/modules/profile/manifests/st2server.pp#L513
        self.cleanup_chain = [
            "/usr/bin/sudo /bin/chmod 660 %s%s" % (self.path, self.configname),
            "/usr/bin/sudo /usr/sbin/service nginx restart",
            "/usr/bin/sudo /usr/bin/st2ctl reload --register-all",
            "/usr/bin/sudo /usr/sbin/service docker-hubot restart",
            "/usr/bin/sudo /usr/bin/st2 run st2.call_home",
        ]

        self.grant_access = "/usr/bin/sudo /bin/chmod 755 %s%s" % (
            self.path, self.configname)
Пример #3
0
def report_config(conf, dump_to_log=False, my_logger=None):
    """ return the configuration (which is set by config.py) as a string
    :param conf:
    :param dump_to_log:
    :param my_logger:
    :return:
    """

    ret = pprint.pformat(conf.to_dict(), indent=4)
    effective_logger = my_logger if my_logger else logger
    if dump_to_log:
        effective_logger.info('Current Configuration:\n' + ret)

    return ret
Пример #4
0
    def __init__(self, config=None):

        self.proc = None
        self.st2stop = '/usr/bin/sudo /usr/bin/st2ctl stop'
        self.output = '/tmp/st2installer.log'
        self.lockfile = '/tmp/st2installer_lock'
        self.keypair = KeypairController()
        self.configname = "answers.json"
        self.hostname = ''
        self.config = None
        self.start_time = None
        self.runtime = None
        self.analytics_sent = False
        self.puppet_check_command = 'ps aux | grep "[p]uppet-apply"'
        self.gen_ssl = 'Self-signed'
        self.gen_ssh = 'Generated'
        self.version = None

        config = config or conf.to_dict()
        if 'app' in config and 'version' in config['app']:
            self.version = config['app']['version']
        if 'puppet' in config and 'command' in config['puppet']:
            self.command = config['puppet']['command']
        else:
            self.command = '/usr/bin/sudo ' + \
                           'FACTER_installer_running=true ' + \
                           'ENV=current_working_directory ' + \
                           'NOCOLOR=true /usr/bin/puprun'
        if 'puppet' in config and 'hieradata' in config['puppet']:
            self.path = config['puppet']['hieradata']
        else:
            self.path = "/opt/puppet/hieradata/"

        password_length = 32
        password_chars = string.ascii_letters + string.digits
        self.password = ''.join([random.choice(password_chars) for n in xrange(password_length)])

        # Note, any command added here needs to be added to the workroom sudoers entry.
        # File can be found at
        # https://github.com/StackStorm/st2workroom/blob/master/modules/profile/manifests/st2server.pp#L513
        self.cleanup_chain = [
            "/usr/bin/sudo /bin/chmod 660 %s%s" % (self.path, self.configname),
            "/usr/bin/sudo /usr/sbin/service nginx restart",
            "/usr/bin/sudo /usr/bin/st2ctl reload --register-all",
            "/usr/bin/sudo /usr/sbin/service docker-hubot restart",
            "/usr/bin/sudo /usr/bin/st2 run st2.call_home",
        ]

        self.grant_access = "/usr/bin/sudo /bin/chmod 755 %s%s" % (self.path, self.configname)
import ConfigParser
from sqlalchemy import *
from sqlalchemy.sql import select
from sqlalchemy import Table, Column, MetaData, DATETIME, ForeignKey, Enum
from pecan import conf
import datetime

try:
    conf_dict = conf.to_dict()
    conf_file = conf_dict['conf_file']
    config = ConfigParser.ConfigParser()
    config.read(conf_file)
    sql_connection = config.get('database', 'connection', '')
except Exception as e:
    sql_connection = ''


class MalwareCheckerModel():
    """
    DB Creations take place here
    """
    metadata = MetaData()
    engine = create_engine(sql_connection, pool_recycle=3600)
    conn = engine.connect()

    #Defining the tables
    malware_data = Table(
        'malware_data',
        metadata,
        Column('id',
               Integer,