feat: 操作审计语义动作标注落库并支持按语义动作筛选
- OperationDescription 新增 actionOf:捕获时由 method/resourceType/path 推导 语义动作键(login/logout/auth + create/update/delete/view + 子动作段 publish/restore/enable 等,activation 归并为 enable),AuditRecorder 落库 spec.action(AuditLogSpec 新增字段) - OperationAuditPlugin 注册 spec.action 索引,AuditLogFilters 白名单放行 fieldSelector=spec.action=...,查询与导出端点共用 - 前端 audit.ts:describeOperation 优先用落库 action(历史记录无标注仍由 method/path 现场推导,同样适用),导出 deriveAction 与 SEMANTIC_ACTIONS (键→中文标签,与后端同一套映射),展示短语统一由动作键推导 - 列表筛选栏新增「语义动作」下拉(7→8 列),buildQuery/重置/watch 接线 - 测试:后端 +10 例(actionOf 全分支、describeAction、落库断言、索引注册、 查询筛选)共 81 例;前端 +8 例(deriveAction、标注优先、选项完备性)共 39 例; gradle build 全绿 - 文档同步:设计文档 V2 行标记已实现(4.1 字段表/4.2 筛选/5 索引/7 局限)、 技术方案 D3 索引表与 5.2 节、两级 README 功能一览与已知局限
This commit is contained in:
@@ -10,7 +10,8 @@ Halo 2.x **操作审计插件**:回答"**谁、在什么时候、对什么资
|
|||||||
| 能力 | 说明 |
|
| 能力 | 说明 |
|
||||||
|---|---|
|
|---|---|
|
||||||
| 自动捕获 | 已登录用户对 `/apis/**` 的 POST/PUT/DELETE/PATCH,另捕获 `/login`、`/logout`(含登录失败) |
|
| 自动捕获 | 已登录用户对 `/apis/**` 的 POST/PUT/DELETE/PATCH,另捕获 `/login`、`/logout`(含登录失败) |
|
||||||
| Console 查看页 | 列表 + 七维筛选(操作者 / 资源类型 / 动作 / 结果 / 时间区间 / 关键字)+ 分页 + 只读详情抽屉(含原始 JSON) |
|
| 语义动作标注 | 捕获时标注语义动作键(登录/发布/恢复…),支持按其筛选;中文操作描述贯穿列表、详情与导出 |
|
||||||
|
| Console 查看页 | 列表 + 八维筛选(操作者 / 资源类型 / 动作 / 语义动作 / 结果 / 时间区间 / 关键字)+ 分页 + 只读详情抽屉(含原始 JSON) |
|
||||||
| 导出 CSV | 按当前筛选条件一键导出全部记录(后端全量流式生成 UTF-8 BOM CSV,Excel/WPS 直开不乱码) |
|
| 导出 CSV | 按当前筛选条件一键导出全部记录(后端全量流式生成 UTF-8 BOM CSV,Excel/WPS 直开不乱码) |
|
||||||
| 保留与清理 | 可配置保留天数(7 ~ ∞,默认 90),每日凌晨自动清理过期记录 |
|
| 保留与清理 | 可配置保留天数(7 ~ ∞,默认 90),每日凌晨自动清理过期记录 |
|
||||||
| 权限 | 默认仅超级管理员可见;附带只读角色模板 `role-template-audit-view`(verbs 仅 `get`/`list`) |
|
| 权限 | 默认仅超级管理员可见;附带只读角色模板 `role-template-audit-view`(verbs 仅 `get`/`list`) |
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ Halo 博客后台缺少操作追溯能力:文章被改、设置被动、评论
|
|||||||
| 时间 | 操作发生时间 |
|
| 时间 | 操作发生时间 |
|
||||||
| 操作者 | 用户名(登录失败暂记"未知用户") |
|
| 操作者 | 用户名(登录失败暂记"未知用户") |
|
||||||
| 动作 | HTTP 方法 |
|
| 动作 | HTTP 方法 |
|
||||||
|
| 语义动作 | 捕获时由方法与路径推导的语义动作键(如 `publish`),支持按其筛选 |
|
||||||
| 资源 | 从路径解析出的资源类型与名称(如 `Posts/xxx`) |
|
| 资源 | 从路径解析出的资源类型与名称(如 `Posts/xxx`) |
|
||||||
| 路径 | 完整请求路径 |
|
| 路径 | 完整请求路径 |
|
||||||
| 结果 | 响应状态码(成功/失败) |
|
| 结果 | 响应状态码(成功/失败) |
|
||||||
@@ -48,8 +49,8 @@ Halo 博客后台缺少操作追溯能力:文章被改、设置被动、评论
|
|||||||
|
|
||||||
Console 左侧菜单新增"操作审计"页:
|
Console 左侧菜单新增"操作审计"页:
|
||||||
|
|
||||||
- 列表:时间、操作者、动作、资源、结果、IP,索引分页查询
|
- 列表:时间、操作者、动作、资源、描述、结果、IP,索引分页查询
|
||||||
- 筛选:按操作者、资源类型、动作、结果、时间范围;关键字可模糊匹配资源名称/路径
|
- 筛选:按操作者、资源类型、动作、语义动作、结果、时间范围;关键字可模糊匹配资源名称/路径
|
||||||
- 详情:单条记录完整字段
|
- 详情:单条记录完整字段
|
||||||
- 只读:不提供任何删除/修改入口
|
- 只读:不提供任何删除/修改入口
|
||||||
|
|
||||||
@@ -69,14 +70,14 @@ Console 左侧菜单新增"操作审计"页:
|
|||||||
审计日志作为 Halo 自定义模型(Extension)存储,注册后自动获得存储与查询 API。
|
审计日志作为 Halo 自定义模型(Extension)存储,注册后自动获得存储与查询 API。
|
||||||
|
|
||||||
- 模型:`AuditLog`(group 用自有域名反写,如 `audit.<你的域名>`)
|
- 模型:`AuditLog`(group 用自有域名反写,如 `audit.<你的域名>`)
|
||||||
- 索引:操作者、资源类型、动作、结果、创建时间(支撑筛选与分页,避免内存分页);另含资源名称、完整路径两个索引,支撑关键字模糊筛选(4.2)
|
- 索引:操作者、资源类型、动作、语义动作、结果、创建时间(支撑筛选与分页,避免内存分页);另含资源名称、完整路径两个索引,支撑关键字模糊筛选(4.2)
|
||||||
- 存储由 Halo 统一管理
|
- 存储由 Halo 统一管理
|
||||||
|
|
||||||
## 6. 非目标(V2+ 展望)
|
## 6. 非目标(V2+ 展望)
|
||||||
|
|
||||||
| 功能 | 说明 | 阶段 |
|
| 功能 | 说明 | 阶段 |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| 语义动作标注 | 区分"发布/编辑/恢复"等中文动作 | V2 |
|
| 语义动作标注 | 区分"发布/编辑/恢复"等中文动作:捕获时由方法/路径推导语义动作键落库(`spec.action`,含索引),Console 按语义动作筛选,中文操作描述贯穿列表、详情与导出 CSV | V2 已实现 |
|
||||||
| 字段级变更 diff | 记录改了什么(需缓存请求体) | V2 |
|
| 字段级变更 diff | 记录改了什么(需缓存请求体) | V2 |
|
||||||
| 系统内部变更 | 定时发布等非 HTTP 触发的变更,执行者记"system" | V2 |
|
| 系统内部变更 | 定时发布等非 HTTP 触发的变更,执行者记"system" | V2 |
|
||||||
| 导出 CSV | 按筛选条件导出(后端全量流式生成 UTF-8 BOM CSV,Console 页一键下载) | V2 已实现 |
|
| 导出 CSV | 按筛选条件导出(后端全量流式生成 UTF-8 BOM CSV,Console 页一键下载) | V2 已实现 |
|
||||||
@@ -87,6 +88,7 @@ Console 左侧菜单新增"操作审计"页:
|
|||||||
|
|
||||||
- 登录失败时无法得知尝试的用户名(解析请求体留到 V2)
|
- 登录失败时无法得知尝试的用户名(解析请求体留到 V2)
|
||||||
- 系统内部触发的资源变更(如定时发布)暂不记录
|
- 系统内部触发的资源变更(如定时发布)暂不记录
|
||||||
|
- 按语义动作筛选仅覆盖标注落库后的记录:升级前写入的历史记录可正常展示(描述现场推导),但不会被语义动作筛选命中
|
||||||
- 超级管理员技术上仍可通过 API 删除审计记录(产品上不提供入口)
|
- 超级管理员技术上仍可通过 API 删除审计记录(产品上不提供入口)
|
||||||
- 审计写入失败静默降级为运行日志,不阻塞业务操作
|
- 审计写入失败静默降级为运行日志,不阻塞业务操作
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ public class AuditLog extends AbstractExtension {
|
|||||||
| `spec.username` | 按操作者筛选 |
|
| `spec.username` | 按操作者筛选 |
|
||||||
| `spec.resourceType` | 按资源类型筛选 |
|
| `spec.resourceType` | 按资源类型筛选 |
|
||||||
| `spec.method` | 按动作筛选(POST/PUT/DELETE/PATCH) |
|
| `spec.method` | 按动作筛选(POST/PUT/DELETE/PATCH) |
|
||||||
|
| `spec.action` | 按语义动作筛选(语义动作标注,捕获时由 method/path 推导落库,如 publish/restore) |
|
||||||
| `spec.statusCode` | 按结果筛选 |
|
| `spec.statusCode` | 按结果筛选 |
|
||||||
|
|
||||||
### D4 权限:只读 verbs 收紧
|
### D4 权限:只读 verbs 收紧
|
||||||
@@ -165,7 +166,7 @@ public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
|||||||
| 更深层子资源 | 取前两段,完整路径由 `path` 字段兜底 |
|
| 更深层子资源 | 取前两段,完整路径由 `path` 字段兜底 |
|
||||||
| `/login`、`/logout` | `resourceType = "auth"` |
|
| `/login`、`/logout` | `resourceType = "auth"` |
|
||||||
|
|
||||||
例:`/apis/api.content.halo.run/v1alpha1/posts/xyz` → `Posts / xyz`。完整性靠 `path` 字段保证,语义化标注留待 V2。
|
例:`/apis/api.content.halo.run/v1alpha1/posts/xyz` → `Posts / xyz`。完整性靠 `path` 字段保证;语义化标注已按 V2 规划实现——捕获时由 method/path 推导语义动作键落库(`spec.action`,`OperationDescription.actionOf`,与前端 `deriveAction` 同一套映射规则),展示描述(`describe`)与语义动作键共用同一推导,历史记录无标注时现场推导不受影响。
|
||||||
|
|
||||||
### 5.3 查询链路
|
### 5.3 查询链路
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ Halo 2.x 操作审计插件:回答"**谁、在什么时候、对什么资源
|
|||||||
- **操作记录**:已登录用户对后台 API(`/apis/**`)的全部写操作(POST/PUT/DELETE/PATCH),
|
- **操作记录**:已登录用户对后台 API(`/apis/**`)的全部写操作(POST/PUT/DELETE/PATCH),
|
||||||
一条通用规则覆盖文章、页面、评论、用户、设置、主题、插件启停、附件等所有管理面操作;
|
一条通用规则覆盖文章、页面、评论、用户、设置、主题、插件启停、附件等所有管理面操作;
|
||||||
另捕获 `/login`、`/logout`(登录成功/失败/登出)。
|
另捕获 `/login`、`/logout`(登录成功/失败/登出)。
|
||||||
- **审计日志查看**:Console 左侧菜单"操作审计"——列表 + 七维筛选(操作者/资源类型/动作/结果/
|
- **语义动作标注**:捕获时由方法/路径推导语义动作键落库(`spec.action`,如
|
||||||
时间区间/关键字)+ 分页 + 只读详情抽屉(含原始 JSON)。不提供任何删除/修改入口。
|
登录/新建/修改/删除/发布/恢复/启用),注册索引后支持按语义动作筛选;
|
||||||
|
中文操作描述由同一套推导生成,贯穿列表、详情与导出 CSV,历史记录同样适用。
|
||||||
|
- **审计日志查看**:Console 左侧菜单"操作审计"——列表 + 八维筛选(操作者/资源类型/动作/
|
||||||
|
语义动作/结果/时间区间/关键字)+ 分页 + 只读详情抽屉(含原始 JSON)。不提供任何删除/修改入口。
|
||||||
- **导出 CSV**:列表页「导出」按钮按当前筛选条件导出全部记录——后端全量流式生成
|
- **导出 CSV**:列表页「导出」按钮按当前筛选条件导出全部记录——后端全量流式生成
|
||||||
(UTF-8 BOM + `\r\n`,Excel/WPS 双击打开中文不乱码),列与界面一致(操作时间、操作者、
|
(UTF-8 BOM + `\r\n`,Excel/WPS 双击打开中文不乱码),列与界面一致(操作时间、操作者、
|
||||||
动作、资源类型、资源名称、路径、操作描述、结果、状态码、来源 IP、User-Agent),
|
动作、资源类型、资源名称、路径、操作描述、结果、状态码、来源 IP、User-Agent),
|
||||||
@@ -57,6 +60,8 @@ Console「插件 → 操作审计 → 设置」:
|
|||||||
|
|
||||||
- 登录失败时无法得知尝试的用户名(解析请求体留到 V2),记为"未知用户"。
|
- 登录失败时无法得知尝试的用户名(解析请求体留到 V2),记为"未知用户"。
|
||||||
- 系统内部触发的资源变更(如定时发布)暂不记录。
|
- 系统内部触发的资源变更(如定时发布)暂不记录。
|
||||||
|
- 按语义动作筛选仅覆盖标注落库后的记录:升级前写入的历史记录可正常展示(描述现场推导),
|
||||||
|
但不会被语义动作筛选命中。
|
||||||
- 超级管理员技术上仍可通过 API 删除审计记录(产品上不提供入口;角色模板已对普通授权
|
- 超级管理员技术上仍可通过 API 删除审计记录(产品上不提供入口;角色模板已对普通授权
|
||||||
角色收紧到 `get`/`list`)。
|
角色收紧到 `get`/`list`)。
|
||||||
- 审计写入失败静默降级为运行日志,不阻塞业务操作。
|
- 审计写入失败静默降级为运行日志,不阻塞业务操作。
|
||||||
@@ -75,9 +80,10 @@ Console「插件 → 操作审计 → 设置」:
|
|||||||
遍历全量,流式输出 CSV——升序保证导出期间并发写入不打乱分页边界。
|
遍历全量,流式输出 CSV——升序保证导出期间并发写入不打乱分页边界。
|
||||||
- 定时清理采用 Reactor 调度方案(技术方案风险项 #3 预案),不依赖 `@Scheduled`
|
- 定时清理采用 Reactor 调度方案(技术方案风险项 #3 预案),不依赖 `@Scheduled`
|
||||||
在插件上下文的可用性。
|
在插件上下文的可用性。
|
||||||
- 关于测试:`./gradlew test`(当前 71 个用例)覆盖捕获规则、资源解析、快照、直写降级、
|
- 关于测试:`./gradlew test`(当前 81 个用例)覆盖捕获规则、资源解析、快照、直写降级、
|
||||||
过滤器行为、查询端点参数校验、导出 CSV(BOM/表头/转义/注入防护/分批取数)、
|
过滤器行为、查询端点参数校验、导出 CSV(BOM/表头/转义/注入防护/分批取数)、
|
||||||
操作描述推导(与前端 describeOperation 用例一一对应)、设置缓存与保留期清理;Console UI 以 vitest 断言
|
操作描述与语义动作标注推导(与前端 describeOperation / deriveAction 用例一一对应)、
|
||||||
|
设置缓存与保留期清理;Console UI 以 vitest 断言
|
||||||
路由注册形态(必须挂在 `Root` 布局路由下,否则页面会全屏渲染)+ 类型检查 + 构建通过为准
|
路由注册形态(必须挂在 `Root` 布局路由下,否则页面会全屏渲染)+ 类型检查 + 构建通过为准
|
||||||
(技术方案 §7,MVP 不引入组件测试)。
|
(技术方案 §7,MVP 不引入组件测试)。
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -15,8 +15,8 @@ import run.halo.app.plugin.PluginContext;
|
|||||||
*
|
*
|
||||||
* <p>负责插件生命周期:
|
* <p>负责插件生命周期:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>启动时注册 {@code AuditLog} 模型与索引(操作者/资源类型/动作/结果/资源名称/路径,
|
* <li>启动时注册 {@code AuditLog} 模型与索引(操作者/资源类型/动作/语义动作/结果/
|
||||||
* 时间索引由 Halo 为所有模型自动注册),并启动保留期清理调度;</li>
|
* 资源名称/路径,时间索引由 Halo 为所有模型自动注册),并启动保留期清理调度;</li>
|
||||||
* <li>停止时注销模型、取消清理调度。</li>
|
* <li>停止时注销模型、取消清理调度。</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@@ -39,6 +39,7 @@ public class OperationAuditPlugin extends BasePlugin {
|
|||||||
addIndex(indexSpecs, "spec.username", String.class, log -> log.getSpec().getUsername());
|
addIndex(indexSpecs, "spec.username", String.class, log -> log.getSpec().getUsername());
|
||||||
addIndex(indexSpecs, "spec.resourceType", String.class, log -> log.getSpec().getResourceType());
|
addIndex(indexSpecs, "spec.resourceType", String.class, log -> log.getSpec().getResourceType());
|
||||||
addIndex(indexSpecs, "spec.method", String.class, log -> log.getSpec().getMethod());
|
addIndex(indexSpecs, "spec.method", String.class, log -> log.getSpec().getMethod());
|
||||||
|
addIndex(indexSpecs, "spec.action", String.class, log -> log.getSpec().getAction());
|
||||||
addIndex(indexSpecs, "spec.statusCode", Integer.class, log -> log.getSpec().getStatusCode());
|
addIndex(indexSpecs, "spec.statusCode", Integer.class, log -> log.getSpec().getStatusCode());
|
||||||
addIndex(indexSpecs, "spec.resourceName", String.class, log -> log.getSpec().getResourceName());
|
addIndex(indexSpecs, "spec.resourceName", String.class, log -> log.getSpec().getResourceName());
|
||||||
addIndex(indexSpecs, "spec.path", String.class, log -> log.getSpec().getPath());
|
addIndex(indexSpecs, "spec.path", String.class, log -> log.getSpec().getPath());
|
||||||
|
|||||||
+2
-2
@@ -22,8 +22,8 @@ import run.halo.app.extension.index.query.Queries;
|
|||||||
final class AuditLogFilters {
|
final class AuditLogFilters {
|
||||||
|
|
||||||
/** fieldSelector 支持等值筛选的字段白名单(与已注册索引一一对应)。 */
|
/** fieldSelector 支持等值筛选的字段白名单(与已注册索引一一对应)。 */
|
||||||
static final Set<String> FILTERABLE_FIELDS =
|
static final Set<String> FILTERABLE_FIELDS = Set.of("spec.username", "spec.resourceType",
|
||||||
Set.of("spec.username", "spec.resourceType", "spec.method", "spec.statusCode");
|
"spec.method", "spec.action", "spec.statusCode");
|
||||||
|
|
||||||
private AuditLogFilters() {
|
private AuditLogFilters() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ public class AuditLogSpec {
|
|||||||
/** HTTP 方法(动作),如 POST/PUT/DELETE/PATCH。 */
|
/** HTTP 方法(动作),如 POST/PUT/DELETE/PATCH。 */
|
||||||
private String method;
|
private String method;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 语义动作键(语义动作标注,产品设计 V2):捕获时由 method/path 推导落库
|
||||||
|
* (如 login/logout/create/update/delete/publish/restore),注册索引后支持
|
||||||
|
* 按语义动作筛选。升级前写入的历史记录无此字段,展示不受影响(现场推导)。
|
||||||
|
*/
|
||||||
|
private String action;
|
||||||
|
|
||||||
/** 资源类型(复数形式,如 posts/comments/users/auth)。 */
|
/** 资源类型(复数形式,如 posts/comments/users/auth)。 */
|
||||||
private String resourceType;
|
private String resourceType;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -48,8 +48,8 @@ public class AuditQueryEndpoint implements CustomEndpoint {
|
|||||||
return org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route()
|
return org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route()
|
||||||
.GET("auditlogs/-/query", this::query, builder -> builder
|
.GET("auditlogs/-/query", this::query, builder -> builder
|
||||||
.operationId("ListAuditLogs")
|
.operationId("ListAuditLogs")
|
||||||
.description("分页查询审计日志:支持等值筛选(fieldSelector)、"
|
.description("分页查询审计日志:支持等值筛选(fieldSelector,含 spec.action "
|
||||||
+ "关键字(resourceName/path 模糊)、结果(success/failure)、"
|
+ "语义动作)、关键字(resourceName/path 模糊)、结果(success/failure)、"
|
||||||
+ "时间区间(含边界)")
|
+ "时间区间(含边界)")
|
||||||
.build())
|
.build())
|
||||||
.GET("auditlogs/-/export", this::export, builder -> builder
|
.GET("auditlogs/-/export", this::export, builder -> builder
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ public class AuditRecorder {
|
|||||||
spec.setUsername(username != null ? username : AuditLogSpec.UNKNOWN_USERNAME);
|
spec.setUsername(username != null ? username : AuditLogSpec.UNKNOWN_USERNAME);
|
||||||
spec.setMethod(snapshot.getMethod());
|
spec.setMethod(snapshot.getMethod());
|
||||||
spec.setResourceType(resolved.resourceType());
|
spec.setResourceType(resolved.resourceType());
|
||||||
|
// 语义动作标注(产品设计 V2):捕获时推导落库,供按语义动作筛选
|
||||||
|
spec.setAction(OperationDescription.actionOf(
|
||||||
|
snapshot.getMethod(), resolved.resourceType(), snapshot.getPath()));
|
||||||
spec.setResourceName(resolved.optionalName().orElse(null));
|
spec.setResourceName(resolved.optionalName().orElse(null));
|
||||||
spec.setPath(snapshot.getFullPath());
|
spec.setPath(snapshot.getFullPath());
|
||||||
spec.setStatusCode(statusCode);
|
spec.setStatusCode(statusCode);
|
||||||
|
|||||||
+88
-36
@@ -7,11 +7,15 @@ import java.util.Map;
|
|||||||
* 操作描述(这条操作真正干了什么):由 method / resourceType / path 推导中文短语,
|
* 操作描述(这条操作真正干了什么):由 method / resourceType / path 推导中文短语,
|
||||||
* 如 登录、登出、新建用户、修改文章、发布文章、启用插件、修改密码。
|
* 如 登录、登出、新建用户、修改文章、发布文章、启用插件、修改密码。
|
||||||
*
|
*
|
||||||
* <p>与前端 {@code ui/src/utils/audit.ts} 的 {@code describeOperation} 保持一致
|
* <p>语义动作标注(产品设计 V2):捕获时由 {@link #actionOf} 推导语义动作键落库
|
||||||
* (同一套 RESOURCE_LABELS / METHOD_VERBS / SUB_ACTION_VERBS / SUB_ACTION_PHRASES
|
* ({@code spec.action},如 login/create/publish,可空),注册索引后支持按语义动作筛选;
|
||||||
* 映射与子动作解析规则),两处需同步修改。推导纯用于展示/导出,不落库:
|
* 展示/导出由 {@link #describe} 推导中文短语,历史记录(无 action 字段)同样按
|
||||||
* 历史记录同样适用;未识别的子动作回退为「动词 + 资源名」,
|
* method/path 现场推导,不受影响。
|
||||||
* 未识别的资源类型直接使用原始 resourceType。
|
*
|
||||||
|
* <p>与前端 {@code ui/src/utils/audit.ts} 的 {@code deriveAction} / {@code describeOperation}
|
||||||
|
* 保持一致(同一套 RESOURCE_LABELS / METHOD_ACTIONS / SEGMENT_ACTIONS / ACTION_PHRASES /
|
||||||
|
* ACTION_VERBS 映射与子动作解析规则),两处需同步修改。未识别的子动作回退为
|
||||||
|
* 「method 动词 + 资源名」,未识别的资源类型直接使用原始 resourceType。
|
||||||
*/
|
*/
|
||||||
final class OperationDescription {
|
final class OperationDescription {
|
||||||
|
|
||||||
@@ -32,19 +36,48 @@ final class OperationDescription {
|
|||||||
Map.entry("categories", "分类"),
|
Map.entry("categories", "分类"),
|
||||||
Map.entry("tags", "标签"));
|
Map.entry("tags", "标签"));
|
||||||
|
|
||||||
/** 动作方法的基础动词(未知方法回退原始值)。 */
|
/** 动作方法 → 语义动作键(未知方法无键)。 */
|
||||||
private static final Map<String, String> METHOD_VERBS = Map.of(
|
private static final Map<String, String> METHOD_ACTIONS = Map.of(
|
||||||
"POST", "新建",
|
"POST", "create",
|
||||||
"PUT", "修改",
|
"PUT", "update",
|
||||||
"PATCH", "修改",
|
"PATCH", "update",
|
||||||
"DELETE", "删除",
|
"DELETE", "delete",
|
||||||
"GET", "查看");
|
"GET", "view");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子资源动作段({@code /apis/.../{plural}/{name}/{action}} 的 action)→ 动词,
|
* 子资源动作段({@code /apis/.../{plural}/{name}/{action}} 的 action)→ 语义动作键。
|
||||||
* 与资源名拼接成短语,如 publish + 文章 = 发布文章。
|
* activation 与 enable 语义相同(激活/启用),归并为同一动作键便于统一筛选。
|
||||||
*/
|
*/
|
||||||
private static final Map<String, String> SUB_ACTION_VERBS = Map.ofEntries(
|
private static final Map<String, String> SEGMENT_ACTIONS = Map.ofEntries(
|
||||||
|
Map.entry("publish", "publish"),
|
||||||
|
Map.entry("unpublish", "unpublish"),
|
||||||
|
Map.entry("recycle", "recycle"),
|
||||||
|
Map.entry("restore", "restore"),
|
||||||
|
Map.entry("enable", "enable"),
|
||||||
|
Map.entry("activation", "enable"),
|
||||||
|
Map.entry("disable", "disable"),
|
||||||
|
Map.entry("upgrade", "upgrade"),
|
||||||
|
Map.entry("uninstall", "uninstall"),
|
||||||
|
Map.entry("reload", "reload"),
|
||||||
|
Map.entry("reply", "reply"),
|
||||||
|
Map.entry("recalculate", "recalculate"),
|
||||||
|
Map.entry("password", "password"),
|
||||||
|
Map.entry("resetpassword", "resetpassword"));
|
||||||
|
|
||||||
|
/** 语义动作键 → 完整短语(不拼接资源名)。 */
|
||||||
|
private static final Map<String, String> ACTION_PHRASES = Map.ofEntries(
|
||||||
|
Map.entry("login", "登录"),
|
||||||
|
Map.entry("logout", "登出"),
|
||||||
|
Map.entry("auth", "认证操作"),
|
||||||
|
Map.entry("password", "修改密码"),
|
||||||
|
Map.entry("resetpassword", "重置密码"));
|
||||||
|
|
||||||
|
/** 语义动作键 → 动词(与资源中文名拼接成短语,如 publish + 文章 = 发布文章)。 */
|
||||||
|
private static final Map<String, String> ACTION_VERBS = Map.ofEntries(
|
||||||
|
Map.entry("create", "新建"),
|
||||||
|
Map.entry("update", "修改"),
|
||||||
|
Map.entry("delete", "删除"),
|
||||||
|
Map.entry("view", "查看"),
|
||||||
Map.entry("publish", "发布"),
|
Map.entry("publish", "发布"),
|
||||||
Map.entry("unpublish", "取消发布"),
|
Map.entry("unpublish", "取消发布"),
|
||||||
Map.entry("recycle", "移入回收站"),
|
Map.entry("recycle", "移入回收站"),
|
||||||
@@ -54,51 +87,70 @@ final class OperationDescription {
|
|||||||
Map.entry("upgrade", "升级"),
|
Map.entry("upgrade", "升级"),
|
||||||
Map.entry("uninstall", "卸载"),
|
Map.entry("uninstall", "卸载"),
|
||||||
Map.entry("reload", "重载"),
|
Map.entry("reload", "重载"),
|
||||||
Map.entry("activation", "启用"),
|
|
||||||
Map.entry("reply", "回复"),
|
Map.entry("reply", "回复"),
|
||||||
Map.entry("recalculate", "重新统计"));
|
Map.entry("recalculate", "重新统计"));
|
||||||
|
|
||||||
/** 子资源动作段 → 完整短语(不拼接资源名)。 */
|
|
||||||
private static final Map<String, String> SUB_ACTION_PHRASES = Map.of(
|
|
||||||
"password", "修改密码",
|
|
||||||
"resetpassword", "重置密码");
|
|
||||||
|
|
||||||
private OperationDescription() {
|
private OperationDescription() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 推导操作中文描述。 */
|
/**
|
||||||
static String describe(String method, String resourceType, String path) {
|
* 推导语义动作键(捕获时落库标注,供筛选):登录/登出/认证操作由路径判定,
|
||||||
|
* 子动作段优先于 HTTP 方法,其余方法归为 create/update/delete/view;
|
||||||
|
* 无法识别(未知方法等)返回 null,记录不标注。
|
||||||
|
*/
|
||||||
|
static String actionOf(String method, String resourceType, String path) {
|
||||||
var cleanPath = pathWithoutQuery(path);
|
var cleanPath = pathWithoutQuery(path);
|
||||||
if ("auth".equals(resourceType) || "/login".equals(cleanPath)
|
|
||||||
|| "/logout".equals(cleanPath)) {
|
|
||||||
if ("/login".equals(cleanPath)) {
|
if ("/login".equals(cleanPath)) {
|
||||||
return "登录";
|
return "login";
|
||||||
}
|
}
|
||||||
if ("/logout".equals(cleanPath)) {
|
if ("/logout".equals(cleanPath)) {
|
||||||
return "登出";
|
return "logout";
|
||||||
}
|
}
|
||||||
return "认证操作";
|
if ("auth".equals(resourceType)) {
|
||||||
|
return "auth";
|
||||||
}
|
}
|
||||||
var label = RESOURCE_LABELS.getOrDefault(resourceType, resourceType);
|
|
||||||
var verb = METHOD_VERBS.getOrDefault(method, method);
|
|
||||||
// /apis/{group}/{version}/{plural}/{name}/{action}:
|
// /apis/{group}/{version}/{plural}/{name}/{action}:
|
||||||
// 去掉空段后 segments 为 [apis, group, version, plural, name, action],
|
// 去掉空段后 segments 为 [apis, group, version, plural, name, action],
|
||||||
// 子动作段为 segments[5]
|
// 子动作段为 segments[5]
|
||||||
var segments = Arrays.stream(cleanPath.split("/"))
|
var segments = Arrays.stream(cleanPath.split("/"))
|
||||||
.filter(segment -> !segment.isEmpty())
|
.filter(segment -> !segment.isEmpty())
|
||||||
.toArray(String[]::new);
|
.toArray(String[]::new);
|
||||||
var action = segments.length >= 6 ? segments[5].toLowerCase() : null;
|
if (segments.length >= 6) {
|
||||||
|
var action = SEGMENT_ACTIONS.get(segments[5].toLowerCase());
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
var phrase = SUB_ACTION_PHRASES.get(action);
|
return action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return METHOD_ACTIONS.get(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 由语义动作键推导中文描述;键为 null 或未识别返回 null(调用方回退 method 推导)。 */
|
||||||
|
static String describeAction(String action, String resourceType) {
|
||||||
|
if (action == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var phrase = ACTION_PHRASES.get(action);
|
||||||
if (phrase != null) {
|
if (phrase != null) {
|
||||||
return phrase;
|
return phrase;
|
||||||
}
|
}
|
||||||
var subVerb = SUB_ACTION_VERBS.get(action);
|
var verb = ACTION_VERBS.get(action);
|
||||||
if (subVerb != null) {
|
return verb == null ? null : verb + resourceLabel(resourceType);
|
||||||
return subVerb + label;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推导操作中文描述(展示/导出用):优先语义动作键,识别失败回退为
|
||||||
|
* 「method 动词 + 资源名」。
|
||||||
|
*/
|
||||||
|
static String describe(String method, String resourceType, String path) {
|
||||||
|
var phrase = describeAction(actionOf(method, resourceType, path), resourceType);
|
||||||
|
if (phrase != null) {
|
||||||
|
return phrase;
|
||||||
}
|
}
|
||||||
return verb + label;
|
return method + resourceLabel(resourceType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String resourceLabel(String resourceType) {
|
||||||
|
return RESOURCE_LABELS.getOrDefault(resourceType, resourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 剥离路径的查询串(spec.path 存的是含查询串的完整路径)。 */
|
/** 剥离路径的查询串(spec.path 存的是含查询串的完整路径)。 */
|
||||||
|
|||||||
+1
@@ -47,6 +47,7 @@ class OperationAuditPluginTest {
|
|||||||
"spec.username",
|
"spec.username",
|
||||||
"spec.resourceType",
|
"spec.resourceType",
|
||||||
"spec.method",
|
"spec.method",
|
||||||
|
"spec.action",
|
||||||
"spec.statusCode",
|
"spec.statusCode",
|
||||||
"spec.resourceName",
|
"spec.resourceName",
|
||||||
"spec.path");
|
"spec.path");
|
||||||
|
|||||||
+16
@@ -80,6 +80,22 @@ class AuditQueryEndpointTest {
|
|||||||
.contains("500");
|
.contains("500");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldApplySemanticActionFieldSelector() {
|
||||||
|
webClient.get()
|
||||||
|
.uri("/apis/audit.guichumo.com/v1alpha1/auditlogs/-/query"
|
||||||
|
+ "?fieldSelector=spec.action=publish")
|
||||||
|
.exchange()
|
||||||
|
.expectStatus().isOk();
|
||||||
|
|
||||||
|
var captor = ArgumentCaptor.forClass(ListOptions.class);
|
||||||
|
verify(client).listBy(eq(AuditLog.class), captor.capture(), any(PageRequest.class));
|
||||||
|
var condition = captor.getValue().toCondition().toString();
|
||||||
|
assertThat(condition)
|
||||||
|
.contains("spec.action")
|
||||||
|
.contains("publish");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldApplyResultFilter() {
|
void shouldApplyResultFilter() {
|
||||||
webClient.get()
|
webClient.get()
|
||||||
|
|||||||
+15
@@ -60,6 +60,8 @@ class AuditRecorderTest {
|
|||||||
|
|
||||||
assertThat(auditLog.getSpec().getUsername()).isEqualTo("admin");
|
assertThat(auditLog.getSpec().getUsername()).isEqualTo("admin");
|
||||||
assertThat(auditLog.getSpec().getMethod()).isEqualTo("DELETE");
|
assertThat(auditLog.getSpec().getMethod()).isEqualTo("DELETE");
|
||||||
|
// 语义动作标注(产品设计 V2):捕获时推导落库
|
||||||
|
assertThat(auditLog.getSpec().getAction()).isEqualTo("delete");
|
||||||
assertThat(auditLog.getSpec().getResourceType()).isEqualTo("posts");
|
assertThat(auditLog.getSpec().getResourceType()).isEqualTo("posts");
|
||||||
assertThat(auditLog.getSpec().getResourceName()).isEqualTo("xyz");
|
assertThat(auditLog.getSpec().getResourceName()).isEqualTo("xyz");
|
||||||
assertThat(auditLog.getSpec().getPath()).isEqualTo(
|
assertThat(auditLog.getSpec().getPath()).isEqualTo(
|
||||||
@@ -80,9 +82,22 @@ class AuditRecorderTest {
|
|||||||
assertThat(captor.getValue().getSpec().getUsername())
|
assertThat(captor.getValue().getSpec().getUsername())
|
||||||
.isEqualTo(AuditLogSpec.UNKNOWN_USERNAME);
|
.isEqualTo(AuditLogSpec.UNKNOWN_USERNAME);
|
||||||
assertThat(captor.getValue().getSpec().getResourceType()).isEqualTo("auth");
|
assertThat(captor.getValue().getSpec().getResourceType()).isEqualTo("auth");
|
||||||
|
assertThat(captor.getValue().getSpec().getAction()).isEqualTo("login");
|
||||||
assertThat(captor.getValue().getSpec().getStatusCode()).isEqualTo(401);
|
assertThat(captor.getValue().getSpec().getStatusCode()).isEqualTo(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldAnnotateSubActionSemanticAction() {
|
||||||
|
recorder.record(RequestSnapshot.of(MockServerHttpRequest
|
||||||
|
.put("http://localhost/apis/api.console.halo.run/v1alpha1/posts/xyz/publish")
|
||||||
|
.build()), 200, "admin");
|
||||||
|
|
||||||
|
var captor = ArgumentCaptor.forClass(AuditLog.class);
|
||||||
|
verify(client).create(captor.capture());
|
||||||
|
assertThat(captor.getValue().getSpec().getAction()).isEqualTo("publish");
|
||||||
|
assertThat(captor.getValue().getSpec().getResourceType()).isEqualTo("posts");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldSkipRecordingWhenAuditDisabled() {
|
void shouldSkipRecordingWhenAuditDisabled() {
|
||||||
when(settingProvider.get()).thenReturn(Mono.just(new AuditSettings(false, 30)));
|
when(settingProvider.get()).thenReturn(Mono.just(new AuditSettings(false, 30)));
|
||||||
|
|||||||
+115
@@ -100,4 +100,119 @@ class OperationDescriptionTest {
|
|||||||
assertThat(OperationDescription.describe("POST", "workflows", null))
|
assertThat(OperationDescription.describe("POST", "workflows", null))
|
||||||
.isEqualTo("新建workflows");
|
.isEqualTo("新建workflows");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldDeriveLoginLogoutAuthActions() {
|
||||||
|
assertThat(OperationDescription.actionOf("POST", "auth", "/login")).isEqualTo("login");
|
||||||
|
// GET /login?redirect_uri=... 也应识别为登录(path 含查询串)
|
||||||
|
assertThat(OperationDescription.actionOf("GET", "auth",
|
||||||
|
"/login?redirect_uri=https%3A%2F%2Fwww.guichumo.com%2Fconsole")).isEqualTo("login");
|
||||||
|
assertThat(OperationDescription.actionOf("POST", "auth", "/logout")).isEqualTo("logout");
|
||||||
|
assertThat(OperationDescription.actionOf("POST", "auth", "/auth/other"))
|
||||||
|
.isEqualTo("auth");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldDeriveMethodActions() {
|
||||||
|
assertThat(OperationDescription.actionOf("POST", "users",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/users")).isEqualTo("create");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "posts",
|
||||||
|
"/apis/content.halo.run/v1alpha1/posts/post-abc")).isEqualTo("update");
|
||||||
|
assertThat(OperationDescription.actionOf("PATCH", "themes",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/themes/theme-abc")).isEqualTo("update");
|
||||||
|
assertThat(OperationDescription.actionOf("DELETE", "plugins",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/plugins/plugin-abc")).isEqualTo("delete");
|
||||||
|
assertThat(OperationDescription.actionOf("GET", "posts",
|
||||||
|
"/apis/content.halo.run/v1alpha1/posts/post-abc")).isEqualTo("view");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldDeriveSubActionFromPathSegment() {
|
||||||
|
assertThat(OperationDescription.actionOf("POST", "posts",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/posts/post-abc/publish")).isEqualTo("publish");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "posts",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/posts/post-abc/unpublish"))
|
||||||
|
.isEqualTo("unpublish");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "posts",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/posts/post-abc/recycle"))
|
||||||
|
.isEqualTo("recycle");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "posts",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/posts/post-abc/restore")).isEqualTo("restore");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "plugins",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/plugins/plugin-abc/enable"))
|
||||||
|
.isEqualTo("enable");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "plugins",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/plugins/plugin-abc/disable"))
|
||||||
|
.isEqualTo("disable");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "plugins",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/plugins/plugin-abc/upgrade"))
|
||||||
|
.isEqualTo("upgrade");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "plugins",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/plugins/plugin-abc/uninstall"))
|
||||||
|
.isEqualTo("uninstall");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "plugins",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/plugins/plugin-abc/reload"))
|
||||||
|
.isEqualTo("reload");
|
||||||
|
assertThat(OperationDescription.actionOf("POST", "comments",
|
||||||
|
"/apis/api.comment.halo.run/v1alpha1/comments/comment-abc/reply"))
|
||||||
|
.isEqualTo("reply");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "posts",
|
||||||
|
"/apis/api.content.halo.run/v1alpha1/posts/post-abc/recalculate"))
|
||||||
|
.isEqualTo("recalculate");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldNormalizeActivationToEnable() {
|
||||||
|
// 激活与启用语义相同(主题/插件 activation 与 enable),归并为同一动作键便于统一筛选
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "themes",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/themes/theme-abc/activation"))
|
||||||
|
.isEqualTo("enable");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldDerivePasswordSubActions() {
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "users",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/users/admin/password")).isEqualTo("password");
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "users",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/users/admin/resetpassword"))
|
||||||
|
.isEqualTo("resetpassword");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldStripQueryBeforeDerivingAction() {
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "posts",
|
||||||
|
"/apis/api.console.halo.run/v1alpha1/posts/post-abc/publish?async=true"))
|
||||||
|
.isEqualTo("publish");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldFallbackToNullActionForUnknownMethod() {
|
||||||
|
assertThat(OperationDescription.actionOf("TRACE", "posts",
|
||||||
|
"/apis/content.halo.run/v1alpha1/posts/post-abc")).isNull();
|
||||||
|
// 未识别的子动作回退到方法推导
|
||||||
|
assertThat(OperationDescription.actionOf("PUT", "posts",
|
||||||
|
"/apis/content.halo.run/v1alpha1/posts/post-abc/content")).isEqualTo("update");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldDescribeFromActionKey() {
|
||||||
|
assertThat(OperationDescription.describeAction("login", "auth")).isEqualTo("登录");
|
||||||
|
assertThat(OperationDescription.describeAction("logout", "auth")).isEqualTo("登出");
|
||||||
|
assertThat(OperationDescription.describeAction("auth", "auth")).isEqualTo("认证操作");
|
||||||
|
assertThat(OperationDescription.describeAction("create", "users")).isEqualTo("新建用户");
|
||||||
|
assertThat(OperationDescription.describeAction("update", "posts")).isEqualTo("修改文章");
|
||||||
|
assertThat(OperationDescription.describeAction("delete", "plugins"))
|
||||||
|
.isEqualTo("删除插件");
|
||||||
|
assertThat(OperationDescription.describeAction("publish", "posts"))
|
||||||
|
.isEqualTo("发布文章");
|
||||||
|
assertThat(OperationDescription.describeAction("restore", "posts"))
|
||||||
|
.isEqualTo("恢复文章");
|
||||||
|
assertThat(OperationDescription.describeAction("enable", "themes"))
|
||||||
|
.isEqualTo("启用主题");
|
||||||
|
assertThat(OperationDescription.describeAction("password", "users"))
|
||||||
|
.isEqualTo("修改密码");
|
||||||
|
// 未识别的键回退 null(调用方回退 method 推导)
|
||||||
|
assertThat(OperationDescription.describeAction(null, "posts")).isNull();
|
||||||
|
assertThat(OperationDescription.describeAction("bogus", "posts")).isNull();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import type { AuditLogSpec } from './audit'
|
import type { AuditLogSpec } from './audit'
|
||||||
import { describeOperation } from './audit'
|
import { deriveAction, describeOperation, SEMANTIC_ACTIONS } from './audit'
|
||||||
|
|
||||||
// 操作描述推导(这条操作真正干了什么):由 method / resourceType / path 推导中文短语。
|
// 操作描述推导(这条操作真正干了什么):由落库的语义动作标注或
|
||||||
// 历史记录不落库新字段,描述纯展示层推导,因此必须覆盖所有回退路径,防止出现英文原始值。
|
// method / resourceType / path 推导中文短语。
|
||||||
|
// 描述必须覆盖所有回退路径,防止出现英文原始值。
|
||||||
function spec(overrides: Partial<AuditLogSpec>): AuditLogSpec {
|
function spec(overrides: Partial<AuditLogSpec>): AuditLogSpec {
|
||||||
return {
|
return {
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
@@ -133,3 +134,107 @@ describe('describeOperation', () => {
|
|||||||
}))).toBe('删除other')
|
}))).toBe('删除other')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('deriveAction 语义动作推导', () => {
|
||||||
|
it('登录/登出/认证操作由路径判定(含查询串剥离)', () => {
|
||||||
|
expect(deriveAction('POST', 'auth', '/login')).toBe('login')
|
||||||
|
expect(deriveAction('GET', 'auth', '/login?redirect_uri=https%3A%2F%2Fwww.guichumo.com'))
|
||||||
|
.toBe('login')
|
||||||
|
expect(deriveAction('POST', 'auth', '/logout')).toBe('logout')
|
||||||
|
expect(deriveAction('POST', 'auth', '/auth/other')).toBe('auth')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('子动作段优先于 HTTP 方法', () => {
|
||||||
|
expect(deriveAction('PUT', 'posts',
|
||||||
|
'/apis/api.console.halo.run/v1alpha1/posts/post-abc/publish')).toBe('publish')
|
||||||
|
expect(deriveAction('POST', 'posts',
|
||||||
|
'/apis/api.console.halo.run/v1alpha1/posts/post-abc/restore')).toBe('restore')
|
||||||
|
// 激活与启用归并为同一动作键
|
||||||
|
expect(deriveAction('PUT', 'themes',
|
||||||
|
'/apis/api.console.halo.run/v1alpha1/themes/theme-abc/activation')).toBe('enable')
|
||||||
|
expect(deriveAction('PUT', 'users',
|
||||||
|
'/apis/api.console.halo.run/v1alpha1/users/admin/password')).toBe('password')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('无子动作段时由 HTTP 方法归为 create/update/delete/view', () => {
|
||||||
|
expect(deriveAction('POST', 'users', '/apis/api.console.halo.run/v1alpha1/users'))
|
||||||
|
.toBe('create')
|
||||||
|
expect(deriveAction('PUT', 'posts', '/apis/content.halo.run/v1alpha1/posts/post-abc'))
|
||||||
|
.toBe('update')
|
||||||
|
expect(deriveAction('DELETE', 'plugins',
|
||||||
|
'/apis/api.console.halo.run/v1alpha1/plugins/plugin-abc')).toBe('delete')
|
||||||
|
expect(deriveAction('GET', 'posts', '/apis/content.halo.run/v1alpha1/posts/post-abc'))
|
||||||
|
.toBe('view')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('未知方法与未识别子动作回退为方法键或 null', () => {
|
||||||
|
expect(deriveAction('TRACE', 'posts', '/apis/content.halo.run/v1alpha1/posts/post-abc'))
|
||||||
|
.toBeNull()
|
||||||
|
expect(deriveAction('PUT', 'posts',
|
||||||
|
'/apis/content.halo.run/v1alpha1/posts/post-abc/content')).toBe('update')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('describeOperation 落库标注优先', () => {
|
||||||
|
it('spec.action 存在时直接由动作键推导(历史记录无 action 仍走 method/path 推导)', () => {
|
||||||
|
expect(describeOperation(spec({
|
||||||
|
method: 'PUT',
|
||||||
|
resourceType: 'posts',
|
||||||
|
path: '/apis/content.halo.run/v1alpha1/posts/post-abc',
|
||||||
|
action: 'publish',
|
||||||
|
}))).toBe('发布文章')
|
||||||
|
expect(describeOperation(spec({
|
||||||
|
method: 'POST',
|
||||||
|
resourceType: 'auth',
|
||||||
|
path: '/login',
|
||||||
|
action: 'login',
|
||||||
|
}))).toBe('登录')
|
||||||
|
// 与 method/path 现场推导结果一致(同一套推导规则)
|
||||||
|
expect(describeOperation(spec({
|
||||||
|
method: 'PUT',
|
||||||
|
resourceType: 'posts',
|
||||||
|
path: '/apis/api.console.halo.run/v1alpha1/posts/post-abc/publish',
|
||||||
|
action: 'publish',
|
||||||
|
}))).toBe(describeOperation(spec({
|
||||||
|
method: 'PUT',
|
||||||
|
resourceType: 'posts',
|
||||||
|
path: '/apis/api.console.halo.run/v1alpha1/posts/post-abc/publish',
|
||||||
|
})))
|
||||||
|
})
|
||||||
|
|
||||||
|
it('动作键未知时回退为 method 动词 + 资源名', () => {
|
||||||
|
expect(describeOperation(spec({
|
||||||
|
method: 'PUT',
|
||||||
|
resourceType: 'posts',
|
||||||
|
path: '/somewhere/odd',
|
||||||
|
action: 'bogus',
|
||||||
|
}))).toBe('修改文章')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('SEMANTIC_ACTIONS 筛选选项', () => {
|
||||||
|
it('值唯一且标签非空', () => {
|
||||||
|
const values = SEMANTIC_ACTIONS.map((a) => a.value)
|
||||||
|
expect(new Set(values).size).toBe(values.length)
|
||||||
|
for (const a of SEMANTIC_ACTIONS) {
|
||||||
|
expect(a.label).not.toBe('')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('覆盖全部可落库的语义动作键(view 不会被捕获规则记录,除外)', () => {
|
||||||
|
// 全量枚举:登录/登出/认证 + 方法动作 + 全部子动作段(含 activation 归并)
|
||||||
|
const storable = new Set([
|
||||||
|
'login', 'logout', 'auth',
|
||||||
|
'create', 'update', 'delete',
|
||||||
|
'publish', 'unpublish', 'recycle', 'restore', 'enable', 'disable',
|
||||||
|
'upgrade', 'uninstall', 'reload', 'reply', 'recalculate',
|
||||||
|
'password', 'resetpassword',
|
||||||
|
])
|
||||||
|
expect(new Set(SEMANTIC_ACTIONS.map((a) => a.value))).toEqual(storable)
|
||||||
|
// 每个选项都能由 describeOperation 从动作键推出非空短语(下拉与描述保持一致)
|
||||||
|
for (const a of SEMANTIC_ACTIONS) {
|
||||||
|
expect(describeOperation(spec({ resourceType: 'posts', action: a.value })))
|
||||||
|
.not.toBe('')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ export interface AuditLogSpec {
|
|||||||
resourceType: string
|
resourceType: string
|
||||||
resourceName?: string | null
|
resourceName?: string | null
|
||||||
path: string
|
path: string
|
||||||
|
/** 语义动作键(语义动作标注,如 login/create/publish);旧版本写入的历史记录可能缺失。 */
|
||||||
|
action?: string | null
|
||||||
statusCode: number
|
statusCode: number
|
||||||
remoteIp: string
|
remoteIp: string
|
||||||
userAgent?: string | null
|
userAgent?: string | null
|
||||||
@@ -78,7 +80,7 @@ const RESOURCE_LABELS: Record<string, string> = {
|
|||||||
tags: '标签',
|
tags: '标签',
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 动作方法的基础动词(未知方法回退原始值)。 */
|
/** 动作方法的基础动词(未知方法回退原始值,用于未知动作键的展示回退)。 */
|
||||||
const METHOD_VERBS: Record<string, string> = {
|
const METHOD_VERBS: Record<string, string> = {
|
||||||
POST: '新建',
|
POST: '新建',
|
||||||
PUT: '修改',
|
PUT: '修改',
|
||||||
@@ -87,11 +89,51 @@ const METHOD_VERBS: Record<string, string> = {
|
|||||||
GET: '查看',
|
GET: '查看',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 动作方法 → 语义动作键(未知方法无键)。 */
|
||||||
|
const METHOD_ACTIONS: Record<string, string> = {
|
||||||
|
POST: 'create',
|
||||||
|
PUT: 'update',
|
||||||
|
PATCH: 'update',
|
||||||
|
DELETE: 'delete',
|
||||||
|
GET: 'view',
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子资源动作段({@code /apis/.../{plural}/{name}/{action}} 的 action)→ 动词,
|
* 子资源动作段({@code /apis/.../{plural}/{name}/{action}} 的 action)→ 语义动作键。
|
||||||
* 与资源名拼接成短语,如 publish + 文章 = 发布文章。
|
* activation 与 enable 语义相同(激活/启用),归并为同一动作键便于统一筛选。
|
||||||
*/
|
*/
|
||||||
const SUB_ACTION_VERBS: Record<string, string> = {
|
const SEGMENT_ACTIONS: Record<string, string> = {
|
||||||
|
publish: 'publish',
|
||||||
|
unpublish: 'unpublish',
|
||||||
|
recycle: 'recycle',
|
||||||
|
restore: 'restore',
|
||||||
|
enable: 'enable',
|
||||||
|
activation: 'enable',
|
||||||
|
disable: 'disable',
|
||||||
|
upgrade: 'upgrade',
|
||||||
|
uninstall: 'uninstall',
|
||||||
|
reload: 'reload',
|
||||||
|
reply: 'reply',
|
||||||
|
recalculate: 'recalculate',
|
||||||
|
password: 'password',
|
||||||
|
resetpassword: 'resetpassword',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 语义动作键 → 完整短语(不拼资源名)。 */
|
||||||
|
const ACTION_PHRASES: Record<string, string> = {
|
||||||
|
login: '登录',
|
||||||
|
logout: '登出',
|
||||||
|
auth: '认证操作',
|
||||||
|
password: '修改密码',
|
||||||
|
resetpassword: '重置密码',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 语义动作键 → 动词(与资源中文名拼接成短语,如 publish + 文章 = 发布文章)。 */
|
||||||
|
const ACTION_VERBS: Record<string, string> = {
|
||||||
|
create: '新建',
|
||||||
|
update: '修改',
|
||||||
|
delete: '删除',
|
||||||
|
view: '查看',
|
||||||
publish: '发布',
|
publish: '发布',
|
||||||
unpublish: '取消发布',
|
unpublish: '取消发布',
|
||||||
recycle: '移入回收站',
|
recycle: '移入回收站',
|
||||||
@@ -101,16 +143,35 @@ const SUB_ACTION_VERBS: Record<string, string> = {
|
|||||||
upgrade: '升级',
|
upgrade: '升级',
|
||||||
uninstall: '卸载',
|
uninstall: '卸载',
|
||||||
reload: '重载',
|
reload: '重载',
|
||||||
activation: '启用',
|
|
||||||
reply: '回复',
|
reply: '回复',
|
||||||
recalculate: '重新统计',
|
recalculate: '重新统计',
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 子资源动作段 → 完整短语(不拼接资源名)。 */
|
/**
|
||||||
const SUB_ACTION_PHRASES: Record<string, string> = {
|
* 语义动作筛选选项(键 → 中文标签,与后端 OperationDescription 保持一致):
|
||||||
password: '修改密码',
|
* view(查看)不会被捕获规则记录,不列入。
|
||||||
resetpassword: '重置密码',
|
*/
|
||||||
}
|
export const SEMANTIC_ACTIONS: Array<{ value: string; label: string }> = [
|
||||||
|
{ value: 'login', label: '登录' },
|
||||||
|
{ value: 'logout', label: '登出' },
|
||||||
|
{ value: 'auth', label: '认证操作' },
|
||||||
|
{ value: 'create', label: '新建' },
|
||||||
|
{ value: 'update', label: '修改' },
|
||||||
|
{ value: 'delete', label: '删除' },
|
||||||
|
{ value: 'publish', label: '发布' },
|
||||||
|
{ value: 'unpublish', label: '取消发布' },
|
||||||
|
{ value: 'recycle', label: '移入回收站' },
|
||||||
|
{ value: 'restore', label: '恢复' },
|
||||||
|
{ value: 'enable', label: '启用' },
|
||||||
|
{ value: 'disable', label: '停用' },
|
||||||
|
{ value: 'upgrade', label: '升级' },
|
||||||
|
{ value: 'uninstall', label: '卸载' },
|
||||||
|
{ value: 'reload', label: '重载' },
|
||||||
|
{ value: 'reply', label: '回复' },
|
||||||
|
{ value: 'recalculate', label: '重新统计' },
|
||||||
|
{ value: 'password', label: '修改密码' },
|
||||||
|
{ value: 'resetpassword', label: '重置密码' },
|
||||||
|
]
|
||||||
|
|
||||||
/** 剥离路径的查询串(spec.path 存的是含查询串的完整路径)。 */
|
/** 剥离路径的查询串(spec.path 存的是含查询串的完整路径)。 */
|
||||||
function pathWithoutQuery(path?: string | null): string {
|
function pathWithoutQuery(path?: string | null): string {
|
||||||
@@ -122,42 +183,69 @@ function pathWithoutQuery(path?: string | null): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作描述(这条操作真正干了什么):由 method / resourceType / path 推导中文短语,
|
* 推导语义动作键(语义动作标注,与后端 OperationDescription.actionOf 保持一致):
|
||||||
* 如 登录、登出、新建用户、修改文章、发布文章、启用插件、修改密码。
|
* 登录/登出/认证操作由路径判定,子动作段优先于 HTTP 方法,其余方法归为
|
||||||
*
|
* create/update/delete/view;无法识别返回 null。
|
||||||
* <p>纯展示层推导,不落库:历史记录同样适用;未识别的子动作回退为「动词 + 资源名」,
|
|
||||||
* 未识别的资源类型直接使用原始 resourceType。
|
|
||||||
*/
|
*/
|
||||||
export function describeOperation(
|
export function deriveAction(
|
||||||
spec: Pick<AuditLogSpec, 'method' | 'resourceType' | 'path'>,
|
method: string,
|
||||||
): string {
|
resourceType: string,
|
||||||
const cleanPath = pathWithoutQuery(spec.path)
|
path?: string | null,
|
||||||
if (spec.resourceType === 'auth' || cleanPath === '/login' || cleanPath === '/logout') {
|
): string | null {
|
||||||
|
const cleanPath = pathWithoutQuery(path)
|
||||||
if (cleanPath === '/login') {
|
if (cleanPath === '/login') {
|
||||||
return '登录'
|
return 'login'
|
||||||
}
|
}
|
||||||
if (cleanPath === '/logout') {
|
if (cleanPath === '/logout') {
|
||||||
return '登出'
|
return 'logout'
|
||||||
}
|
}
|
||||||
return '认证操作'
|
if (resourceType === 'auth') {
|
||||||
|
return 'auth'
|
||||||
}
|
}
|
||||||
const label = RESOURCE_LABELS[spec.resourceType] ?? spec.resourceType
|
|
||||||
const verb = METHOD_VERBS[spec.method] ?? spec.method
|
|
||||||
// /apis/{group}/{version}/{plural}/{name}/{action}:
|
// /apis/{group}/{version}/{plural}/{name}/{action}:
|
||||||
// filter(Boolean) 去掉首段空串后,segments 为 [apis, group, version, plural, name, action],
|
// filter(Boolean) 去掉首段空串后,segments 为 [apis, group, version, plural, name, action],
|
||||||
// 子动作段为 segments[5]
|
// 子动作段为 segments[5]
|
||||||
const segments = cleanPath.split('/').filter(Boolean)
|
const segments = cleanPath.split('/').filter(Boolean)
|
||||||
const action = segments.length >= 6 ? segments[5].toLowerCase() : null
|
if (segments.length >= 6) {
|
||||||
|
const action = SEGMENT_ACTIONS[segments[5].toLowerCase()]
|
||||||
if (action) {
|
if (action) {
|
||||||
const phrase = SUB_ACTION_PHRASES[action]
|
return action
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return METHOD_ACTIONS[method] ?? null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 由语义动作键推导中文短语;键为 null 或未识别返回 null(调用方回退 method 推导)。 */
|
||||||
|
function describeFromAction(action: string | null, resourceType: string): string | null {
|
||||||
|
if (!action) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const phrase = ACTION_PHRASES[action]
|
||||||
if (phrase) {
|
if (phrase) {
|
||||||
return phrase
|
return phrase
|
||||||
}
|
}
|
||||||
const subVerb = SUB_ACTION_VERBS[action]
|
const verb = ACTION_VERBS[action]
|
||||||
if (subVerb) {
|
return verb ? `${verb}${RESOURCE_LABELS[resourceType] ?? resourceType}` : null
|
||||||
return `${subVerb}${label}`
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 操作描述(这条操作真正干了什么):推导中文短语,
|
||||||
|
* 如 登录、登出、新建用户、修改文章、发布文章、启用插件、修改密码。
|
||||||
|
*
|
||||||
|
* <p>优先使用落库的语义动作标注(spec.action);历史记录(无 action 字段)由
|
||||||
|
* method/path 现场推导,同样适用。识别失败回退为「method 动词 + 资源名」,
|
||||||
|
* 未识别的资源类型直接使用原始 resourceType。
|
||||||
|
*/
|
||||||
|
export function describeOperation(
|
||||||
|
spec: Pick<AuditLogSpec, 'method' | 'resourceType' | 'path' | 'action'>,
|
||||||
|
): string {
|
||||||
|
const action = spec.action ?? deriveAction(spec.method, spec.resourceType, spec.path)
|
||||||
|
const fromAction = describeFromAction(action, spec.resourceType)
|
||||||
|
if (fromAction) {
|
||||||
|
return fromAction
|
||||||
}
|
}
|
||||||
|
const label = RESOURCE_LABELS[spec.resourceType] ?? spec.resourceType
|
||||||
|
const verb = METHOD_VERBS[spec.method] ?? spec.method
|
||||||
return `${verb}${label}`
|
return `${verb}${label}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ describe('AuditLogList 页面外观', () => {
|
|||||||
expect(sfc.match(/<VCard/g)?.length).toBe(1)
|
expect(sfc.match(/<VCard/g)?.length).toBe(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('.audit-filter .filter-grid 筛选字段与操作按钮排成一行(7 列 + auto 按钮)', () => {
|
it('.audit-filter .filter-grid 筛选字段与操作按钮排成一行(8 列 + auto 按钮)', () => {
|
||||||
const rule = styleRule('.filter-grid')
|
const rule = styleRule('.filter-grid')
|
||||||
expect(rule).toMatch(/grid-template-columns:\s*repeat\(7,\s*minmax\(0,\s*1fr\)\)\s+auto/)
|
expect(rule).toMatch(/grid-template-columns:\s*repeat\(8,\s*minmax\(0,\s*1fr\)\)\s+auto/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('.audit-pagination 白底铺满整行(不再左右缩进 1rem),仅以 1px 分隔线与列表相接', () => {
|
it('.audit-pagination 白底铺满整行(不再左右缩进 1rem),仅以 1px 分隔线与列表相接', () => {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
isSuccessful,
|
isSuccessful,
|
||||||
localDateTimeToInstant,
|
localDateTimeToInstant,
|
||||||
methodBadgeClass,
|
methodBadgeClass,
|
||||||
|
SEMANTIC_ACTIONS,
|
||||||
} from '@/utils/audit'
|
} from '@/utils/audit'
|
||||||
import AuditLogDetail from './AuditLogDetail.vue'
|
import AuditLogDetail from './AuditLogDetail.vue'
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ const size = ref(20)
|
|||||||
const filterUsername = ref('')
|
const filterUsername = ref('')
|
||||||
const filterResourceType = ref('')
|
const filterResourceType = ref('')
|
||||||
const filterMethod = ref('')
|
const filterMethod = ref('')
|
||||||
|
const filterAction = ref('')
|
||||||
const filterResult = ref('')
|
const filterResult = ref('')
|
||||||
const filterKeyword = ref('')
|
const filterKeyword = ref('')
|
||||||
const filterStartTime = ref('')
|
const filterStartTime = ref('')
|
||||||
@@ -64,6 +66,7 @@ const hasActiveFilter = computed(
|
|||||||
filterUsername.value ||
|
filterUsername.value ||
|
||||||
filterResourceType.value ||
|
filterResourceType.value ||
|
||||||
filterMethod.value ||
|
filterMethod.value ||
|
||||||
|
filterAction.value ||
|
||||||
filterResult.value ||
|
filterResult.value ||
|
||||||
filterKeyword.value ||
|
filterKeyword.value ||
|
||||||
filterStartTime.value ||
|
filterStartTime.value ||
|
||||||
@@ -84,6 +87,10 @@ function buildQuery(): string {
|
|||||||
if (filterMethod.value) {
|
if (filterMethod.value) {
|
||||||
params.append('fieldSelector', `spec.method=${filterMethod.value}`)
|
params.append('fieldSelector', `spec.method=${filterMethod.value}`)
|
||||||
}
|
}
|
||||||
|
// 语义动作筛选(spec.action,捕获时标注落库;历史记录无标注不会被筛出)
|
||||||
|
if (filterAction.value) {
|
||||||
|
params.append('fieldSelector', `spec.action=${filterAction.value}`)
|
||||||
|
}
|
||||||
if (filterResult.value) {
|
if (filterResult.value) {
|
||||||
params.set('result', filterResult.value)
|
params.set('result', filterResult.value)
|
||||||
}
|
}
|
||||||
@@ -162,13 +169,14 @@ function resetFilter() {
|
|||||||
filterUsername.value = ''
|
filterUsername.value = ''
|
||||||
filterResourceType.value = ''
|
filterResourceType.value = ''
|
||||||
filterMethod.value = ''
|
filterMethod.value = ''
|
||||||
|
filterAction.value = ''
|
||||||
filterResult.value = ''
|
filterResult.value = ''
|
||||||
filterKeyword.value = ''
|
filterKeyword.value = ''
|
||||||
filterStartTime.value = ''
|
filterStartTime.value = ''
|
||||||
filterEndTime.value = ''
|
filterEndTime.value = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
watch([filterUsername, filterResourceType, filterMethod, filterResult], () => {
|
watch([filterUsername, filterResourceType, filterMethod, filterAction, filterResult], () => {
|
||||||
page.value = 1
|
page.value = 1
|
||||||
fetchLogs()
|
fetchLogs()
|
||||||
})
|
})
|
||||||
@@ -246,6 +254,15 @@ onMounted(fetchLogs)
|
|||||||
<option value="PATCH">PATCH</option>
|
<option value="PATCH">PATCH</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="filter-item">
|
||||||
|
<span>语义动作</span>
|
||||||
|
<select v-model="filterAction">
|
||||||
|
<option value="">全部</option>
|
||||||
|
<option v-for="a in SEMANTIC_ACTIONS" :key="a.value" :value="a.value">
|
||||||
|
{{ a.label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
<label class="filter-item">
|
<label class="filter-item">
|
||||||
<span>结果</span>
|
<span>结果</span>
|
||||||
<select v-model="filterResult">
|
<select v-model="filterResult">
|
||||||
@@ -407,8 +424,8 @@ onMounted(fetchLogs)
|
|||||||
}
|
}
|
||||||
.filter-grid {
|
.filter-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
/* 7 个筛选字段 + 自动宽度的操作按钮,全部排成一行 */
|
/* 8 个筛选字段 + 自动宽度的操作按钮,全部排成一行 */
|
||||||
grid-template-columns: repeat(7, minmax(0, 1fr)) auto;
|
grid-template-columns: repeat(8, minmax(0, 1fr)) auto;
|
||||||
gap: 0.75rem 1rem;
|
gap: 0.75rem 1rem;
|
||||||
align-items: end;
|
align-items: end;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user