Skip to content

Commit

Permalink
bumped to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
msmannan00 committed Oct 31, 2024
1 parent ebd66de commit 6fc256f
Show file tree
Hide file tree
Showing 578 changed files with 35,416 additions and 10,666 deletions.
16 changes: 14 additions & 2 deletions backend/bin/gl-admin
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ from globaleaks.utils.crypto import GCE, generateRandomPassword
from globaleaks.utils.utility import datetime_now


# Function to check if input is a number
def is_number(value):
try:
# Try converting the value to a float
int(value)
return True
except ValueError:
return False


def check_file(f):
if not os.path.isfile(f) or not os.access(f, os.R_OK):
raise RuntimeError("Missing or inaccessible file: {}".format(f))
Expand Down Expand Up @@ -269,10 +279,12 @@ def get_var(args):
def set_var(args, silent=False):
db_path = check_db(args.workdir)

if args.value == 'True':
if args.value.lower() == 'true':
args.value = True
elif args.value == 'False':
elif args.value.lower() == 'false':
args.value = False
elif is_number(args.value):
args.value = int(args.value)

value = json.dumps(args.value)

Expand Down
8 changes: 4 additions & 4 deletions backend/bin/globaleaks
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ sys.path.insert(0, root)

from globaleaks.utils.utility import get_distribution_codename

if get_distribution_codename() != 'bookworm':
print("WARNING: The current long term supported platform is Debian 12 (bookworm)")
print("WARNING: It is recommended to use only this platform to ensure stability and security")
print("WARNING: To upgrade your system consult: https://docs.globaleaks.org/en/main/user/admin/UpgradeGuide.html")
if get_distribution_codename() not in ['bookworm', 'noble'] :
print("WARNING: The recommended up-to-date platforms are Debian 12 (Bookworm) and Ubuntu 24.04 (Noble)")
print("WARNING: Use one of these platforms to ensure best stability and security")
print("WARNING: To upgrade your system consult: https://docs.globaleaks.org/en/stable/user/admin/UpgradeGuide.html")


# this import seems unused but it is required in order to load the mocks
Expand Down
3 changes: 2 additions & 1 deletion backend/globaleaks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__author__ = 'GlobaLeaks'
__email__ = '[email protected]'
__copyright__ = '2011-2024 - GlobaLeaks'
__version__ = '5.0.6'
__version__ = '5.0.20'
__license__ = 'AGPL-3.0'

DATABASE_VERSION = 68
Expand Down Expand Up @@ -57,6 +57,7 @@
{'code': 'ja', 'name': 'Japanese', 'native': '\u65e5\u672c\u8a9e'},
{'code': 'ka', 'name': 'Georgian', 'native': '\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8'},
{'code': 'kk', 'name': 'Kazakh', 'native': '\u049b\u0430\u0437\u0430\u049b\u0020\u0442\u0456\u043b\u0456'},
{'code': 'kl', 'name': 'Greenlandic', 'native': 'Kalaallisut'},
{'code': 'km', 'name': 'Khmer', 'native': '\u1781\u17d2\u1798\u17c2\u179a'},
{'code': 'ko', 'name': 'Korean', 'native': '\ud55c\uad6d\uc5b4'},
{'code': 'ky', 'name': 'Kyrgyz', 'native': '\u043a\u044b\u0440\u0433\u044b\u0437\u0447\u0430'},
Expand Down
4 changes: 2 additions & 2 deletions backend/globaleaks/anomaly.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ def check_disk_anomalies(self):
workingdir: is performed a percentage check (at least 1% and an absolute comparison)
"unusable node" threshold: happen when the space is really shitty.
https://github.com/globaleaks/GlobaLeaks/issues/297
https://github.com/globaleaks/GlobaLeaks/issues/872
https://github.com/globaleaks/globaleaks-whistleblowing-software/issues/297
https://github.com/globaleaks/globaleaks-whistleblowing-software/issues/872
"""
self.measured_freespace, self.measured_totalspace = get_disk_space(State.settings.working_path)

Expand Down
63 changes: 10 additions & 53 deletions backend/globaleaks/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import sys
import traceback
import warnings
from collections import defaultdict
from operator import or_

from sqlalchemy.exc import SAWarning
from globaleaks.rest.cache import Cache

from globaleaks import models, DATABASE_VERSION
from globaleaks.handlers.admin.https import db_load_tls_configs
Expand Down Expand Up @@ -71,8 +68,7 @@ def initialize_db(session):
:param session: An ORM session
"""
from globaleaks.handlers.admin import tenant
tenant.db_create(session, {'active': False, 'mode': 'default', 'profile_counter': 1000000, 'name': 'GLOBALEAKS', 'subdomain': ''},False)
tenant.db_create(session, {'active': True, 'mode': 'default', 'profile_counter': 1000000, 'name': 'GLOBALEAKS', 'subdomain': ''})
tenant.db_create(session, {'active': True, 'mode': 'default', 'name': 'GLOBALEAKS', 'subdomain': ''})


