From f7e46d204be81fd2ebb9e5a90728e945700a2c23 Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期五, 17 四月 2026 17:27:10 +0800
Subject: [PATCH] 配置

---
 rsf-http-audit/src/main/java/com/vincent/rsf/httpaudit/props/HttpAuditProperties.java |   69 ++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/rsf-http-audit/src/main/java/com/vincent/rsf/httpaudit/props/HttpAuditProperties.java b/rsf-http-audit/src/main/java/com/vincent/rsf/httpaudit/props/HttpAuditProperties.java
index a553c23..f2aacb2 100644
--- a/rsf-http-audit/src/main/java/com/vincent/rsf/httpaudit/props/HttpAuditProperties.java
+++ b/rsf-http-audit/src/main/java/com/vincent/rsf/httpaudit/props/HttpAuditProperties.java
@@ -17,11 +17,29 @@
 
     private boolean enabled = true;
 
+    /**
+     * true锛氬叆绔�/鍑虹珯鏄惁钀藉簱鐢� {@code sys_http_audit_rule} 鍐冲畾锛堝惈 record_all=1 鍏ㄩ噺銆佹柟鍚� IN/OUT/BOTH銆佹埅鏂暱搴︼級锛沠alse锛氭帓闄よ矾寰勫鍏ョ珯涓庡叏閮ㄥ嚭绔欏潎璁板綍锛屾埅鏂敤鏈厤缃� + 瑙勫垯涓�屽叏閲忋�嶈鐨� request/response_max_chars锛堣嫢鏈夛級
+     */
+    private boolean whitelistOnly = true;
+
+    /** 瑙勫垯缂撳瓨瀹氭椂鍒锋柊闂撮殧锛堟绉掞級 */
+    private long ruleCacheRefreshMs = 60_000L;
+
+    /** 瀹氭椂娓呯悊寮�鍏� */
+    private boolean cleanupEnabled = true;
+    /** 淇濈暀澶╂暟 */
+    private int cleanupRetentionDays = 180;
+
     /** 鏌ヨ绫诲搷搴旀渶澶氫繚鐣欏瓧绗︽暟 */
     private int queryResponseMaxChars = 500;
 
     /** 闈炴煡璇㈢被鍝嶅簲鏈�澶氬叆搴撳瓧鑺傦紙瓒呭嚭鎴柇骞舵爣璁帮級 */
     private int maxResponseStoreChars = 65535;
+
+    /**
+     * 瑙勫垯鏈寚瀹� request_max_chars 鏃剁殑榛樿锛氬瓧绗︽暟锛�-1 琛ㄧず鍏ュ簱涓嶆埅鏂姹備綋
+     */
+    private int defaultRequestStoreChars = 65535;
 
     /** 璇锋眰浣撶紦瀛樹笂闄愶紙瀛楄妭锛� */
     private int maxRequestCacheBytes = 2 * 1024 * 1024;
@@ -32,11 +50,61 @@
     /** 涓嶈惤搴撶殑璺緞鍓嶇紑 */
     private List<String> excludePathPrefixes = defaultExcludes();
 
+    /**
+     * true锛氶粯璁ゆ帓闄や腑鐨� /httpAuditLog銆�/httpAuditRule 浠嶇敓鏁堬紱false锛氫笉鍐嶆帓闄よ繖涓ら」锛堜究浜庤皟璇曪紱record_all 涔熸棤娉曠粫杩� true 鏃剁殑鎺掗櫎锛�
+     */
+    private boolean excludeAuditSelfPaths = true;
+
+    /** Filter 瀹為檯浣跨敤鐨勫墠缂�锛堝彈 excludeAuditSelfPaths 褰卞搷锛� */
+    public List<String> getEffectiveExcludePrefixes() {
+        List<String> list = excludePathPrefixes == null ? new ArrayList<>() : new ArrayList<>(excludePathPrefixes);
+        if (!isExcludeAuditSelfPaths()) {
+            list.removeIf(p -> "/httpAuditLog".equals(p) || "/httpAuditRule".equals(p));
+        }
+        return list;
+    }
+
     /** 瑙嗕负澶栭儴璋冪敤鐨勮矾寰勫墠缂�锛堝叾浣欎负鍐呴儴锛� */
     private List<String> externalPathPrefixes = defaultExternal();
 
     /** 璺緞 -> 鍔熻兘鎻忚堪锛堟寜鏈�闀胯矾寰勫墠缂�鍖归厤锛� */
     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<>();
@@ -51,6 +119,7 @@
         list.add("/favicon.ico");
         list.add("/static/");
         list.add("/httpAuditLog");
+        list.add("/httpAuditRule");
         return list;
     }
 

--
Gitblit v1.9.1