Compare commits

...

478 Commits

Author SHA1 Message Date
Eric
66099b9e5d perf: modify url 2024-05-21 15:17:21 +08:00
Eric
eaa052a380 perf: 添加加密配置API 2024-05-21 15:17:21 +08:00
wangruidong
606d2c8933 fix: 关闭ssh client后,sftp,telnet不显示客户端连接方式 2024-05-20 10:02:12 +08:00
feng
a534c496d0 perf: core celery always active 2024-05-16 15:52:11 +08:00
wangruidong
a11097fb5a fix: 定时任务,再次执行报错 2024-05-16 15:48:45 +08:00
feng
d4c1f93ef6 fix: send slack message failed 2024-05-16 15:23:31 +08:00
fit2bot
9168e92669 perf: update poetry lock (#13229)
Co-authored-by: feng <1304903146@qq.com>
2024-05-16 10:27:29 +08:00
fit2bot
bfd030d70f perf: upgrade jms-storage (#13223)
Co-authored-by: feng <1304903146@qq.com>
Co-authored-by: feng626 <57284900+feng626@users.noreply.github.com>
2024-05-15 14:38:26 +08:00
wangruidong
da0c017c4f fix: ldap定时任务未执行 2024-05-15 14:16:33 +08:00
fit2bot
5ffc0a9665 perf: add new dependencies (#13220)
Co-authored-by: feng <1304903146@qq.com>
2024-05-15 10:13:14 +08:00
fit2bot
10e9026ec7 perf: add gpt 4o (#13218)
Co-authored-by: feng <1304903146@qq.com>
2024-05-14 16:29:41 +08:00
Bai
7c4c0b5924 fix: Fixed ACLs Asset connect select attribute assets while both include labels not matched. 2024-05-14 16:16:00 +08:00
wangruidong
42c3008ec9 perf: 更新ldap相关翻译文件 2024-05-14 15:08:37 +08:00
吴小白
2f6d743cf0 perf: 优化 CI 构建测试 2024-05-14 14:17:02 +08:00
fit2bot
e8faaeb8fb fix: Accounts of ssh key type will no longer export fingerprints. (#13215)
Co-authored-by: feng <1304903146@qq.com>
2024-05-14 13:04:11 +08:00
feng
0ea675f8d6 fix: windows gather account failed 2024-05-13 18:23:40 +08:00
halo
77caa5536f fix: chrome应用加载多个插件不生效问题 2024-05-13 16:30:17 +08:00
fit2bot
52c905832b fix: 账号密钥长度为8192时 刷新账号列表504 (#13196)
Co-authored-by: feng <1304903146@qq.com>
2024-05-11 14:45:29 +08:00
Bai
94ee3169dc perf: While Asset amount (GLOBAL) > 5000 delay (20s) refresh user perm tree 2024-05-10 12:38:31 +08:00
fit2bot
92b6286feb fix: ldap更换OU后无法登录 (#13172)
* fix: ldap更换OU后无法登录

* perf: 翻译

---------

Co-authored-by: wangruidong <940853815@qq.com>
2024-05-08 14:23:20 +08:00
Bai
bce776bb63 fix: 修复 v2 升级到 v3 授权的手动登录系统用户显示空字符串的问题 2024-05-07 14:33:01 +08:00
wangruidong
dc39cbf037 fix: ldap定时任务未执行 2024-05-07 10:27:44 +08:00
Bai
38175d6b57 fix: Fixed csv file export for 0 chars is not appear 2024-04-28 17:56:45 +08:00
wangruidong
7408ed0f03 perf: add XPACKModelFieldsMixin 2024-04-28 15:58:14 +08:00
wangruidong
5135186961 perf: 社区版去掉一些东西 2024-04-28 15:58:14 +08:00
wangruidong
5be399616b fix: 华为交换机执行某些命令报错 2024-04-28 14:17:38 +08:00
wangruidong
46a23afbec perf: 创建、更新用户时MFA选项根据系统设置选项进行动态渲染 2024-04-26 11:35:56 +08:00
Bai
8c4add241d perf: Support django shell run orm output SQL 2024-04-26 10:39:49 +08:00
Bai
feee92daee fix: Fixed issue of v2 to v3 Account missing su_from 2024-04-25 19:13:34 +08:00
Bai
42054c7989 feat: Support asset tree node drag to another one 2024-04-24 18:05:51 +08:00
Aaron3S
9b20b67039 fix: 修复执行快捷命令时 local_connection 没有被正确设置 2024-04-23 19:07:22 +08:00
Bai
2acc84dc69 fix: Adhoc support mariadb with module of mysql 2024-04-23 18:57:08 +08:00
吴小白
3383d0f314 perf: 镜像添加 nc 命令 2024-04-23 16:53:25 +08:00
Bai
c9858b5a84 fix: 修改配置 RECEPTOR_ENABLED=False 默认 2024-04-23 16:52:44 +08:00
Bai
25e21b185f fix: 修改配置 RECEPTOR_ENABLED 2024-04-23 15:03:04 +08:00
Aaron3S
720231f692 feat: 修改 receptor 容器通信地址 2024-04-23 13:12:18 +08:00
jiangweidong
95f29a584e perf: 优化会话过期500问题 2024-04-23 13:11:41 +08:00
Bai
50cbb75b96 perf: 优化 Web 资产详情时根据 autofill 类型返回对应的 spec_info 信息 2024-04-23 13:09:40 +08:00
Bai
d418647774 fix: 修复仪表盘会话排序数量都是 1 的问题 2024-04-22 19:37:45 +08:00
Bai
6b5d4a4810 fix: 修复仪表盘会话排序数量都是 1 的问题 2024-04-22 19:32:42 +08:00
Eric
2cc67634a4 perf: 发布机支持平台连接参数 2024-04-22 16:40:41 +08:00
fit2bot
52922088a9 feat: 优化代码结构,receptor开关,修改为 tcp 通信 (#13078)
* feat: 优化代码结构,receptor开关,修改为 tcp 通信

* fix: 修改导包路径

* fix: 修复错别字

* fix: 修改导包路径

* perf: 优化代码

* fix: 修复任务不执行的问题

* perf: 优化配置项名称

* perf: 优化代码结构

* perf: 优化代码

---------

Co-authored-by: Aaron3S <chenyang@fit2cloud.com>
2024-04-22 13:51:52 +08:00
jiangweidong
ef7329a721 perf: 优化频繁发送短信,将后端的频繁发送警告提示到页面上来提醒用户 2024-04-22 13:20:51 +08:00
Bai
ad0bc82539 perf: 优化 HUAWEI 设备判断逻辑 2024-04-22 13:19:32 +08:00
wangruidong
1ecf8534f6 perf: 兼容自定义平台的华为交换机执行命令 2024-04-22 13:19:32 +08:00
feng
94286caec4 fix: 命令输出取消长度限制 2024-04-22 10:31:35 +08:00
wangruidong
d4c8425218 fix: 快捷命令账号选择未按账号数量排序 2024-04-22 10:31:02 +08:00
fit2bot
59f9a4f369 fix: 获取 k8s 树取消异常 返回空 优化错误日志 (#13077)
Co-authored-by: feng <1304903146@qq.com>
2024-04-19 17:41:41 +08:00
Bai
64125051df fix: Org is None not has id attribute 2024-04-19 17:15:30 +08:00
Bai
660572a0ea fix: merge_delay_run 偶尔会出现 (2006, MySQL server has gone away 的报错) 2024-04-19 17:15:30 +08:00
ibuler
c0273dc698 perf: 去掉 js 报错 2024-04-19 11:21:27 +08:00
Bai
2782d4b5f1 fix: 修复 Celery Execution 任务保存失败导致 View 事务回滚的问题(首次登录用户修改密码失败) 2024-04-18 21:21:09 +08:00
fit2bot
d4f9e30306 perf: translate (#13061)
Co-authored-by: feng <1304903146@qq.com>
2024-04-18 17:28:55 +08:00
Aaron3S
1b221d1cb6 fix: celery kwargs 参数解析问题 2024-04-18 17:06:09 +08:00
halo
fbf42ebbf9 perf: 更新客户端版本 2024-04-18 15:58:50 +08:00
Aaron3S
a0c4eae04c perf: 优化变量名, 防止和翻译方法冲突 2024-04-18 14:31:44 +08:00
Aaron3S
d1c293940a fix: 修复 celery task not found 的问题 2024-04-18 14:31:44 +08:00
Aaron3S
6f2d04a029 fix: 修复自动化任务重包含多个playbook runtime 目录被提前删除的问题 2024-04-18 14:10:34 +08:00
wangruidong
29dbc2e4d4 perf: 用户详情页-资产授权规则字段排序优化 2024-04-18 13:14:16 +08:00
wangruidong
e8d717d174 fix: 资产不存在指定用户的时候,没有用特权用户任务未执行 2024-04-17 20:17:24 +08:00
Aaron3S
138a3a2f46 fix: 修复 receptor_ctl 的并发安全问题 2024-04-17 18:58:20 +08:00
fit2bot
cade2cfa13 fix: 改密推送没有更新版本 (#13044)
Co-authored-by: feng <1304903146@qq.com>
2024-04-17 16:14:40 +08:00
wangruidong
ac988a76b4 fix: 重启服务禁用的定时任务会执行问题 2024-04-17 14:25:10 +08:00
ibuler
5a9815481a perf: 修改 token expire 逻辑 2024-04-17 14:23:56 +08:00
feng
bfbddfdead fix: 【账号改密】任务列表-详情:获取任务记录tab报错 2024-04-17 11:27:18 +08:00
Aaron3S
3cf526fdf3 fix: 修复测试根节点连接性 task 找不到的问题 2024-04-16 19:27:56 +08:00
Aaron3S
f6a4ee54d0 fix: 补充遗漏的网关参数 2024-04-16 19:27:56 +08:00
wangruidong
5755d281d7 perf: ldap测试登录前端不需要先测试连接 2024-04-16 18:13:45 +08:00
Aaron3S
1569524583 fix: 修复调用 ssh_ping 模块测试走网关的资产连接性失败 2024-04-16 17:14:30 +08:00
fit2bot
7ba876eb0a fix: 登录复核 审批后 刷新页面工单没清除 (#13031)
Co-authored-by: feng <1304903146@qq.com>
2024-04-16 14:04:18 +08:00
wangruidong
a31ea77b3c fix: 会话详情中文件传输显示有误 2024-04-16 10:38:05 +08:00
Aaron3S
44445a9482 fix: 修复一些因使用 receptor runner 造成的 bug 2024-04-15 19:42:36 +08:00
Bai
b8449a6efa fix: Export csv file can run program for windows 2024-04-15 19:42:03 +08:00
fit2bot
ccf6b00084 perf: 迁移文件和翻译 (#13024)
Co-authored-by: feng <1304903146@qq.com>
2024-04-15 17:57:47 +08:00
fit2bot
4423f842e0 fix: 历史账号数量计算错误 (#13023)
Co-authored-by: feng <1304903146@qq.com>
2024-04-15 17:17:11 +08:00
fit2bot
7660e3228e fix: 【账号推送】创建账号推送失败 (#13021)
Co-authored-by: feng <1304903146@qq.com>
2024-04-15 14:48:58 +08:00
wangruidong
482f5613e4 fix: 会话详情中文件传输显示有误 2024-04-15 14:42:18 +08:00
Bai
3cfb46f798 fix: Update jms-storage version 0.0.57 2024-04-15 14:34:58 +08:00
fit2bot
f0d1279a42 perf: 修改user session 权限判断 (#13019)
Co-authored-by: feng <1304903146@qq.com>
2024-04-15 11:26:22 +08:00
halo
140118c9c6 perf: 更新copyright年份 2024-04-15 10:33:45 +08:00
wangruidong
637b9b1b15 perf: 申请工单-指定账号信息优化 2024-04-12 13:26:23 +08:00
Aaron3S
969069dde0 feat: receptor 中添加环境变量 2024-04-12 13:24:54 +08:00
Jiangweidong
84a71c8b3a perf: 火山引擎翻译 2024-04-12 13:24:32 +08:00
fit2bot
f3bd727c32 perf: 改密失败发给收件人 (#13009)
Co-authored-by: feng <1304903146@qq.com>
2024-04-12 11:53:47 +08:00
Aaron3S
2ac87e4ad6 feat: 修改重复的删除目录的逻辑 2024-04-12 11:35:51 +08:00
fit2bot
3740a4ad6f fix: 开启仅一台设置登录 退出失败 (#13007)
Co-authored-by: feng <1304903146@qq.com>
2024-04-12 11:16:58 +08:00
fit2bot
3bc8db7c3d fix: 改密任务记录搜索失败 (#13006)
Co-authored-by: feng <1304903146@qq.com>
2024-04-12 11:02:47 +08:00
fit2bot
f3d19ad9f4 fix: 【Lark】绑定时,一些报错信息优化 (#13004)
Co-authored-by: feng <1304903146@qq.com>
2024-04-12 10:39:49 +08:00
Bai
d2396afdd5 fix: User my assets sorted by connectivity did not take effect 2024-04-12 10:39:34 +08:00
Eric
43f9c07838 perf: 优化任务日志输出 2024-04-11 22:27:44 +08:00
Aaron3S
6052306c04 feat: ansible receptor kill 进程 2024-04-11 22:26:01 +08:00
Aaron3S
6a12bc39e9 feat: ansible receptor 适配文件上传 2024-04-11 22:22:29 +08:00
Bai
3f67b40975 fix: Export excel file can running instructions(csv no need deal) 2024-04-11 20:37:17 +08:00
fit2bot
0adc854721 perf: 优化审计台命令记录代码 (#12998)
Co-authored-by: feng <1304903146@qq.com>
2024-04-11 18:32:00 +08:00
fit2bot
ab76745a9f perf: 优化审计台仪表盘命令记录总数统计数据库和所有es数据 (#12997)
Co-authored-by: feng <1304903146@qq.com>
2024-04-11 18:29:02 +08:00
Aaron3S
574639d5e1 feat: 支持 ansible receptor private 方式认证, 支持运行完成工作空间清理 2024-04-11 17:51:22 +08:00
fit2bot
fa5d9d3df4 fix: 二级审批通过,一级审批人员查看不到工单 (#12993)
Co-authored-by: feng <1304903146@qq.com>
2024-04-11 16:35:00 +08:00
Aaron3S
0c31925131 feat: 设置默认的 ansible 配置文件 2024-04-11 15:10:39 +08:00
wangruidong
94b5d8b9e9 perf: 处理停止任务异常情况 2024-04-11 14:25:40 +08:00
Bai
bffc9f4b1d fix: Fix session Duration label 2024-04-11 11:00:46 +08:00
wangruidong
6b5d18222e fix: 全局组织-组织角色用户数量不对 2024-04-10 18:20:05 +08:00
Aaron3S
2b05fd5276 fix: 修复 ansible receptor playbook 无法执行的问题 2024-04-10 18:18:32 +08:00
fit2bot
3e46d72ba3 fix: 修复lark登录 Backend错误问题 (#12981)
Co-authored-by: feng <1304903146@qq.com>
2024-04-10 17:07:48 +08:00
feng
6502adb772 perf: 切换zh hant 2024-04-10 14:39:58 +08:00
fit2bot
a8112c86e3 feat: 全面修改 ansible 执行方式为 receptor (#12975)
* feat: 修复 receptor kill job  的问题

* feat: 全面修改 ansible 执行方式为 receptor

---------

Co-authored-by: Aaron3S <chenyang@fit2cloud.com>
2024-04-10 11:35:38 +08:00
wangruidong
8911c9c649 fix: Luna引导下载版本更新 2024-04-09 20:10:30 +08:00
Bai
3b70b4cf9e feat: LDAP User Auth support cache user_dn 2024-04-09 20:09:50 +08:00
wangruidong
1e0ea3905e fix: 忘记密码短信验证码过期 2024-04-09 20:05:34 +08:00
fit2bot
79f8480ae4 perf: core celery 不做报警 (#12970)
Co-authored-by: feng <1304903146@qq.com>
2024-04-09 17:07:48 +08:00
Bai
dec502e025 perf: Update user orgs roles 2024-04-09 16:52:11 +08:00
Aaron3S
c7b5cc7d89 feat: 暂时注释ansible runner write pid 逻辑 2024-04-09 16:46:56 +08:00
Aaron3S
bc76ce50e1 feat: 修改 receptor 启动参数 2024-04-09 15:59:14 +08:00
Bai
be90bf6b28 perf: Update user orgs roles 2024-04-09 15:43:27 +08:00
hzhfit2cloud
dfa68d1ca8 支持中文繁体 2024-04-09 15:18:36 +08:00
hzhfit2cloud
0237edf6c1 支持中文繁体 2024-04-09 15:18:36 +08:00
吴小白
6a87221c2a fix: 修正构建错误 2024-04-09 10:11:04 +08:00
ibuler
f0e87ef3f8 perf: rdp token 复用
perf: connection token
2024-04-08 19:03:47 +08:00
fit2bot
cd19a276c9 fix: 修复工单申请人过滤问题 (#12957)
Co-authored-by: feng <1304903146@qq.com>
2024-04-08 18:56:59 +08:00
jiangweidong
5ea4bba676 perf: 优化资产修改激活状态记录操作日志 2024-04-08 18:52:46 +08:00
Bryan
8c93d419fe Merge pull request #12956 from jumpserver/revert-12949-dev
Revert "feat: 支持中文繁体"
2024-04-08 18:05:45 +08:00
Bryan
2530827d07 Revert "feat: 支持中文繁体" 2024-04-08 18:04:38 +08:00
Bryan
8e54c446bc Merge pull request #12949 from elf168/dev
feat: 支持中文繁体
2024-04-08 18:02:31 +08:00
Bryan
3456e9ac5b Merge branch 'dev' into dev 2024-04-08 18:01:55 +08:00
fit2bot
689f858f97 feat: 支持 ansible 沙盒运行 (#12953)
* feat: 支持 ansible 沙盒运行

* feat: 修改 receptor sock 默认路径

* feat: 增加 adhoc 执行命令的 local connection 权限

---------

Co-authored-by: Aaron3S <chenyang@fit2cloud.com>
Co-authored-by: Bai <baijiangjie@gmail.com>
2024-04-08 17:54:34 +08:00
jiangweidong
93eebd7876 perf: 依赖包去掉多余的内容 2024-04-08 17:38:49 +08:00
jiangweidong
82cc21ef59 perf: 增加火山引擎依赖包volcengine-python-sdk 2024-04-08 17:38:49 +08:00
wangruidong
e61f9efbf2 perf: 内置平台置顶 2024-04-08 16:33:44 +08:00
Bai
45bac09dc7 perf: ROOT Org show orgs-and-roles in user-detail page 2024-04-08 14:00:57 +08:00
Eddie
989a970a7c 簡轉繁 2024-04-07 10:57:48 +00:00
Eddie
0296df0480 簡轉繁 2024-04-07 10:31:04 +00:00
wangruidong
9776d35140 perf: 批量上传添加权限校验 2024-04-07 15:49:41 +08:00
fit2bot
0aeea414f5 fix: 支持 SSO 用户登录时校验 (#12923)
Co-authored-by: feng <1304903146@qq.com>
2024-04-07 14:57:38 +08:00
Bai
9817154234 perf: 优化所有View默认排序规则(name) 2024-04-03 19:10:34 +08:00
Bai
39ae14877b perf: 优化所有View默认排序规则(name) 2024-04-03 18:33:00 +08:00
Bai
9c238a9147 perf: 优化所有View默认排序规则(name) 2024-04-03 18:12:15 +08:00
fit2bot
42d7e983e4 perf: 翻译 (#12937)
Co-authored-by: feng <1304903146@qq.com>
2024-04-03 16:53:08 +08:00
fit2bot
611d0b71e8 fix: 修复用户下线失败问题 SESSION_EXPIRE_AT_BROWSER_CLOSE 可配置 (#12936)
Co-authored-by: feng <1304903146@qq.com>
2024-04-03 16:41:37 +08:00
Bai
d78d55091c fix: 修复过滤用户组织角色不生效的问题 2024-04-03 15:52:52 +08:00
ibuler
3b8aab8c25 perf: 修改 export 使用的 serializer 2024-04-02 19:15:48 +08:00
Eric
2f16bdc4be perf: 优化针对低版本 ssh 版本的任务 2024-04-02 19:01:21 +08:00
wangruidong
22d70eb416 fix: 华为交换机执行快捷命令报错 2024-04-02 18:48:40 +08:00
wangruidong
afa1ba4f6b fix: 统一成模板 2024-04-02 17:21:47 +08:00
ibuler
39d3e5477c perf: migrate label model with the id 2024-04-02 16:47:38 +08:00
fit2bot
d499b94e04 fix: gpt 配置取消长度限制 (#12907)
Co-authored-by: feng <1304903146@qq.com>
2024-03-29 18:53:24 +08:00
fit2bot
7a6468530f fix: 修复测试rdp资产可连接性时使用的python解释器路径不对问题 (#12902)
Co-authored-by: feng <1304903146@qq.com>
2024-03-29 16:09:42 +08:00
fit2bot
02893c2a2b perf: 翻译 (#12899)
Co-authored-by: feng <1304903146@qq.com>
2024-03-29 15:18:54 +08:00
Eric
4470b68de9 perf: 优化代码,避免录像下载异常 2024-03-29 11:37:47 +08:00
wangruidong
d3d89b0853 perf: 去掉工单重新打开状态 2024-03-29 11:06:51 +08:00
wangruidong
681cecc52b perf: 优化所有资源列表的默认排序规则 2024-03-29 10:48:54 +08:00
fit2bot
3336a4526b fix: 解决beat无法在redis-ssl下运行报错的问题 (#12893)
Co-authored-by: jiangweidong <weidong.jiang@fit2cloud.com>
2024-03-28 18:44:52 +08:00
feng
bca0863952 fix: 【标签】标签绑定资源api需校验正确的uuid 2024-03-28 18:43:00 +08:00
fit2bot
bf1a29fac2 fix: 修改content type 权限 (#12890)
Co-authored-by: feng <1304903146@qq.com>
2024-03-28 15:22:26 +08:00
wangruidong
47ceaf967c fix: 查看作业命令任务执行结果添加用户隔离 2024-03-28 14:42:08 +08:00
feng
00c5b3c0a2 fix: 【资产登录】属性为标签时,规则不生效 2024-03-28 14:36:17 +08:00
fit2bot
3aeadc2f03 fix: 修复收藏文件夹中的资产时不时莫名的丢失 (#12886)
Co-authored-by: feng <1304903146@qq.com>
2024-03-27 16:04:16 +08:00
wangruidong
f0cbd77310 perf: 优化资产、网域、网关的操作体验 2024-03-27 16:02:08 +08:00
fit2bot
f11852c60d perf: lark logo (#12878)
Co-authored-by: feng <1304903146@qq.com>
2024-03-26 17:46:16 +08:00
feng
8b870678df perf: 翻译 2024-03-26 17:34:27 +08:00
feng
470a088a9f feat: 拆分 feishu lark 2024-03-26 17:10:25 +08:00
jiangweidong
ccd4f3ada4 fix: tcpdump想捕捉所有ip时,空ip被解析成0.0.0.0,导致捕捉不到的问题 2024-03-22 17:31:03 +08:00
ibuler
ae7a562b85 fix: ansible playbook render and run in localhost 2024-03-22 17:06:19 +08:00
wangruidong
be6d8566da perf: 去掉enabled字段默认值 2024-03-22 16:02:25 +08:00
wangruidong
f264bf03ff feat: 支持开启、关闭定时任务执行 2024-03-21 18:23:41 +08:00
fit2bot
02c2ee8c54 perf: 登录界面文案优化 (#12849)
Co-authored-by: feng <1304903146@qq.com>
2024-03-21 16:21:44 +08:00
Eric
d71374ca8a perf: 优化代码 2024-03-21 16:08:34 +08:00
Eric
0589f7fe33 perf: 支持发布机卸载远程应用 2024-03-21 16:08:34 +08:00
fit2bot
a5e8792092 perf: 翻译 (#12847)
Co-authored-by: feng <1304903146@qq.com>
2024-03-21 11:32:23 +08:00
fit2bot
15acfe84b0 perf: 改密记录可查看密文 (#12821)
* perf: 改密记录可查看密文

* perf: 自动化任务错误处理

* feat: 改密记录可批量重试 新增更多过滤选项

* perf: 改密任务失败添加消息通知

---------

Co-authored-by: feng <1304903146@qq.com>
2024-03-21 11:05:04 +08:00
jiangweidong
08b483140c fix: 解决FTP审计文件无法清理的问题 2024-03-20 19:06:30 +08:00
Bai
cf1e048328 perf: 优化 Session 支持 duration 字段 2024-03-20 15:51:33 +08:00
wangruidong
a6228f145d fix: 作业命令用户隔离执行 2024-03-19 11:25:46 +08:00
ibuler
b6ab3df038 perf: 优化 celery task log 权限控制 2024-03-18 19:00:04 +08:00
ibuler
e9f591b33b perf: 优化 ops task 2024-03-18 18:54:48 +08:00
wangruidong
90d4914280 perf: 删除job-execution/asset-detail接口 2024-03-18 18:54:27 +08:00
wangruidong
80a506e99f perf:LDAP报错信息不对 2024-03-18 15:56:57 +08:00
Eric
d8a891a7d7 perf: 支持发布机仅初始化配置 2024-03-18 15:52:42 +08:00
wangruidong
d71c41e384 perf: 提高短信发送任务优先级 2024-03-18 15:50:00 +08:00
fit2bot
bb27ff7f8a fix: 批量上传文件关闭作业中心配置后上传会报错 (#12814)
* fix: 批量上传文件关闭作业中心配置后上传会报错

* fix: format

---------

Co-authored-by: wangruidong <940853815@qq.com>
Co-authored-by: Bai <baijiangjie@gmail.com>
2024-03-18 15:49:13 +08:00
wangruidong
0671e56d65 fix: Another user can use this job id to spoof both the file name and
its contents
2024-03-18 14:22:17 +08:00
feng
73a4ce0943 perf: 优化user secret key 处理逻辑 2024-03-15 11:39:59 +08:00
fit2bot
902fac61e9 perf: playbook api 去掉多余的rbac_perms (#12813)
Co-authored-by: feng <1304903146@qq.com>
2024-03-14 14:27:31 +08:00
wangruidong
dcd7f9f7e6 perf: 支持终断批量快捷命令执行的任务 2024-03-14 14:20:47 +08:00
Bai
80035e7cb6 fix: 修复 Playbook 脚本文件问题 2024-03-14 10:26:30 +08:00
Eric
e2d14f5e4b perf: 支持 razor 的监控 2024-03-13 19:36:26 +08:00
刘瑞斌
a27cc22596 chore: edit readme_en 2024-03-13 15:47:04 +08:00
ibuler
72362274ce perf: 优化 console_orgs 的选择问题 2024-03-13 10:58:30 +08:00
feng
cfb1d306a3 perf: 优化user session 逻辑 2024-03-13 10:58:03 +08:00
wangruidong
e5cb99d682 perf: 登录页面排版优化 2024-03-12 17:05:03 +08:00
fit2bot
cbd812ab5f feat: 自定义footer (#12795)
Co-authored-by: feng <1304903146@qq.com>
Co-authored-by: feng626 <57284900+feng626@users.noreply.github.com>
2024-03-12 14:36:20 +08:00
Bai
d0117b5a91 perf: 优化邮箱校验逻辑 2024-03-11 18:41:50 +08:00
jiangweidong
afe3777895 perf: 减少一次邮箱的判断 2024-03-11 18:41:50 +08:00
jiangweidong
e45676edc4 perf: 优化获取邮箱后缀代码位置 2024-03-11 18:41:50 +08:00
jiangweidong
60e4b19d07 perf: 优化三方登录创建的用户邮箱会校验,非法邮箱会重置成默认格式 2024-03-11 18:41:50 +08:00
Bai
86d76c53d6 perf: 优化 MongoDB 数据库支持 authSource 认证数据库配置 2024-03-11 18:27:57 +08:00
fit2bot
b50f1a662d fix: 优化手动输入的账号username遵循登录资产的ACL控制 (#12774)
Co-authored-by: feng <1304903146@qq.com>
2024-03-11 15:10:51 +08:00
fit2bot
b3e4c10bc2 perf: 用户个人设置操作记录翻译 (#12788)
Co-authored-by: feng <1304903146@qq.com>
2024-03-11 15:10:15 +08:00
Bai
ba11e646d6 fix: 修复 redis lock 导致 celery 异步任务卡住不执行的问题 2024-03-11 14:12:18 +08:00
wangruidong
6de524c797 perf: 不满足自动登录勾选条件时从禁用修改为隐藏 2024-03-08 18:35:18 +08:00
Bai
2e067a7950 perf: 优化升级 django-celery-beat==2.6.0; 删除之前修复的 celery-beat 的代码 2024-03-08 17:47:07 +08:00
fit2bot
a3658136e2 feat: 支持配置资产连接默认打开方式 (#12781)
Co-authored-by: feng <1304903146@qq.com>
2024-03-08 10:47:18 +08:00
Bai
4108415894 perf: 优化 issue 提交模版 2024-03-08 10:33:04 +08:00
Bai
ae2fdff9a7 perf: 优化 issue 提交模版 2024-03-07 18:58:28 +08:00
Bryan
b9422c096e fix: 修复连接 Token 时报错的问题((1139, "Got error empty (sub)expression from regexp")) (#12768) 2024-03-07 12:37:33 +08:00
fit2bot
b3e73605b0 perf: 创建网域时资产不用必选 (#12766)
Co-authored-by: feng <1304903146@qq.com>
2024-03-07 11:20:40 +08:00
fit2bot
6c89349194 perf: 优化会话 命令记录 分片删除 (#12763)
Co-authored-by: feng <1304903146@qq.com>
2024-03-06 15:22:55 +08:00
jiangweidong
670eac49b6 perf: 优化oauth2登录未激活用户时,会重复跳转登录问题 2024-03-06 15:03:58 +08:00
feng
a7a099f290 perf: 支持配置文件配置限制的最大数量 2024-03-06 14:53:48 +08:00
feng
5157514c62 perf: 优化会话清理任务使用分片删除过期的会话和命令 2024-03-06 14:50:19 +08:00
jiangweidong
533d2ab98a perf: 优化自定义短信测试总是成功的问题 2024-03-06 14:32:58 +08:00
wangruidong
40730b741d fix: 个别页面搜索不生效的问题 2024-03-05 11:21:20 +08:00
halo
786cb23f98 perf: 优化ansible_winrm执行超时时间 2024-03-01 17:02:48 +08:00
fit2bot
518ae3fa09 perf: 自动化资产探活支持Telnet方式 (#12728)
Co-authored-by: jiangweidong <weidong.jiang@fit2cloud.com>
2024-03-01 15:05:34 +08:00
ibuler
18707d365b perf: 优化标签搜索资产使用的关系 2024-03-01 15:05:01 +08:00
feng
f0ffa2408d fix: 哨兵redis 密码里有@ 无法连接 2024-02-29 16:19:33 +08:00
jiangweidong
b557e264bc fix: 账号备份选择SFTP有多个时,重复编码password会导致任务异常 2024-02-29 16:10:21 +08:00
wangruidong
457d2b2359 fix: 作业管理资产根据标签过滤获取不对 2024-02-28 15:50:46 +05:00
Bai
8ebc99339b perf: 更新 poetry.lock 文件 2024-02-28 07:22:16 +05:00
wangruidong
e71e335f5c fix: 终断任务时接口报错 2024-02-27 16:22:06 +05:00
masix
7517e77af9 指定lxml版本为4.9.3
修复SAML2认证回调/core/auth/saml2/callback/时偶发出现http 502错误
2024-02-27 08:16:10 +05:00
wangruidong
889cdca3b0 fix: 操作日志资源类型搜索无效 2024-02-26 16:36:05 +05:00
wangruidong
4cfd1bc047 fix: 远程应用列表接口报错 2024-02-26 16:03:34 +05:00
Eric
fc0891ceee perf: 会话生命周期日志翻译 2024-02-26 15:33:11 +05:00
feng
cea16fc41f perf: 命令上传 取消input长度限制 2024-02-26 14:29:13 +05:00
fit2bot
4b7c0b8437 perf: 用户列表翻译超级管理员,组织管理员 2024-02-26 14:27:19 +05:00
fit2bot
09432b01a7 fix: 自动化任务密钥为 None 报错 (#12709)
Co-authored-by: feng <1304903146@qq.com>
2024-02-26 14:47:19 +08:00
wangruidong
d7f8ba58ad perf: 作业日志添加任务类型 2024-02-26 13:43:49 +08:00
吴小白
f660c38d80 fix: 添加 psycopg2 缺失依赖 2024-02-22 19:08:18 +08:00
wangruidong
edf0630cef fix: 用户列表导出优化 2024-02-22 17:44:56 +08:00
wangruidong
c4342567ba fix: 远程应用README国际化 2024-02-22 16:11:43 +08:00
fit2bot
d4e53be7ce perf: 修改core celery 组件状态 (#12684)
Co-authored-by: feng <1304903146@qq.com>
2024-02-22 14:47:26 +08:00
wangruidong
d4721e90d5 fix: LDAP用户导入会超时 2024-02-22 11:37:30 +08:00
jiangweidong
bb6c6c8f6a perf: jms-storage==0.0.56 2024-02-22 11:36:33 +08:00
fit2bot
753ab77c46 perf: 关闭页面等待ws的最大重连时间改为6秒 (#12677)
Co-authored-by: feng <1304903146@qq.com>
2024-02-21 17:51:06 +08:00
jiangweidong
ba127c506d feat: 支持工单链接直接免密审批 2024-02-21 11:39:01 +08:00
fit2bot
c21ca70158 perf: 账号收集添加资产名称模糊搜索 (#12673)
Co-authored-by: feng <1304903146@qq.com>
2024-02-20 18:42:11 +08:00
wangruidong
135fb7c6f9 perf: 终断批量快捷命令执行的任务 2024-02-20 15:09:39 +08:00
feng
f592f19b08 perf: 自动化任务按优先级默认排序 2024-02-19 18:19:14 +08:00
fit2bot
dce68cd011 perf: 授权用户不显示组件用户 (#12664)
Co-authored-by: feng <1304903146@qq.com>
2024-02-19 14:48:31 +08:00
fit2bot
d7b1903fb7 perf: 修改登录页面定期 check 的时间 (#12660)
Co-authored-by: feng <1304903146@qq.com>
2024-02-19 10:57:40 +08:00
feng
6e506e3146 fix: 【登录超时】修复登录页面提示 <登录超时,请重新登录> 问题 2024-02-19 10:21:13 +08:00
fit2bot
58d30e7f85 perf: 记录会话活动日志 (#12523)
* perf: 更新会话生命周期日志

* perf: 优化错误原因

* perf: 增加错误类型

---------

Co-authored-by: Eric <xplzv@126.com>
2024-02-06 18:28:31 +08:00
wangruidong
2062778ab8 fix: 资产登录未发送提醒 2024-02-06 15:24:41 +08:00
wangruidong
eaca296bd0 perf: 支持改密日志记录保留天数 2024-02-05 18:09:45 +08:00
Bai
1051c6af04 fix: 修复用户登录后仪表盘显示403的问题(用户在非Default组织下是组织管理员权限) 2024-02-05 16:52:09 +08:00
wangruidong
aa69353474 perf: 支持远程应用描述文案的国际化 2024-02-05 10:46:47 +08:00
jiangweidong
d1f31f078b perf: 账号支持批量更新 2024-02-04 17:28:31 +08:00
ibuler
be80663436 perf: 优化日志显示避免太长 2024-02-04 17:23:37 +08:00
wangruidong
1ae363d6bd perf: MFA认证App支持自定义下载二维码 2024-02-04 17:19:04 +08:00
fit2bot
31b0d345ad perf: 使用新的钉钉登录接口 (#12635)
* perf: 暂存

* perf: 使用新的钉钉登录接口

---------

Co-authored-by: halo <wuyihuangw@gmail.com>
2024-02-04 17:05:11 +08:00
Bai
cabda0a32f perf: 修改依赖 2024-02-04 17:02:07 +08:00
wangruidong
f606dd8920 perf: 增加国际电话区号选择 2024-02-04 14:52:15 +08:00
wangruidong
973df0360c fix: 控制台-仪表盘会话用户,资产排名不对 2024-02-04 11:42:58 +08:00
wangruidong
f9f1d96674 fix: 资产过期消息提示发送失败 2024-02-04 11:42:15 +08:00
feng
8cb74976e1 perf: 优化用户session 会话过期 2024-02-02 17:52:50 +08:00
wangruidong
279109c9a6 perf: 使用winrm协议批量上传文件 2024-01-30 11:12:24 +08:00
jiangweidong
8c7ba4a497 perf: 优化工单审批时间不准确问题 2024-01-29 16:40:03 +08:00
feng
9cc048267b feat: 批量测试账号可连接性 2024-01-29 16:39:24 +08:00
wangruidong
78d0e3f485 perf: 使用winrm协议执行快捷命令 2024-01-29 11:21:30 +08:00
wangruidong
8aefacd7ed perf: 安全模式返回授权的资产 2024-01-25 17:07:37 +08:00
ibuler
ef8db68db1 perf: 优化组织刷新资源 2024-01-25 14:48:15 +08:00
fit2bot
00256f86df perf: OAuth2协议获取token支持配置json或者data (#12602)
* perf: OAuth2协议获取token支持配置json或者data

* perf: 优化注释

---------

Co-authored-by: jiangweidong <weidong.jiang@fit2cloud.com>
2024-01-25 14:00:13 +08:00
ibuler
77569c554b perf: 去掉资产查询的默认排序 2024-01-25 13:49:49 +08:00
jiangweidong
7897462e32 perf: jms_storage==0.0.55 2024-01-25 13:48:34 +08:00
Bai
aee11827c4 feat: 修改 jms-storage 0.0.55 2024-01-25 11:48:16 +08:00
fit2bot
a6bf592046 perf: 翻译 (#12600)
Co-authored-by: feng <1304903146@qq.com>
2024-01-24 19:50:05 +08:00
Bryan
1dea424104 Revert "fix: 修复 OAuth2 认证时 POST 方式获取 access_token API 使用 json 传递数据" 2024-01-24 18:23:29 +08:00
Bai
1f5554d945 fix: 修复 OAuth2 认证时 POST 方式获取 access_token API 使用 json 传递数据 2024-01-24 16:53:11 +08:00
ibuler
0303408be8 perf: 优化授权树的刷新,同步解决同步异步的问题 2024-01-24 16:44:19 +08:00
fit2bot
f5802ace02 fix: oracle 用户是sysdba类型的 改密推送 验证账号可连接性失败 (#12596)
Co-authored-by: feng <1304903146@qq.com>
2024-01-24 16:39:43 +08:00
fit2bot
8bde45d9dc perf: 改密添加最后汇总信息 (#12595)
Co-authored-by: feng <1304903146@qq.com>
2024-01-24 16:20:44 +08:00
ibuler
e8bbc44647 perf: 优化授权的资产,速度快 10 倍 2024-01-24 16:00:18 +08:00
ibuler
34aa48d18c fix: 修复定时检测用户是否活跃任务无法执行的问题 2024-01-23 09:29:00 +00:00
jiangweidong
7aa6613e69 perf: 更新jms-storage版本 2024-01-23 03:42:59 +00:00
fit2bot
503034299e fix: windows 收集账号 收集失败 (#12583)
Co-authored-by: feng <1304903146@qq.com>
2024-01-23 11:07:56 +08:00
fit2bot
0c74e92bfb perf: 优化 labels 在 json field 中的筛选 (#12577)
* perf: 优化 labels 在 json field 中的筛选

* perf: 修改 labels 搜索

---------

Co-authored-by: ibuler <ibuler@qq.com>
2024-01-21 23:36:18 -04:00
wangruidong
3853d0bcc6 fix:绑定的端点Default下载RDP文件中的地址是空的 2024-01-19 10:38:52 +00:00
feng
cd0348cca1 perf: 优化任务列表执行时间 性能快了10倍 2024-01-19 10:33:41 +00:00
Eric
ce94348d45 perf: ignore some err 2024-01-19 12:56:46 +08:00
Eric
f74f8b7d8c perf: 优化 delay_run 执行 2024-01-19 12:56:46 +08:00
Bai
dc79346bdc perf: 修复 Count 时没有去重的问题 2024-01-19 12:54:14 +08:00
wangruidong
37a0d831da perf:ldap sync add no user msg 2024-01-18 10:31:53 +00:00
feng
e509568fe5 fix: redis 密码有特殊字符celery beat启动失败 2024-01-18 10:30:00 +00:00
fit2bot
2c2c3eb21a perf: 翻译 (#12564)
Co-authored-by: feng <1304903146@qq.com>
2024-01-17 19:18:00 +08:00
fit2bot
18681d1f50 perf: 连接k8s 添加错误处理 (#12563)
Co-authored-by: feng <1304903146@qq.com>
2024-01-17 18:41:29 +08:00
feng
86ef984c02 perf: 查看授权用户 不展示组件用户 2024-01-17 03:13:39 -07:00
feng
e4d8ce097a fix: 创建资产失败 2024-01-17 18:05:30 +08:00
Eric
ae68241812 perf: 修复录像在线播放问题 2024-01-17 00:02:00 -07:00
feng
13d4177531 fix: 工单批量更新没有权限 2024-01-16 20:01:36 -07:00
feng
641e75a905 fix: 用户组列表 用户数量不准确 2024-01-16 02:19:36 -07:00
ibuler
a2d6e41816 perf: labels getter and setter for inherite model 2024-01-16 15:00:46 +08:00
wangruidong
6cd3672604 fix: sync LDAP notification error 2024-01-15 23:08:55 -07:00
Bai
3c3c1499b7 perf: Add requirement for exchangelib==5.1.0 2024-01-15 22:55:58 -07:00
fit2bot
e29e51121d perf: 优化账号版本计算策略 (#12547)
Co-authored-by: feng <1304903146@qq.com>
2024-01-16 11:33:21 +08:00
ibuler
fabee37e9e fix: user permed type tree recurse root node 2024-01-15 19:50:14 +08:00
ibuler
2994ea6f68 perf: revert asset labels api 2024-01-15 19:49:55 +08:00
halo
644eada8a1 fix: 解决openssh低版本时测试可连接失败问题 2024-01-15 10:39:34 +08:00
wangruidong
000a3038e1 fix: 终端输入错误的MFA无日志记录 2024-01-14 18:32:33 -08:00
ibuler
9c8635b230 perf: 优化授权资产 api,很多资产也不怕 2024-01-14 18:30:57 -08:00
wangruidong
e428eb351b feat: 同步ldap用户消息通知 2024-01-12 11:17:23 +05:00
fit2bot
1275087f19 perf: 添加LC_ALL环境变量C.UTF-8 解决ansible无法初始化首选语言环境问题 (#12530)
Co-authored-by: feng <1304903146@qq.com>
2024-01-12 11:21:27 +08:00
feng
311c01242b fix: 分页后排序失效 2024-01-12 10:18:05 +08:00
ibuler
bab5b67c52 fix: 修复自定义 applet 导入的 bug 2024-01-11 15:41:10 +05:00
fit2bot
3eb0b768a6 fix: 改密账号更新日期没有更新 (#12524)
Co-authored-by: feng <1304903146@qq.com>
2024-01-11 16:57:23 +07:00
fit2bot
6dcc74a388 fix: 账号备份只导出一条记录 (#12517)
Co-authored-by: wangruidong <940853815@qq.com>
2024-01-10 18:52:45 +08:00
ibuler
2b15fc5e8b perf: 兼用处理一下 tree 2024-01-10 11:23:16 +05:00
wangruidong
df655f304a fix: 登录日志不显示 2024-01-10 11:21:29 +05:00
Bai
25223719cb perf: 支持配置 RADIUS_ATTRIBUTES 属性 2024-01-09 18:36:16 +08:00
jiangweidong
814dbeb749 fix: 解决手机号加密导致忘记密码判断总是失败问题 2024-01-08 16:24:28 +05:00
jiangweidong
630bb56601 fix: 解决手机号加密导致忘记密码判断总是失败问题 2024-01-08 16:24:28 +05:00
ibuler
496b72aaee perf: 优化导入错误 2024-01-08 17:44:49 +08:00
吴小白
b57e943990 build(deps): 更新依赖版本 2024-01-08 17:03:08 +08:00
jiangweidong
b4c1dd2944 perf: slack消息解析优化-mistune升级 2024-01-08 12:35:26 +05:00
jiangweidong
9ede3670a7 perf: 邮箱支持exchange协议 2024-01-08 12:35:01 +05:00
Eric
2a29cd0e70 perf: 使用 nginx 处理静态资源 2024-01-03 17:20:14 +08:00
ibuler
15ac81a422 perf: 优化标签绑定,仅绑定到资产上 2024-01-03 17:08:15 +08:00
fit2bot
eb5a53b91b perf: 翻译 (#12487)
Co-authored-by: feng <1304903146@qq.com>
2024-01-03 11:25:45 +08:00
feng
4dd72b109f feat: 历史账号定期删除 可设置保留数量 2024-01-03 07:52:24 +05:00
fit2bot
2fcbfe9f21 perf: 优化 tree nodes 避免太慢 (#12472)
* perf: 优化 tree nodes 避免太慢

perf: 优化大量资产上的资产数生成比较慢

perf: 优化节点树

perf: 修改 tree nooooooooodes

perf: 优化一些 api 比较大的问题

perf: 优化平台 api

perf: 分页返回同步树

perf: 优化节点树

perf: 深度优化节点树

* perf: remove unused config

---------

Co-authored-by: ibuler <ibuler@qq.com>
2024-01-02 16:11:56 +08:00
wangruidong
e80a0e41ba fix: 同步LDAP用户时,用户组只移除LDAP同步过来的 2024-01-02 12:04:25 +05:00
吴小白
7cdba3ef38 build(deps): bump pyfreerdp from 0.0.1 to 0.0.2 2024-01-02 08:13:28 +05:00
feng
2d6e815b3d fix: 如 Redis密码信息包含特殊字符时,服务启动失败 2024-01-02 08:11:12 +05:00
Bryan
38642024be Update README.md (#12463) 2023-12-29 16:23:02 +08:00
faming.zhou
257ee205ac fix: UNION 的类型 character varying 和 uuid 不匹配 2023-12-29 12:14:31 +05:00
feng
4b961a626b perf: 用户组列表中的用户添加 is_service_account 属性 2023-12-29 11:11:19 +05:00
wangruidong
653a6752b6 fix: 用户组删除用户权限问题 2023-12-29 13:36:39 +08:00
wangruidong
32255c6077 fix: 更新用户组权限问题 2023-12-29 07:42:10 +05:00
feng626
7a708156ee Revert "fix: 特定key paramiko 测试可连接性失败"
This reverts commit a4d0e3fd17.
2023-12-28 14:34:42 +05:00
Bai
b72a446bbd fix: 修复label关联用户时不显示服务账号 2023-12-28 14:21:38 +05:00
feng
219fad9b62 fix: 账号备份密码如 t08\x08fIE 备份失败 2023-12-28 13:53:57 +05:00
Bai
6c1c8b241e perf: 优化资产管理中的标签权限位不显示 2023-12-28 15:27:20 +08:00
feng
a4d0e3fd17 fix: 特定key paramiko 测试可连接性失败 2023-12-27 13:13:03 +05:00
fit2bot
af44ffab0a fix: 资产账号不存在时 同步删除资产账号任务报错 (#12437)
Co-authored-by: feng <1304903146@qq.com>
2023-12-27 14:39:11 +08:00
fit2bot
a09b7b29e2 fix: 【账号收集】账号收集任务,关闭同步到资产时,只收集了一个资产的账号,其他资产的账号未收集 (#12428)
Co-authored-by: feng <1304903146@qq.com>
2023-12-26 16:05:28 +08:00
wangruidong
8f67922c80 perf: 资产登录提醒和用户登录提醒能显示用户名称 2023-12-26 12:54:28 +05:00
feng
f1db5d6f44 perf: 重写GenericForeignKey 2023-12-26 12:51:09 +05:00
fit2bot
33ea5eb41f perf: 资产可以通过address 排序 (#12427)
Co-authored-by: feng <1304903146@qq.com>
2023-12-26 14:23:04 +08:00
fit2bot
48bcbc6c53 perf: 翻译 (#12426)
Co-authored-by: feng <1304903146@qq.com>
2023-12-26 14:16:11 +08:00
Bai
3e090eb701 fix: 修复 连接远程应用时标签匹配失败的问题 2023-12-25 16:20:38 +05:00
Bai
6ac956c626 fix: 修复 api/docs 报错问题 2023-12-25 19:04:44 +08:00
wangruidong
edb2d1bd7b fix: 我的资产列表标签信息没有显示 2023-12-25 16:02:16 +05:00
feng
81b4909016 fix: 【用户登录会话失效问题】SESSION_COOKIE_AGE 配置不生效的问题 2023-12-25 13:10:58 +05:00
wangruidong
f6f1be423c perf: 统计任务执行结果 2023-12-22 14:18:25 +05:00
Bryan
fae5392a03 Update README.md 2023-12-22 12:30:11 +05:00
Bryan
d5224968bc Update README.md 2023-12-22 12:30:11 +05:00
feng
6565f8c0a8 perf: 在 ansible 中切换用户时 添加超时操作 2023-12-22 12:23:19 +05:00
ibuler
bc5494bbb0 perf: 优化 label choice 2023-12-21 16:51:36 +08:00
fit2bot
febf08629a fix: 翻译 (#12400)
Co-authored-by: feng <1304903146@qq.com>
2023-12-21 16:15:20 +08:00
fit2bot
b6774aa749 perf: 更新全局组织名字 添加唯一性校验 (#12399)
Co-authored-by: feng <1304903146@qq.com>
2023-12-21 16:07:11 +08:00
fit2bot
bc668f3e9f fix: applet 压缩包名字(1).zip时 上传失败} (#12397)
Co-authored-by: feng <1304903146@qq.com>
2023-12-21 15:42:09 +08:00
fit2bot
dc56b019b1 perf: 权限树翻译 (#12396)
Co-authored-by: feng <1304903146@qq.com>
2023-12-21 15:00:46 +08:00
ibuler
a38624d198 perf: 修改同名账号登录报错 2023-12-21 14:04:09 +08:00
ibuler
ca026040fe perf: 优化导入账号报错 2023-12-21 12:40:59 +08:00
ibuler
88b9a4d693 perf: 修改搜索 2023-12-20 17:50:40 +05:00
ibuler
4d15e46ceb perf: 修改搜索 2023-12-20 17:50:40 +05:00
fit2bot
55575e9f7f perf: 用户账号导出去除is_service_account (#12388)
Co-authored-by: feng <1304903146@qq.com>
2023-12-20 19:24:09 +08:00
wangruidong
98c9cddcbf fix: es命令记录可以看到其他资产执行的命令 2023-12-20 16:00:35 +05:00
fit2bot
9f67ba573c perf: dockerfile 添加 freerdp2-dev 依赖 (#12386)
Co-authored-by: feng <1304903146@qq.com>
2023-12-20 18:48:37 +08:00
fit2bot
533f13c634 perf: 优化创建账号密码校验逻辑 (#12383)
Co-authored-by: feng <1304903146@qq.com>
2023-12-20 16:35:36 +08:00
fit2bot
c66b1db784 fix: 自动化任务网关连接数 自定义ansible rdp 测试可连接性端口错误 (#12373)
Co-authored-by: feng <1304903146@qq.com>
2023-12-20 16:02:13 +08:00
Eric
d03ba7c391 perf: 页面配置是否启用 Vitual App 2023-12-20 13:01:50 +05:00
fit2bot
6544f8ade8 perf: 修改 labels 搜索 (#12379)
* perf: 修改标签的搜索

* perf: 修改 labels 搜索

---------

Co-authored-by: ibuler <ibuler@qq.com>
2023-12-20 14:31:03 +08:00
ibuler
ac5991fc43 perf: 修改标签的搜索 2023-12-20 10:57:58 +05:00
wangruidong
9b2b71dddc fix: 工单列表类型没有翻译 2023-12-20 10:57:29 +05:00
fit2bot
e18e019460 fix: 账号列表,添加账号模版 500 (#12375)
Co-authored-by: feng <1304903146@qq.com>
2023-12-20 11:05:42 +08:00
fit2bot
ef1875d9b5 perf: 优化工单显示 (#12368)
Co-authored-by: wangruidong <940853815@qq.com>
2023-12-19 19:06:39 +08:00
ibuler
0b7552a6ee perf: 修改 labels 绑定引起的问题 2023-12-19 16:06:05 +05:00
fit2bot
45425b11d2 perf: 优化 labels 支持多个搜索 (#12367)
Co-authored-by: ibuler <ibuler@qq.com>
2023-12-19 18:46:02 +08:00
jiangweidong
fda3e6ec9b perf: model_to_dict无法转换不可编辑字段,导致消息中有的值为None 2023-12-19 14:30:13 +05:00
huailei
2b41486f2a Merge pull request #12369 from jumpserver/pr@dev@chat_ai_test
fix: chatAI代理配置错误,服务器报错500
2023-12-19 15:42:06 +08:00
feng
59d9a3d4ec fix: chatAI代理配置错误,服务器报错500 2023-12-19 15:39:22 +08:00
wangruidong
3c7ba029dd perf: 工单显示优化 2023-12-19 12:10:34 +05:00
huailei
1335556272 Merge pull request #12366 from jumpserver/pr@dev@command
fix: 命令组模糊搜索,500
2023-12-19 15:07:50 +08:00
feng
8eab87f40d fix: 命令组模糊搜索,500 2023-12-19 15:05:35 +08:00
huailei
c441e5bb92 Merge pull request #12365 from jumpserver/pr@dev@ansible
fix: 修复ansible 任务 {{123}} 这样的密码失败问题
2023-12-19 14:59:23 +08:00
feng
da8d78f384 fix: 修复ansible 任务 {{123}} 这样的密码失败问题 2023-12-19 14:57:51 +08:00
jiangweidong
83b91cb739 perf: 优化命令禁止发送消息时,slack消息会包含html标签内容 2023-12-19 11:40:18 +05:00
fit2bot
1afad40dd3 perf: 优化 labels 绑定资源 (#12361)
* perf: 优化 labels 绑定资源

* perf: 优化 labels list 显示

* perf: add migrations

---------

Co-authored-by: ibuler <ibuler@qq.com>
2023-12-19 10:20:11 +08:00
ibuler
1358cf532f perf: 修改 labels 和 role 搜索 2023-12-18 18:23:06 +05:00
huailei
1e7f268f0c Merge pull request #12360 from jumpserver/pr@dev@translate
perf: 翻译
2023-12-18 18:38:21 +08:00
feng
d6b5590505 perf: 翻译 2023-12-18 18:36:44 +08:00
huailei
79b3b31492 Merge pull request #12358 from jumpserver/pr@dev@makemigrations
perf: 迁移文件
2023-12-18 17:46:23 +08:00
feng
4f2b3fbb43 perf: 迁移文件 2023-12-18 17:44:59 +08:00
fit2bot
1f2db65dba fix: ansible 密码支持 {{ }} {% %} (#12354)
Co-authored-by: feng <1304903146@qq.com>
2023-12-18 17:31:35 +08:00
halo
006faac326 perf: 配置xpack后logo没有修改 2023-12-18 14:51:28 +08:00
ibuler
f7fee0f430 perf: 修复标签搜索 2023-12-15 18:34:44 +08:00
fit2bot
714c44fbf4 perf: 授权创建时 通过模版创建账号 给账号添加来源 (#12345)
Co-authored-by: feng <1304903146@qq.com>
2023-12-15 18:28:48 +08:00
fit2bot
84b316e2c1 fix: 修复自动禁用用户默认排除 admin 用户 (#12346)
Co-authored-by: Bai <baijiangjie@gmail.com>
2023-12-15 18:28:24 +08:00
wangruidong
6955a3db11 perf: ldap测试登录提示优化&上产文件名长度限制 2023-12-15 18:06:47 +08:00
huailei
d92736e624 Merge pull request #12343 from jumpserver/pr@dev@perf_password_rules
perf: 优化校验密码规则 特殊字符校验
2023-12-15 17:16:04 +08:00
feng
9d0da64ea1 perf: 优化校验密码规则 特殊字符校验 2023-12-15 17:14:34 +08:00
wangruidong
b9e1d6093e perf: 翻译 2023-12-15 15:21:52 +08:00
Bai
c3820b30b8 fix: 修复远程应用连接 labels 过滤问题 2023-12-15 13:26:01 +08:00
huailei
6955fc1734 Merge pull request #12337 from jumpserver/pr@dev@prompt
perf: 修改默认prompt顺序
2023-12-15 10:57:18 +08:00
feng
32178b2344 perf: 修改默认prompt顺序 2023-12-15 10:48:04 +08:00
fit2bot
e3c0518cfb perf: 上传目标目录指定在/tmp下 (#12334)
Co-authored-by: wangruidong <940853815@qq.com>
2023-12-14 19:44:53 +08:00
jiangweidong
438e9dee2a fix: 解决第三方登录一个不存在的本地用户时,改密日志会增加的问题 2023-12-14 19:36:06 +08:00
Bai
3c9239eb09 fix: 修复 Release 应用账号的逻辑,解决首次连接远程应用可能出现没有可用账号的问题 2023-12-14 19:35:05 +08:00
Eric
81fb080c67 perf: 调整搜索字段 2023-12-14 18:28:55 +08:00
feng
6cf05435bf feat: chat prompt 2023-12-14 17:39:15 +08:00
wangruidong
65718c5a84 perf: 接口返回上传文件大小限制 2023-12-14 11:26:44 +08:00
wangruidong
27daebbe1b perf: 上传文件大小限制 2023-12-14 10:34:58 +08:00
huailei
dce1079fdc Merge pull request #12324 from jumpserver/pr@dev@perm_label
perf: 修改下线用户会话的权限位label
2023-12-13 17:39:15 +08:00
feng
d07db68426 perf: 修改下线用户会话的权限位label 2023-12-13 17:28:57 +08:00
huailei
6d37300a30 Merge pull request #12323 from jumpserver/pr@dev@gather_account
fix: 收集账号过滤asset_id 失败
2023-12-13 16:35:17 +08:00
feng
0c96af32c2 fix: 手机账号过滤asset_id 失败 2023-12-13 16:33:50 +08:00
huailei
1c6b1b0625 Merge pull request #12321 from jumpserver/pr@dev@translate
perf: 翻译
2023-12-13 16:16:50 +08:00
feng
4f7b4842f6 perf: 翻译 2023-12-13 16:15:34 +08:00
fit2bot
c4fef5899c perf: 连接 RDP 协议会话时,高级选项支持 session bpp:i 参数配置;默认 32; (#12319)
Co-authored-by: feng <1304903146@qq.com>
2023-12-13 15:51:22 +08:00
wangruidong
5b51a8231c fix: 点击备案号未跳转到指定链接 2023-12-13 11:22:41 +08:00
huailei
54417dd6d3 Merge pull request #12312 from jumpserver/pr@dev@chat_setting
fix: chat ai测试可连接性时失败
2023-12-12 19:15:26 +08:00
feng
2c7ad90524 fix: chat ai测试可连接性时失败 2023-12-12 19:14:13 +08:00
ibuler
01fcdad489 perf: 优化用户不活跃检测 2023-12-12 17:19:19 +08:00
feng
8801003461 perf: 支持 西班牙 Keyboard Layout 2023-12-12 17:16:55 +08:00
huailei
696397fdb0 Merge pull request #12306 from jumpserver/pr@dev@translate
perf: 翻译
2023-12-12 15:37:37 +08:00
feng
87a24991f1 perf: 翻译 2023-12-12 15:34:13 +08:00
Eric
3ec93b8f04 perf: 添加录像不支持 2023-12-12 14:56:45 +08:00
ibuler
4f1826d3ed perf: get request ip, only using x-forwarded-for 2023-12-12 14:44:57 +08:00
ibuler
9260f26c99 perf: 优化 db constrains 2023-12-12 14:44:11 +08:00
fit2bot
93da3e58f2 perf: 【优化系统任务】支持显示 执行周期、下次开始时间 字段 (#12298)
Co-authored-by: feng <1304903146@qq.com>
2023-12-12 14:18:26 +08:00
wangruidong
1eff33f3f7 perf: 优化获取同名文件列表 2023-12-12 10:39:23 +08:00
wangruidong
8e89d42343 perf: 同名文件处理 2023-12-12 10:39:23 +08:00
wangruidong
d0b0c87d3c feat: 支持批量发送文件 2023-12-12 10:39:23 +08:00
ibuler
e3ac26e377 perf: 修改 rbac labels node 2023-12-11 14:43:15 +08:00
Eric
4ea20a9103 perf: 优化迁移文件 verbose_name 2023-12-11 14:40:21 +08:00
fit2bot
dd57b14562 feat: 增加 sqlserver 支持 (#12288)
* feat: 增加 sqlserver 支持

* feat: 删除一些  migrations

---------

Co-authored-by: Aaron3S <chenyang@fit2cloud.com>
2023-12-11 13:57:35 +08:00
wangruidong
c312cdb625 perf: 优化资产授权过期提示信息 2023-12-11 11:41:52 +08:00
huailei
85fedf0704 Merge pull request #12287 from jumpserver/pr@dev@public_api
perf: PublicSetting API 添加GPT参数
2023-12-08 17:54:06 +08:00
feng
8b05260a6c perf: PublicSetting API 添加GPT参数 2023-12-08 17:46:40 +08:00
Bai
47cb6b1ec0 perf: 优化资产列表支持通过 创建日期 进行排序 2023-12-08 16:39:13 +08:00
huailei
79b5dff210 Merge pull request #12286 from jumpserver/pr@dev@password_rule
fix: 改密计划创建更新失败
2023-12-08 16:36:04 +08:00
feng
b08e1f6a47 fix: 改密计划创建更新失败 2023-12-08 16:34:46 +08:00
Bai
2e3184cbd6 fix: 修复 Endpoint 获取错误问题 2023-12-08 16:33:27 +08:00
huailei
fb903e53a4 Merge pull request #12284 from jumpserver/pr@dev@translate
perf: 翻译
2023-12-08 16:18:36 +08:00
feng
cc7220a4ad perf: 翻译 2023-12-08 16:17:20 +08:00
fit2bot
81de527e32 perf: 解决Slack解绑用户404问题 (#12283)
Co-authored-by: jiangweidong <weidong.jiang@fit2cloud.com>
2023-12-08 15:11:49 +08:00
huailei
7ad2abe104 Merge pull request #12280 from jumpserver/pr@dev@migrate
perf: 修改迁移文件
2023-12-08 14:22:55 +08:00
feng
9a2da98bd4 perf: 修改迁移文件 2023-12-08 14:21:10 +08:00
feng
eca50874f0 feat: 同步删除远程机器账号 2023-12-08 14:13:55 +08:00
fit2bot
8f82ca9856 perf: 优化操作日志 (#12249)
* perf: 优化操作日志

* perf: 修改migrations中关于Nodes的verbose_name

* perf: 优化代码逻辑

* perf: 优化日志详情展示逻辑

* perf: 代码优雅一下

---------

Co-authored-by: jiangweidong <weidong.jiang@fit2cloud.com>
2023-12-05 17:26:47 +08:00
Eric
e193d7a942 perf: 完善 yaml 加载 2023-12-05 17:25:25 +08:00
fit2bot
d2429f7883 feat: 支持 virtual app (#12199)
* feat: 支持 virtual app

* perf: 增加 virtual host

* perf: 新增 virtual app 上传接口

* perf: 更名为 app provider

* perf: 优化代码

---------

Co-authored-by: Eric <xplzv@126.com>
2023-12-05 16:52:11 +08:00
ibuler
a43bb25b5a perf: 优化 applet 账号选择 2023-12-05 16:19:56 +08:00
ibuler
ffe3e8a70c perf: 优化 for tidb 2023-12-05 16:13:16 +08:00
ibuler
0e7e499a1e perf: 修改 labels 创建 2023-12-05 15:22:47 +08:00
ibuler
e812e3ff89 fix: 优化 endpoint 的 ipv6 支持 2023-12-05 14:56:05 +08:00
halo
d2eacad97b perf: 更新客户端 v2.1.0 2023-12-05 14:02:33 +08:00
fit2bot
8291a81efd perf: 支持全局的 labels (#12043)
* perf: 支持全局的 labels

* perf: stash

* stash

* stash

* stash

* stash

* perf: 优化 labels

* stash

* perf: add debug sql

* perf: 修改 labels

* perf: 优化提交

* perf: 优化提交 labels

* perf: 基本完成

* perf: 完成 labels 搜索

* perf: 优化 labels

* perf: 去掉不用 debug

---------

Co-authored-by: ibuler <ibuler@qq.com>
2023-12-05 11:16:34 +08:00
fit2bot
a91cb1afd5 feat: 系统设置可配置gpt (#12207)
* feat: 系统设置可配置gpt

* perf: 添加gpt的terminal config

---------

Co-authored-by: feng <1304903146@qq.com>
2023-12-05 10:58:19 +08:00
wangruidong
2cad97065f feat: 资产详情页面添加历史执行命令列表页面 2023-12-04 16:38:28 +08:00
fit2bot
cf18300360 fix: 添加Slack认证发送消息格式包 (#12229)
Co-authored-by: jiangweidong <weidong.jiang@fit2cloud.com>
2023-11-30 14:38:43 +08:00
wangruidong
3cd22f05d2 perf: 优化工单处理提示消息页面 2023-11-30 10:15:26 +08:00
吴小白
eee41008cc perf: 优化 celery health 判断 2023-11-30 10:09:42 +08:00
fit2bot
0fdae00722 perf: 支持slack通知和认证 (#12193)
* perf: 支持slack通知和认证

* perf: 生成迁移文件

* perf: 优化获取access_token逻辑

---------

Co-authored-by: jiangweidong <weidong.jiang@fit2cloud.com>
2023-11-29 17:45:44 +08:00
吴小白
575562c416 Merge pull request #12216 from jumpserver/pr@dev@patch_greenlet
build(deps): bump github.com/python-greenlet/greenlet from 2.0.2 to 3.0.1
2023-11-28 16:26:25 +08:00
吴小白
e2b7f67fdc build(deps): bump github.com/python-greenlet/greenlet from 2.0.2 to 3.0.1
Signed-off-by: 吴小白 <296015668@qq.com>
2023-11-28 16:14:48 +08:00
fit2bot
d2498c0d53 fix: sftp不能设置为默认存储 (#12213)
Co-authored-by: wangruidong <940853815@qq.com>
2023-11-28 15:21:40 +08:00
huailei
01e40fd238 Merge pull request #12211 from jumpserver/pr@dev@random
perf: 随机密码生成规则添加可排除字符选项
2023-11-28 14:49:35 +08:00
feng
370ef11486 perf: 随机密码生成规则添加可排除字符选项 2023-11-28 14:46:51 +08:00
ibuler
089cadeae3 perf: 优化 queryset count 2023-11-28 12:54:04 +08:00
wangruidong
6b748e5ac5 feat: 用户详情展示所有会话 2023-11-28 12:52:11 +08:00
fit2bot
6d611bbbbd feat: 作业中心数据库支持网域命令执行 (#12117)
Co-authored-by: jiangweidong <weidong.jiang@fit2cloud.com>
2023-11-27 11:22:34 +08:00
wangruidong
18670d493e perf: 优化工单处理提示消息页面 2023-11-27 11:14:27 +08:00
ibuler
ba38852354 perf: 优化跳转页 2023-11-24 17:00:39 +08:00
wangruidong
64f3509c8c feat: 支持备案配置 2023-11-24 13:55:47 +08:00
huailei
805c78c0de Merge pull request #12188 from jumpserver/pr@dev@perf_ldap_user_websocket
perf: ldap接口请求换成websocket连接
2023-11-23 15:09:15 +08:00
huailei
11accf8854 Merge pull request #12189 from jumpserver/pr@dev@translate
perf: 国际化翻译
2023-11-22 18:33:06 +08:00
feng
18f6ffe0ce perf: 国际化翻译 2023-11-22 18:30:56 +08:00
wangruidong
6b7119ea74 perf: ldap接口请求换成websocket连接 2023-11-22 16:56:31 +08:00
huailei
efc7ca1164 Merge pull request #12182 from jumpserver/pr@dev@translate
perf: 修改翻译
2023-11-22 11:12:45 +08:00
feng
a6de9bdde6 perf: 修改翻译 2023-11-22 11:09:16 +08:00
feng
6e7074ba40 fix: mysql 开始ssl后 再关闭测试失败 2023-11-20 15:38:53 +08:00
feng
2edcb2f2d3 fix: mysql 开启ssl 再关闭 测试可连接性失败 2023-11-20 10:52:23 +08:00
ibuler
07e1918fa1 perf: 优化延迟运行
fix: 延迟执行设置超时

perf: 修改 delay run

perf: 优化 delay_run 执行

perf: 修改 delay run
2023-11-20 10:29:51 +08:00
feng
452b383278 fix: redis 开启 ssl websocket连接失败 2023-11-20 10:23:21 +08:00
ibuler
ed92f10208 fix: 修复自动禁用非活跃用户任务 2023-11-17 15:41:16 +08:00
Chenyang Shen
e8331ca708 Merge pull request #12148 from jumpserver/pr@dev@fix_delete_debug_info
fix: 删除debug信息
2023-11-17 11:33:52 +08:00
Aaron3S
814130204a fix: 删除debug信息 2023-11-17 10:45:44 +08:00
吴小白
e7dc9a2f6f perf: 优化 Dockerfile 2023-11-17 10:39:17 +08:00
515 changed files with 23918 additions and 5862 deletions

View File

@@ -1,11 +1,35 @@
---
name: 需求建议
about: 提出针对本项目的想法和建议
title: "[Feature] "
title: "[Feature] 需求标题"
labels: 类型:需求
assignees:
- ibuler
- baijiangjie
---
**请描述您的需求或者改进建议.**
## 注意
_针对过于简单的需求描述不予考虑。请确保提供足够的细节和信息以支持功能的开发和实现。_
## 功能名称
[在这里输入功能的名称或标题]
## 功能描述
[在这里描述该功能的详细内容,包括其作用、目的和所需的功能]
## 用户故事(可选)
[如果适用,可以提供用户故事来更好地理解该功能的使用场景和用户期望]
## 功能要求
- [要求1描述该功能的具体要求如界面设计、交互逻辑等]
- [要求2描述该功能的另一个具体要求]
- [以此类推,列出所有相关的功能要求]
## 示例或原型(可选)
[如果有的话,提供该功能的示例或原型图以更好地说明功能的实现方式]
## 优先级
[描述该功能的优先级,如高、中、低,或使用数字等其他标识]
## 备注(可选)
[在这里添加任何其他相关信息或备注]

View File

@@ -1,22 +1,51 @@
---
name: Bug 提交
about: 提交产品缺陷帮助我们更好的改进
title: "[Bug] "
title: "[Bug] Bug 标题"
labels: 类型:Bug
assignees:
- baijiangjie
---
**JumpServer 版本( v2.28 之前的版本不再支持 )**
## 注意
**JumpServer 版本( v2.28 之前的版本不再支持 )** <br>
_针对过于简单的 Bug 描述不予考虑。请确保提供足够的细节和信息以支持 Bug 的复现和修复。_
## 当前使用的 JumpServer 版本 (必填)
[在这里输入当前使用的 JumpServer 的版本号]
## 使用的版本类型 (必填)
- [ ] 社区版
- [ ] 企业版
- [ ] 企业试用版
**浏览器版本**
## 版本安装方式 (必填)
- [ ] 在线安装 (一键命令)
- [ ] 离线安装 (下载离线包)
- [ ] All-in-One
- [ ] 1Panel 安装
- [ ] Kubernetes 安装
- [ ] 源码安装
## Bug 描述 (详细)
[在这里描述 Bug 的详细情况,包括其影响和出现的具体情况]
**Bug 描述**
## 复现步骤
1. [描述如何复现 Bug 的第一步]
2. [描述如何复现 Bug 的第二步]
3. [以此类推,列出所有复现 Bug 所需的步骤]
## 期望行为
[描述 Bug 出现时期望的系统行为或结果]
**Bug 重现步骤(有截图更好)**
1.
2.
3.
## 实际行为
[描述实际上发生了什么,以及 Bug 出现的具体情况]
## 系统环境
- 操作系统:[例如Windows 10, macOS Big Sur]
- 浏览器/应用版本:[如果适用,请提供相关版本信息]
- 其他相关环境信息:[如果有其他相关环境信息,请在此处提供]
## 附加信息(可选)
[在这里添加任何其他相关信息,如截图、错误信息等]

View File

@@ -1,10 +1,50 @@
---
name: 问题咨询
about: 提出针对本项目安装部署、使用及其他方面的相关问题
title: "[Question] "
title: "[Question] 问题标题"
labels: 类型:提问
assignees:
- baijiangjie
---
## 注意
**请描述您的问题.** <br>
**JumpServer 版本( v2.28 之前的版本不再支持 )** <br>
_针对过于简单的 Bug 描述不予考虑。请确保提供足够的细节和信息以支持 Bug 的复现和修复。_
## 当前使用的 JumpServer 版本 (必填)
[在这里输入当前使用的 JumpServer 的版本号]
## 使用的版本类型 (必填)
- [ ] 社区版
- [ ] 企业版
- [ ] 企业试用版
## 版本安装方式 (必填)
- [ ] 在线安装 (一键命令)
- [ ] 离线安装 (下载离线包)
- [ ] All-in-One
- [ ] 1Panel 安装
- [ ] Kubernetes 安装
- [ ] 源码安装
## 问题描述 (详细)
[在这里描述你遇到的问题]
## 背景信息
- 操作系统:[例如Windows 10, macOS Big Sur]
- 浏览器/应用版本:[如果适用,请提供相关版本信息]
- 其他相关环境信息:[如果有其他相关环境信息,请在此处提供]
## 具体问题
[在这里详细描述你的问题,包括任何相关细节或错误信息]
## 尝试过的解决方法
[如果你已经尝试过解决问题,请在这里列出你已经尝试过的解决方法]
## 预期结果
[描述你期望的解决方案或结果]
## 我们的期望
[描述你希望我们提供的帮助或支持]
**请描述您的问题.**

View File

@@ -1,26 +1,32 @@
name: "Run Build Test"
on:
push:
branches:
- pr@*
- repr@*
paths:
- 'Dockerfile'
- 'Dockerfile-*'
- 'pyproject.toml'
- 'poetry.lock'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/setup-qemu-action@v2
- name: Check Dockerfile
run: |
test -f Dockerfile-ce || cp -f Dockerfile Dockerfile-ce
- uses: docker/setup-buildx-action@v2
- uses: docker/build-push-action@v3
- name: Build CE Image
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: jumpserver/core-ce:test
file: Dockerfile-ce
tags: jumpserver/core-ce:test
platforms: linux/amd64
build-args: |
APT_MIRROR=http://deb.debian.org
PIP_MIRROR=https://pypi.org/simple
@@ -28,9 +34,22 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: LouisBrunner/checks-action@v1.5.0
if: always()
- name: Prepare EE Image
run: |
sed -i 's@^FROM registry.fit2cloud.com@# FROM registry.fit2cloud.com@g' Dockerfile-ee
sed -i 's@^COPY --from=build-xpack@# COPY --from=build-xpack@g' Dockerfile-ee
- name: Build EE Image
uses: docker/build-push-action@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Check Build
conclusion: ${{ job.status }}
context: .
push: false
file: Dockerfile-ee
tags: jumpserver/core-ee:test
platforms: linux/amd64
build-args: |
APT_MIRROR=http://deb.debian.org
PIP_MIRROR=https://pypi.org/simple
PIP_JMS_MIRROR=https://pypi.org/simple
cache-from: type=gha
cache-to: type=gha,mode=max

1
.gitignore vendored
View File

@@ -43,3 +43,4 @@ releashe
data/*
test.py
.history/
.test/

View File

@@ -19,11 +19,11 @@ ARG BUILD_DEPENDENCIES=" \
ARG DEPENDENCIES=" \
freetds-dev \
libpq-dev \
libffi-dev \
libjpeg-dev \
libkrb5-dev \
libldap2-dev \
libpq-dev \
libsasl2-dev \
libssl-dev \
libxml2-dev \
@@ -44,8 +44,8 @@ ARG TOOLS=" \
wget"
ARG APT_MIRROR=http://mirrors.ustc.edu.cn
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=core \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core-apt \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=core-apt \
sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
&& rm -f /etc/apt/apt.conf.d/docker-clean \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
@@ -63,9 +63,9 @@ RUN --mount=type=cache,target=/root/.cache \
--mount=type=bind,source=pyproject.toml,target=/opt/jumpserver/pyproject.toml \
set -ex \
&& python3 -m venv /opt/py3 \
&& . /opt/py3/bin/activate \
&& pip install poetry -i ${PIP_MIRROR} \
&& poetry config virtualenvs.create false \
&& . /opt/py3/bin/activate \
&& poetry install
FROM python:3.11-slim-bullseye
@@ -75,8 +75,10 @@ ENV LANG=zh_CN.UTF-8 \
ARG DEPENDENCIES=" \
libjpeg-dev \
libxmlsec1-openssl \
libx11-dev"
libpq-dev \
libx11-dev \
freerdp2-dev \
libxmlsec1-openssl"
ARG TOOLS=" \
ca-certificates \
@@ -85,6 +87,7 @@ ARG TOOLS=" \
default-mysql-client \
iputils-ping \
locales \
netcat-openbsd \
nmap \
openssh-client \
patch \
@@ -94,8 +97,8 @@ ARG TOOLS=" \
wget"
ARG APT_MIRROR=http://mirrors.ustc.edu.cn
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=core \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core-apt \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=core-apt \
sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \
&& rm -f /etc/apt/apt.conf.d/docker-clean \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
@@ -109,8 +112,17 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=core \
&& sed -i "s@# export @export @g" ~/.bashrc \
&& sed -i "s@# alias @alias @g" ~/.bashrc
ARG RECEPTOR_VERSION=v1.4.5
RUN set -ex \
&& wget -O /opt/receptor.tar.gz https://github.com/ansible/receptor/releases/download/${RECEPTOR_VERSION}/receptor_${RECEPTOR_VERSION/v/}_linux_${TARGETARCH}.tar.gz \
&& tar -xf /opt/receptor.tar.gz -C /usr/local/bin/ \
&& chown root:root /usr/local/bin/receptor \
&& chmod 755 /usr/local/bin/receptor \
&& rm -f /opt/receptor.tar.gz
COPY --from=stage-2 /opt/py3 /opt/py3
COPY --from=stage-1 /opt/jumpserver/release/jumpserver /opt/jumpserver
COPY --from=stage-1 /opt/jumpserver/release/jumpserver/apps/libs/ansible/ansible.cfg /etc/ansible/
WORKDIR /opt/jumpserver
@@ -118,7 +130,6 @@ ARG VERSION
ENV VERSION=$VERSION
VOLUME /opt/jumpserver/data
VOLUME /opt/jumpserver/logs
EXPOSE 8080

View File

@@ -94,7 +94,8 @@ JumpServer 堡垒机帮助企业以更安全的方式管控和登录各种类型
| [KoKo](https://github.com/jumpserver/koko) | <a href="https://github.com/jumpserver/koko/releases"><img alt="Koko release" src="https://img.shields.io/github/release/jumpserver/koko.svg" /></a> | JumpServer 字符协议 Connector 项目 |
| [Lion](https://github.com/jumpserver/lion-release) | <a href="https://github.com/jumpserver/lion-release/releases"><img alt="Lion release" src="https://img.shields.io/github/release/jumpserver/lion-release.svg" /></a> | JumpServer 图形协议 Connector 项目,依赖 [Apache Guacamole](https://guacamole.apache.org/) |
| [Razor](https://github.com/jumpserver/razor) | <img alt="Chen" src="https://img.shields.io/badge/release-私有发布-red" /> | JumpServer RDP 代理 Connector 项目 |
| [Tinker](https://github.com/jumpserver/tinker) | <img alt="Tinker" src="https://img.shields.io/badge/release-私有发布-red" /> | JumpServer 远程应用 Connector 项目 |
| [Tinker](https://github.com/jumpserver/tinker) | <img alt="Tinker" src="https://img.shields.io/badge/release-私有发布-red" /> | JumpServer 远程应用 Connector 项目 (Windows) |
| [Panda](https://github.com/jumpserver/Panda) | <img alt="Panda" src="https://img.shields.io/badge/release-私有发布-red" /> | JumpServer 远程应用 Connector 项目 (Linux) |
| [Magnus](https://github.com/jumpserver/magnus-release) | <a href="https://github.com/jumpserver/magnus-release/releases"><img alt="Magnus release" src="https://img.shields.io/github/release/jumpserver/magnus-release.svg" /> | JumpServer 数据库代理 Connector 项目 |
| [Chen](https://github.com/jumpserver/chen-release) | <a href="https://github.com/jumpserver/chen-release/releases"><img alt="Chen release" src="https://img.shields.io/github/release/jumpserver/chen-release.svg" /> | JumpServer Web DB 项目,替代原来的 OmniDB |
| [Kael](https://github.com/jumpserver/kael) | <a href="https://github.com/jumpserver/kael/releases"><img alt="Kael release" src="https://img.shields.io/github/release/jumpserver/kael.svg" /> | JumpServer 连接 GPT 资产的组件项目 |
@@ -112,7 +113,7 @@ JumpServer是一款安全产品请参考 [基本安全建议](https://docs.ju
## License & Copyright
Copyright (c) 2014-2023 飞致云 FIT2CLOUD, All rights reserved.
Copyright (c) 2014-2024 飞致云 FIT2CLOUD, All rights reserved.
Licensed under The GNU General Public License version 3 (GPLv3) (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at

View File

@@ -85,7 +85,7 @@ If you find a security problem, please contact us directly
- 400-052-0755
### License & Copyright
Copyright (c) 2014-2022 FIT2CLOUD Tech, Inc., All rights reserved.
Copyright (c) 2014-2024 FIT2CLOUD Tech, Inc., All rights reserved.
Licensed under The GNU General Public License version 3 (GPLv3) (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

View File

@@ -1,9 +1,13 @@
from django.db.models import Q
from rest_framework.generics import CreateAPIView
from rest_framework.response import Response
from accounts import serializers
from accounts.tasks import verify_accounts_connectivity_task, push_accounts_to_assets_task
from assets.exceptions import NotSupportedTemporarilyError
from accounts.models import Account
from accounts.permissions import AccountTaskActionPermission
from accounts.tasks import (
remove_accounts_task, verify_accounts_connectivity_task, push_accounts_to_assets_task
)
from authentication.permissions import UserConfirmation, ConfirmType
__all__ = [
'AccountsTaskCreateAPI',
@@ -12,40 +16,48 @@ __all__ = [
class AccountsTaskCreateAPI(CreateAPIView):
serializer_class = serializers.AccountTaskSerializer
permission_classes = (AccountTaskActionPermission,)
def check_permissions(self, request):
act = request.data.get('action')
if act == 'push':
code = 'accounts.push_account'
else:
code = 'accounts.verify_account'
has = request.user.has_perm(code)
if not has:
self.permission_denied(request)
def get_permissions(self):
act = self.request.data.get('action')
if act == 'remove':
self.permission_classes = [
AccountTaskActionPermission,
UserConfirmation.require(ConfirmType.PASSWORD)
]
return super().get_permissions()
@staticmethod
def get_account_ids(data, action):
account_type = 'gather_accounts' if action == 'remove' else 'accounts'
accounts = data.get(account_type, [])
account_ids = [str(a.id) for a in accounts]
if action == 'remove':
return account_ids
assets = data.get('assets', [])
asset_ids = [str(a.id) for a in assets]
ids = Account.objects.filter(
Q(id__in=account_ids) | Q(asset_id__in=asset_ids)
).distinct().values_list('id', flat=True)
return [str(_id) for _id in ids]
def perform_create(self, serializer):
data = serializer.validated_data
accounts = data.get('accounts', [])
params = data.get('params')
account_ids = [str(a.id) for a in accounts]
action = data['action']
ids = self.get_account_ids(data, action)
if data['action'] == 'push':
task = push_accounts_to_assets_task.delay(account_ids, params)
if action == 'push':
task = push_accounts_to_assets_task.delay(ids, data.get('params'))
elif action == 'remove':
task = remove_accounts_task.delay(ids)
elif action == 'verify':
task = verify_accounts_connectivity_task.delay(ids)
else:
account = accounts[0]
asset = account.asset
if not asset.auto_config['ansible_enabled'] or \
not asset.auto_config['ping_enabled']:
raise NotSupportedTemporarilyError()
task = verify_accounts_connectivity_task.delay(account_ids)
raise ValueError(f"Invalid action: {action}")
data = getattr(serializer, '_data', {})
data["task"] = task.id
setattr(serializer, '_data', data)
return task
def get_exception_handler(self):
def handler(e, context):
return Response({"error": str(e)}, status=401)
return handler

View File

@@ -18,9 +18,8 @@ __all__ = [
class AccountBackupPlanViewSet(OrgBulkModelViewSet):
model = AccountBackupAutomation
filter_fields = ('name',)
search_fields = filter_fields
ordering = ('name',)
filterset_fields = ('name',)
search_fields = filterset_fields
serializer_class = serializers.AccountBackupSerializer

View File

@@ -20,8 +20,8 @@ __all__ = [
class AutomationAssetsListApi(generics.ListAPIView):
model = BaseAutomation
serializer_class = serializers.AutomationAssetsSerializer
filter_fields = ("name", "address")
search_fields = filter_fields
filterset_fields = ("name", "address")
search_fields = filterset_fields
def get_object(self):
pk = self.kwargs.get('pk')

View File

@@ -6,9 +6,12 @@ from rest_framework.response import Response
from accounts import serializers
from accounts.const import AutomationTypes
from accounts.filters import ChangeSecretRecordFilterSet
from accounts.models import ChangeSecretAutomation, ChangeSecretRecord
from accounts.tasks import execute_automation_record_task
from authentication.permissions import UserConfirmation, ConfirmType
from orgs.mixins.api import OrgBulkModelViewSet, OrgGenericViewSet
from rbac.permissions import RBACPermission
from .base import (
AutomationAssetsListApi, AutomationRemoveAssetApi, AutomationAddAssetApi,
AutomationNodeAddRemoveApi, AutomationExecutionViewSet
@@ -24,35 +27,54 @@ __all__ = [
class ChangeSecretAutomationViewSet(OrgBulkModelViewSet):
model = ChangeSecretAutomation
filter_fields = ('name', 'secret_type', 'secret_strategy')
search_fields = filter_fields
filterset_fields = ('name', 'secret_type', 'secret_strategy')
search_fields = filterset_fields
serializer_class = serializers.ChangeSecretAutomationSerializer
class ChangeSecretRecordViewSet(mixins.ListModelMixin, OrgGenericViewSet):
serializer_class = serializers.ChangeSecretRecordSerializer
filterset_fields = ('asset_id', 'execution_id')
filterset_class = ChangeSecretRecordFilterSet
search_fields = ('asset__address',)
tp = AutomationTypes.change_secret
serializer_classes = {
'default': serializers.ChangeSecretRecordSerializer,
'secret': serializers.ChangeSecretRecordViewSecretSerializer,
}
rbac_perms = {
'execute': 'accounts.add_changesecretexecution',
'secret': 'accounts.view_changesecretrecord',
}
def get_permissions(self):
if self.action == 'secret':
self.permission_classes = [
RBACPermission,
UserConfirmation.require(ConfirmType.MFA)
]
return super().get_permissions()
def get_queryset(self):
return ChangeSecretRecord.objects.all()
@action(methods=['post'], detail=False, url_path='execute')
def execute(self, request, *args, **kwargs):
record_id = request.data.get('record_id')
record = self.get_queryset().filter(pk=record_id)
if not record:
record_ids = request.data.get('record_ids')
records = self.get_queryset().filter(id__in=record_ids)
execution_count = records.values_list('execution_id', flat=True).distinct().count()
if execution_count != 1:
return Response(
{'detail': 'record not found'},
status=status.HTTP_404_NOT_FOUND
{'detail': 'Only one execution is allowed to execute'},
status=status.HTTP_400_BAD_REQUEST
)
task = execute_automation_record_task.delay(record_id, self.tp)
task = execute_automation_record_task.delay(record_ids, self.tp)
return Response({'task': task.id}, status=status.HTTP_200_OK)
@action(methods=['get'], detail=True, url_path='secret')
def secret(self, request, *args, **kwargs):
instance = self.get_object()
serializer = self.get_serializer(instance)
return Response(serializer.data)
class ChangSecretExecutionViewSet(AutomationExecutionViewSet):
rbac_perms = (

View File

@@ -20,8 +20,8 @@ __all__ = [
class GatherAccountsAutomationViewSet(OrgBulkModelViewSet):
model = GatherAccountsAutomation
filter_fields = ('name',)
search_fields = filter_fields
filterset_fields = ('name',)
search_fields = filterset_fields
serializer_class = serializers.GatherAccountAutomationSerializer

View File

@@ -20,8 +20,8 @@ __all__ = [
class PushAccountAutomationViewSet(OrgBulkModelViewSet):
model = PushAccountAutomation
filter_fields = ('name', 'secret_type', 'secret_strategy')
search_fields = filter_fields
filterset_fields = ('name', 'secret_type', 'secret_strategy')
search_fields = filterset_fields
serializer_class = serializers.PushAccountAutomationSerializer

View File

@@ -3,13 +3,13 @@ import time
from collections import defaultdict, OrderedDict
from django.conf import settings
from openpyxl import Workbook
from rest_framework import serializers
from xlsxwriter import Workbook
from accounts.const.automation import AccountBackupType
from accounts.const import AccountBackupType
from accounts.models.automations.backup_account import AccountBackupAutomation
from accounts.notifications import AccountBackupExecutionTaskMsg, AccountBackupByObjStorageExecutionTaskMsg
from accounts.serializers import AccountSecretSerializer
from accounts.models.automations.backup_account import AccountBackupAutomation
from assets.const import AllTypes
from common.utils.file import encrypt_and_compress_zip_file, zip_files
from common.utils.timezone import local_now_filename, local_now_display
@@ -144,10 +144,11 @@ class AccountBackupHandler:
wb = Workbook(filename)
for sheet, data in data_map.items():
ws = wb.create_sheet(str(sheet))
for row in data:
ws.append(row)
wb.save(filename)
ws = wb.add_worksheet(str(sheet))
for row_index, row_data in enumerate(data):
for col_index, col_data in enumerate(row_data):
ws.write_string(row_index, col_index, col_data)
wb.close()
files.append(filename)
timedelta = round((time.time() - time_start), 2)
print('创建备份文件完成: 用时 {}s'.format(timedelta))
@@ -167,9 +168,8 @@ class AccountBackupHandler:
if not user.secret_key:
attachment_list = []
else:
password = user.secret_key.encode('utf8')
attachment = os.path.join(PATH, f'{plan_name}-{local_now_filename()}-{time.time()}.zip')
encrypt_and_compress_zip_file(attachment, password, files)
encrypt_and_compress_zip_file(attachment, user.secret_key, files)
attachment_list = [attachment, ]
AccountBackupExecutionTaskMsg(plan_name, user).publish(attachment_list)
print('邮件已发送至{}({})'.format(user, user.email))
@@ -190,7 +190,6 @@ class AccountBackupHandler:
attachment = os.path.join(PATH, f'{plan_name}-{local_now_filename()}-{time.time()}.zip')
if password:
print('\033[32m>>> 使用加密密码对文件进行加密中\033[0m')
password = password.encode('utf8')
encrypt_and_compress_zip_file(attachment, password, files)
else:
zip_files(attachment, files)

View File

@@ -1,7 +1,6 @@
- hosts: custom
gather_facts: no
vars:
asset_port: "{{ jms_asset.protocols | selectattr('name', 'equalto', 'ssh') | map(attribute='port') | first }}"
ansible_connection: local
ansible_become: false
@@ -9,7 +8,7 @@
- name: Test privileged account (paramiko)
ssh_ping:
login_host: "{{ jms_asset.address }}"
login_port: "{{ asset_port }}"
login_port: "{{ jms_asset.port }}"
login_user: "{{ jms_account.username }}"
login_password: "{{ jms_account.secret }}"
login_secret_type: "{{ jms_account.secret_type }}"
@@ -19,6 +18,8 @@
become_user: "{{ custom_become_user | default('') }}"
become_password: "{{ custom_become_password | default('') }}"
become_private_key_path: "{{ custom_become_private_key_path | default(None) }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
gateway_args: "{{ jms_asset.ansible_ssh_common_args | default(None) }}"
register: ping_info
delegate_to: localhost
@@ -27,7 +28,7 @@
login_user: "{{ jms_account.username }}"
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ asset_port }}"
login_port: "{{ jms_asset.port }}"
login_secret_type: "{{ jms_account.secret_type }}"
login_private_key_path: "{{ jms_account.private_key_path }}"
become: "{{ custom_become | default(False) }}"
@@ -49,10 +50,12 @@
login_user: "{{ account.username }}"
login_password: "{{ account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ asset_port }}"
login_port: "{{ jms_asset.port }}"
become: "{{ account.become.ansible_become | default(False) }}"
become_method: su
become_user: "{{ account.become.ansible_user | default('') }}"
become_password: "{{ account.become.ansible_password | default('') }}"
become_private_key_path: "{{ account.become.ansible_ssh_private_key_file | default(None) }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
gateway_args: "{{ jms_asset.ansible_ssh_common_args | default(None) }}"
delegate_to: localhost

View File

@@ -6,15 +6,27 @@ category:
type:
- all
method: change_secret
protocol: ssh
priority: 50
params:
- name: commands
type: list
label: '自定义命令'
label: "{{ 'Params commands label' | trans }}"
default: [ '' ]
help_text: '自定义命令中如需包含账号的 账号、密码、SSH 连接的用户密码 字段,<br />请使用 &#123;username&#125;、&#123;password&#125;、&#123;login_password&#125;格式,执行任务时会进行替换 。<br />比如针对 Cisco 主机进行改密,一般需要配置五条命令:<br />1. enable<br />2. &#123;login_password&#125;<br />3. configure terminal<br />4. username &#123;username&#125; privilege 0 password &#123;password&#125; <br />5. end'
help_text: "{{ 'Params commands help text' | trans }}"
i18n:
SSH account change secret:
zh: 使用 SSH 命令行自定义改密
ja: SSH コマンドライン方式でカスタムパスワード変更
en: Custom password change by SSH command line
zh: '使用 SSH 命令行自定义改密'
ja: 'SSH コマンドライン方式でカスタムパスワード変更'
en: 'Custom password change by SSH command line'
Params commands help text:
zh: '自定义命令中如需包含账号的 账号、密码、SSH 连接的用户密码 字段,<br />请使用 &#123;username&#125;、&#123;password&#125;、&#123;login_password&#125;格式,执行任务时会进行替换 。<br />比如针对 Cisco 主机进行改密,一般需要配置五条命令:<br />1. enable<br />2. &#123;login_password&#125;<br />3. configure terminal<br />4. username &#123;username&#125; privilege 0 password &#123;password&#125; <br />5. end'
ja: 'カスタム コマンドに SSH 接続用のアカウント番号、パスワード、ユーザー パスワード フィールドを含める必要がある場合は、<br />&#123;ユーザー名&#125;、&#123;パスワード&#125;、&#123;login_password& を使用してください。 # 125; 形式。タスクの実行時に置き換えられます。 <br />たとえば、Cisco ホストのパスワードを変更するには、通常、次の 5 つのコマンドを設定する必要があります:<br />1.enable<br />2.&#123;login_password&#125;<br />3 .ターミナルの設定<br / >4. ユーザー名 &#123;ユーザー名&#125; 権限 0 パスワード &#123;パスワード&#125; <br />5. 終了'
en: 'If the custom command needs to include the account number, password, and user password field for SSH connection,<br />Please use &#123;username&#125;, &#123;password&#125;, &#123;login_password&# 125; format, which will be replaced when executing the task. <br />For example, to change the password of a Cisco host, you generally need to configure five commands:<br />1. enable<br />2. &#123;login_password&#125;<br />3. configure terminal<br / >4. username &#123;username&#125; privilege 0 password &#123;password&#125; <br />5. end'
Params commands label:
zh: '自定义命令'
ja: 'カスタムコマンド'
en: 'Custom command'

View File

@@ -3,6 +3,7 @@
vars:
ansible_python_interpreter: /opt/py3/bin/python
db_name: "{{ jms_asset.spec_info.db_name }}"
check_ssl: "{{ jms_asset.spec_info.use_ssl and not jms_asset.spec_info.allow_invalid_cert }}"
tasks:
- name: Test MySQL connection
@@ -11,10 +12,10 @@
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
check_hostname: "{{ omit if not jms_asset.spec_info.use_ssl else jms_asset.spec_info.allow_invalid_cert }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) }}"
check_hostname: "{{ check_ssl if check_ssl else omit }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) if check_ssl else omit }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) if check_ssl else omit }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) if check_ssl else omit }}"
filter: version
register: db_info
@@ -28,10 +29,10 @@
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
check_hostname: "{{ omit if not jms_asset.spec_info.use_ssl else jms_asset.spec_info.allow_invalid_cert }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) }}"
check_hostname: "{{ check_ssl if check_ssl else omit }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) if check_ssl else omit }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) if check_ssl else omit }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) if check_ssl else omit }}"
name: "{{ account.username }}"
password: "{{ account.secret }}"
host: "%"
@@ -45,8 +46,8 @@
login_password: "{{ account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
check_hostname: "{{ omit if not jms_asset.spec_info.use_ssl else jms_asset.spec_info.allow_invalid_cert }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) }}"
check_hostname: "{{ check_ssl if check_ssl else omit }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) if check_ssl else omit }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) if check_ssl else omit }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) if check_ssl else omit }}"
filter: version

View File

@@ -39,3 +39,4 @@
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
login_database: "{{ jms_asset.spec_info.db_name }}"
mode: "{{ account.mode }}"

View File

@@ -85,6 +85,7 @@
become_user: "{{ account.become.ansible_user | default('') }}"
become_password: "{{ account.become.ansible_password | default('') }}"
become_private_key_path: "{{ account.become.ansible_ssh_private_key_file | default(None) }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
when: account.secret_type == "password"
delegate_to: localhost
@@ -95,5 +96,6 @@
login_user: "{{ account.username }}"
login_private_key_path: "{{ account.private_key_path }}"
gateway_args: "{{ jms_asset.ansible_ssh_common_args | default('') }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
when: account.secret_type == "ssh_key"
delegate_to: localhost

View File

@@ -85,6 +85,7 @@
become_user: "{{ account.become.ansible_user | default('') }}"
become_password: "{{ account.become.ansible_password | default('') }}"
become_private_key_path: "{{ account.become.ansible_ssh_private_key_file | default(None) }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
when: account.secret_type == "password"
delegate_to: localhost
@@ -95,5 +96,6 @@
login_user: "{{ account.username }}"
login_private_key_path: "{{ account.private_key_path }}"
gateway_args: "{{ jms_asset.ansible_ssh_common_args | default('') }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
when: account.secret_type == "ssh_key"
delegate_to: localhost

View File

@@ -5,6 +5,7 @@ method: change_secret
category: host
type:
- windows
priority: 49
params:
- name: groups
type: str

View File

@@ -4,11 +4,12 @@ from copy import deepcopy
from django.conf import settings
from django.utils import timezone
from openpyxl import Workbook
from django.utils.translation import gettext_lazy as _
from xlsxwriter import Workbook
from accounts.const import AutomationTypes, SecretType, SSHKeyStrategy, SecretStrategy
from accounts.const import AutomationTypes, SecretType, SSHKeyStrategy, SecretStrategy, ChangeSecretRecordStatusChoice
from accounts.models import ChangeSecretRecord
from accounts.notifications import ChangeSecretExecutionTaskMsg
from accounts.notifications import ChangeSecretExecutionTaskMsg, ChangeSecretFailedMsg
from accounts.serializers import ChangeSecretRecordBackUpSerializer
from assets.const import HostTypes
from common.utils import get_logger
@@ -26,7 +27,7 @@ class ChangeSecretManager(AccountBasePlaybookManager):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.record_id = self.execution.snapshot.get('record_id')
self.record_map = self.execution.snapshot.get('record_map', {})
self.secret_type = self.execution.snapshot.get('secret_type')
self.secret_strategy = self.execution.snapshot.get(
'secret_strategy', SecretStrategy.custom
@@ -118,14 +119,24 @@ class ChangeSecretManager(AccountBasePlaybookManager):
else:
new_secret = self.get_secret(secret_type)
if self.record_id is None:
if new_secret is None:
print(f'new_secret is None, account: {account}')
continue
asset_account_id = f'{asset.id}-{account.id}'
if asset_account_id not in self.record_map:
recorder = ChangeSecretRecord(
asset=asset, account=account, execution=self.execution,
old_secret=account.secret, new_secret=new_secret,
)
records.append(recorder)
else:
recorder = ChangeSecretRecord.objects.get(id=self.record_id)
record_id = self.record_map[asset_account_id]
try:
recorder = ChangeSecretRecord.objects.get(id=record_id)
except ChangeSecretRecord.DoesNotExist:
print(f"Record {record_id} not found")
continue
self.name_recorder_mapper[h['name']] = recorder
@@ -139,7 +150,7 @@ class ChangeSecretManager(AccountBasePlaybookManager):
'name': account.name,
'username': account.username,
'secret_type': secret_type,
'secret': new_secret,
'secret': account.escape_jinja2_syntax(new_secret),
'private_key_path': private_key_path,
'become': account.get_ansible_become_auth(),
}
@@ -153,24 +164,43 @@ class ChangeSecretManager(AccountBasePlaybookManager):
recorder = self.name_recorder_mapper.get(host)
if not recorder:
return
recorder.status = 'success'
recorder.status = ChangeSecretRecordStatusChoice.success.value
recorder.date_finished = timezone.now()
recorder.save()
account = recorder.account
if not account:
print("Account not found, deleted ?")
return
account.secret = recorder.new_secret
account.save(update_fields=['secret'])
account.date_updated = timezone.now()
max_retries = 3
retry_count = 0
while retry_count < max_retries:
try:
recorder.save()
account.save(update_fields=['secret', 'version', 'date_updated'])
break
except Exception as e:
retry_count += 1
if retry_count == max_retries:
self.on_host_error(host, str(e), result)
else:
print(f'retry {retry_count} times for {host} recorder save error: {e}')
time.sleep(1)
def on_host_error(self, host, error, result):
recorder = self.name_recorder_mapper.get(host)
if not recorder:
return
recorder.status = 'failed'
recorder.status = ChangeSecretRecordStatusChoice.failed.value
recorder.date_finished = timezone.now()
recorder.error = error
recorder.save()
try:
recorder.save()
except Exception as e:
print(f"\033[31m Save {host} recorder error: {e} \033[0m\n")
def on_runner_failed(self, runner, e):
logger.error("Account error: ", e)
@@ -182,23 +212,56 @@ class ChangeSecretManager(AccountBasePlaybookManager):
return False
return True
@staticmethod
def get_summary(recorders):
total, succeed, failed = 0, 0, 0
for recorder in recorders:
if recorder.status == ChangeSecretRecordStatusChoice.success.value:
succeed += 1
else:
failed += 1
total += 1
summary = _('Success: %s, Failed: %s, Total: %s') % (succeed, failed, total)
return summary
def run(self, *args, **kwargs):
if self.secret_type and not self.check_secret():
return
super().run(*args, **kwargs)
if self.record_id:
return
recorders = self.name_recorder_mapper.values()
recorders = list(recorders)
self.send_recorder_mail(recorders)
recorders = list(self.name_recorder_mapper.values())
summary = self.get_summary(recorders)
print(summary, end='')
if self.record_map:
return
failed_recorders = [
r for r in recorders
if r.status == ChangeSecretRecordStatusChoice.failed.value
]
def send_recorder_mail(self, recorders):
recipients = self.execution.recipients
if not recorders or not recipients:
recipients = User.objects.filter(id__in=list(recipients.keys()))
if not recipients:
return
recipients = User.objects.filter(id__in=list(recipients.keys()))
if failed_recorders:
name = self.execution.snapshot.get('name')
execution_id = str(self.execution.id)
_ids = [r.id for r in failed_recorders]
asset_account_errors = ChangeSecretRecord.objects.filter(
id__in=_ids).values_list('asset__name', 'account__username', 'error')
for user in recipients:
ChangeSecretFailedMsg(name, execution_id, user, asset_account_errors).publish()
if not recorders:
return
self.send_recorder_mail(recipients, recorders, summary)
def send_recorder_mail(self, recipients, recorders, summary):
name = self.execution.snapshot['name']
path = os.path.join(os.path.dirname(settings.BASE_DIR), 'tmp')
filename = os.path.join(path, f'{name}-{local_now_filename()}-{time.time()}.xlsx')
@@ -208,11 +271,10 @@ class ChangeSecretManager(AccountBasePlaybookManager):
for user in recipients:
attachments = []
if user.secret_key:
password = user.secret_key.encode('utf8')
attachment = os.path.join(path, f'{name}-{local_now_filename()}-{time.time()}.zip')
encrypt_and_compress_zip_file(attachment, password, [filename])
encrypt_and_compress_zip_file(attachment, user.secret_key, [filename])
attachments = [attachment]
ChangeSecretExecutionTaskMsg(name, user).publish(attachments)
ChangeSecretExecutionTaskMsg(name, user, summary).publish(attachments)
os.remove(filename)
@staticmethod
@@ -227,8 +289,9 @@ class ChangeSecretManager(AccountBasePlaybookManager):
rows.insert(0, header)
wb = Workbook(filename)
ws = wb.create_sheet('Sheet1')
for row in rows:
ws.append(row)
wb.save(filename)
ws = wb.add_worksheet('Sheet1')
for row_index, row_data in enumerate(rows):
for col_index, col_data in enumerate(row_data):
ws.write_string(row_index, col_index, col_data)
wb.close()
return True

View File

@@ -1,8 +1,9 @@
from .push_account.manager import PushAccountManager
from .change_secret.manager import ChangeSecretManager
from .verify_account.manager import VerifyAccountManager
from .backup_account.manager import AccountBackupManager
from .change_secret.manager import ChangeSecretManager
from .gather_accounts.manager import GatherAccountsManager
from .push_account.manager import PushAccountManager
from .remove_account.manager import RemoveAccountManager
from .verify_account.manager import VerifyAccountManager
from .verify_gateway_account.manager import VerifyGatewayAccountManager
from ..const import AutomationTypes
@@ -12,6 +13,7 @@ class ExecutionManager:
AutomationTypes.push_account: PushAccountManager,
AutomationTypes.change_secret: ChangeSecretManager,
AutomationTypes.verify_account: VerifyAccountManager,
AutomationTypes.remove_account: RemoveAccountManager,
AutomationTypes.gather_accounts: GatherAccountsManager,
AutomationTypes.verify_gateway_account: VerifyGatewayAccountManager,
# TODO 后期迁移到自动化策略中

View File

@@ -2,6 +2,7 @@
gather_facts: no
vars:
ansible_python_interpreter: /opt/py3/bin/python
check_ssl: "{{ jms_asset.spec_info.use_ssl and not jms_asset.spec_info.allow_invalid_cert }}"
tasks:
- name: Get info
@@ -10,10 +11,10 @@
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
check_hostname: "{{ omit if not jms_asset.spec_info.use_ssl else jms_asset.spec_info.allow_invalid_cert }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) }}"
check_hostname: "{{ check_ssl if check_ssl else omit }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) if check_ssl else omit }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) if check_ssl else omit }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) if check_ssl else omit }}"
filter: users
register: db_info

View File

@@ -1,9 +1,10 @@
- hosts: demo
gather_facts: no
tasks:
- name: Gather posix account
- name: Gather windows account
ansible.builtin.win_shell: net user
register: result
ignore_errors: true
- name: Define info by set_fact
ansible.builtin.set_fact:

View File

@@ -51,14 +51,22 @@ class GatherAccountsManager(AccountBasePlaybookManager):
data = self.generate_data(asset, result)
self.asset_account_info[asset] = data
@staticmethod
def get_nested_info(data, *keys):
for key in keys:
data = data.get(key, {})
if not data:
break
return data
def on_host_success(self, host, result):
info = result.get('debug', {}).get('res', {}).get('info', {})
info = self.get_nested_info(result, 'debug', 'res', 'info')
asset = self.host_asset_mapper.get(host)
if asset and info:
result = self.filter_success_result(asset.type, info)
self.collect_asset_account_info(asset, result)
else:
logger.error(f'Not found {host} info')
print(f'\033[31m Not found {host} info \033[0m\n')
def update_or_create_accounts(self):
for asset, data in self.asset_account_info.items():
@@ -72,7 +80,7 @@ class GatherAccountsManager(AccountBasePlaybookManager):
)
gathered_accounts.append(gathered_account)
if not self.is_sync_account:
return
continue
GatheredAccount.sync_accounts(gathered_accounts)
def run(self, *args, **kwargs):

View File

@@ -3,6 +3,7 @@
vars:
ansible_python_interpreter: /opt/py3/bin/python
db_name: "{{ jms_asset.spec_info.db_name }}"
check_ssl: "{{ jms_asset.spec_info.use_ssl and not jms_asset.spec_info.allow_invalid_cert }}"
tasks:
- name: Test MySQL connection
@@ -11,10 +12,10 @@
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
check_hostname: "{{ omit if not jms_asset.spec_info.use_ssl else jms_asset.spec_info.allow_invalid_cert }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) }}"
check_hostname: "{{ check_ssl if check_ssl else omit }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) if check_ssl else omit }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) if check_ssl else omit }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) if check_ssl else omit }}"
filter: version
register: db_info
@@ -28,10 +29,10 @@
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
check_hostname: "{{ omit if not jms_asset.spec_info.use_ssl else jms_asset.spec_info.allow_invalid_cert }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) }}"
check_hostname: "{{ check_ssl if check_ssl else omit }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) if check_ssl else omit }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) if check_ssl else omit }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) if check_ssl else omit }}"
name: "{{ account.username }}"
password: "{{ account.secret }}"
host: "%"
@@ -45,8 +46,8 @@
login_password: "{{ account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
check_hostname: "{{ omit if not jms_asset.spec_info.use_ssl else jms_asset.spec_info.allow_invalid_cert }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) }}"
check_hostname: "{{ check_ssl if check_ssl else omit }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) if check_ssl else omit }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) if check_ssl else omit }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) if check_ssl else omit }}"
filter: version

View File

@@ -39,3 +39,4 @@
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
login_database: "{{ jms_asset.spec_info.db_name }}"
mode: "{{ account.mode }}"

View File

@@ -85,6 +85,7 @@
become_user: "{{ account.become.ansible_user | default('') }}"
become_password: "{{ account.become.ansible_password | default('') }}"
become_private_key_path: "{{ account.become.ansible_ssh_private_key_file | default(None) }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
when: account.secret_type == "password"
delegate_to: localhost
@@ -95,6 +96,7 @@
login_user: "{{ account.username }}"
login_private_key_path: "{{ account.private_key_path }}"
gateway_args: "{{ jms_asset.ansible_ssh_common_args | default('') }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
when: account.secret_type == "ssh_key"
delegate_to: localhost

View File

@@ -9,7 +9,7 @@ params:
type: str
label: 'Sudo'
default: '/bin/whoami'
help_text: '使用逗号分隔多个命令,如: /bin/whoami,/sbin/ifconfig'
help_text: "{{ 'Params sudo help text' | trans }}"
- name: shell
type: str
@@ -18,19 +18,44 @@ params:
- name: home
type: str
label: '家目录'
label: "{{ 'Params home label' | trans }}"
default: ''
help_text: '默认家目录 /home/系统用户名: /home/username'
help_text: "{{ 'Params home help text' | trans }}"
- name: groups
type: str
label: '用户组'
label: "{{ 'Params groups label' | trans }}"
default: ''
help_text: '请输入用户组,多个用户组使用逗号分隔(需填写已存在的用户组)'
help_text: "{{ 'Params groups help text' | trans }}"
i18n:
Aix account push:
zh: 使用 Ansible 模块 user 执行 Aix 账号推送 (DES)
ja: Ansible user モジュールを使用して Aix アカウントをプッシュする (DES)
en: Using Ansible module user to push account (DES)
zh: '使用 Ansible 模块 user 执行 Aix 账号推送 (DES)'
ja: 'Ansible user モジュールを使用して Aix アカウントをプッシュする (DES)'
en: 'Using Ansible module user to push account (DES)'
Params sudo help text:
zh: '使用逗号分隔多个命令,如: /bin/whoami,/sbin/ifconfig'
ja: 'コンマで区切って複数のコマンドを入力してください。例: /bin/whoami,/sbin/ifconfig'
en: 'Use commas to separate multiple commands, such as: /bin/whoami,/sbin/ifconfig'
Params home help text:
zh: '默认家目录 /home/{账号用户名}'
ja: 'デフォルトのホームディレクトリ /home/{アカウントユーザ名}'
en: 'Default home directory /home/{account username}'
Params groups help text:
zh: '请输入用户组,多个用户组使用逗号分隔(需填写已存在的用户组)'
ja: 'グループを入力してください。複数のグループはコンマで区切ってください(既存のグループを入力してください)'
en: 'Please enter the group. Multiple groups are separated by commas (please enter the existing group)'
Params home label:
zh: '家目录'
ja: 'ホームディレクトリ'
en: 'Home'
Params groups label:
zh: '用户组'
ja: 'グループ'
en: 'Groups'

View File

@@ -85,6 +85,7 @@
become_user: "{{ account.become.ansible_user | default('') }}"
become_password: "{{ account.become.ansible_password | default('') }}"
become_private_key_path: "{{ account.become.ansible_ssh_private_key_file | default(None) }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
when: account.secret_type == "password"
delegate_to: localhost
@@ -95,6 +96,7 @@
login_user: "{{ account.username }}"
login_private_key_path: "{{ account.private_key_path }}"
gateway_args: "{{ jms_asset.ansible_ssh_common_args | default('') }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
when: account.secret_type == "ssh_key"
delegate_to: localhost

View File

@@ -10,7 +10,7 @@ params:
type: str
label: 'Sudo'
default: '/bin/whoami'
help_text: '使用逗号分隔多个命令,如: /bin/whoami,/sbin/ifconfig'
help_text: "{{ 'Params sudo help text' | trans }}"
- name: shell
type: str
@@ -20,18 +20,43 @@ params:
- name: home
type: str
label: '家目录'
label: "{{ 'Params home label' | trans }}"
default: ''
help_text: '默认家目录 /home/系统用户名: /home/username'
help_text: "{{ 'Params home help text' | trans }}"
- name: groups
type: str
label: '用户组'
label: "{{ 'Params groups label' | trans }}"
default: ''
help_text: '请输入用户组,多个用户组使用逗号分隔(需填写已存在的用户组)'
help_text: "{{ 'Params groups help text' | trans }}"
i18n:
Posix account push:
zh: 使用 Ansible 模块 user 执行账号推送 (sha512)
ja: Ansible user モジュールを使用してアカウントをプッシュする (sha512)
en: Using Ansible module user to push account (sha512)
zh: '使用 Ansible 模块 user 执行账号推送 (sha512)'
ja: 'Ansible user モジュールを使用してアカウントをプッシュする (sha512)'
en: 'Using Ansible module user to push account (sha512)'
Params sudo help text:
zh: '使用逗号分隔多个命令,如: /bin/whoami,/sbin/ifconfig'
ja: 'コンマで区切って複数のコマンドを入力してください。例: /bin/whoami,/sbin/ifconfig'
en: 'Use commas to separate multiple commands, such as: /bin/whoami,/sbin/ifconfig'
Params home help text:
zh: '默认家目录 /home/{账号用户名}'
ja: 'デフォルトのホームディレクトリ /home/{アカウントユーザ名}'
en: 'Default home directory /home/{account username}'
Params groups help text:
zh: '请输入用户组,多个用户组使用逗号分隔(需填写已存在的用户组)'
ja: 'グループを入力してください。複数のグループはコンマで区切ってください(既存のグループを入力してください)'
en: 'Please enter the group. Multiple groups are separated by commas (please enter the existing group)'
Params home label:
zh: '家目录'
ja: 'ホームディレクトリ'
en: 'Home'
Params groups label:
zh: '用户组'
ja: 'グループ'
en: 'Groups'

View File

@@ -10,10 +10,15 @@ params:
type: str
label: '用户组'
default: 'Users,Remote Desktop Users'
help_text: '请输入用户组,多个用户组使用逗号分隔(需填写已存在的用户组)'
help_text: "{{ 'Params groups help text' | trans }}"
i18n:
Windows account push:
zh: 使用 Ansible 模块 win_user 执行 Windows 账号推送
ja: Ansible win_user モジュールを使用して Windows アカウントをプッシュする
en: Using Ansible module win_user to push account
zh: '使用 Ansible 模块 win_user 执行 Windows 账号推送'
ja: 'Ansible win_user モジュールを使用して Windows アカウントをプッシュする'
en: 'Using Ansible module win_user to push account'
Params groups help text:
zh: '请输入用户组,多个用户组使用逗号分隔(需填写已存在的用户组)'
ja: 'グループを入力してください。複数のグループはコンマで区切ってください(既存のグループを入力してください)'
en: 'Please enter the group. Multiple groups are separated by commas (please enter the existing group)'

View File

@@ -5,15 +5,21 @@ method: push_account
category: host
type:
- windows
priority: 49
params:
- name: groups
type: str
label: '用户组'
default: 'Users,Remote Desktop Users'
help_text: '请输入用户组,多个用户组使用逗号分隔(需填写已存在的用户组)'
help_text: "{{ 'Params groups help text' | trans }}"
i18n:
Windows account push rdp verify:
zh: 使用 Ansible 模块 win_user 执行 Windows 账号推送 RDP 协议测试最后的可连接性
ja: Ansibleモジュールwin_userWindowsアカウントプッシュRDPプロトコルテストを実行する最後の接続性
en: Using the Ansible module win_user performs Windows account push RDP protocol testing for final connectivity
zh: '使用 Ansible 模块 win_user 执行 Windows 账号推送(最后使用 Python 模块 pyfreerdp 验证账号的可连接性'
ja: 'Ansible モジュール win_user を使用して Windows アカウントプッシュを実行します (最後に Python モジュール pyfreerdp を使用してアカウントの接続性を確認します)'
en: 'Use the Ansible module win_user to perform Windows account push (finally use the Python module pyfreerdp to verify the connectability of the account)'
Params groups help text:
zh: '请输入用户组,多个用户组使用逗号分隔(需填写已存在的用户组)'
ja: 'グループを入力してください。複数のグループはコンマで区切ってください(既存のグループを入力してください)'
en: 'Please enter the group. Multiple groups are separated by commas (please enter the existing group)'

View File

@@ -0,0 +1,21 @@
- hosts: mongodb
gather_facts: no
vars:
ansible_python_interpreter: /opt/py3/bin/python
tasks:
- name: "Remove account"
mongodb_user:
login_user: "{{ jms_account.username }}"
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
login_database: "{{ jms_asset.spec_info.db_name }}"
ssl: "{{ jms_asset.spec_info.use_ssl }}"
ssl_ca_certs: "{{ jms_asset.secret_info.ca_cert | default('') }}"
ssl_certfile: "{{ jms_asset.secret_info.client_key | default('') }}"
connection_options:
- tlsAllowInvalidHostnames: "{{ jms_asset.spec_info.allow_invalid_cert}}"
db: "{{ jms_asset.spec_info.db_name }}"
name: "{{ account.username }}"
state: absent

View File

@@ -0,0 +1,12 @@
id: remove_account_mongodb
name: "{{ 'MongoDB account remove' | trans }}"
category: database
type:
- mongodb
method: remove_account
i18n:
MongoDB account remove:
zh: 使用 Ansible 模块 mongodb 删除账号
ja: Ansible モジュール mongodb を使用してアカウントを削除する
en: Delete account using Ansible module mongodb

View File

@@ -0,0 +1,18 @@
- hosts: mysql
gather_facts: no
vars:
ansible_python_interpreter: /opt/py3/bin/python
tasks:
- name: "Remove account"
community.mysql.mysql_user:
login_user: "{{ jms_account.username }}"
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
check_hostname: "{{ check_ssl if check_ssl else omit }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) if check_ssl else omit }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) if check_ssl else omit }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) if check_ssl else omit }}"
name: "{{ account.username }}"
state: absent

View File

@@ -0,0 +1,14 @@
id: remove_account_mysql
name: "{{ 'MySQL account remove' | trans }}"
category: database
type:
- mysql
- mariadb
method: remove_account
i18n:
MySQL account remove:
zh: 使用 Ansible 模块 mysql_user 删除账号
ja: Ansible モジュール mysql_user を使用してアカウントを削除します
en: Use the Ansible module mysql_user to delete the account

View File

@@ -0,0 +1,16 @@
- hosts: oracle
gather_facts: no
vars:
ansible_python_interpreter: /opt/py3/bin/python
tasks:
- name: "Remove account"
oracle_user:
login_user: "{{ jms_account.username }}"
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
login_database: "{{ jms_asset.spec_info.db_name }}"
mode: "{{ jms_account.mode }}"
name: "{{ account.username }}"
state: absent

View File

@@ -0,0 +1,12 @@
id: remove_account_oracle
name: "{{ 'Oracle account remove' | trans }}"
category: database
type:
- oracle
method: remove_account
i18n:
Oracle account remove:
zh: 使用 Python 模块 oracledb 删除账号
ja: Python モジュール oracledb を使用してアカウントを検証する
en: Using Python module oracledb to verify account

View File

@@ -0,0 +1,15 @@
- hosts: postgresql
gather_facts: no
vars:
ansible_python_interpreter: /opt/py3/bin/python
tasks:
- name: "Remove account"
community.postgresql.postgresql_user:
login_user: "{{ jms_account.username }}"
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
db: "{{ jms_asset.spec_info.db_name }}"
name: "{{ account.username }}"
state: absent

View File

@@ -0,0 +1,12 @@
id: remove_account_postgresql
name: "{{ 'PostgreSQL account remove' | trans }}"
category: database
type:
- postgresql
method: remove_account
i18n:
PostgreSQL account remove:
zh: 使用 Ansible 模块 postgresql_user 删除账号
ja: Ansible モジュール postgresql_user を使用してアカウントを削除します
en: Use the Ansible module postgresql_user to delete the account

View File

@@ -0,0 +1,14 @@
- hosts: sqlserver
gather_facts: no
vars:
ansible_python_interpreter: /opt/py3/bin/python
tasks:
- name: "Remove account"
community.general.mssql_script:
login_user: "{{ jms_account.username }}"
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
name: "{{ jms_asset.spec_info.db_name }}"
script: "DROP USER {{ account.username }}"

View File

@@ -0,0 +1,12 @@
id: remove_account_sqlserver
name: "{{ 'SQLServer account remove' | trans }}"
category: database
type:
- sqlserver
method: remove_account
i18n:
SQLServer account remove:
zh: 使用 Ansible 模块 mssql 删除账号
ja: Ansible モジュール mssql を使用してアカウントを削除する
en: Use Ansible module mssql to delete account

View File

@@ -0,0 +1,26 @@
- hosts: demo
gather_facts: no
tasks:
- name: "Get user home directory path"
ansible.builtin.shell:
cmd: "getent passwd {{ account.username }} | cut -d: -f6"
register: user_home_dir
ignore_errors: yes
- name: "Check if user home directory exists"
ansible.builtin.stat:
path: "{{ user_home_dir.stdout }}"
register: home_dir
when: user_home_dir.stdout != ""
- name: "Rename user home directory if it exists"
ansible.builtin.command:
cmd: "mv {{ user_home_dir.stdout }} {{ user_home_dir.stdout }}.bak"
when: home_dir.stat | default(false) and user_home_dir.stdout != ""
- name: "Remove account"
ansible.builtin.user:
name: "{{ account.username }}"
state: absent
remove: "{{ home_dir.stat.exists }}"
when: home_dir.stat | default(false)

View File

@@ -0,0 +1,13 @@
id: remove_account_posix
name: "{{ 'Posix account remove' | trans }}"
category: host
type:
- linux
- unix
method: remove_account
i18n:
Posix account remove:
zh: 使用 Ansible 模块 user 删除账号
ja: Ansible モジュール ユーザーを使用してアカウントを削除します
en: Use the Ansible module user to delete the account

View File

@@ -0,0 +1,9 @@
- hosts: windows
gather_facts: no
tasks:
- name: "Remove account"
ansible.windows.win_user:
name: "{{ account.username }}"
state: absent
purge: yes
force: yes

View File

@@ -0,0 +1,13 @@
id: remove_account_windows
name: "{{ 'Windows account remove' | trans }}"
version: 1
method: remove_account
category: host
type:
- windows
i18n:
Windows account remove:
zh: 使用 Ansible 模块 win_user 删除账号
ja: Ansible モジュール win_user を使用してアカウントを削除する
en: Use the Ansible module win_user to delete an account

View File

@@ -0,0 +1,70 @@
import os
from copy import deepcopy
from django.db.models import QuerySet
from accounts.const import AutomationTypes
from accounts.models import Account
from common.utils import get_logger
from ..base.manager import AccountBasePlaybookManager
logger = get_logger(__name__)
class RemoveAccountManager(AccountBasePlaybookManager):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.host_account_mapper = {}
def prepare_runtime_dir(self):
path = super().prepare_runtime_dir()
ansible_config_path = os.path.join(path, 'ansible.cfg')
with open(ansible_config_path, 'w') as f:
f.write('[ssh_connection]\n')
f.write('ssh_args = -o ControlMaster=no -o ControlPersist=no\n')
return path
@classmethod
def method_type(cls):
return AutomationTypes.remove_account
def get_gather_accounts(self, privilege_account, gather_accounts: QuerySet):
gather_account_ids = self.execution.snapshot['gather_accounts']
gather_accounts = gather_accounts.filter(id__in=gather_account_ids)
gather_accounts = gather_accounts.exclude(
username__in=[privilege_account.username, 'root', 'Administrator']
)
return gather_accounts
def host_callback(self, host, asset=None, account=None, automation=None, path_dir=None, **kwargs):
if host.get('error'):
return host
gather_accounts = asset.gatheredaccount_set.all()
gather_accounts = self.get_gather_accounts(account, gather_accounts)
inventory_hosts = []
for gather_account in gather_accounts:
h = deepcopy(host)
h['name'] += '(' + gather_account.username + ')'
self.host_account_mapper[h['name']] = (asset, gather_account)
h['account'] = {'username': gather_account.username}
inventory_hosts.append(h)
return inventory_hosts
def on_host_success(self, host, result):
tuple_asset_gather_account = self.host_account_mapper.get(host)
if not tuple_asset_gather_account:
return
asset, gather_account = tuple_asset_gather_account
try:
Account.objects.filter(
asset_id=asset.id,
username=gather_account.username
).delete()
gather_account.delete()
except Exception as e:
print(f'\033[31m Delete account {gather_account.username} failed: {e} \033[0m\n')

View File

@@ -3,12 +3,13 @@
vars:
ansible_shell_type: sh
ansible_connection: local
ansible_python_interpreter: /opt/py3/bin/python
tasks:
- name: Verify account (pyfreerdp)
rdp_ping:
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.protocols | selectattr('name', 'equalto', 'rdp') | map(attribute='port') | first }}"
login_port: "{{ jms_asset.port }}"
login_user: "{{ account.username }}"
login_password: "{{ account.secret }}"
login_secret_type: "{{ account.secret_type }}"

View File

@@ -5,9 +5,11 @@ category:
type:
- windows
method: verify_account
protocol: rdp
priority: 1
i18n:
Windows rdp account verify:
zh: 使用 Python 模块 pyfreerdp 验证账号
ja: Python モジュール pyfreerdp を使用してアカウントを検証する
en: Using Python module pyfreerdp to verify account
zh: '使用 Python 模块 pyfreerdp 验证账号'
ja: 'Python モジュール pyfreerdp を使用してアカウントを検証する'
en: 'Using Python module pyfreerdp to verify account'

View File

@@ -9,7 +9,7 @@
- name: Verify account (paramiko)
ssh_ping:
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.protocols | selectattr('name', 'equalto', 'ssh') | map(attribute='port') | first }}"
login_port: "{{ jms_asset.port }}"
login_user: "{{ account.username }}"
login_password: "{{ account.secret }}"
login_secret_type: "{{ account.secret_type }}"
@@ -19,3 +19,5 @@
become_user: "{{ account.become.ansible_user | default('') }}"
become_password: "{{ account.become.ansible_password | default('') }}"
become_private_key_path: "{{ account.become.ansible_ssh_private_key_file | default(None) }}"
old_ssh_version: "{{ jms_asset.old_ssh_version | default(False) }}"
gateway_args: "{{ jms_asset.ansible_ssh_common_args | default(None) }}"

View File

@@ -6,9 +6,11 @@ category:
type:
- all
method: verify_account
protocol: ssh
priority: 50
i18n:
SSH account verify:
zh: 使用 Python 模块 paramiko 验证账号
ja: Python モジュール paramiko を使用してアカウントを検証する
en: Using Python module paramiko to verify account
zh: '使用 Python 模块 paramiko 验证账号'
ja: 'Python モジュール paramiko を使用してアカウントを検証する'
en: 'Using Python module paramiko to verify account'

View File

@@ -1,4 +1,4 @@
- hosts: mongdb
- hosts: mongodb
gather_facts: no
vars:
ansible_python_interpreter: /opt/py3/bin/python

View File

@@ -2,6 +2,7 @@
gather_facts: no
vars:
ansible_python_interpreter: /opt/py3/bin/python
check_ssl: "{{ jms_asset.spec_info.use_ssl and not jms_asset.spec_info.allow_invalid_cert }}"
tasks:
- name: Verify account
@@ -10,8 +11,8 @@
login_password: "{{ account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
check_hostname: "{{ omit if not jms_asset.spec_info.use_ssl else jms_asset.spec_info.allow_invalid_cert }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) }}"
check_hostname: "{{ check_ssl if check_ssl else omit }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) if check_ssl else omit }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) if check_ssl else omit }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) if check_ssl else omit }}"
filter: version

View File

@@ -51,6 +51,9 @@ class VerifyAccountManager(AccountBasePlaybookManager):
h['name'] += '(' + account.username + ')'
self.host_account_mapper[h['name']] = account
secret = account.secret
if secret is None:
print(f'account {account.name} secret is None')
continue
private_key_path = None
if account.secret_type == SecretType.SSH_KEY:
@@ -62,7 +65,7 @@ class VerifyAccountManager(AccountBasePlaybookManager):
'name': account.name,
'username': account.username,
'secret_type': account.secret_type,
'secret': secret,
'secret': account.escape_jinja2_syntax(secret),
'private_key_path': private_key_path,
'become': account.get_ansible_become_auth(),
}
@@ -73,8 +76,14 @@ class VerifyAccountManager(AccountBasePlaybookManager):
def on_host_success(self, host, result):
account = self.host_account_mapper.get(host)
account.set_connectivity(Connectivity.OK)
try:
account.set_connectivity(Connectivity.OK)
except Exception as e:
print(f'\033[31m Update account {account.name} connectivity failed: {e} \033[0m\n')
def on_host_error(self, host, error, result):
account = self.host_account_mapper.get(host)
account.set_connectivity(Connectivity.ERR)
try:
account.set_connectivity(Connectivity.ERR)
except Exception as e:
print(f'\033[31m Update account {account.name} connectivity failed: {e} \033[0m\n')

View File

@@ -15,6 +15,7 @@ class AliasAccount(TextChoices):
INPUT = '@INPUT', _('Manual input')
USER = '@USER', _('Dynamic user')
ANON = '@ANON', _('Anonymous account')
SPEC = '@SPEC', _('Specified account')
@classmethod
def virtual_choices(cls):

View File

@@ -16,7 +16,7 @@ DEFAULT_PASSWORD_RULES = {
__all__ = [
'AutomationTypes', 'SecretStrategy', 'SSHKeyStrategy', 'Connectivity',
'DEFAULT_PASSWORD_LENGTH', 'DEFAULT_PASSWORD_RULES', 'TriggerChoice',
'PushAccountActionChoice', 'AccountBackupType'
'PushAccountActionChoice', 'AccountBackupType', 'ChangeSecretRecordStatusChoice',
]
@@ -24,6 +24,7 @@ class AutomationTypes(models.TextChoices):
push_account = 'push_account', _('Push account')
change_secret = 'change_secret', _('Change secret')
verify_account = 'verify_account', _('Verify account')
remove_account = 'remove_account', _('Remove account')
gather_accounts = 'gather_accounts', _('Gather accounts')
verify_gateway_account = 'verify_gateway_account', _('Verify gateway account')
@@ -102,3 +103,9 @@ class AccountBackupType(models.TextChoices):
email = 'email', _('Email')
# 目前只支持sftp方式
object_storage = 'object_storage', _('SFTP')
class ChangeSecretRecordStatusChoice(models.TextChoices):
failed = 'failed', _('Failed')
success = 'success', _('Success')
pending = 'pending', _('Pending')

View File

@@ -5,7 +5,7 @@ from django_filters import rest_framework as drf_filters
from assets.models import Node
from common.drf.filters import BaseFilterSet
from .models import Account, GatheredAccount
from .models import Account, GatheredAccount, ChangeSecretRecord
class AccountFilterSet(BaseFilterSet):
@@ -51,6 +51,8 @@ class AccountFilterSet(BaseFilterSet):
class GatheredAccountFilterSet(BaseFilterSet):
node_id = drf_filters.CharFilter(method='filter_nodes')
asset_id = drf_filters.CharFilter(field_name='asset_id', lookup_expr='exact')
asset_name = drf_filters.CharFilter(field_name='asset__name', lookup_expr='icontains')
@staticmethod
def filter_nodes(queryset, name, value):
@@ -58,4 +60,14 @@ class GatheredAccountFilterSet(BaseFilterSet):
class Meta:
model = GatheredAccount
fields = ['id', 'asset_id', 'username']
fields = ['id', 'username']
class ChangeSecretRecordFilterSet(BaseFilterSet):
asset_name = drf_filters.CharFilter(field_name='asset__name', lookup_expr='icontains')
account_username = drf_filters.CharFilter(field_name='account__username', lookup_expr='icontains')
execution_id = drf_filters.CharFilter(field_name='execution_id', lookup_expr='exact')
class Meta:
model = ChangeSecretRecord
fields = ['id', 'status', 'asset_id', 'execution']

View File

@@ -4,7 +4,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('accounts', '0006_gatheredaccount'),
]
@@ -12,6 +11,13 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterModelOptions(
name='account',
options={'permissions': [('view_accountsecret', 'Can view asset account secret'), ('view_historyaccount', 'Can view asset history account'), ('view_historyaccountsecret', 'Can view asset history account secret'), ('verify_account', 'Can verify account'), ('push_account', 'Can push account')], 'verbose_name': 'Account'},
options={'permissions': [
('view_accountsecret', 'Can view asset account secret'),
('view_historyaccount', 'Can view asset history account'),
('view_historyaccountsecret', 'Can view asset history account secret'),
('verify_account', 'Can verify account'),
('push_account', 'Can push account'),
('remove_account', 'Can remove account'),
], 'verbose_name': 'Account'},
),
]

View File

@@ -1,8 +1,9 @@
# Generated by Django 4.1.10 on 2023-08-01 09:12
from django.db import migrations, models
import uuid
from django.db import migrations, models
class Migration(migrations.Migration):
@@ -20,7 +21,7 @@ class Migration(migrations.Migration):
('date_updated', models.DateTimeField(auto_now=True, verbose_name='Date updated')),
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
('org_id', models.CharField(blank=True, db_index=True, default='', max_length=36, verbose_name='Organization')),
('alias', models.CharField(choices=[('@INPUT', 'Manual input'), ('@USER', 'Dynamic user'), ('@ANON', 'Anonymous account')], max_length=128, verbose_name='Alias')),
('alias', models.CharField(choices=[('@INPUT', 'Manual input'), ('@USER', 'Dynamic user'), ('@ANON', 'Anonymous account'), ('@SPEC', 'Specified account')], max_length=128, verbose_name='Alias')),
('secret_from_login', models.BooleanField(default=None, null=True, verbose_name='Secret from login')),
],
options={

View File

@@ -4,6 +4,7 @@ from simple_history.models import HistoricalRecords
from assets.models.base import AbsConnectivity
from common.utils import lazyproperty
from labels.mixins import LabeledMixin
from .base import BaseAccount
from .mixins import VaultModelMixin
from ..const import Source
@@ -42,7 +43,7 @@ class AccountHistoricalRecords(HistoricalRecords):
return super().create_history_model(model, inherited)
class Account(AbsConnectivity, BaseAccount):
class Account(AbsConnectivity, LabeledMixin, BaseAccount):
asset = models.ForeignKey(
'assets.Asset', related_name='accounts',
on_delete=models.CASCADE, verbose_name=_('Asset')
@@ -68,10 +69,15 @@ class Account(AbsConnectivity, BaseAccount):
('view_historyaccountsecret', _('Can view asset history account secret')),
('verify_account', _('Can verify account')),
('push_account', _('Can push account')),
('remove_account', _('Can remove account')),
]
def __str__(self):
return '{}'.format(self.username)
if self.asset_id:
host = self.asset.name
else:
host = 'Dynamic'
return '{}({})'.format(self.name, host)
@lazyproperty
def platform(self):
@@ -95,14 +101,13 @@ class Account(AbsConnectivity, BaseAccount):
""" 排除自己和以自己为 su-from 的账号 """
return self.asset.accounts.exclude(id=self.id).exclude(su_from=self)
@staticmethod
def make_account_ansible_vars(su_from):
def make_account_ansible_vars(self, su_from):
var = {
'ansible_user': su_from.username,
}
if not su_from.secret:
return var
var['ansible_password'] = su_from.secret
var['ansible_password'] = self.escape_jinja2_syntax(su_from.secret)
var['ansible_ssh_private_key_file'] = su_from.private_key_path
return var
@@ -119,9 +124,25 @@ class Account(AbsConnectivity, BaseAccount):
auth['ansible_become'] = True
auth['ansible_become_method'] = become_method
auth['ansible_become_user'] = self.username
auth['ansible_become_password'] = password
auth['ansible_become_password'] = self.escape_jinja2_syntax(password)
return auth
@staticmethod
def escape_jinja2_syntax(value):
if not isinstance(value, str):
return value
def escape(v):
v = v.replace('{{', '__TEMP_OPEN_BRACES__') \
.replace('}}', '__TEMP_CLOSE_BRACES__')
v = v.replace('__TEMP_OPEN_BRACES__', '{{ "{{" }}') \
.replace('__TEMP_CLOSE_BRACES__', '{{ "}}" }}')
return v.replace('{%', '{{ "{%" }}').replace('%}', '{{ "%}" }}')
return escape(value)
def replace_history_model_with_mixin():
"""

View File

@@ -8,7 +8,7 @@ from django.db import models
from django.db.models import F
from django.utils.translation import gettext_lazy as _
from accounts.const.automation import AccountBackupType
from accounts.const import AccountBackupType
from common.const.choices import Trigger
from common.db import fields
from common.db.encoder import ModelJSONFieldEncoder

View File

@@ -2,7 +2,7 @@ from django.db import models
from django.utils.translation import gettext_lazy as _
from accounts.const import (
AutomationTypes
AutomationTypes, ChangeSecretRecordStatusChoice
)
from common.db import fields
from common.db.models import JMSBaseModel
@@ -40,7 +40,10 @@ class ChangeSecretRecord(JMSBaseModel):
new_secret = fields.EncryptTextField(blank=True, null=True, verbose_name=_('New secret'))
date_started = models.DateTimeField(blank=True, null=True, verbose_name=_('Date started'))
date_finished = models.DateTimeField(blank=True, null=True, verbose_name=_('Date finished'))
status = models.CharField(max_length=16, default='pending', verbose_name=_('Status'))
status = models.CharField(
max_length=16, verbose_name=_('Status'),
default=ChangeSecretRecordStatusChoice.pending.value
)
error = models.TextField(blank=True, null=True, verbose_name=_('Error'))
class Meta:

View File

@@ -137,16 +137,13 @@ class BaseAccount(VaultModelMixin, JMSOrgBaseModel):
else:
return None
@property
def private_key_path(self):
def get_private_key_path(self, path):
if self.secret_type != SecretType.SSH_KEY \
or not self.secret \
or not self.private_key:
return None
project_dir = settings.PROJECT_DIR
tmp_dir = os.path.join(project_dir, 'tmp')
key_name = '.' + md5(self.private_key.encode('utf-8')).hexdigest()
key_path = os.path.join(tmp_dir, key_name)
key_path = os.path.join(path, key_name)
if not os.path.exists(key_path):
# https://github.com/ansible/ansible-runner/issues/544
# ssh requires OpenSSH format keys to have a full ending newline.
@@ -158,6 +155,12 @@ class BaseAccount(VaultModelMixin, JMSOrgBaseModel):
os.chmod(key_path, 0o400)
return key_path
@property
def private_key_path(self):
project_dir = settings.PROJECT_DIR
tmp_dir = os.path.join(project_dir, 'tmp')
return self.get_private_key_path(tmp_dir)
def get_private_key(self):
if not self.private_key:
return None

View File

@@ -3,13 +3,14 @@ from django.db.models import Count, Q
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from labels.mixins import LabeledMixin
from .account import Account
from .base import BaseAccount, SecretWithRandomMixin
__all__ = ['AccountTemplate', ]
class AccountTemplate(BaseAccount, SecretWithRandomMixin):
class AccountTemplate(LabeledMixin, BaseAccount, SecretWithRandomMixin):
su_from = models.ForeignKey(
'self', related_name='su_to', null=True,
on_delete=models.SET_NULL, verbose_name=_("Su from")

View File

@@ -1,10 +1,11 @@
from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _
from accounts.models import ChangeSecretRecord
from common.tasks import send_mail_attachment_async, upload_backup_to_obj_storage
from notifications.notifications import UserMessage
from users.models import User
from terminal.models.component.storage import ReplayStorage
from users.models import User
class AccountBackupExecutionTaskMsg(object):
@@ -23,8 +24,8 @@ class AccountBackupExecutionTaskMsg(object):
else:
return _("{} - The account backup passage task has been completed: "
"the encryption password has not been set - "
"please go to personal information -> file encryption password "
"to set the encryption password").format(name)
"please go to personal information -> Basic file encryption password for preference settings"
).format(name)
def publish(self, attachment_list=None):
send_mail_attachment_async(
@@ -54,20 +55,23 @@ class AccountBackupByObjStorageExecutionTaskMsg(object):
class ChangeSecretExecutionTaskMsg(object):
subject = _('Notification of implementation result of encryption change plan')
def __init__(self, name: str, user: User):
def __init__(self, name: str, user: User, summary):
self.name = name
self.user = user
self.summary = summary
@property
def message(self):
name = self.name
if self.user.secret_key:
return _('{} - The encryption change task has been completed. '
'See the attachment for details').format(name)
default_message = _('{} - The encryption change task has been completed. '
'See the attachment for details').format(name)
else:
return _("{} - The encryption change task has been completed: the encryption "
"password has not been set - please go to personal information -> "
"file encryption password to set the encryption password").format(name)
default_message = _("{} - The encryption change task has been completed: the encryption "
"password has not been set - please go to personal information -> "
"set encryption password in preferences").format(name)
return self.summary + '\n' + default_message
def publish(self, attachments=None):
send_mail_attachment_async(
@@ -95,3 +99,35 @@ class GatherAccountChangeMsg(UserMessage):
def gen_test_msg(cls):
user = User.objects.first()
return cls(user, {})
class ChangeSecretFailedMsg(UserMessage):
subject = _('Change secret or push account failed information')
def __init__(self, name, execution_id, user, asset_account_errors: list):
self.name = name
self.execution_id = execution_id
self.asset_account_errors = asset_account_errors
super().__init__(user)
def get_html_msg(self) -> dict:
context = {
'name': self.name,
'recipient': self.user,
'execution_id': self.execution_id,
'asset_account_errors': self.asset_account_errors
}
message = render_to_string('accounts/change_secret_failed_info.html', context)
return {
'subject': str(self.subject),
'message': message
}
@classmethod
def gen_test_msg(cls):
name = 'test'
user = User.objects.first()
record = ChangeSecretRecord.objects.first()
execution_id = str(record.execution_id)
return cls(name, execution_id, user, [])

View File

@@ -0,0 +1,19 @@
from rest_framework import permissions
def check_permissions(request):
act = request.data.get('action')
if act == 'push':
code = 'accounts.push_account'
elif act == 'remove':
code = 'accounts.remove_account'
else:
code = 'accounts.verify_account'
return request.user.has_perm(code)
class AccountTaskActionPermission(permissions.IsAuthenticated):
def has_permission(self, request, view):
return super().has_permission(request, view) \
and check_permissions(request)

View File

@@ -10,7 +10,7 @@ from rest_framework.generics import get_object_or_404
from rest_framework.validators import UniqueTogetherValidator
from accounts.const import SecretType, Source, AccountInvalidPolicy
from accounts.models import Account, AccountTemplate
from accounts.models import Account, AccountTemplate, GatheredAccount
from accounts.tasks import push_accounts_to_assets_task
from assets.const import Category, AllTypes
from assets.models import Asset
@@ -58,7 +58,7 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
for data in initial_data:
if not data.get('asset') and not self.instance:
raise serializers.ValidationError({'asset': UniqueTogetherValidator.missing_message})
asset = data.get('asset') or self.instance.asset
asset = data.get('asset') or getattr(self.instance, 'asset', None)
self.from_template_if_need(data)
self.set_uniq_name_if_need(data, asset)
@@ -66,6 +66,9 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
name = initial_data.get('name')
if name is not None:
return
request = self.context.get('request')
if request and request.method == 'PATCH':
return
if not name:
name = initial_data.get('username')
if self.instance and self.instance.name == name:
@@ -238,7 +241,7 @@ class AccountSerializer(AccountCreateUpdateSerializerMixin, BaseAccountSerialize
queryset = queryset.prefetch_related(
'asset', 'asset__platform',
'asset__platform__automation'
)
).prefetch_related('labels', 'labels__label')
return queryset
@@ -428,8 +431,11 @@ class AssetAccountBulkSerializer(
class AccountSecretSerializer(SecretReadableMixin, AccountSerializer):
class Meta(AccountSerializer.Meta):
fields = AccountSerializer.Meta.fields + ['spec_info']
extra_kwargs = {
**AccountSerializer.Meta.extra_kwargs,
'secret': {'write_only': False},
'spec_info': {'label': _('Spec info')},
}
@@ -452,14 +458,20 @@ class AccountHistorySerializer(serializers.ModelSerializer):
class AccountTaskSerializer(serializers.Serializer):
ACTION_CHOICES = (
('test', 'test'),
('verify', 'verify'),
('push', 'push'),
('remove', 'remove'),
)
action = serializers.ChoiceField(choices=ACTION_CHOICES, write_only=True)
assets = serializers.PrimaryKeyRelatedField(
queryset=Asset.objects, required=False, allow_empty=True, many=True
)
accounts = serializers.PrimaryKeyRelatedField(
queryset=Account.objects, required=False, allow_empty=True, many=True
)
gather_accounts = serializers.PrimaryKeyRelatedField(
queryset=GatheredAccount.objects, required=False, allow_empty=True, many=True
)
task = serializers.CharField(read_only=True)
params = serializers.JSONField(
decoder=None, encoder=None, required=False,

View File

@@ -5,6 +5,7 @@ from rest_framework import serializers
from accounts.const import SecretType
from accounts.models import BaseAccount
from accounts.utils import validate_password_for_ansible, validate_ssh_key
from common.serializers import ResourceLabelsMixin
from common.serializers.fields import EncryptedField, LabeledChoiceField
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
@@ -60,22 +61,20 @@ class AuthValidateMixin(serializers.Serializer):
return super().update(instance, validated_data)
class BaseAccountSerializer(AuthValidateMixin, BulkOrgResourceModelSerializer):
class BaseAccountSerializer(AuthValidateMixin, ResourceLabelsMixin, BulkOrgResourceModelSerializer):
class Meta:
model = BaseAccount
fields_mini = ['id', 'name', 'username']
fields_small = fields_mini + [
'secret_type', 'secret', 'passphrase',
'privileged', 'is_active', 'spec_info',
'privileged', 'is_active',
]
fields_other = ['created_by', 'date_created', 'date_updated', 'comment']
fields = fields_small + fields_other
fields = fields_small + fields_other + ['labels']
read_only_fields = [
'spec_info', 'date_verified', 'created_by', 'date_created',
'date_verified', 'created_by', 'date_created',
]
extra_kwargs = {
'spec_info': {'label': _('Spec info')},
'username': {'help_text': _(
"Tip: If no username is required for authentication, fill in `null`, "
"If AD account, like `username@domain`"

View File

@@ -15,6 +15,9 @@ class PasswordRulesSerializer(serializers.Serializer):
uppercase = serializers.BooleanField(default=True, label=_('Uppercase'))
digit = serializers.BooleanField(default=True, label=_('Digit'))
symbol = serializers.BooleanField(default=True, label=_('Special symbol'))
exclude_symbols = serializers.CharField(
default='', allow_blank=True, max_length=16, label=_('Exclude symbol')
)
class AccountTemplateSerializer(BaseAccountSerializer):
@@ -32,6 +35,7 @@ class AccountTemplateSerializer(BaseAccountSerializer):
'su_from'
]
extra_kwargs = {
**BaseAccountSerializer.Meta.extra_kwargs,
'secret_strategy': {'help_text': _('Secret generation strategy for account creation')},
'auto_push': {'help_text': _('Whether to automatically push the account to the asset')},
'platforms': {
@@ -61,6 +65,9 @@ class AccountTemplateSerializer(BaseAccountSerializer):
class AccountTemplateSecretSerializer(SecretReadableMixin, AccountTemplateSerializer):
class Meta(AccountTemplateSerializer.Meta):
fields = AccountTemplateSerializer.Meta.fields + ['spec_info']
extra_kwargs = {
**AccountTemplateSerializer.Meta.extra_kwargs,
'secret': {'write_only': False},
'spec_info': {'label': _('Spec info')},
}

View File

@@ -21,6 +21,7 @@ __all__ = [
class BaseAutomationSerializer(PeriodTaskSerializerMixin, BulkOrgResourceModelSerializer):
assets = ObjectRelatedField(many=True, required=False, queryset=Asset.objects, label=_('Assets'))
nodes = ObjectRelatedField(many=True, required=False, queryset=Node.objects, label=_('Nodes'))
is_periodic = serializers.BooleanField(default=False, required=False, label=_("Periodic perform"))
class Meta:
read_only_fields = [

View File

@@ -4,7 +4,8 @@ from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from accounts.const import (
AutomationTypes, SecretType, SecretStrategy, SSHKeyStrategy
AutomationTypes, SecretType, SecretStrategy,
SSHKeyStrategy, ChangeSecretRecordStatusChoice
)
from accounts.models import (
Account, ChangeSecretAutomation,
@@ -21,6 +22,7 @@ logger = get_logger(__file__)
__all__ = [
'ChangeSecretAutomationSerializer',
'ChangeSecretRecordSerializer',
'ChangeSecretRecordViewSecretSerializer',
'ChangeSecretRecordBackUpSerializer',
'ChangeSecretUpdateAssetSerializer',
'ChangeSecretUpdateNodeSerializer',
@@ -104,7 +106,10 @@ class ChangeSecretAutomationSerializer(AuthValidateMixin, BaseAutomationSerializ
class ChangeSecretRecordSerializer(serializers.ModelSerializer):
is_success = serializers.SerializerMethodField(label=_('Is success'))
asset = ObjectRelatedField(queryset=Asset.objects, label=_('Asset'))
account = ObjectRelatedField(queryset=Account.objects, label=_('Account'))
account = ObjectRelatedField(
queryset=Account.objects, label=_('Account'),
attrs=("id", "name", "username")
)
execution = ObjectRelatedField(
queryset=AutomationExecution.objects, label=_('Automation task execution')
)
@@ -119,7 +124,16 @@ class ChangeSecretRecordSerializer(serializers.ModelSerializer):
@staticmethod
def get_is_success(obj):
return obj.status == 'success'
return obj.status == ChangeSecretRecordStatusChoice.success.value
class ChangeSecretRecordViewSecretSerializer(serializers.ModelSerializer):
class Meta:
model = ChangeSecretRecord
fields = [
'id', 'old_secret', 'new_secret',
]
read_only_fields = fields
class ChangeSecretRecordBackUpSerializer(serializers.ModelSerializer):
@@ -145,7 +159,7 @@ class ChangeSecretRecordBackUpSerializer(serializers.ModelSerializer):
@staticmethod
def get_is_success(obj):
if obj.status == 'success':
if obj.status == ChangeSecretRecordStatusChoice.success.value:
return _("Success")
return _("Failed")

View File

@@ -21,7 +21,8 @@ def on_account_pre_save(sender, instance, **kwargs):
if instance.version == 0:
instance.version = 1
else:
instance.version = instance.history.count()
history_account = instance.history.first()
instance.version = history_account.version + 1 if history_account else 0
@merge_delay_run(ttl=5)
@@ -62,7 +63,7 @@ def create_accounts_activities(account, action='create'):
def on_account_create_by_template(sender, instance, created=False, **kwargs):
if not created or instance.source != 'template':
return
push_accounts_if_need(accounts=(instance,))
push_accounts_if_need.delay(accounts=(instance,))
create_accounts_activities(instance, action='create')

View File

@@ -2,5 +2,6 @@ from .automation import *
from .backup_account import *
from .gather_accounts import *
from .push_account import *
from .remove_account import *
from .template import *
from .verify_account import *

View File

@@ -36,14 +36,14 @@ def execute_account_automation_task(pid, trigger, tp):
instance.execute(trigger)
def record_task_activity_callback(self, record_id, *args, **kwargs):
def record_task_activity_callback(self, record_ids, *args, **kwargs):
from accounts.models import ChangeSecretRecord
with tmp_to_root_org():
record = get_object_or_none(ChangeSecretRecord, id=record_id)
if not record:
records = ChangeSecretRecord.objects.filter(id__in=record_ids)
if not records:
return
resource_ids = [record.id]
org_id = record.execution.org_id
resource_ids = [str(i.id) for i in records]
org_id = records[0].execution.org_id
return resource_ids, org_id
@@ -51,22 +51,26 @@ def record_task_activity_callback(self, record_id, *args, **kwargs):
queue='ansible', verbose_name=_('Execute automation record'),
activity_callback=record_task_activity_callback
)
def execute_automation_record_task(record_id, tp):
def execute_automation_record_task(record_ids, tp):
from accounts.models import ChangeSecretRecord
task_name = gettext_noop('Execute automation record')
with tmp_to_root_org():
instance = get_object_or_none(ChangeSecretRecord, pk=record_id)
if not instance:
logger.error("No automation record found: {}".format(record_id))
records = ChangeSecretRecord.objects.filter(id__in=record_ids)
if not records:
logger.error('No automation record found: {}'.format(record_ids))
return
task_name = gettext_noop('Execute automation record')
record = records[0]
record_map = {f'{record.asset_id}-{record.account_id}': str(record.id) for record in records}
task_snapshot = {
'secret': instance.new_secret,
'secret_type': instance.execution.snapshot.get('secret_type'),
'accounts': [str(instance.account_id)],
'assets': [str(instance.asset_id)],
'params': {},
'record_id': record_id,
'record_map': record_map,
'secret': record.new_secret,
'secret_type': record.execution.snapshot.get('secret_type'),
'assets': [str(instance.asset_id) for instance in records],
'accounts': [str(instance.account_id) for instance in records],
}
with tmp_to_org(instance.execution.org_id):
with tmp_to_org(record.execution.org_id):
quickstart_automation_by_snapshot(task_name, tp, task_snapshot)

View File

@@ -0,0 +1,77 @@
import uuid
from collections import defaultdict
from celery import shared_task, current_task
from django.conf import settings
from django.db.models import Count
from django.utils.translation import gettext_noop, gettext_lazy as _
from accounts.const import AutomationTypes
from accounts.models import Account
from accounts.tasks.common import quickstart_automation_by_snapshot
from audits.const import ActivityChoices
from common.const.crontab import CRONTAB_AT_AM_TWO
from common.utils import get_logger
from ops.celery.decorator import register_as_period_task
from orgs.utils import tmp_to_root_org
logger = get_logger(__file__)
__all__ = ['remove_accounts_task']
@shared_task(
queue="ansible", verbose_name=_('Remove account'),
activity_callback=lambda self, gather_account_ids, *args, **kwargs: (gather_account_ids, None)
)
def remove_accounts_task(gather_account_ids):
from accounts.models import GatheredAccount
gather_accounts = GatheredAccount.objects.filter(
id__in=gather_account_ids
)
task_name = gettext_noop("Remove account")
task_snapshot = {
'assets': [str(i.asset_id) for i in gather_accounts],
'gather_accounts': [str(i.id) for i in gather_accounts],
}
tp = AutomationTypes.remove_account
quickstart_automation_by_snapshot(task_name, tp, task_snapshot)
@shared_task(verbose_name=_('Clean historical accounts'))
@register_as_period_task(crontab=CRONTAB_AT_AM_TWO)
@tmp_to_root_org()
def clean_historical_accounts():
from audits.signal_handlers import create_activities
print("Clean historical accounts start.")
if settings.HISTORY_ACCOUNT_CLEAN_LIMIT >= 999:
return
limit = settings.HISTORY_ACCOUNT_CLEAN_LIMIT
history_ids_to_be_deleted = []
history_model = Account.history.model
history_id_mapper = defaultdict(list)
ids = history_model.objects.values('id').annotate(count=Count('id')) \
.filter(count__gte=limit).values_list('id', flat=True)
if not ids:
return
for i in history_model.objects.filter(id__in=ids):
_id = str(i.id)
history_id_mapper[_id].append(i.history_id)
for history_ids in history_id_mapper.values():
history_ids_to_be_deleted.extend(history_ids[limit:])
history_qs = history_model.objects.filter(history_id__in=history_ids_to_be_deleted)
resource_ids = list(history_qs.values_list('history_id', flat=True))
history_qs.delete()
task_id = current_task.request.id if current_task else str(uuid.uuid4())
detail = gettext_noop('Remove historical accounts that are out of range.')
create_activities(resource_ids, detail, task_id, action=ActivityChoices.task, org_id='')

View File

@@ -29,7 +29,8 @@ def template_sync_related_accounts(template_id, user_id=None):
name = template.name
username = template.username
secret_type = template.secret_type
print(f'\033[32m>>> 开始同步模版名称、用户名、密钥类型到相关联的账号 ({datetime.now().strftime("%Y-%m-%d %H:%M:%S")})')
print(
f'\033[32m>>> 开始同步模板名称、用户名、密钥类型到相关联的账号 ({datetime.now().strftime("%Y-%m-%d %H:%M:%S")})')
with tmp_to_org(org_id):
for account in accounts:
account.name = name

View File

@@ -1,10 +1,10 @@
{% load i18n %}
<h3>{% trans 'Gather account change information' %}</h3>
<table style="width: 100%; border-collapse: collapse; max-width: 100%; text-align: left; margin-top: 20px;">
<caption></caption>
<tr style="background-color: #f2f2f2;">
<th style="border: 1px solid #ddd; padding: 10px; font-weight: bold;">{% trans 'Asset' %}</th>
<th style="border: 1px solid #ddd; padding: 10px;">{% trans 'Asset' %}</th>
<th style="border: 1px solid #ddd; padding: 10px;">{% trans 'Added account' %}</th>
<th style="border: 1px solid #ddd; padding: 10px;">{% trans 'Deleted account' %}</th>
</tr>

View File

@@ -0,0 +1,36 @@
{% load i18n %}
<h3>{% trans 'Task name' %}: {{ name }}</h3>
<h3>{% trans 'Task execution id' %}: {{ execution_id }}</h3>
<p>{% trans 'Respectful' %} {{ recipient }}</p>
<p>{% trans 'Hello! The following is the failure of changing the password of your assets or pushing the account. Please check and handle it in time.' %}</p>
<table style="width: 100%; border-collapse: collapse; max-width: 100%; text-align: left; margin-top: 20px;">
<caption></caption>
<thead>
<tr style="background-color: #f2f2f2;">
<th style="border: 1px solid #ddd; padding: 10px;">{% trans 'Asset' %}</th>
<th style="border: 1px solid #ddd; padding: 10px;">{% trans 'Account' %}</th>
<th style="border: 1px solid #ddd; padding: 10px;">{% trans 'Error' %}</th>
</tr>
</thead>
<tbody>
{% for asset_name, account_username, error in asset_account_errors %}
<tr>
<td style="border: 1px solid #ddd; padding: 10px;">{{ asset_name }}</td>
<td style="border: 1px solid #ddd; padding: 10px;">{{ account_username }}</td>
<td style="border: 1px solid #ddd; padding: 10px;">
<div style="
max-width: 90%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: block;"
title="{{ error }}"
>
{{ error }}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@@ -30,7 +30,8 @@ class SecretGenerator:
'lower': rules['lowercase'],
'upper': rules['uppercase'],
'digit': rules['digit'],
'special_char': rules['symbol']
'special_char': rules['symbol'],
'exclude_chars': rules.get('exclude_symbols', ''),
}
return random_string(**rules)
@@ -46,18 +47,10 @@ class SecretGenerator:
def validate_password_for_ansible(password):
""" 校验 Ansible 不支持的特殊字符 """
# validate password contains left double curly bracket
# check password not contains `{{`
# Ansible 推送的时候不支持
if '{{' in password or '}}' in password:
raise serializers.ValidationError(_('Password can not contains `{{` or `}}`'))
if '{%' in password or '%}' in password:
raise serializers.ValidationError(_('Password can not contains `{%` or `%}`'))
# Ansible Windows 推送的时候不支持
# if "'" in password:
# raise serializers.ValidationError(_("Password can not contains `'` "))
# if '"' in password:
# raise serializers.ValidationError(_('Password can not contains `"` '))
if password.startswith('{{') and password.endswith('}}'):
raise serializers.ValidationError(
_('If the password starts with {{` and ends with }} `, then the password is not allowed.')
)
def validate_ssh_key(ssh_key, passphrase=None):

View File

@@ -11,7 +11,7 @@ __all__ = ['CommandFilterACLViewSet', 'CommandGroupViewSet']
class CommandGroupViewSet(OrgBulkModelViewSet):
model = models.CommandGroup
filterset_fields = ('name', 'command_filters')
search_fields = filterset_fields
search_fields = ('name',)
serializer_class = serializers.CommandGroupSerializer

View File

@@ -1,6 +1,7 @@
from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _
from accounts.models import Account
from assets.models import Asset
from audits.models import UserLoginLog
from notifications.notifications import UserMessage
@@ -16,12 +17,11 @@ class UserLoginReminderMsg(UserMessage):
def get_html_msg(self) -> dict:
user_log = self.user_log
context = {
'ip': user_log.ip,
'city': user_log.city,
'username': user_log.username,
'recipient': self.user.username,
'recipient': self.user,
'user_agent': user_log.user_agent,
}
message = render_to_string('acls/user_login_reminder.html', context)
@@ -41,18 +41,21 @@ class UserLoginReminderMsg(UserMessage):
class AssetLoginReminderMsg(UserMessage):
subject = _('Asset login reminder')
def __init__(self, user, asset: Asset, login_user: User, account_username):
def __init__(self, user, asset: Asset, login_user: User, account: Account, input_username):
self.asset = asset
self.login_user = login_user
self.account_username = account_username
self.account = account
self.input_username = input_username
super().__init__(user)
def get_html_msg(self) -> dict:
context = {
'recipient': self.user.username,
'recipient': self.user,
'username': self.login_user.username,
'name': self.login_user.name,
'asset': str(self.asset),
'account': self.account_username,
'account': self.input_username,
'account_name': self.account.name,
}
message = render_to_string('acls/asset_login_reminder.html', context)

View File

@@ -1,10 +1,10 @@
{% load i18n %}
<h3>{% trans 'Respectful' %}{{ recipient }}</h3>
<h3>{% trans 'Respectful' %}: {{ recipient.name }}[{{ recipient.username }}]</h3>
<hr>
<p><strong>{% trans 'Username' %}:</strong> [{{ username }}]</p>
<p><strong>{% trans 'User' %}:</strong> [{{ name }}({{ username }})]</p>
<p><strong>{% trans 'Assets' %}:</strong> [{{ asset }}]</p>
<p><strong>{% trans 'Account' %}:</strong> [{{ account }}]</p>
<p><strong>{% trans 'Account' %}:</strong> [{{ account_name }}({{ account }})]</p>
<hr>
<p>{% trans 'The user has just logged in to the asset. Please ensure that this is an authorized operation. If you suspect that this is an unauthorized access, please take appropriate measures immediately.' %}</p>

View File

@@ -1,8 +1,8 @@
{% load i18n %}
<h3>{% trans 'Respectful' %}{{ recipient }}</h3>
<h3>{% trans 'Respectful' %}: {{ recipient.name }}[{{ recipient.username }}]</h3>
<hr>
<p><strong>{% trans 'Username' %}:</strong> [{{ username }}]</p>
<p><strong>{% trans 'User' %}:</strong> [{{ username }}]</p>
<p><strong>IP:</strong> [{{ ip }}]</p>
<p><strong>{% trans 'Login city' %}:</strong> [{{ city }}]</p>
<p><strong>{% trans 'User agent' %}:</strong> [{{ user_agent }}]</p>

View File

@@ -2,7 +2,6 @@ from .asset import *
from .category import *
from .domain import *
from .favorite_asset import *
from .label import *
from .mixin import *
from .node import *
from .platform import *

View File

@@ -3,7 +3,6 @@
from collections import defaultdict
import django_filters
from django.db.models import Q
from django.shortcuts import get_object_or_404
from django.utils.translation import gettext as _
from rest_framework import status
@@ -14,7 +13,7 @@ from rest_framework.status import HTTP_200_OK
from accounts.tasks import push_accounts_to_assets_task, verify_accounts_connectivity_task
from assets import serializers
from assets.exceptions import NotSupportedTemporarilyError
from assets.filters import IpInFilterBackend, LabelFilterBackend, NodeFilterBackend
from assets.filters import IpInFilterBackend, NodeFilterBackend
from assets.models import Asset, Gateway, Platform, Protocol
from assets.tasks import test_assets_connectivity_manual, update_assets_hardware_info_manual
from common.api import SuggestionMixin
@@ -22,7 +21,6 @@ from common.drf.filters import BaseFilterSet, AttrRulesFilterBackend
from common.utils import get_logger, is_uuid
from orgs.mixins import generics
from orgs.mixins.api import OrgBulkModelViewSet
from ..mixin import NodeFilterMixin
from ...notifications import BulkUpdatePlatformSkipAssetUserMsg
logger = get_logger(__file__)
@@ -33,8 +31,8 @@ __all__ = [
class AssetFilterSet(BaseFilterSet):
labels = django_filters.CharFilter(method='filter_labels')
platform = django_filters.CharFilter(method='filter_platform')
exclude_platform = django_filters.CharFilter(field_name="platform__name", lookup_expr='exact', exclude=True)
domain = django_filters.CharFilter(method='filter_domain')
type = django_filters.CharFilter(field_name="platform__type", lookup_expr="exact")
category = django_filters.CharFilter(field_name="platform__category", lookup_expr="exact")
@@ -64,7 +62,7 @@ class AssetFilterSet(BaseFilterSet):
class Meta:
model = Asset
fields = [
"id", "name", "address", "is_active", "labels",
"id", "name", "address", "is_active",
"type", "category", "platform",
]
@@ -87,25 +85,15 @@ class AssetFilterSet(BaseFilterSet):
value = value.split(',')
return queryset.filter(protocols__name__in=value).distinct()
@staticmethod
def filter_labels(queryset, name, value):
if ':' in value:
n, v = value.split(':', 1)
queryset = queryset.filter(labels__name=n, labels__value=v)
else:
q = Q(labels__name__contains=value) | Q(labels__value__contains=value)
queryset = queryset.filter(q).distinct()
return queryset
class AssetViewSet(SuggestionMixin, NodeFilterMixin, OrgBulkModelViewSet):
class AssetViewSet(SuggestionMixin, OrgBulkModelViewSet):
"""
API endpoint that allows Asset to be viewed or edited.
"""
model = Asset
filterset_class = AssetFilterSet
search_fields = ("name", "address", "comment")
ordering_fields = ('name', 'connectivity', 'platform', 'date_updated')
ordering_fields = ('name', 'address', 'connectivity', 'platform', 'date_updated', 'date_created')
serializer_classes = (
("default", serializers.AssetSerializer),
("platform", serializers.PlatformSerializer),
@@ -121,14 +109,12 @@ class AssetViewSet(SuggestionMixin, NodeFilterMixin, OrgBulkModelViewSet):
("sync_platform_protocols", "assets.change_asset"),
)
extra_filter_backends = [
LabelFilterBackend, IpInFilterBackend,
IpInFilterBackend,
NodeFilterBackend, AttrRulesFilterBackend
]
def get_queryset(self):
queryset = super().get_queryset() \
.prefetch_related('nodes', 'protocols') \
.select_related('platform', 'domain')
queryset = super().get_queryset()
if queryset.model is not Asset:
queryset = queryset.select_related('asset_ptr')
return queryset

View File

@@ -48,7 +48,7 @@ class AssetPermUserListApi(BaseAssetPermUserOrUserGroupListApi):
def get_queryset(self):
perms = self.get_asset_related_perms()
users = User.objects.filter(
users = User.get_queryset().filter(
Q(assetpermissions__in=perms) | Q(groups__assetpermissions__in=perms)
).distinct()
return users

View File

@@ -19,15 +19,19 @@ class DomainViewSet(OrgBulkModelViewSet):
model = Domain
filterset_fields = ("name",)
search_fields = filterset_fields
ordering = ('name',)
serializer_classes = {
'default': serializers.DomainSerializer,
'list': serializers.DomainListSerializer,
}
def get_serializer_class(self):
if self.request.query_params.get('gateway'):
return serializers.DomainWithGatewaySerializer
return serializers.DomainSerializer
return super().get_serializer_class()
def get_queryset(self):
return super().get_queryset().prefetch_related('assets')
def partial_update(self, request, *args, **kwargs):
kwargs['partial'] = True
return self.update(request, *args, **kwargs)
class GatewayViewSet(HostViewSet):

View File

@@ -1,43 +0,0 @@
# ~*~ coding: utf-8 ~*~
# Copyright (C) 2014-2018 Beijing DuiZhan Technology Co.,Ltd. All Rights Reserved.
#
# Licensed under the GNU General Public License v2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.gnu.org/licenses/gpl-2.0.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from django.db.models import Count
from common.utils import get_logger
from orgs.mixins.api import OrgBulkModelViewSet
from ..models import Label
from .. import serializers
logger = get_logger(__file__)
__all__ = ['LabelViewSet']
class LabelViewSet(OrgBulkModelViewSet):
model = Label
filterset_fields = ("name", "value")
search_fields = filterset_fields
serializer_class = serializers.LabelSerializer
def list(self, request, *args, **kwargs):
if request.query_params.get("distinct"):
self.serializer_class = serializers.LabelDistinctSerializer
self.queryset = self.queryset.values("name").distinct()
return super().list(request, *args, **kwargs)
def get_queryset(self):
self.queryset = Label.objects.prefetch_related(
'assets').annotate(asset_count=Count("assets"))
return self.queryset

View File

@@ -2,7 +2,7 @@ from typing import List
from rest_framework.request import Request
from assets.models import Node, Protocol
from assets.models import Node, Platform, Protocol
from assets.utils import get_node_from_request, is_query_node_all_assets
from common.utils import lazyproperty, timeit
@@ -71,37 +71,49 @@ class SerializeToTreeNodeMixin:
return 'file'
@timeit
def serialize_assets(self, assets, node_key=None, pid=None):
if node_key is None:
get_pid = lambda asset: getattr(asset, 'parent_key', '')
else:
get_pid = lambda asset: node_key
def serialize_assets(self, assets, node_key=None, get_pid=None):
if not get_pid and not node_key:
get_pid = lambda asset, platform: getattr(asset, 'parent_key', '')
sftp_asset_ids = Protocol.objects.filter(name='sftp') \
.values_list('asset_id', flat=True)
sftp_asset_ids = list(sftp_asset_ids)
data = [
{
sftp_asset_ids = set(sftp_asset_ids)
platform_map = {p.id: p for p in Platform.objects.all()}
data = []
root_assets_count = 0
for asset in assets:
platform = platform_map.get(asset.platform_id)
if not platform:
continue
pid = node_key or get_pid(asset, platform)
if not pid:
continue
# 根节点最多显示 1000 个资产
if pid.isdigit():
if root_assets_count > 1000:
continue
root_assets_count += 1
data.append({
'id': str(asset.id),
'name': asset.name,
'title': f'{asset.address}\n{asset.comment}',
'pId': pid or get_pid(asset),
'title': f'{asset.address}\n{asset.comment}'.strip(),
'pId': pid,
'isParent': False,
'open': False,
'iconSkin': self.get_icon(asset),
'iconSkin': self.get_icon(platform),
'chkDisabled': not asset.is_active,
'meta': {
'type': 'asset',
'data': {
'platform_type': asset.platform.type,
'platform_type': platform.type,
'org_name': asset.org_name,
'sftp': asset.id in sftp_asset_ids,
'name': asset.name,
'address': asset.address
},
}
}
for asset in assets
]
})
return data

View File

@@ -22,6 +22,7 @@ from orgs.utils import current_org
from rbac.permissions import RBACPermission
from .. import serializers
from ..models import Node
from ..signal_handlers import update_nodes_assets_amount
from ..tasks import (
update_node_assets_hardware_info_manual,
test_node_assets_connectivity_manual,
@@ -94,6 +95,7 @@ class NodeAddChildrenApi(generics.UpdateAPIView):
children = Node.objects.filter(id__in=node_ids)
for node in children:
node.parent = instance
update_nodes_assets_amount.delay(ttl=5, node_ids=(instance.id,))
return Response("OK")

View File

@@ -21,6 +21,7 @@ class AssetPlatformViewSet(JMSModelViewSet):
}
filterset_fields = ['name', 'category', 'type']
search_fields = ['name']
ordering = ['-internal', 'name']
rbac_perms = {
'categories': 'assets.view_platform',
'type_constraints': 'assets.view_platform',
@@ -29,7 +30,10 @@ class AssetPlatformViewSet(JMSModelViewSet):
}
def get_queryset(self):
queryset = super().get_queryset()
# 因为没有走分页逻辑,所以需要这里 prefetch
queryset = super().get_queryset().prefetch_related(
'protocols', 'automation', 'labels', 'labels__label',
)
queryset = queryset.filter(type__in=AllTypes.get_types_values())
return queryset

View File

@@ -126,6 +126,8 @@ class NodeChildrenAsTreeApi(SerializeToTreeNodeMixin, NodeChildrenApi):
include_assets = self.request.query_params.get('assets', '0') == '1'
if not self.instance or not include_assets:
return Asset.objects.none()
if self.instance.is_org_root():
return Asset.objects.none()
if query_all:
assets = self.instance.get_all_assets()
else:

View File

@@ -1,2 +1,2 @@
from .endpoint import ExecutionManager
from .methods import platform_automation_methods, filter_platform_methods
from .methods import platform_automation_methods, filter_platform_methods, sorted_methods

View File

@@ -12,11 +12,70 @@ from sshtunnel import SSHTunnelForwarder
from assets.automations.methods import platform_automation_methods
from common.utils import get_logger, lazyproperty, is_openssh_format_key, ssh_pubkey_gen
from ops.ansible import JMSInventory, PlaybookRunner, DefaultCallback
from ops.ansible import JMSInventory, DefaultCallback, SuperPlaybookRunner
from ops.ansible.interface import interface
logger = get_logger(__name__)
class SSHTunnelManager:
def __init__(self, *args, **kwargs):
self.gateway_servers = dict()
@staticmethod
def file_to_json(path):
with open(path, 'r') as f:
d = json.load(f)
return d
@staticmethod
def json_to_file(path, data):
with open(path, 'w') as f:
json.dump(data, f, indent=4, sort_keys=True)
def local_gateway_prepare(self, runner):
info = self.file_to_json(runner.inventory)
servers, not_valid = [], []
for k, host in info['all']['hosts'].items():
jms_asset, jms_gateway = host.get('jms_asset'), host.get('gateway')
if not jms_gateway:
continue
try:
server = SSHTunnelForwarder(
(jms_gateway['address'], jms_gateway['port']),
ssh_username=jms_gateway['username'],
ssh_password=jms_gateway['secret'],
ssh_pkey=jms_gateway['private_key_path'],
remote_bind_address=(jms_asset['address'], jms_asset['port'])
)
server.start()
except Exception as e:
err_msg = 'Gateway is not active: %s' % jms_asset.get('name', '')
print(f'\033[31m {err_msg} 原因: {e} \033[0m\n')
not_valid.append(k)
else:
local_bind_port = server.local_bind_port
host['ansible_host'] = jms_asset['address'] = host[
'login_host'] = interface.get_gateway_proxy_host()
host['ansible_port'] = jms_asset['port'] = host['login_port'] = local_bind_port
servers.append(server)
# 网域不可连接的,就不继续执行此资源的后续任务了
for a in set(not_valid):
info['all']['hosts'].pop(a)
self.json_to_file(runner.inventory, info)
self.gateway_servers[runner.id] = servers
def local_gateway_clean(self, runner):
servers = self.gateway_servers.get(runner.id, [])
for s in servers:
try:
s.stop()
except Exception:
pass
class PlaybookCallback(DefaultCallback):
def playbook_on_stats(self, event_data, **kwargs):
super().playbook_on_stats(event_data, **kwargs)
@@ -37,7 +96,6 @@ class BasePlaybookManager:
# 根据执行方式就行分组, 不同资产的改密、推送等操作可能会使用不同的执行方式
# 然后根据执行方式分组, 再根据 bulk_size 分组, 生成不同的 playbook
self.playbooks = []
self.gateway_servers = dict()
params = self.execution.snapshot.get('params')
self.params = params or {}
@@ -157,22 +215,19 @@ class BasePlaybookManager:
os.chmod(key_path, 0o400)
return key_path
def generate_inventory(self, platformed_assets, inventory_path):
def generate_inventory(self, platformed_assets, inventory_path, protocol):
inventory = JMSInventory(
assets=platformed_assets,
account_prefer=self.ansible_account_prefer,
account_policy=self.ansible_account_policy,
host_callback=self.host_callback,
task_type=self.__class__.method_type(),
protocol=protocol,
)
inventory.write_to_file(inventory_path)
def generate_playbook(self, platformed_assets, platform, sub_playbook_dir):
method_id = getattr(platform.automation, '{}_method'.format(self.__class__.method_type()))
method = self.method_id_meta_mapper.get(method_id)
if not method:
logger.error("Method not found: {}".format(method_id))
return
@staticmethod
def generate_playbook(method, sub_playbook_dir):
method_playbook_dir_path = method['dir']
sub_playbook_path = os.path.join(sub_playbook_dir, 'project', 'main.yml')
shutil.copytree(method_playbook_dir_path, os.path.dirname(sub_playbook_path))
@@ -204,12 +259,20 @@ class BasePlaybookManager:
sub_dir = '{}_{}'.format(platform.name, i)
playbook_dir = os.path.join(self.runtime_dir, sub_dir)
inventory_path = os.path.join(self.runtime_dir, sub_dir, 'hosts.json')
self.generate_inventory(_assets, inventory_path)
playbook_path = self.generate_playbook(_assets, platform, playbook_dir)
method_id = getattr(platform.automation, '{}_method'.format(self.__class__.method_type()))
method = self.method_id_meta_mapper.get(method_id)
if not method:
logger.error("Method not found: {}".format(method_id))
continue
protocol = method.get('protocol')
self.generate_inventory(_assets, inventory_path, protocol)
playbook_path = self.generate_playbook(method, playbook_dir)
if not playbook_path:
continue
runer = PlaybookRunner(
runer = SuperPlaybookRunner(
inventory_path,
playbook_path,
self.runtime_dir,
@@ -237,80 +300,28 @@ class BasePlaybookManager:
for host in hosts:
result = cb.host_results.get(host)
if state == 'ok':
self.on_host_success(host, result)
self.on_host_success(host, result.get('ok', ''))
elif state == 'skipped':
pass
else:
error = hosts.get(host)
self.on_host_error(host, error, result)
self.on_host_error(
host, error,
result.get('failures', '')
or result.get('dark', '')
)
def on_runner_failed(self, runner, e):
print("Runner failed: {} {}".format(e, self))
@staticmethod
def file_to_json(path):
with open(path, 'r') as f:
d = json.load(f)
return d
@staticmethod
def json_dumps(data):
return json.dumps(data, indent=4, sort_keys=True)
@staticmethod
def json_to_file(path, data):
with open(path, 'w') as f:
json.dump(data, f, indent=4, sort_keys=True)
def local_gateway_prepare(self, runner):
info = self.file_to_json(runner.inventory)
servers, not_valid = [], []
for k, host in info['all']['hosts'].items():
jms_asset, jms_gateway = host.get('jms_asset'), host.get('gateway')
if not jms_gateway:
continue
try:
server = SSHTunnelForwarder(
(jms_gateway['address'], jms_gateway['port']),
ssh_username=jms_gateway['username'],
ssh_password=jms_gateway['secret'],
ssh_pkey=jms_gateway['private_key_path'],
remote_bind_address=(jms_asset['address'], jms_asset['port'])
)
server.start()
except Exception as e:
err_msg = 'Gateway is not active: %s' % jms_asset.get('name', '')
print(f'\033[31m {err_msg} 原因: {e} \033[0m\n')
not_valid.append(k)
else:
host['ansible_host'] = jms_asset['address'] = '127.0.0.1'
host['ansible_port'] = jms_asset['port'] = server.local_bind_port
servers.append(server)
# 网域不可连接的,就不继续执行此资源的后续任务了
for a in set(not_valid):
info['all']['hosts'].pop(a)
self.json_to_file(runner.inventory, info)
self.gateway_servers[runner.id] = servers
def local_gateway_clean(self, runner):
servers = self.gateway_servers.get(runner.id, [])
for s in servers:
try:
s.stop()
except Exception:
pass
def before_runner_start(self, runner):
self.local_gateway_prepare(runner)
def after_runner_end(self, runner):
self.local_gateway_clean(runner)
def delete_runtime_dir(self):
if settings.DEBUG_DEV:
return
shutil.rmtree(self.runtime_dir)
shutil.rmtree(self.runtime_dir, ignore_errors=True)
def run(self, *args, **kwargs):
print(">>> 任务准备阶段\n")
@@ -326,14 +337,16 @@ class BasePlaybookManager:
for i, runner in enumerate(runners, start=1):
if len(runners) > 1:
print(">>> 开始执行第 {} 批任务".format(i))
self.before_runner_start(runner)
ssh_tunnel = SSHTunnelManager()
ssh_tunnel.local_gateway_prepare(runner)
try:
kwargs.update({"clean_workspace": False})
cb = runner.run(**kwargs)
self.on_runner_success(runner, cb)
except Exception as e:
self.on_runner_failed(runner, e)
finally:
self.after_runner_end(runner)
ssh_tunnel.local_gateway_clean(runner)
print('\n')
self.execution.status = 'success'
self.execution.date_finished = timezone.now()

View File

@@ -2,6 +2,7 @@
gather_facts: no
vars:
ansible_python_interpreter: /opt/py3/bin/python
check_ssl: "{{ jms_asset.spec_info.use_ssl and not jms_asset.spec_info.allow_invalid_cert }}"
tasks:
- name: Get info
@@ -10,10 +11,10 @@
login_password: "{{ jms_account.secret }}"
login_host: "{{ jms_asset.address }}"
login_port: "{{ jms_asset.port }}"
check_hostname: "{{ omit if not jms_asset.spec_info.use_ssl else jms_asset.spec_info.allow_invalid_cert }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) }}"
check_hostname: "{{ check_ssl if check_ssl else omit }}"
ca_cert: "{{ jms_asset.secret_info.ca_cert | default(omit) if check_ssl else omit }}"
client_cert: "{{ jms_asset.secret_info.client_cert | default(omit) if check_ssl else omit }}"
client_key: "{{ jms_asset.secret_info.client_key | default(omit) if check_ssl else omit }}"
filter: version
register: db_info

View File

@@ -7,6 +7,6 @@ type:
method: gather_facts
i18n:
Gather posix facts:
zh: 使用 Ansible 指令 gather_facts 从主机获取设备信息
en: Gather facts from asset using gather_facts
ja: gather_factsを使用してPosixから情報を収集する
zh: '使用 Ansible 指令 gather_facts 从主机获取设备信息'
en: 'Gather facts from asset using gather_facts'
ja: 'gather_factsを使用してPosixから情報を収集する'

Some files were not shown because too many files have changed in this diff Show More