| | |
| | | /** 规则缓存定时刷新间隔(毫秒) */ |
| | | private long ruleCacheRefreshMs = 60_000L; |
| | | |
| | | /** 定时清理开关 */ |
| | | private boolean cleanupEnabled = true; |
| | | /** 保留天数 */ |
| | | private int cleanupRetentionDays = 180; |
| | | |
| | | /** 查询类响应最多保留字符数 */ |
| | | private int queryResponseMaxChars = 500; |
| | | |
| | |
| | | /** Filter 实际使用的前缀(受 excludeAuditSelfPaths 影响) */ |
| | | public List<String> getEffectiveExcludePrefixes() { |
| | | List<String> list = excludePathPrefixes == null ? new ArrayList<>() : new ArrayList<>(excludePathPrefixes); |
| | | if (!excludeAuditSelfPaths) { |
| | | if (!isExcludeAuditSelfPaths()) { |
| | | list.removeIf(p -> "/httpAuditLog".equals(p) || "/httpAuditRule".equals(p)); |
| | | } |
| | | return list; |
| | |
| | | /** 路径 -> 功能描述(按最长路径前缀匹配) */ |
| | | private Map<String, String> pathDescriptions = new LinkedHashMap<>(); |
| | | |
| | | public boolean isWhitelistOnly() { |
| | | return HttpAuditDbConfigHolder.getBoolean(HttpAuditDbConfigHolder.KEY_WHITELIST_ONLY, whitelistOnly); |
| | | } |
| | | |
| | | public boolean isExcludeAuditSelfPaths() { |
| | | return HttpAuditDbConfigHolder.getBoolean(HttpAuditDbConfigHolder.KEY_EXCLUDE_AUDIT_SELF_PATHS, excludeAuditSelfPaths); |
| | | } |
| | | |
| | | public long getRuleCacheRefreshMs() { |
| | | return HttpAuditDbConfigHolder.getLong(HttpAuditDbConfigHolder.KEY_RULE_CACHE_REFRESH_MS, ruleCacheRefreshMs); |
| | | } |
| | | |
| | | public int getQueryResponseMaxChars() { |
| | | return HttpAuditDbConfigHolder.getInt(HttpAuditDbConfigHolder.KEY_QUERY_RESPONSE_MAX_CHARS, queryResponseMaxChars); |
| | | } |
| | | |
| | | public int getMaxResponseStoreChars() { |
| | | return HttpAuditDbConfigHolder.getInt(HttpAuditDbConfigHolder.KEY_MAX_RESPONSE_STORE_CHARS, maxResponseStoreChars); |
| | | } |
| | | |
| | | public int getDefaultRequestStoreChars() { |
| | | return HttpAuditDbConfigHolder.getInt(HttpAuditDbConfigHolder.KEY_DEFAULT_REQUEST_STORE_CHARS, defaultRequestStoreChars); |
| | | } |
| | | |
| | | public boolean isCleanupEnabled() { |
| | | return HttpAuditDbConfigHolder.getBoolean(HttpAuditDbConfigHolder.KEY_CLEANUP_ENABLED, cleanupEnabled); |
| | | } |
| | | |
| | | public int getCleanupRetentionDays() { |
| | | return HttpAuditDbConfigHolder.getInt(HttpAuditDbConfigHolder.KEY_CLEANUP_RETENTION_DAYS, cleanupRetentionDays); |
| | | } |
| | | |
| | | public Map<String, String> getPathDescriptions() { |
| | | return HttpAuditDbConfigHolder.getPathDescriptions(pathDescriptions); |
| | | } |
| | | |
| | | private static List<String> defaultExcludes() { |
| | | List<String> list = new ArrayList<>(); |
| | | list.add("/actuator"); |