def update_db():
Expand Down Expand Up @@ -160,17 +156,8 @@ def sync_initialize_snimap(session):
for cfg in db_load_tls_configs(session):
State.snimap.load(cfg['tid'], cfg)

def update_cache(cfg, tid):
tenant_cache = State.tenants[tid].cache
if cfg.var_name in ['https_cert', 'tor_onion_key'] or cfg.var_name in ConfigFilters['node']:
tenant_cache[cfg.var_name] = cfg.value
elif cfg.var_name in ConfigFilters['notification']:
tenant_cache.setdefault('notification', {})[cfg.var_name] = cfg.value
elif cfg.var_name in ConfigFilters['node']:
tenant_cache[cfg.var_name] = cfg.value

def db_refresh_tenant_cache(session, to_refresh=None):

active_tids = set([tid[0] for tid in session.query(models.Tenant.id).filter(models.Tenant.active.is_(True))])

cached_tids = set(State.tenants.keys())
Expand Down Expand Up @@ -200,21 +187,7 @@ def db_refresh_tenant_cache(session, to_refresh=None):
if to_refresh is None or to_refresh == 1:
tids = active_tids
else:
if to_refresh in active_tids:
tids = [to_refresh]
if to_refresh < 1000001:
default_profile_exists = session.query(Config).filter_by(tid=to_refresh, var_name='default_profile').first()
if default_profile_exists:
tids.append(default_profile_exists.tid)

elif to_refresh > 1000001:
matching_tids = [tid[0] for tid in session.query(Config.tid).filter_by(var_name='default_profile', value=str(to_refresh)).all()]
tids.extend(matching_tids)

for tid in matching_tids:
Cache.invalidate(tid)
else:
tids = []
tids = [to_refresh] if to_refresh in active_tids else []

if not tids:
return
Expand All @@ -241,31 +214,15 @@ def db_refresh_tenant_cache(session, to_refresh=None):
.filter(models.EnabledLanguage.tid.in_(tids)):
State.tenants[tid].cache['languages_enabled'].append(lang)

configs = defaultdict(dict)
default_configs = {}

for cfg in session.query(Config).filter(or_(Config.tid.in_(tids), Config.tid == 1000001)):
if cfg.tid == 1000001:
default_configs[cfg.var_name] = cfg
else:
configs[cfg.tid][cfg.var_name] = cfg
for cfg in session.query(Config).filter(Config.tid.in_(tids)):
tenant_cache = State.tenants[cfg.tid].cache

for var_name, default_cfg in default_configs.items():
for tid, tenant in list(configs.items()):
if "default_profile" in tenant:
profile_id = int(tenant["default_profile"].value)
profile = configs[profile_id]
else:
profile_id = None
profile = None

