id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
40,800 | base.py | jumpserver_jumpserver/apps/terminal/backends/command/base.py | # coding: utf-8
import abc
class CommandBase(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def save(self, command):
pass
@abc.abstractmethod
def bulk_save(self, commands):
pass
@abc.abstractmethod
def filter(self, date_from=None, date_to=None,
u... | 622 | Python | .py | 20 | 23.45 | 71 | 0.62521 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,801 | multi.py | jumpserver_jumpserver/apps/terminal/backends/command/multi.py | # -*- coding: utf-8 -*-
#
from .base import CommandBase
class CommandStore(CommandBase):
def __init__(self, storage_list):
self.storage_list = storage_list
def filter(self, **kwargs):
if len(self.storage_list) == 1:
storage = list(self.storage_list)[0]
queryset = stor... | 826 | Python | .py | 24 | 26.416667 | 84 | 0.61335 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,802 | __init__.py | jumpserver_jumpserver/apps/terminal/automations/deploy_applet_host/__init__.py | import datetime
import os
import re
import shutil
import yaml
from django.conf import settings
from django.utils import timezone
from common.db.utils import safe_db_connection
from common.utils import get_logger, random_string
from ops.ansible import SuperPlaybookRunner, JMSInventory
from terminal.models import Apple... | 6,112 | Python | .py | 135 | 35.474074 | 94 | 0.634713 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,803 | terminal.py | jumpserver_jumpserver/apps/terminal/signal_handlers/terminal.py | from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils.functional import LazyObject
from common.decorators import on_transaction_commit
from common.utils import get_logger
from common.utils.connection import RedisPubSub
from ..const import TaskNameType
from ..models impor... | 1,440 | Python | .py | 37 | 32 | 64 | 0.694891 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,804 | db_port.py | jumpserver_jumpserver/apps/terminal/signal_handlers/db_port.py | from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from assets.models import Asset, Database
from common.decorators import on_transaction_commit
from common.signals import django_ready
from common.utils import get_logger
from ..utils import db_port_manager
logger = get_lo... | 1,172 | Python | .py | 30 | 34.2 | 83 | 0.726212 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,805 | session_sharing.py | jumpserver_jumpserver/apps/terminal/signal_handlers/session_sharing.py | from django.db.models.signals import post_save
from django.dispatch import receiver
from terminal.models import SessionSharing
from terminal.notifications import SessionSharingMessage
from terminal.session_lifecycle import UserCreateShareLink
@receiver(post_save, sender=SessionSharing)
def on_session_sharing_created... | 643 | Python | .py | 14 | 40.642857 | 84 | 0.808264 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,806 | __init__.py | jumpserver_jumpserver/apps/terminal/signal_handlers/__init__.py | from .applet import *
from .db_port import *
from .session import *
from .session_sharing import *
from .terminal import *
from .virtualapp import *
| 149 | Python | .py | 6 | 23.833333 | 30 | 0.776224 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,807 | applet.py | jumpserver_jumpserver/apps/terminal/signal_handlers/applet.py | from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver
from django.utils.functional import LazyObject
from accounts.const import AliasAccount
from accounts.models import Account, VirtualAccount
from common.decorators import on_transaction_commit
from common.signals import djan... | 3,687 | Python | .py | 84 | 37.880952 | 95 | 0.742702 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,808 | virtualapp.py | jumpserver_jumpserver/apps/terminal/signal_handlers/virtualapp.py | from django.db.models.signals import post_save
from django.dispatch import receiver
from common.decorators import on_transaction_commit
from ..models import AppProvider, VirtualApp
@receiver(post_save, sender=AppProvider)
@on_transaction_commit
def on_virtual_host_create(sender, instance, created=False, **kwargs):
... | 688 | Python | .py | 19 | 32.210526 | 70 | 0.75753 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,809 | session.py | jumpserver_jumpserver/apps/terminal/signal_handlers/session.py | from django.db.models.signals import pre_save, post_save
from django.dispatch import receiver
from terminal.models import Session
@receiver(pre_save, sender=Session)
def on_session_pre_save(sender, instance,**kwargs):
if instance.need_update_cmd_amount:
instance.cmd_amount = instance.compute_command_amou... | 582 | Python | .py | 13 | 38.538462 | 70 | 0.771107 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,810 | sharing.py | jumpserver_jumpserver/apps/terminal/serializers/sharing.py | from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from common.serializers.fields import LabeledChoiceField
from common.utils.common import pretty_string
from common.utils.random import random_string
from orgs.mixins.serializers import OrgResourceModelSerializerMixin
from ..c... | 3,121 | Python | .py | 68 | 37.676471 | 90 | 0.6476 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,811 | loki.py | jumpserver_jumpserver/apps/terminal/serializers/loki.py | import time
from rest_framework import serializers
__all__ = [
'LokiLogSerializer',
]
class LokiLogSerializer(serializers.Serializer):
components = serializers.CharField(required=False, )
start = serializers.IntegerField()
end = serializers.IntegerField(default=time.time)
search = serializers.Ch... | 356 | Python | .py | 10 | 32.2 | 62 | 0.774854 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,812 | terminal.py | jumpserver_jumpserver/apps/terminal/serializers/terminal.py | from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from common.serializers import BulkModelSerializer
from common.serializers.fields import LabeledChoiceField
from common.utils import get_request_ip, pretty_string, is_uuid
from users.serializers import ServiceAccountSerialize... | 5,255 | Python | .py | 128 | 32.828125 | 109 | 0.640227 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,813 | command.py | jumpserver_jumpserver/apps/terminal/serializers/command.py | # ~*~ coding: utf-8 ~*~
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from common.serializers.fields import LabeledChoiceField
from common.utils import pretty_string, is_uuid, get_logger
from terminal.const import RiskLevelChoices
from terminal.models import Command
log... | 3,552 | Python | .py | 74 | 38.783784 | 94 | 0.683082 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,814 | endpoint.py | jumpserver_jumpserver/apps/terminal/serializers/endpoint.py | from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from acls.serializers.rules import ip_group_child_validator, ip_group_help_text
from common.serializers import BulkModelSerializer
from common.serializers.fields import ObjectRelatedField
from ..models import Endpoint, Endpoi... | 3,698 | Python | .py | 82 | 35.695122 | 101 | 0.625598 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,815 | __init__.py | jumpserver_jumpserver/apps/terminal/serializers/__init__.py | # -*- coding: utf-8 -*-
#
from .applet import *
from .applet_host import *
from .command import *
from .endpoint import *
from .session import *
from .sharing import *
from .storage import *
from .task import *
from .terminal import *
from .virtualapp import *
from .virtualapp_provider import *
from .loki import *
| 316 | Python | .py | 14 | 21.571429 | 34 | 0.748344 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,816 | storage.py | jumpserver_jumpserver/apps/terminal/serializers/storage.py | # -*- coding: utf-8 -*-
#
from urllib.parse import urlparse
from django.core.validators import MaxValueValidator, MinValueValidator, validate_ipv46_address
from django.db.models import TextChoices
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from rest_framework.validato... | 11,641 | Python | .py | 255 | 38.705882 | 100 | 0.697189 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,817 | applet_host.py | jumpserver_jumpserver/apps/terminal/serializers/applet_host.py | from django.conf import settings
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from accounts.models import Account
from assets.models import Platform
from assets.serializers import HostSerializer
from common.const.choices import Status
from common.serializers.fields impo... | 7,353 | Python | .py | 154 | 38.311688 | 117 | 0.660732 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,818 | task.py | jumpserver_jumpserver/apps/terminal/serializers/task.py | from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from terminal.const import TaskNameType as SessionTaskChoices
class LockTaskSessionSerializer(serializers.Serializer):
session_id = serializers.CharField(max_length=40, label=_('Session id'))
task_name = serializer... | 392 | Python | .py | 6 | 62.333333 | 97 | 0.82199 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,819 | virtualapp_provider.py | jumpserver_jumpserver/apps/terminal/serializers/virtualapp_provider.py | from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from common.serializers.fields import LabeledChoiceField
from terminal import const
from ..models import AppProvider
__all__ = ['AppProviderSerializer', 'AppProviderContainerSerializer', ]
class AppProviderSerializer(seria... | 1,163 | Python | .py | 23 | 45.217391 | 102 | 0.734982 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,820 | applet.py | jumpserver_jumpserver/apps/terminal/serializers/applet.py | from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from common.const.choices import Status
from common.serializers.fields import ObjectRelatedField, LabeledChoiceField
from terminal.const import PublishStatus
from ..models import Applet, AppletPublication, AppletHost
__all__... | 1,762 | Python | .py | 36 | 42.055556 | 107 | 0.680442 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,821 | virtualapp.py | jumpserver_jumpserver/apps/terminal/serializers/virtualapp.py | from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from common.const.choices import Status
from common.serializers.fields import ObjectRelatedField, LabeledChoiceField
from terminal.const import PublishStatus
from ..models import VirtualApp, VirtualAppPublication, AppProvider... | 1,696 | Python | .py | 33 | 44.666667 | 105 | 0.694864 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,822 | session.py | jumpserver_jumpserver/apps/terminal/serializers/session.py | from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from assets.models import Asset
from common.serializers.fields import LabeledChoiceField
from common.utils import pretty_string
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from terminal.session_lifecycl... | 5,283 | Python | .py | 110 | 40.172727 | 107 | 0.657348 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,823 | filters.py | jumpserver_jumpserver/apps/audits/filters.py | from django.apps import apps
from django.utils import translation
from django_filters import rest_framework as drf_filters
from rest_framework import filters
from rest_framework.compat import coreapi, coreschema
from common.drf.filters import BaseFilterSet
from common.sessions.cache import user_session_manager
from or... | 2,346 | Python | .py | 59 | 31.677966 | 101 | 0.657281 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,824 | models.py | jumpserver_jumpserver/apps/audits/models.py | import os
import uuid
from datetime import timedelta
from importlib import import_module
from django.conf import settings
from django.core.cache import caches
from django.db import models
from django.db.models import Q
from django.utils import timezone
from django.utils.translation import gettext, gettext_lazy as _
f... | 10,822 | Python | .py | 256 | 35.332031 | 105 | 0.663805 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,825 | serializers.py | jumpserver_jumpserver/apps/audits/serializers.py | # -*- coding: utf-8 -*-
#
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from audits.backends.db import OperateLogStore
from common.serializers.fields import LabeledChoiceField, ObjectRelatedField
from common.utils import reverse, i18n_trans
from common.utils.timezone imp... | 6,535 | Python | .py | 158 | 33.164557 | 97 | 0.634458 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,826 | tasks.py | jumpserver_jumpserver/apps/audits/tasks.py | # -*- coding: utf-8 -*-
#
import datetime
import os
import subprocess
from celery import shared_task
from django.conf import settings
from django.core.files.storage import default_storage
from django.db import transaction
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from co... | 6,882 | Python | .py | 154 | 39.337662 | 98 | 0.702925 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,827 | const.py | jumpserver_jumpserver/apps/audits/const.py | # -*- coding: utf-8 -*-
#
from django.db.models import TextChoices, IntegerChoices
from django.utils.translation import gettext_lazy as _
DEFAULT_CITY = _("Unknown")
MODELS_NEED_RECORD = set()
class OperateChoices(TextChoices):
mkdir = "mkdir", _("Mkdir")
rmdir = "rmdir", _("Rmdir")
delete = "delete", _... | 1,710 | Python | .py | 49 | 30.55102 | 57 | 0.606687 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,828 | apps.py | jumpserver_jumpserver/apps/audits/apps.py | from django.apps import AppConfig
from django.conf import settings
from django.db.models.signals import post_save
from django.utils.translation import gettext_lazy as _
class AuditsConfig(AppConfig):
name = 'audits'
verbose_name = _('App Audits')
def ready(self):
from . import signal_handlers # ... | 465 | Python | .py | 12 | 33.416667 | 67 | 0.721604 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,829 | api.py | jumpserver_jumpserver/apps/audits/api.py | # -*- coding: utf-8 -*-
#
from importlib import import_module
from django.conf import settings
from django.db.models import F, Value, CharField, Q
from django.db.models.functions import Cast
from django.http import HttpResponse, FileResponse
from django.utils.encoding import escape_uri_path
from rest_framework import ... | 10,959 | Python | .py | 256 | 35.628906 | 114 | 0.670323 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,830 | utils.py | jumpserver_jumpserver/apps/audits/utils.py | import copy
from datetime import datetime
from itertools import chain
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
from django.db import models
from django.db.models import F, Value, CharField
from django.db.models.functions import Concat
from common.db.fields import RelatedManage... | 4,966 | Python | .py | 117 | 31.623932 | 115 | 0.589892 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,831 | handler.py | jumpserver_jumpserver/apps/audits/handler.py | import json
from datetime import datetime
from django.core.cache import cache
from django.db import transaction
from django.utils.translation import gettext_lazy as _
from common.local import similar_encrypted_pattern, exclude_encrypted_fields
from common.utils import get_request_ip, get_logger
from common.utils.enco... | 7,261 | Python | .py | 168 | 33.375 | 86 | 0.624373 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,832 | 0002_ftplog_org_id.py | jumpserver_jumpserver/apps/audits/migrations/0002_ftplog_org_id.py | # Generated by Django 4.1.13 on 2024-05-09 03:16
from django.db import migrations
class Migration(migrations.Migration):
initial = True
dependencies = [
('ops', '0001_initial'),
('audits', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='JobLog',
... | 597 | Python | .py | 22 | 17.318182 | 48 | 0.479789 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,833 | 0001_initial.py | jumpserver_jumpserver/apps/audits/migrations/0001_initial.py | # Generated by Django 4.1.13 on 2024-05-09 03:16
import uuid
import django.utils.timezone
from django.db import migrations, models
import common.db.encoder
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Ac... | 7,965 | Python | .py | 117 | 54.188034 | 452 | 0.577679 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,834 | 0003_auto_20180816_1652.py | jumpserver_jumpserver/apps/audits/migrations/0003_auto_20180816_1652.py | # Generated by Django 4.1.13 on 2024-05-09 03:16
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('audits', '0002_ftplog_org_id'),
migrations.swappable_dependenc... | 641 | Python | .py | 17 | 31.176471 | 156 | 0.684466 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,835 | api_urls.py | jumpserver_jumpserver/apps/audits/urls/api_urls.py | # ~*~ coding: utf-8 ~*~
from __future__ import unicode_literals
from django.urls.conf import path
from rest_framework.routers import DefaultRouter
from .. import api
app_name = "audits"
router = DefaultRouter()
router.register(r'ftp-logs', api.FTPLogViewSet, 'ftp-log')
router.register(r'login-logs', api.UserLoginLo... | 855 | Python | .py | 18 | 45.944444 | 93 | 0.780987 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,836 | view_urls.py | jumpserver_jumpserver/apps/audits/urls/view_urls.py | # ~*~ coding: utf-8 ~*~
from __future__ import unicode_literals
from django.urls import path
__all__ = ["urlpatterns"]
app_name = "audits"
urlpatterns = [
]
| 161 | Python | .py | 7 | 21.428571 | 39 | 0.686667 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,837 | db.py | jumpserver_jumpserver/apps/audits/backends/db.py | # ~*~ coding: utf-8 ~*~
from django.utils.translation import gettext_lazy as _
from audits.models import OperateLog
from perms.const import ActionChoices
class OperateLogStore(object):
# 使用 Unicode 单元分隔符\u001f,替代旧的分隔符\0 PostgreSQL 数据库不支持\0
SEP = '\u001f'
OLD_SEP = '\0'
def __init__(self, config):
... | 4,069 | Python | .py | 99 | 30.535354 | 99 | 0.578551 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,838 | es.py | jumpserver_jumpserver/apps/audits/backends/es.py | # -*- coding: utf-8 -*-
#
import uuid
from common.utils.timezone import local_now_display
from common.utils import get_logger
from common.utils.encode import Singleton
from common.plugins.es import ES
logger = get_logger(__file__)
class OperateLogStore(ES, metaclass=Singleton):
def __init__(self, config):
... | 2,718 | Python | .py | 77 | 24.532468 | 88 | 0.491075 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,839 | __init__.py | jumpserver_jumpserver/apps/audits/backends/__init__.py | from importlib import import_module
from django.conf import settings
TYPE_ENGINE_MAPPING = {
'db': 'audits.backends.db',
'es': 'audits.backends.es',
}
def get_operate_log_storage(default=False):
engine_mod = import_module(TYPE_ENGINE_MAPPING['db'])
es_config = settings.OPERATE_LOG_ELASTICSEARCH_CON... | 491 | Python | .py | 13 | 33.615385 | 61 | 0.733615 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,840 | operate_log.py | jumpserver_jumpserver/apps/audits/signal_handlers/operate_log.py | # -*- coding: utf-8 -*-
#
import uuid
from django.apps import apps
from django.db.models.signals import (
pre_delete, pre_save, m2m_changed, post_delete, post_save
)
from django.dispatch import receiver
from django.utils import translation
from audits.handler import (
get_instance_current_with_cache_diff, cac... | 7,451 | Python | .py | 175 | 34.354286 | 90 | 0.65816 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,841 | activity_log.py | jumpserver_jumpserver/apps/audits/signal_handlers/activity_log.py | # -*- coding: utf-8 -*-
#
from celery import signals
from django.db.models.signals import post_save
from django.utils.translation import gettext_lazy as _, gettext_noop
from audits.models import ActivityLog
from common.utils import i18n_fmt, get_logger
from jumpserver.utils import current_request
from ops.celery impo... | 4,384 | Python | .py | 103 | 35.660194 | 107 | 0.667918 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,842 | other.py | jumpserver_jumpserver/apps/audits/signal_handlers/other.py | # -*- coding: utf-8 -*-
#
from django.dispatch import receiver
from django.db import transaction
from audits.models import (
PasswordChangeLog, UserLoginLog, FTPLog, OperateLog
)
from audits.serializers import (
UserLoginLogSerializer, FTPLogSerializer, OperateLogSerializer,
PasswordChangeLogSerializer
)
f... | 2,224 | Python | .py | 60 | 31.333333 | 76 | 0.710575 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,843 | login_log.py | jumpserver_jumpserver/apps/audits/signal_handlers/login_log.py | # -*- coding: utf-8 -*-
#
from django.conf import settings
from django.contrib.auth import BACKEND_SESSION_KEY
from django.dispatch import receiver
from django.utils import timezone, translation
from django.utils.functional import LazyObject
from django.utils.translation import gettext_lazy as _
from rest_framework.re... | 5,432 | Python | .py | 118 | 40.09322 | 86 | 0.699753 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,844 | __init__.py | jumpserver_jumpserver/apps/audits/signal_handlers/__init__.py | from .activity_log import *
from .login_log import *
from .operate_log import *
from .other import *
| 101 | Python | .py | 4 | 24.25 | 27 | 0.762887 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,845 | translate.py | jumpserver_jumpserver/apps/i18n/translate.py | import asyncio
import os
from _translator.const import LOCALE_DIR, RED
from _translator.core import CoreTranslateManager
from _translator.other import OtherTranslateManager
from _translator.utils import OpenAITranslate
class Translate:
IGNORE_TRANSLATE_DIRS = ('translate',)
def __init__(self, oai_trans_inst... | 1,886 | Python | .py | 47 | 31.361702 | 78 | 0.611172 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,846 | sort_json.py | jumpserver_jumpserver/apps/i18n/sort_json.py | #!/usr/bin/env python
#
import json
import os
def sort_json(json_file):
with open(json_file, 'r') as f:
json_data = json.load(f)
with open(json_file, 'w') as f:
json.dump(json_data, f, indent=4, sort_keys=True, ensure_ascii=False)
def walk_dir(dir_path):
for root, dirs, files in os.wal... | 561 | Python | .py | 17 | 27.294118 | 77 | 0.61194 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,847 | other.py | jumpserver_jumpserver/apps/i18n/_translator/other.py | import json
import os
from .base import BaseTranslateManager
from .const import RED, GREEN
class OtherTranslateManager(BaseTranslateManager):
@staticmethod
def get_need_trans_dict(zh_dict, other_dict):
diff_keys = set(zh_dict.keys()) - set(other_dict.keys())
need_trans_dict = {k: zh_dict[k] ... | 1,836 | Python | .py | 39 | 37.205128 | 87 | 0.605366 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,848 | const.py | jumpserver_jumpserver/apps/i18n/_translator/const.py | import os
LOCALE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
RED = "\033[91m"
BLUE = "\033[94m"
CYAN = "\033[96m"
RESET = "\033[0m"
GREEN = "\033[92m"
WHITE = "\033[97m"
YELLOW = "\033[93m"
MAGENTA = "\033[95m"
| 235 | Python | .py | 10 | 22.3 | 72 | 0.654709 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,849 | utils.py | jumpserver_jumpserver/apps/i18n/_translator/utils.py | from openai import AsyncOpenAI
class OpenAITranslate:
def __init__(self, key: str | None = None, base_url: str | None = None):
self.client = AsyncOpenAI(api_key=key, base_url=base_url)
async def translate_text(self, text, target_lang="English") -> str | None:
try:
response = await... | 1,618 | Python | .py | 31 | 32.096774 | 134 | 0.470812 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,850 | base.py | jumpserver_jumpserver/apps/i18n/_translator/base.py | import asyncio
import os
from tqdm import tqdm
from .const import RED, GREEN, RESET
class BaseTranslateManager:
bulk_size = 15
SEPARATOR = "<SEP>"
LANG_MAPPER = {
'ja': 'Japanese',
'zh_hant': 'Taiwan',
# 'en': 'English',
}
def __init__(self, dir_path, oai_trans_instance)... | 2,235 | Python | .py | 56 | 30.053571 | 93 | 0.580526 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,851 | core.py | jumpserver_jumpserver/apps/i18n/_translator/core.py | import os
import polib
from .base import BaseTranslateManager
from .const import RED, GREEN, MAGENTA
class CoreTranslateManager(BaseTranslateManager):
@staticmethod
def get_need_trans_dict(zh_dict, trans_po):
need_trans_dict = {
entry.msgid: zh_dict[entry.msgid]
for entry in... | 1,979 | Python | .py | 41 | 37.365854 | 91 | 0.607772 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,852 | filters.py | jumpserver_jumpserver/apps/notifications/filters.py | import django_filters
from common.drf.filters import BaseFilterSet
from .models import MessageContent
class SiteMsgFilter(BaseFilterSet):
# 不用 Django 的关联表过滤,有个小bug,会重复关联相同表
# SELECT DISTINCT * FROM `notifications_sitemessage`
# INNER JOIN `notifications_sitemessageusers` ON (`notifications_sitemessage`... | 869 | Python | .py | 14 | 54.357143 | 141 | 0.752781 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,853 | apps.py | jumpserver_jumpserver/apps/notifications/apps.py | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class NotificationsConfig(AppConfig):
name = 'notifications'
verbose_name = _('App Notifications')
def ready(self):
from . import signal_handlers # noqa
from . import notifications # noqa
su... | 334 | Python | .py | 9 | 31.777778 | 54 | 0.708075 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,854 | site_msg.py | jumpserver_jumpserver/apps/notifications/site_msg.py | from django.db import transaction
from common.utils import get_logger
from common.utils.timezone import local_now
from users.models import User
from .models import MessageContent as SiteMessageModel, SiteMessage
logger = get_logger(__file__)
class SiteMessageUtil:
@classmethod
def send_msg(cls, subject, me... | 2,353 | Python | .py | 55 | 33 | 74 | 0.618214 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,855 | ws.py | jumpserver_jumpserver/apps/notifications/ws.py | import json
from channels.generic.websocket import JsonWebsocketConsumer
from common.db.utils import safe_db_connection
from common.utils import get_logger
from .signal_handlers import new_site_msg_chan
from .site_msg import SiteMessageUtil
logger = get_logger(__name__)
class SiteMsgWebsocket(JsonWebsocketConsumer... | 2,034 | Python | .py | 51 | 31.117647 | 86 | 0.634546 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,856 | notifications.py | jumpserver_jumpserver/apps/notifications/notifications.py | import textwrap
import traceback
from itertools import chain
from celery import shared_task
from django.utils.translation import gettext_lazy as _
from html2text import HTML2Text
from common.utils import lazyproperty
from common.utils.timezone import local_now
from notifications.backends import BACKEND
from settings.... | 9,146 | Python | .py | 253 | 26.407115 | 91 | 0.602834 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,857 | signal_handlers.py | jumpserver_jumpserver/apps/notifications/signal_handlers.py | import inspect
from importlib import import_module
from django.apps import AppConfig
from django.db.models.signals import post_migrate
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils.functional import LazyObject
from common.decorators import on_transaction_commit
... | 2,956 | Python | .py | 73 | 32.739726 | 115 | 0.680799 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,858 | notification.py | jumpserver_jumpserver/apps/notifications/models/notification.py | from django.db import models
from django.utils.translation import gettext_lazy as _
from common.db.models import JMSBaseModel, CASCADE_SIGNAL_SKIP
__all__ = ('SystemMsgSubscription', 'UserMsgSubscription')
class UserMsgSubscription(JMSBaseModel):
user = models.OneToOneField(
'users.User', related_name='... | 2,366 | Python | .py | 53 | 34.867925 | 95 | 0.650635 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,859 | site_msg.py | jumpserver_jumpserver/apps/notifications/models/site_msg.py | from django.db import models
from common.db.models import JMSBaseModel
__all__ = ('SiteMessage', 'MessageContent')
class SiteMessage(JMSBaseModel):
content = models.ForeignKey('notifications.MessageContent', on_delete=models.CASCADE,
db_constraint=False, related_name='messages')
... | 1,126 | Python | .py | 26 | 37.115385 | 96 | 0.707228 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,860 | 0001_initial.py | jumpserver_jumpserver/apps/notifications/migrations/0001_initial.py | # Generated by Django 4.1.13 on 2024-05-09 03:16
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='MessageContent',
fields=[
('cr... | 3,753 | Python | .py | 69 | 41.188406 | 115 | 0.582926 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,861 | 0002_auto_20210909_1946.py | jumpserver_jumpserver/apps/notifications/migrations/0002_auto_20210909_1946.py | # Generated by Django 4.1.13 on 2024-05-09 03:16
import common.db.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
def init_user_msg_subscription(apps, schema_editor):
User = apps.get_model('users', 'User')
UserMsgSubscription = apps.get_model(... | 2,897 | Python | .py | 65 | 35.538462 | 193 | 0.658753 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,862 | api_urls.py | jumpserver_jumpserver/apps/notifications/urls/api_urls.py | from django.conf import settings
from django.urls import path
from rest_framework_bulk.routes import BulkRouter
from notifications import api
app_name = 'notifications'
router = BulkRouter()
router.register('system-msg-subscription', api.SystemMsgSubscriptionViewSet, 'system-msg-subscription')
router.register('user-... | 710 | Python | .py | 17 | 39.294118 | 103 | 0.78343 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,863 | ws_urls.py | jumpserver_jumpserver/apps/notifications/urls/ws_urls.py | from django.urls import path
from .. import ws
app_name = 'notifications'
urlpatterns = [
path('ws/notifications/site-msg/', ws.SiteMsgWebsocket.as_asgi(), name='site-msg-ws'),
]
| 186 | Python | .py | 6 | 28.833333 | 90 | 0.734463 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,864 | site_msgs.py | jumpserver_jumpserver/apps/notifications/api/site_msgs.py | from rest_framework.decorators import action
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin
from rest_framework.response import Response
from common.api import JMSGenericViewSet
from common.const.http import GET, PATCH, POST
from common.permissions import IsValidUser
from common.utils.http import... | 2,359 | Python | .py | 53 | 38.113208 | 88 | 0.697735 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,865 | notifications.py | jumpserver_jumpserver/apps/notifications/api/notifications.py | from rest_framework.mixins import ListModelMixin, UpdateModelMixin, RetrieveModelMixin
from rest_framework.response import Response
from rest_framework.views import APIView
from common.api import JMSGenericViewSet
from common.permissions import IsValidUser
from notifications.backends import BACKEND
from notifications.... | 4,201 | Python | .py | 109 | 29.119266 | 86 | 0.630784 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,866 | slack.py | jumpserver_jumpserver/apps/notifications/backends/slack.py | from django.conf import settings
from common.sdk.im.slack import Slack as Client
from .base import BackendBase
class Slack(BackendBase):
account_field = 'slack_id'
is_enable_field_in_settings = 'AUTH_SLACK'
def __init__(self):
self.client = Client(
bot_token=settings.SLACK_BOT_TOKEN,... | 556 | Python | .py | 16 | 28.3125 | 55 | 0.666041 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,867 | feishu.py | jumpserver_jumpserver/apps/notifications/backends/feishu.py | from django.conf import settings
from common.sdk.im.feishu import FeiShu as Client
from .base import BackendBase
class FeiShu(BackendBase):
account_field = 'feishu_id'
is_enable_field_in_settings = 'AUTH_FEISHU'
def __init__(self):
self.client = Client(
app_id=settings.FEISHU_APP_ID,... | 607 | Python | .py | 17 | 28.882353 | 55 | 0.665523 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,868 | dingtalk.py | jumpserver_jumpserver/apps/notifications/backends/dingtalk.py | from django.conf import settings
from common.sdk.im.dingtalk import DingTalk as Client
from .base import BackendBase
class DingTalk(BackendBase):
account_field = 'dingtalk_id'
is_enable_field_in_settings = 'AUTH_DINGTALK'
def __init__(self):
self.dingtalk = Client(
appid=settings.DING... | 683 | Python | .py | 18 | 30.833333 | 70 | 0.682853 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,869 | wecom.py | jumpserver_jumpserver/apps/notifications/backends/wecom.py | from django.conf import settings
from common.sdk.im.wecom import WeCom as Client
from .base import BackendBase
class WeCom(BackendBase):
account_field = 'wecom_id'
is_enable_field_in_settings = 'AUTH_WECOM'
def __init__(self):
self.wecom = Client(
corpid=settings.WECOM_CORPID,
... | 652 | Python | .py | 18 | 29.055556 | 69 | 0.665072 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,870 | site_msg.py | jumpserver_jumpserver/apps/notifications/backends/site_msg.py | from notifications.site_msg import SiteMessageUtil as Client
from .base import BackendBase
class SiteMessage(BackendBase):
account_field = 'id'
def send_msg(self, users, message, subject):
accounts, __, __ = self.get_accounts(users)
Client.send_msg(subject, message, user_ids=accounts)
@c... | 399 | Python | .py | 11 | 31.090909 | 60 | 0.719895 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,871 | __init__.py | jumpserver_jumpserver/apps/notifications/backends/__init__.py | import importlib
from django.db import models
from django.utils.translation import gettext_lazy as _
client_name_mapper = {}
class BACKEND(models.TextChoices):
EMAIL = 'email', _('Email')
WECOM = 'wecom', _('WeCom')
DINGTALK = 'dingtalk', _('DingTalk')
SITE_MSG = 'site_msg', _('Site message')
FE... | 947 | Python | .py | 28 | 28.571429 | 67 | 0.643172 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,872 | base.py | jumpserver_jumpserver/apps/notifications/backends/base.py | from django.conf import settings
class BackendBase:
# User 表中的字段
account_field = None
# Django setting 中的字段名
is_enable_field_in_settings = None
def get_accounts(self, users):
accounts = []
unbound_users = []
account_user_mapper = {}
for user in users:
... | 865 | Python | .py | 25 | 25.16 | 67 | 0.619926 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,873 | sms.py | jumpserver_jumpserver/apps/notifications/backends/sms.py | from common.sdk.sms.endpoint import SMS
from .base import BackendBase
class SMS(BackendBase):
account_field = 'phone'
is_enable_field_in_settings = 'SMS_ENABLED'
def __init__(self):
self.client = SMS()
def send_msg(self, users, sign_name: str, template_code: str, template_param: dict):
... | 515 | Python | .py | 13 | 33.538462 | 88 | 0.673387 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,874 | email.py | jumpserver_jumpserver/apps/notifications/backends/email.py | from common.tasks import send_mail_async
from .base import BackendBase
class Email(BackendBase):
account_field = 'email'
is_enable_field_in_settings = 'EMAIL_HOST_USER'
def send_msg(self, users, message, subject):
accounts, __, __ = self.get_accounts(users)
if not accounts:
re... | 417 | Python | .py | 11 | 32.090909 | 73 | 0.693267 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,875 | lark.py | jumpserver_jumpserver/apps/notifications/backends/lark.py | from django.conf import settings
from common.sdk.im.lark import Lark as Client
from .base import BackendBase
class Lark(BackendBase):
account_field = 'lark_id'
is_enable_field_in_settings = 'AUTH_LARK'
def __init__(self):
self.client = Client(
app_id=settings.LARK_APP_ID,
... | 622 | Python | .py | 18 | 27.611111 | 55 | 0.649916 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,876 | site_msgs.py | jumpserver_jumpserver/apps/notifications/serializers/site_msgs.py | from rest_framework import serializers
from rest_framework.serializers import ModelSerializer
from common.utils import convert_html_to_markdown
from ..models import MessageContent
class SenderMixin(ModelSerializer):
sender = serializers.SerializerMethodField()
def get_sender(self, site_msg):
sender ... | 1,601 | Python | .py | 40 | 33.25 | 84 | 0.712807 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,877 | notifications.py | jumpserver_jumpserver/apps/notifications/serializers/notifications.py | from rest_framework import serializers
from common.serializers import BulkModelSerializer
from notifications.models import SystemMsgSubscription, UserMsgSubscription
class SystemMsgSubscriptionSerializer(BulkModelSerializer):
receive_backends = serializers.ListField(child=serializers.CharField())
class Meta... | 1,398 | Python | .py | 31 | 37.580645 | 92 | 0.703021 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,878 | filters.py | jumpserver_jumpserver/apps/perms/filters.py | from django.db.models import QuerySet, Q
from django_filters import rest_framework as filters
from assets.models import Node, Asset
from common.drf.filters import BaseFilterSet
from common.utils import get_object_or_none
from perms.models import AssetPermission, AssetPermissionQuerySet
from users.models import User, U... | 7,794 | Python | .py | 175 | 34.765714 | 119 | 0.618457 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,879 | pagination.py | jumpserver_jumpserver/apps/perms/pagination.py | from django.conf import settings
from rest_framework.request import Request
from assets.pagination import AssetPaginationBase
from perms.models import UserAssetGrantedTreeNodeRelation
from common.utils import get_logger
logger = get_logger(__name__)
class GrantedAssetPaginationBase(AssetPaginationBase):
_user: ... | 1,616 | Python | .py | 34 | 39.029412 | 97 | 0.679389 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,880 | hands.py | jumpserver_jumpserver/apps/perms/hands.py | # ~*~ coding: utf-8 ~*~
#
from users.models import User, UserGroup
from assets.models import Asset, Node, Label, FavoriteAsset
from assets.serializers import NodeSerializer
__all__ = [
'User', 'UserGroup',
'Asset', 'Node', 'Label', 'FavoriteAsset',
'NodeSerializer',
]
| 283 | Python | .py | 10 | 25.9 | 59 | 0.704797 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,881 | tasks.py | jumpserver_jumpserver/apps/perms/tasks.py | # ~*~ coding: utf-8 ~*~
from __future__ import absolute_import, unicode_literals
from collections import defaultdict
from datetime import timedelta
from celery import shared_task
from django.conf import settings
from django.db.transaction import atomic
from django.utils.translation import gettext_lazy as _
from comm... | 3,953 | Python | .py | 85 | 39.576471 | 100 | 0.713528 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,882 | const.py | jumpserver_jumpserver/apps/perms/const.py | # -*- coding: utf-8 -*-
#
from django.utils.translation import gettext_lazy as _
from common.db.fields import BitChoices
from common.utils.integer import bit
__all__ = ["ActionChoices"]
class ActionChoices(BitChoices):
connect = bit(1), _("Connect (All protocols)")
upload = bit(2), _("Upload (RDP, SFTP)")
... | 1,385 | Python | .py | 40 | 28.45 | 83 | 0.613193 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,883 | apps.py | jumpserver_jumpserver/apps/perms/apps.py | from __future__ import unicode_literals
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class PermsConfig(AppConfig):
name = 'perms'
verbose_name = _('App Permissions')
def ready(self):
from . import signal_handlers # noqa
from . import tasks # ... | 393 | Python | .py | 11 | 30.363636 | 54 | 0.687831 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,884 | notifications.py | jumpserver_jumpserver/apps/perms/notifications.py | from django.template.loader import render_to_string
from django.utils.translation import gettext as _
from common.utils import reverse as js_reverse
from notifications.notifications import UserMessage
class PermedAssetsWillExpireUserMsg(UserMessage):
def __init__(self, user, assets, day_count=0):
super()... | 2,775 | Python | .py | 69 | 30.985507 | 86 | 0.59614 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,885 | locks.py | jumpserver_jumpserver/apps/perms/locks.py | from common.utils.lock import DistributedLock
class UserGrantedTreeRebuildLock(DistributedLock):
name_template = 'perms.user.asset.node.tree.rebuild.<user_id:{user_id}>'
def __init__(self, user_id):
name = self.name_template.format(user_id=user_id)
super().__init__(name=name, release_on_trans... | 340 | Python | .py | 6 | 51.166667 | 76 | 0.728097 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,886 | __init__.py | jumpserver_jumpserver/apps/perms/models/__init__.py | # coding: utf-8
#
from .asset_permission import *
from .perm_node import *
| 76 | Python | .py | 4 | 17.75 | 31 | 0.746479 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,887 | perm_node.py | jumpserver_jumpserver/apps/perms/models/perm_node.py | from django.db import models
from django.db.models import F, TextChoices
from django.utils.translation import gettext_lazy as _
from accounts.models import Account
from assets.models import Asset, Node, FamilyMixin
from common.utils import lazyproperty
from orgs.mixins.models import JMSOrgBaseModel
class NodeFrom(Te... | 4,400 | Python | .py | 116 | 28.887931 | 95 | 0.640598 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,888 | asset_permission.py | jumpserver_jumpserver/apps/perms/models/asset_permission.py | import logging
from django.db import models
from django.db.models import Q
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from accounts.const import AliasAccount
from accounts.models import Account
from assets.models import Asset
from common.utils import date_expired_default,... | 6,797 | Python | .py | 156 | 36.025641 | 104 | 0.665085 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,889 | 0001_initial.py | jumpserver_jumpserver/apps/perms/migrations/0001_initial.py | # Generated by Django 4.1.13 on 2024-05-09 03:16
import assets.models.node
import common.utils.django
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import perms.models.asset_permission
import uuid
class Migration(migrations.Migration):
initial = True
... | 5,129 | Python | .py | 98 | 39.520408 | 192 | 0.572736 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,890 | 0002_auto_20171228_0025.py | jumpserver_jumpserver/apps/perms/migrations/0002_auto_20171228_0025.py | # Generated by Django 4.1.13 on 2024-05-09 03:16
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('assets', '0002_auto_20180105_1807'),
migrations.swappable_depe... | 1,815 | Python | .py | 43 | 32.883721 | 133 | 0.630238 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,891 | permission.py | jumpserver_jumpserver/apps/perms/utils/permission.py | from django.db.models import QuerySet
from assets.models import Node, Asset
from common.utils import get_logger, timeit
from perms.models import AssetPermission
logger = get_logger(__file__)
__all__ = ['AssetPermissionUtil']
class AssetPermissionUtil(object):
""" 资产授权相关的方法工具 """
@timeit
def get_permis... | 4,614 | Python | .py | 96 | 37.802083 | 94 | 0.640393 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,892 | __init__.py | jumpserver_jumpserver/apps/perms/utils/__init__.py | from .asset_perm import *
from .permission import *
from .user_perm import *
from .user_perm_tree import *
| 107 | Python | .py | 4 | 25.75 | 29 | 0.76699 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,893 | user_perm.py | jumpserver_jumpserver/apps/perms/utils/user_perm.py | import json
import re
from django.conf import settings
from django.core.cache import cache
from django.db.models import Q
from rest_framework.utils.encoders import JSONEncoder
from assets.const import AllTypes
from assets.models import FavoriteAsset, Asset, Node
from common.utils.common import timeit, get_logger
from... | 11,368 | Python | .py | 244 | 35.159836 | 99 | 0.626193 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,894 | asset_perm.py | jumpserver_jumpserver/apps/perms/utils/asset_perm.py | from collections import defaultdict
from accounts.const import AliasAccount
from accounts.models import VirtualAccount
from assets.models import Asset, MyAsset
from common.utils import lazyproperty
from orgs.utils import tmp_to_org, tmp_to_root_org
from .permission import AssetPermissionUtil
from perms.const import Ac... | 6,531 | Python | .py | 138 | 36.210145 | 109 | 0.647725 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,895 | user_perm_tree.py | jumpserver_jumpserver/apps/perms/utils/user_perm_tree.py | import time
from collections import defaultdict
from django.conf import settings
from django.core.cache import cache
from django.db import transaction
from django.db.models import F
from assets.models import Asset
from assets.utils import NodeAssetsUtil
from common.decorators import merge_delay_run
from common.decora... | 15,630 | Python | .py | 351 | 34.333333 | 106 | 0.628626 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,896 | api_urls.py | jumpserver_jumpserver/apps/perms/urls/api_urls.py | # coding:utf-8
from .asset_permission import asset_permission_urlpatterns
from .user_permission import user_permission_urlpatterns
app_name = 'perms'
urlpatterns = asset_permission_urlpatterns + user_permission_urlpatterns
| 226 | Python | .py | 5 | 43.6 | 72 | 0.844037 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,897 | user_permission.py | jumpserver_jumpserver/apps/perms/urls/user_permission.py | from django.urls import path, include
from .. import api
user_permission_urlpatterns = [
# <str:user> such as: my | self | user.id
# assets
path('<str:user>/assets/<uuid:pk>/', api.UserPermedAssetRetrieveApi.as_view(),
name='user-permed-asset'),
path('<str:user>/assets/', api.UserAllPermedAss... | 3,023 | Python | .py | 60 | 43 | 95 | 0.683575 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,898 | asset_permission.py | jumpserver_jumpserver/apps/perms/urls/asset_permission.py | # coding:utf-8
from django.urls import path, include
from rest_framework_bulk.routes import BulkRouter
from .. import api
router = BulkRouter()
router.register('asset-permissions', api.AssetPermissionViewSet, 'asset-permission')
router.register('asset-permissions-users-relations', api.AssetPermissionUserRelationView... | 1,401 | Python | .py | 25 | 50.48 | 116 | 0.77037 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,899 | __init__.py | jumpserver_jumpserver/apps/perms/api/__init__.py | # -*- coding: utf-8 -*-
#
from .user_permission import *
from .asset_permission import *
from .asset_permission_relation import *
from .user_group_permission import *
| 168 | Python | .py | 6 | 26.833333 | 40 | 0.751553 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |