Class ZipBombDetectedException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class ZipBombDetectedException extends OpenIOOperationException
Thrown when ZIP archive operations breach the configured anti-bomb thresholds. 当 ZIP 操作触发配置的反炸弹阈值时抛出。

Triggered by any of the ZipOptions caps: maxCompressionRatio / maxTotalSize / maxEntryCount / maxNestingDepth / maxSingleEntrySize. Carries structured fields (getViolatedThreshold() / getActualValue() / getConfiguredLimit()) so observability and policy code can react without parsing the free-text message.

ZipOptions 的以下任一上限触发: maxCompressionRatio / maxTotalSize / maxEntryCount / maxNestingDepth / maxSingleEntrySize。携带结构化字段 (getViolatedThreshold() / getActualValue() / getConfiguredLimit()), 让观测与策略代码无需解析自由文本消息即可处理。

Since:
JDK 25, opencode-base-io V1.0.4
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • ZipBombDetectedException

      public ZipBombDetectedException(String zipFile, String violatedThreshold, long actualValue, long configuredLimit)
      Constructs a new exception with structured threshold metadata. 构造异常并携带结构化阈值元数据。
      Parameters:
      zipFile - path of the archive being processed | 正在处理的 ZIP 路径
      violatedThreshold - logical name of the breached cap, e.g. "maxCompressionRatio" | 被触发的限制名(逻辑标识符)
      actualValue - the observed value that breached the cap | 触发上限时观测到的值
      configuredLimit - the cap value the caller configured via ZipOptions | 调用方通过 ZipOptions 配置的限制值
    • ZipBombDetectedException

      public ZipBombDetectedException(String zipFile, String message)
      Constructs a new exception describing which threshold was breached. Free-text constructor retained for callers that don't have numeric values to attach (e.g. nested-zip detection by name); structured fields default to empty / 0. 构造异常说明被触发的阈值。本重载保留供没有数值可附带的调用方(如按名称检测嵌套 ZIP); 结构化字段默认为空 / 0
      Parameters:
      zipFile - path of the archive being processed | 正在处理的 ZIP 路径
      message - description of which limit was breached | 被触发的限制说明
    • ZipBombDetectedException

      public ZipBombDetectedException(String zipFile, String message, Throwable cause)
      Constructs a new exception with cause. 构造带原因的异常。
      Parameters:
      zipFile - path of the archive being processed | 正在处理的 ZIP 路径
      message - description of which limit was breached | 被触发的限制说明
      cause - underlying cause | 原始原因
  • Method Details

    • getViolatedThreshold

      public String getViolatedThreshold()
      Returns the logical name of the threshold that was breached, or empty string when the exception was constructed without structured metadata. 返回被触发阈值的逻辑名;以无结构化元数据的构造器创建时返回空串。
      Returns:
      threshold identifier such as "maxCompressionRatio" | 阈值标识符
    • getActualValue

      public long getActualValue()
      Returns the observed value that breached the cap, or 0 when not provided. 返回触发上限时观测到的值;未提供时返回 0
      Returns:
      observed value | 观测值
    • getConfiguredLimit

      public long getConfiguredLimit()
      Returns the cap value the caller configured via ZipOptions, or 0 when not provided. 返回调用方通过 ZipOptions 配置的限制值;未提供时返回 0
      Returns:
      configured limit | 配置的限制值