Esempio n. 1
0
    def __init__(self):
        from globaleaks.settings import Settings

        self.settings = Settings

        self.process_supervisor = None
        self.tor_exit_set = TorExitSet()

        self.https_socks = []
        self.http_socks = []

        self.jobs = []
        self.jobs_monitor = None
        self.services = []
        self.onion_service_job = None

        self.api_token_session = None

        self.exceptions = {}
        self.exceptions_email_count = 0
        self.mail_counters = {}
        self.stats_collection_start_time = datetime_now()

        self.accept_submissions = True

        self.tenant_state = {}
        self.tenant_cache = {}
        self.tenant_hostname_id_map = {}

        self.set_orm_tp(ThreadPool(4, 16))
        self.TempUploadFiles = TempDict(timeout=3600)
Esempio n. 2
0
    def __init__(self):
        self.settings = Settings

        self.tor_exit_set = TorExitSet()

        self.https_socks = []
        self.http_socks = []

        self.snimap = SNIMap()

        self.jobs = []
        self.jobs_monitor = None
        self.services = []
        self.onion_service_job = None

        self.exceptions = {}
        self.exceptions_email_count = 0
        self.stats_collection_start_time = datetime_now()

        self.accept_submissions = True

        self.tenant_state = {}
        self.tenant_cache = {}
        self.tenant_hostname_id_map = {}

        self.set_orm_tp(ThreadPool(4, 16))

        self.TempLogs = []
        self.TempKeys = TempDict(3600 * 72)
        self.TempUploadFiles = TempDict(3600)

        self.shutdown = False
Esempio n. 3
0
    def __init__(self):
        self.orm_tp = ThreadPool(1, 1)
        self.process_supervisor = None
        self.tor_exit_set = TorExitSet()

        self.https_socks = []
        self.http_socks = []
        self.jobs = []
        self.jobs_monitor = None
        self.services = []

        self.api_token_session = None
        self.api_token_session_suspended = False

        self.RecentEventQ = []
        self.RecentAnomaliesQ = {}
        self.exceptions = {}
        self.exceptions_email_count = 0
        self.mail_counters = {}
        self.stats_collection_start_time = datetime_now()

        self.accept_submissions = True

        self.tenant_cache = {}
        self.tenant_cache[1] = ObjectDict({
            'maximum_namesize':
            128,
            'maximum_textsize':
            4096,
            'maximum_filesize':
            30,
            'allow_iframes_inclusion':
            False,
            'accept_tor2web_access': {
                'admin': True,
                'whistleblower': False,
                'custodian': False,
                'receiver': False
            },
            'private': {
                'https_enabled': False,
            },
            'anonymize_outgoing_connections':
            True,
        })
Esempio n. 4
0
    def __init__(self):
        # command line parsing utils
        self.parser = OptionParser()
        self.cmdline_options = None

        # version
        self.version_string = __version__

        # testing
        # This variable is to be able to hook/bypass code when unit-tests are run
        self.testing = False

        # daemonize the process
        self.nodaemon = False

        # thread pool size of 1
        self.orm_tp = ThreadPool(1, 1)

        self.bind_address = '0.0.0.0'
        self.bind_remote_ports = [80, 443]
        self.bind_local_ports = [8082, 8083]

        # store name
        self.store_name = 'main_store'

        self.db_type = 'sqlite'

        # debug defaults
        self.orm_debug = False

        # files and paths
        self.root_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '..'))
        self.pid_path = '/var/run/globaleaks'
        self.working_path = '/var/globaleaks'

        # TODO(bug-fix-italian-style) why is this set to the 2nd entry in the possible
        # client paths...? please fix.
        self.client_path = '/usr/share/globaleaks/client'
        for path in possible_client_paths:
            if os.path.exists(path):
                self.client_path = path
                break

        self.set_ramdisk_path()

        self.authentication_lifetime = 3600

        self.jobs = []
        self.jobs_monitor = None

        self.services = []

        self.RecentEventQ = []
        self.RecentAnomaliesQ = {}
        self.stats_collection_start_time = datetime_now()

        self.accept_submissions = True

        # statistical, referred to latest period
        # and resetted by session_management sched
        self.failed_login_attempts = 0

        # static file rules
        self.staticfile_regexp = r'(.*)'
        self.staticfile_overwrite = False

        self.local_hosts = ['127.0.0.1', 'localhost']

        self.onionservice = None

        self.receipt_regexp = u'[0-9]{16}'

        # A lot of operations performed massively by globaleaks
        # should avoid to fetch continuously variables from the DB so that
        # it is important to keep this variables in memory
        #
        # Initialization is handled by db_refresh_memory_variables
        self.memory_copy = ObjectDict({
            'maximum_namesize': 128,
            'maximum_textsize': 4096,
            'maximum_filesize': 30,
            'allow_iframes_inclusion': False,
            'accept_tor2web_access': {
                'admin': True,
                'whistleblower': False,
                'custodian': False,
                'receiver': False
            },
            'private': {
                'https_enabled': False,
            },
            'anonymize_outgoing_connections': True,
        })

        # Default request time uniform value
        self.side_channels_guard = 150

        # SOCKS default
        self.socks_host = "127.0.0.1"
        self.socks_port = 9050

        self.key_bits = 2048
        self.csr_sign_bits = 512

        self.api_token_len = 32

        self.notification_limit = 30
        self.jobs_operation_limit = 20

        self.user = getpass.getuser()
        self.group = getpass.getuser()
        self.uid = os.getuid()
        self.gid = os.getgid()
        self.devel_mode = False
        self.developer_name = ''
        self.disable_swap = False

        # Number of failed login enough to generate an alarm
        self.failed_login_alarm = 5

        # Number of minutes in which a user is prevented to login in case of triggered alarm
        self.failed_login_block_time = 5

        # Limit for log sizes and number of log files
        # https://github.com/globaleaks/GlobaLeaks/issues/1578
        self.log_size = 10000000  # 10MB
        self.log_file_size = 1000000  # 1MB
        self.num_log_files = self.log_size / self.log_file_size

        # size used while streaming files
        self.file_chunk_size = 65535  # 64kb

        self.AES_key_size = 32
        self.AES_key_id_regexp = u'[A-Za-z0-9]{16}'
        self.AES_counter_nonce = 128 / 8
        self.AES_file_regexp = r'(.*)\.aes'
        self.AES_file_regexp_comp = re.compile(self.AES_file_regexp)
        self.AES_keyfile_prefix = "aeskey-"

        self.exceptions = {}
        self.exceptions_email_count = 0
        self.exceptions_email_hourly_limit = 20

        self.disable_backend_exception_notification = False
        self.disable_client_exception_notification = False

        self.enable_input_length_checks = True

        self.submission_minimum_delay = 3  # seconds
        self.submission_maximum_ttl = 3600  # 1 hour

        self.mail_counters = {}
        self.mail_timeout = 15  # seconds
        self.mail_attempts_limit = 3  # per mail limit

        self.https_socks = []
        self.http_socks = []

        # TODO holds global state until GLSettings is inverted and this
        # state managed as an object by the application
        self.appstate = ObjectDict()
        self.appstate.process_supervisor = None
        self.appstate.tor_exit_set = TorExitSet()
        self.appstate.latest_version = StrictVersion(__version__)
        self.appstate.api_token_session = None
        self.appstate.api_token_session_suspended = False

        self.acme_directory_url = 'https://acme-v01.api.letsencrypt.org/directory'