if to_refresh == 1 or to_refresh is None or (to_refresh < 1000001 and to_refresh == tid) or (1000001 < to_refresh == profile_id) or (1000001 < to_refresh == tid):
if var_name in tenant:
update_cache(tenant[var_name], tid)
elif profile and var_name in profile:
update_cache(profile[var_name], tid)
elif tid:
update_cache(default_cfg, tid)
if cfg.var_name in ['https_cert', 'tor_onion_key']:
tenant_cache[cfg.var_name] = cfg.value
elif cfg.var_name in ConfigFilters['node']:
tenant_cache[cfg.var_name] = cfg.value
elif cfg.var_name in ConfigFilters['notification']:
tenant_cache['notification'][cfg.var_name] = cfg.value

for tid, mail, pub_key in session.query(models.User.tid, models.User.mail_address, models.User.pgp_key_public) \
.filter(models.User.role == 'admin',
Expand Down
3 changes: 1 addition & 2 deletions backend/globaleaks/db/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from globaleaks.db.migrations.update_67 import \
InternalTip_v_66, ReceiverFile_v_66, Redaction_v_66, User_v_66, WhistleblowerFile_v_66
from globaleaks.db.migrations.update_68 import Subscriber_v_67
from globaleaks.db.migrations.update_69 import Tenant_v_68


from globaleaks.orm import get_engine, get_session, make_db_uri
Expand Down Expand Up @@ -81,7 +80,7 @@
('SubmissionStatusChange', [SubmissionStatusChange_v_54, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]),
('Step', [models._Step, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
('Subscriber', [Subscriber_v_52, Subscriber_v_62, 0, 0, 0, 0, 0, 0, 0, 0, 0, Subscriber_v_67, 0, 0, 0, 0, models._Subscriber]),
('Tenant', [Tenant_v_52, models._Tenant, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,Tenant_v_68]),
('Tenant', [Tenant_v_52, models._Tenant, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
('User', [User_v_52, User_v_54, 0, User_v_56, 0, User_v_61, 0, 0, 0, 0, User_v_64, 0, 0, User_v_66, 0, models._User, 0]),
('WhistleblowerFile', [WhistleblowerFile_v_57, 0, 0, 0, 0, 0, WhistleblowerFile_v_64, 0, 0, 0, 0, 0, 0, WhistleblowerFile_v_66, 0, models._WhistleblowerFile, 0]),

Expand Down
107 changes: 0 additions & 107 deletions backend/globaleaks/db/migrations/update_69/__init__.py

This file was deleted.

4 changes: 3 additions & 1 deletion backend/globaleaks/handlers/admin/auditlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def serialize_log(log):

@transact
def get_audit_log(session, tid):
logs = session.query(models.AuditLog).filter(models.AuditLog.tid == tid)
logs = session.query(models.AuditLog) \
.filter(models.AuditLog.tid == tid) \
.order_by(models.AuditLog.date.desc())

return [serialize_log(log) for log in logs]

Expand Down
7 changes: 3 additions & 4 deletions backend/globaleaks/handlers/admin/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from globaleaks.utils.crypto import GCE
from globaleaks.utils.fs import read_file
from globaleaks.utils.log import log
from globaleaks.models import Config


def db_update_enabled_languages(session, tid, languages, default_language):
"""
Expand Down Expand Up @@ -72,8 +72,7 @@ def db_admin_serialize_node(session, tid, language, config_desc='node'):
'https_possible': tid == 1 or root_config.get_val('reachable_via_web'),
'encryption_possible': tid == 1 or root_config.get_val('encryption'),
'escrow': config.get_val('crypto_escrow_pub_key') != '',
'logo': True if logo else False,
'profile': session.query(Config).filter_by(tid=tid, var_name='default_profile').first() is not None if int(tid) < 1000001 else False
'logo': True if logo else False
})

if 'version' in ret:
Expand Down Expand Up @@ -141,7 +140,7 @@ def get(self):
self.request.tid,
self.request.language,
config_desc=config[0])
ret["is_profile"] = True if self.request.tid > 1000001 else False

returnValue(ret)

@inlineCallbacks
Expand Down
Loading

0 comments on commit 6fc256f

Please sign in to comment.