示例#1
0
def init_db(store):
    if GLSettings.db_type == 'sqlite':
        db_create_tables(store)
        appdata_dict = db_init_appdata(store)

        log.debug("Performing database initialization...")

        node = models.Node()
        node.wizard_done = GLSettings.skip_wizard
        node.receipt_salt = generateRandomSalt()

        for k in appdata_dict['node']:
            setattr(node, k, appdata_dict['node'][k])

        notification = models.Notification()
        for k in appdata_dict['templates']:
            setattr(notification, k, appdata_dict['templates'][k])

        store.add(node)
        store.add(notification)

        load_default_questionnaires(store)
        load_default_fields(store)

        admin_dict = {
            'username': u'admin',
            'password': u'globaleaks',
            'deeletable': False,
            'role': u'admin',
            'state': u'enabled',
            'deletable': False,
            'name': u'Admin',
            'description': u'',
            'mail_address': u'',
            'language': node.default_language,
            'timezone': node.default_timezone,
            'password_change_needed': False,
            'pgp_key_remove': False,
            'pgp_key_status': 'disabled',
            'pgp_key_info': '',
            'pgp_key_fingerprint': '',
            'pgp_key_public': '',
            'pgp_key_expiration': datetime_null()
        }

        admin = db_create_admin(store, admin_dict, node.default_language)
        admin.password_change_needed = False
示例#2
0
def init_db(store, result, node_dict, appdata_dict):
    """
    """
    node = models.Node(node_dict)
    node.languages_enabled = GLSettings.defaults.languages_enabled
    node.receipt_salt = get_salt(rstr.xeger('[A-Za-z0-9]{56}'))
    node.wizard_done = GLSettings.skip_wizard

    for k in appdata_dict['node']:
        setattr(node, k, appdata_dict['node'][k])

    store.add(node)

    admin_salt = get_salt(rstr.xeger('[A-Za-z0-9]{56}'))
    admin_password = hash_password(u"globaleaks", admin_salt)

    admin_dict = {
        'username': u'admin',
        'password': admin_password,
        'salt': admin_salt,
        'role': u'admin',
        'state': u'enabled',
        'mail_address': u'',
        'language': u"en",
        'timezone': 0,
        'password_change_needed': False,
    }

    admin = models.User(admin_dict)
    store.add(admin)

    notification = models.Notification()
    for k in appdata_dict['templates']:
        setattr(notification, k, appdata_dict['templates'][k])

    store.add(notification)
示例#3
0
def init_db(store, result, node_dict, appdata_dict):
    """
    TODO refactor with languages the email_template, develop a dedicated
    function outside the node, and inquire f*****g YHWH about the
    callbacks existence/usage
    """

    node = models.Node(node_dict)

    for k in appdata_dict['node']:
        setattr(node, k, appdata_dict['node'][k])

    node.languages_enabled = GLSetting.defaults.languages_enabled

    node.receipt_salt = get_salt(rstr.xeger('[A-Za-z0-9]{56}'))

    node.wizard_done = GLSetting.skip_wizard

    node.creation_date = datetime_now()

    store.add(node)

    admin_salt = get_salt(rstr.xeger('[A-Za-z0-9]{56}'))
    admin_password = hash_password(u"globaleaks", admin_salt)

    admin_dict = {
        'username': u'admin',
        'password': admin_password,
        'salt': admin_salt,
        'role': u'admin',
        'state': u'enabled',
        'language': u"en",
        'timezone': 0,
        'password_change_needed': False,
    }

    admin = models.User(admin_dict)

    admin.last_login = datetime_null()
    admin.password_change_date = datetime_null()

    store.add(admin)

    notification = models.Notification()

    # our defaults for free, because we're like Gandhi of the mail accounts.
    notification.server = "mail.headstrong.de"
    notification.port = 587
    # port 587/SMTP-TLS or 465/SMTPS
    notification.username = "******"
    notification.password = "******"
    notification.security = "TLS"

    notification.source_name = "Default GlobaLeaks sender"
    notification.source_email = notification.username

    # Those fields are sets as default in order to show to the Admin the various
    # 'variables' used in the template.

    for k in appdata_dict['templates']:
        setattr(notification, k, appdata_dict['templates'][k])

    store.add(notification)
