Files
schemaCheck/src/main/java/com/codechecker/cache/config/CheckerConfig.java
2026-08-03 14:48:29 +08:00

133 lines
4.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.codechecker.cache.config;
import lombok.Data;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* 检测器运行配置。由 {@link ConfigLoader} 加载 jar 内默认配置并与业务配置深度合并后构建。
*/
@Data
public class CheckerConfig {
/** 总开关false 时跳过检测与通知(流水线 exit 0 */
private boolean enabled = true;
/** 运行模式notify仅通知| block有变更则失败退出 */
private String mode = "notify";
/** 是否扫描 test 源码目录 */
private boolean scanTestSources = false;
/** 额外源码根路径(相对仓库根);空则按约定扫描 main */
private List<String> sourceRoots = new ArrayList<>();
/** 企微通知配置 */
private Notify notify = new Notify();
/** 忽略规则key / 文件 / 写入方法 / MQ destination */
private Ignore ignore = new Ignore();
/** 检测模式与推断参数 */
private Detection detection = new Detection();
/** 按 ChangeType 名覆盖默认严重级别,如 FIELD_ADDED → P0 */
private Map<String, String> severityOverrides = new LinkedHashMap<>();
/** 人工写入点映射(自动推断不准时补齐) */
private List<ManualMapping> manualMappings = new ArrayList<>();
/** 已知误报抑制规则 */
private List<Suppression> suppressions = new ArrayList<>();
/** 仅检测这些模块(路径前缀/模块名);空表示不限制 */
private List<String> includeModules = new ArrayList<>();
/** 排除这些模块,不参与检测 */
private List<String> excludeModules = new ArrayList<>();
public boolean isBlockMode() {
return "block".equalsIgnoreCase(mode);
}
/** 企微通知相关配置。 */
@Data
public static class Notify {
/** 是否发送企微通知 */
private boolean enabled = true;
/** 企微机器人 Webhook 完整 URL */
private String webhookUrl = "";
/** 无变更时是否仍发「清洁」通知 */
private boolean notifyOnClean = false;
/** 报告标题前缀 */
private String titlePrefix = "[序列化结构变更]";
}
/** 忽略规则key / 文件路径 / 写入方法 / MQ destination。 */
@Data
public static class Ignore {
/** 忽略的 Redis key / 模式 */
private List<String> keyPatterns = new ArrayList<>();
/** 忽略的源文件 glob */
private List<String> filePatterns = new ArrayList<>();
/** 忽略的写入方法Class#method 或简单名) */
private List<String> writerMethods = new ArrayList<>();
/** 忽略的 MQ destination 模式topic / topic:tag */
private List<String> mqDestinations = new ArrayList<>();
}
/** 检测模式与推断参数Redis W*、MQ MQ*、读侧补强开关等)。 */
@Data
public static class Detection {
/** Redis 写入检测模式列表,如 W01~W06 */
private List<String> patterns = new ArrayList<>();
/** MQ 投递检测模式MQ01~MQ05、MQ-K01~MQ-K04 */
private List<String> mqPatterns = new ArrayList<>();
/** 低于此置信度的结构变更按低置信度降级处理 */
private double minConfidence = 0.6;
/** 字段展开最大深度,防止循环引用爆栈 */
private int maxFieldDepth = 8;
/** W06是否启用读侧反序列化类型辅助补强 */
private boolean readHintsEnabled = true;
/** MQ-R读侧 Listener / parse 补强 */
private boolean mqReadHintsEnabled = true;
}
/**
* 人工补充映射:在自动推断不准时指定写入方法对应的 key 模式与 value 类型。
*/
@Data
public static class ManualMapping {
/** 规则 id便于配置追溯 */
private String id;
/** 目标写入方法标识 */
private String writerMethod;
/** 指定的 key / destination 模式 */
private String keyPattern;
/** 指定的 value 类型 */
private String valueType;
/** 备注说明 */
private String description;
}
/**
* 抑制规则:对已知误报按 key 模式和/或变更类型跳过告警。
*/
@Data
public static class Suppression {
/** 规则 id */
private String id;
/** 可选:限定写入方法 */
private String writerMethod;
/** 可选:匹配的 key / destination 模式 */
private String keyPattern;
/** 要抑制的 ChangeType 名列表;空表示不按类型过滤 */
private List<String> changeTypes = new ArrayList<>();
/** 抑制原因(文档用) */
private String reason;
}
}