mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-12-16 09:02:49 +00:00
Compare commits
29 Commits
pr@v5@mcp
...
v3.10.9-lt
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfb6cc990b | ||
|
|
4f287925f3 | ||
|
|
422478f9fb | ||
|
|
a748a5f421 | ||
|
|
6f89fa245c | ||
|
|
31c5d9e717 | ||
|
|
a3a907e9bb | ||
|
|
361b367e30 | ||
|
|
08bd628589 | ||
|
|
67277dd622 | ||
|
|
82e7f020ea | ||
|
|
f20b9e01ab | ||
|
|
8cf8a3701b | ||
|
|
7ba24293d1 | ||
|
|
f10114c9ed | ||
|
|
cf31cbfb07 | ||
|
|
0edad24d5d | ||
|
|
1f1c1a9157 | ||
|
|
6c9d271ae1 | ||
|
|
6ff852e225 | ||
|
|
baa75dc735 | ||
|
|
8a9f0436b8 | ||
|
|
a9620a3cbe | ||
|
|
769e7dc8a0 | ||
|
|
2a70449411 | ||
|
|
8df720f19e | ||
|
|
dabbb45f6e | ||
|
|
ce24c1c3fd | ||
|
|
3c54c82ce9 |
@@ -87,6 +87,7 @@ ARG TOOLS=" \
|
|||||||
default-mysql-client \
|
default-mysql-client \
|
||||||
iputils-ping \
|
iputils-ping \
|
||||||
locales \
|
locales \
|
||||||
|
netcat-openbsd \
|
||||||
nmap \
|
nmap \
|
||||||
openssh-client \
|
openssh-client \
|
||||||
patch \
|
patch \
|
||||||
|
|||||||
@@ -22,6 +22,36 @@ class WebSpecSerializer(serializers.ModelSerializer):
|
|||||||
'submit_selector', 'script'
|
'submit_selector', 'script'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_fields(self):
|
||||||
|
fields = super().get_fields()
|
||||||
|
if self.is_retrieve():
|
||||||
|
# 查看 Web 资产详情时
|
||||||
|
self.pop_fields_if_need(fields)
|
||||||
|
return fields
|
||||||
|
|
||||||
|
def is_retrieve(self):
|
||||||
|
try:
|
||||||
|
self.context.get('request').method and self.parent.instance.web
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def pop_fields_if_need(self, fields):
|
||||||
|
fields_script = ['script']
|
||||||
|
fields_basic = ['username_selector', 'password_selector', 'submit_selector']
|
||||||
|
autofill = self.parent.instance.web.autofill
|
||||||
|
pop_fields_mapper = {
|
||||||
|
FillType.no: fields_script + fields_basic,
|
||||||
|
FillType.basic: fields_script,
|
||||||
|
FillType.script: fields_basic,
|
||||||
|
}
|
||||||
|
fields_pop = pop_fields_mapper.get(autofill, [])
|
||||||
|
for f in fields_pop:
|
||||||
|
fields.pop(f, None)
|
||||||
|
return fields
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
category_spec_serializer_map = {
|
category_spec_serializer_map = {
|
||||||
'database': DatabaseSpecSerializer,
|
'database': DatabaseSpecSerializer,
|
||||||
|
|||||||
@@ -50,7 +50,10 @@ class MFASendCodeApi(AuthMixin, CreateAPIView):
|
|||||||
mfa_type = serializer.validated_data['type']
|
mfa_type = serializer.validated_data['type']
|
||||||
|
|
||||||
if not username:
|
if not username:
|
||||||
user = self.get_user_from_session()
|
try:
|
||||||
|
user = self.get_user_from_session()
|
||||||
|
except errors.SessionEmptyError as e:
|
||||||
|
raise ValidationError({'error': e})
|
||||||
else:
|
else:
|
||||||
user = self.get_user_from_db(username)
|
user = self.get_user_from_db(username)
|
||||||
|
|
||||||
|
|||||||
@@ -617,9 +617,9 @@ class Config(dict):
|
|||||||
'TICKET_APPLY_ASSET_SCOPE': 'all',
|
'TICKET_APPLY_ASSET_SCOPE': 'all',
|
||||||
|
|
||||||
# Ansible Receptor
|
# Ansible Receptor
|
||||||
'ANSIBLE_RECEPTOR_ENABLED': True,
|
'RECEPTOR_ENABLED': False,
|
||||||
'ANSIBLE_RECEPTOR_GATEWAY_PROXY_HOST': 'jms_celery',
|
'ANSIBLE_RECEPTOR_GATEWAY_PROXY_HOST': 'jms_celery',
|
||||||
'ANSIBLE_RECEPTOR_TCP_LISTEN_ADDRESS': 'jms_receptor:7521'
|
'ANSIBLE_RECEPTOR_TCP_LISTEN_ADDRESS': 'receptor:7521'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -232,6 +232,6 @@ FILE_UPLOAD_SIZE_LIMIT_MB = CONFIG.FILE_UPLOAD_SIZE_LIMIT_MB
|
|||||||
TICKET_APPLY_ASSET_SCOPE = CONFIG.TICKET_APPLY_ASSET_SCOPE
|
TICKET_APPLY_ASSET_SCOPE = CONFIG.TICKET_APPLY_ASSET_SCOPE
|
||||||
|
|
||||||
# Ansible Receptor
|
# Ansible Receptor
|
||||||
ANSIBLE_RECEPTOR_ENABLED = CONFIG.ANSIBLE_RECEPTOR_ENABLED
|
RECEPTOR_ENABLED = CONFIG.RECEPTOR_ENABLED
|
||||||
ANSIBLE_RECEPTOR_GATEWAY_PROXY_HOST = CONFIG.ANSIBLE_RECEPTOR_GATEWAY_PROXY_HOST
|
ANSIBLE_RECEPTOR_GATEWAY_PROXY_HOST = CONFIG.ANSIBLE_RECEPTOR_GATEWAY_PROXY_HOST
|
||||||
ANSIBLE_RECEPTOR_TCP_LISTEN_ADDRESS = CONFIG.ANSIBLE_RECEPTOR_TCP_LISTEN_ADDRESS
|
ANSIBLE_RECEPTOR_TCP_LISTEN_ADDRESS = CONFIG.ANSIBLE_RECEPTOR_TCP_LISTEN_ADDRESS
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class _LazyRunnerInterface(LazyObject):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def make_interface():
|
def make_interface():
|
||||||
runner_type = AnsibleReceptorRunner \
|
runner_type = AnsibleReceptorRunner \
|
||||||
if settings.ANSIBLE_RECEPTOR_ENABLED else AnsibleNativeRunner
|
if settings.RECEPTOR_ENABLED else AnsibleNativeRunner
|
||||||
gateway_host = settings.ANSIBLE_RECEPTOR_GATEWAY_PROXY_HOST \
|
gateway_host = settings.ANSIBLE_RECEPTOR_GATEWAY_PROXY_HOST \
|
||||||
if settings.ANSIBLE_RECEPTOR_GATEWAY_PROXY_HOST else '127.0.0.1'
|
if settings.ANSIBLE_RECEPTOR_GATEWAY_PROXY_HOST else '127.0.0.1'
|
||||||
return RunnerInterface(runner_type=runner_type, gateway_proxy_host=gateway_host)
|
return RunnerInterface(runner_type=runner_type, gateway_proxy_host=gateway_host)
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ __all__ = ['AdHocRunner', 'PlaybookRunner', 'SuperPlaybookRunner', 'UploadFileRu
|
|||||||
|
|
||||||
class AdHocRunner:
|
class AdHocRunner:
|
||||||
cmd_modules_choices = ('shell', 'raw', 'command', 'script', 'win_shell')
|
cmd_modules_choices = ('shell', 'raw', 'command', 'script', 'win_shell')
|
||||||
|
need_local_connection_modules_choices = ("mysql", "postgresql", "sqlserver", "huawei")
|
||||||
|
|
||||||
def __init__(self, inventory, module, module_args='', pattern='*', project_dir='/tmp/', extra_vars=None,
|
def __init__(self, inventory, job_module, module, module_args='', pattern='*', project_dir='/tmp/',
|
||||||
|
extra_vars=None,
|
||||||
dry_run=False, timeout=-1):
|
dry_run=False, timeout=-1):
|
||||||
if extra_vars is None:
|
if extra_vars is None:
|
||||||
extra_vars = {}
|
extra_vars = {}
|
||||||
@@ -23,6 +25,7 @@ class AdHocRunner:
|
|||||||
self.inventory = inventory
|
self.inventory = inventory
|
||||||
self.pattern = pattern
|
self.pattern = pattern
|
||||||
self.module = module
|
self.module = module
|
||||||
|
self.job_module = job_module
|
||||||
self.module_args = module_args
|
self.module_args = module_args
|
||||||
self.project_dir = project_dir
|
self.project_dir = project_dir
|
||||||
self.cb = DefaultCallback()
|
self.cb = DefaultCallback()
|
||||||
@@ -30,8 +33,7 @@ class AdHocRunner:
|
|||||||
self.extra_vars = extra_vars
|
self.extra_vars = extra_vars
|
||||||
self.dry_run = dry_run
|
self.dry_run = dry_run
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
# enable local connection
|
self.envs = {}
|
||||||
self.extra_vars.update({"LOCAL_CONNECTION_ENABLED": "1"})
|
|
||||||
|
|
||||||
def check_module(self):
|
def check_module(self):
|
||||||
if self.module not in self.cmd_modules_choices:
|
if self.module not in self.cmd_modules_choices:
|
||||||
@@ -40,8 +42,13 @@ class AdHocRunner:
|
|||||||
raise CommandInBlackListException(
|
raise CommandInBlackListException(
|
||||||
"Command is rejected by black list: {}".format(self.module_args.split()[0]))
|
"Command is rejected by black list: {}".format(self.module_args.split()[0]))
|
||||||
|
|
||||||
|
def set_local_connection(self):
|
||||||
|
if self.job_module in self.need_local_connection_modules_choices:
|
||||||
|
self.envs.update({"LOCAL_CONNECTION_ENABLED": "1"})
|
||||||
|
|
||||||
def run(self, verbosity=0, **kwargs):
|
def run(self, verbosity=0, **kwargs):
|
||||||
self.check_module()
|
self.check_module()
|
||||||
|
self.set_local_connection()
|
||||||
verbosity = get_ansible_log_verbosity(verbosity)
|
verbosity = get_ansible_log_verbosity(verbosity)
|
||||||
|
|
||||||
if not os.path.exists(self.project_dir):
|
if not os.path.exists(self.project_dir):
|
||||||
@@ -53,6 +60,7 @@ class AdHocRunner:
|
|||||||
interface.run(
|
interface.run(
|
||||||
timeout=self.timeout if self.timeout > 0 else None,
|
timeout=self.timeout if self.timeout > 0 else None,
|
||||||
extravars=self.extra_vars,
|
extravars=self.extra_vars,
|
||||||
|
envvars=self.envs,
|
||||||
host_pattern=self.pattern,
|
host_pattern=self.pattern,
|
||||||
private_data_dir=self.project_dir,
|
private_data_dir=self.project_dir,
|
||||||
inventory=self.inventory,
|
inventory=self.inventory,
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class JMSPermedInventory(JMSInventory):
|
|||||||
|
|
||||||
protocol_supported_modules_mapping = {
|
protocol_supported_modules_mapping = {
|
||||||
'mysql': ['mysql'],
|
'mysql': ['mysql'],
|
||||||
|
'mariadb': ['mysql'],
|
||||||
'postgresql': ['postgresql'],
|
'postgresql': ['postgresql'],
|
||||||
'sqlserver': ['sqlserver'],
|
'sqlserver': ['sqlserver'],
|
||||||
'ssh': ['shell', 'python', 'win_shell', 'raw', 'huawei'],
|
'ssh': ['shell', 'python', 'win_shell', 'raw', 'huawei'],
|
||||||
@@ -77,7 +78,7 @@ class JMSPermedInventory(JMSInventory):
|
|||||||
host['error'] = "Module {} is not suitable for this asset".format(self.module)
|
host['error'] = "Module {} is not suitable for this asset".format(self.module)
|
||||||
return host
|
return host
|
||||||
|
|
||||||
if protocol.name in ('mysql', 'postgresql', 'sqlserver'):
|
if protocol.name in ('mariadb', 'mysql', 'postgresql', 'sqlserver'):
|
||||||
host['login_host'] = asset.address
|
host['login_host'] = asset.address
|
||||||
host['login_port'] = protocol.port
|
host['login_port'] = protocol.port
|
||||||
host['login_user'] = account.username
|
host['login_user'] = account.username
|
||||||
@@ -333,6 +334,7 @@ class JobExecution(JMSOrgBaseModel):
|
|||||||
|
|
||||||
runner = AdHocRunner(
|
runner = AdHocRunner(
|
||||||
self.inventory_path,
|
self.inventory_path,
|
||||||
|
self.job.module,
|
||||||
module,
|
module,
|
||||||
timeout=self.current_job.timeout,
|
timeout=self.current_job.timeout,
|
||||||
module_args=args,
|
module_args=args,
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ def import_ldap_user_periodic():
|
|||||||
if not settings.AUTH_LDAP:
|
if not settings.AUTH_LDAP:
|
||||||
return
|
return
|
||||||
task_name = 'import_ldap_user_periodic'
|
task_name = 'import_ldap_user_periodic'
|
||||||
disable_celery_periodic_task(task_name)
|
|
||||||
if not settings.AUTH_LDAP_SYNC_IS_PERIODIC:
|
if not settings.AUTH_LDAP_SYNC_IS_PERIODIC:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@
|
|||||||
|
|
||||||
function onError (responseText, responseJson, status) {
|
function onError (responseText, responseJson, status) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
toastr.error(responseJson.detail);
|
toastr.error(responseJson.detail || responseJson.error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
1
receptor
1
receptor
@@ -75,7 +75,6 @@ class ReceptorService:
|
|||||||
print("\n- PID file is corrupted, starting Receptor...")
|
print("\n- PID file is corrupted, starting Receptor...")
|
||||||
os.remove(self.pid_file)
|
os.remove(self.pid_file)
|
||||||
|
|
||||||
os.environ.update({'LOCAL_CONNECTION_ENABLED': '1'})
|
|
||||||
os.environ.setdefault('ANSIBLE_LIBRARY', DEFAULT_ANSIBLE_MODULES_DIR)
|
os.environ.setdefault('ANSIBLE_LIBRARY', DEFAULT_ANSIBLE_MODULES_DIR)
|
||||||
os.environ.update({'PYTHONPATH': APPS_DIR})
|
os.environ.update({'PYTHONPATH': APPS_DIR})
|
||||||
process = subprocess.Popen(self.receptor_command)
|
process = subprocess.Popen(self.receptor_command)
|
||||||
|
|||||||
Reference in New Issue
Block a user