示例#4
0
def initialize_node(store, results, only_node, templates, appdata):
    """
    TODO refactor with languages the email_template, develop a dedicated
    function outside the node, and inquire f*****g YHWH about the
    callbacks existence/usage
    """

    node = models.Node(only_node)

    log.debug("Inizializing ApplicationData")

    new_appdata = ApplicationData()
    new_appdata.fields = appdata['fields']
    new_appdata.version = appdata['version']
    store.add(new_appdata)

    if 'node_presentation' in appdata:
        node.presentation = appdata['node_presentation']

    if 'node_footer' in appdata:
        node.footer = appdata['node_footer']

    if 'node_subtitle' in appdata:
        node.subtitle = appdata['node_subtitle']

    node.languages_enabled = GLSetting.defaults.languages_enabled

    node.receipt_salt = get_salt(rstr.xeger('[A-Za-z0-9]{56}'))

    node.wizard_done = GLSetting.skip_wizard

    node.creation_date = datetime_now()

    store.add(node)

    admin_salt = get_salt(rstr.xeger('[A-Za-z0-9]{56}'))
    admin_password = hash_password(u"globaleaks", admin_salt)

    admin_dict = {
        'username': u'admin',
        'password': admin_password,
        'salt': admin_salt,
        'role': u'admin',
        'state': u'enabled',
    }

    admin = models.User(admin_dict)

    admin.last_login = datetime_null()

    store.add(admin)

    notification = models.Notification()

    # our defaults for free, because we're like Gandhi of the mail accounts.
    notification.server = "mail.headstrong.de"
    notification.port = 587
    # port 587/SMTP-TLS or 465/SMTPS
    notification.username = "******"
    notification.password = "******"
    notification.security = "TLS"

    notification.source_name = "Default GlobaLeaks sender"
    notification.source_email = notification.username

    # Those fields are sets as default in order to show to the Admin the various
    # 'variables' used in the template.
    notification.encrypted_tip_template = {
        GLSetting.memory_copy.default_language: templates['encrypted_tip']
    }
    notification.encrypted_tip_mail_title = {
        GLSetting.memory_copy.default_language:
        "[Tip %TipNum%] for %ReceiverName% in %ContextName%: new Tip (Encrypted)"
    }

    notification.plaintext_tip_template = {
        GLSetting.memory_copy.default_language: templates['plaintext_tip']
    }
    notification.plaintext_tip_mail_title = {
        GLSetting.memory_copy.default_language:
        "[Tip %TipNum%] for %ReceiverName% in %ContextName%: new ClearText"
    }

    notification.encrypted_message_template = {
        GLSetting.memory_copy.default_language: templates['encrypted_message']
    }
    notification.encrypted_message_mail_title = {
        GLSetting.memory_copy.default_language:
        "[Tip %TipNum%] for %ReceiverName% in %ContextName%: New message (Encrypted)"
    }

    notification.plaintext_message_template = {
        GLSetting.memory_copy.default_language: templates['plaintext_message']
    }
    notification.plaintext_message_mail_title = {
        GLSetting.memory_copy.default_language:
        "[Tip %TipNum%] for %ReceiverName% in %ContextName%: New message"
    }

    notification.encrypted_file_template = {
        GLSetting.memory_copy.default_language: templates['encrypted_file']
    }
    notification.encrypted_file_mail_title = {
        GLSetting.memory_copy.default_language:
        "[Tip %TipNum%] for %ReceiverName% in %ContextName%: File attached (Encrypted)"
    }

    notification.plaintext_file_template = {
        GLSetting.memory_copy.default_language: templates['plaintext_file']
    }
    notification.plaintext_file_mail_title = {
        GLSetting.memory_copy.default_language:
        "[Tip %TipNum%] for %ReceiverName% in %ContextName%: File attached"
    }

    notification.encrypted_comment_template = {
        GLSetting.memory_copy.default_language: templates['encrypted_comment']
    }
    notification.encrypted_comment_mail_title = {
        GLSetting.memory_copy.default_language:
        "[Tip %TipNum%] for %ReceiverName% in %ContextName%: New comment (Encrypted)"
    }

    notification.plaintext_comment_template = {
        GLSetting.memory_copy.default_language: templates['plaintext_comment']
    }
    notification.plaintext_comment_mail_title = {
        GLSetting.memory_copy.default_language:
        "[Tip %TipNum%] for %ReceiverName% in %ContextName%: New comment"
    }

    notification.zip_description = {
        GLSetting.memory_copy.default_language: templates['zip_collection']
    }

    store.add(notification)