// This file is auto-generated by alef — DO NOT EDIT. // alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75 // To regenerate: alef generate // To verify freshness: alef verify --exit-code // Issues & docs: https://github.com/kreuzberg-dev/alef package dev.kreuzberg; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; /** * Configuration for security limits across extractors. * * All limits are intentionally conservative to prevent DoS attacks * while still supporting legitimate documents. */ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = SecurityLimits.Builder.class) public record SecurityLimits( /** * Maximum uncompressed size for archives (500 MB) */ @JsonProperty("max_archive_size") long maxArchiveSize, /** * Maximum compression ratio before flagging as potential bomb (100:1) */ @JsonProperty("max_compression_ratio") long maxCompressionRatio, /** * Maximum number of files in archive (10,000) */ @JsonProperty("max_files_in_archive") long maxFilesInArchive, /** * Maximum nesting depth for structures (100) */ @JsonProperty("max_nesting_depth") long maxNestingDepth, /** * Maximum length of any single XML entity / attribute / token (1 MiB). * This is a per-token cap, NOT a total cap — billion-laughs class * attacks where a single entity expands to hundreds of MB are caught * here, while normal long text content (a paragraph, a CDATA block) is * caught by {@code max_content_size} instead. */ @JsonProperty("max_entity_length") long maxEntityLength, /** * Maximum string growth per document (100 MB) */ @JsonProperty("max_content_size") long maxContentSize, /** * Maximum iterations per operation */ @JsonProperty("max_iterations") long maxIterations, /** * Maximum XML depth (100 levels) */ @JsonProperty("max_xml_depth") long maxXmlDepth, /** * Maximum cells per table (100,000) */ @JsonProperty("max_table_cells") long maxTableCells ) { public static Builder builder() { return new Builder(); } public SecurityLimits{ if (maxArchiveSize == 0) maxArchiveSize = 524288000; if (maxCompressionRatio == 0) maxCompressionRatio = 100; if (maxFilesInArchive == 0) maxFilesInArchive = 10000; if (maxNestingDepth == 0) maxNestingDepth = 1024; if (maxEntityLength == 0) maxEntityLength = 1048576; if (maxContentSize == 0) maxContentSize = 104857600; if (maxIterations == 0) maxIterations = 10000000; if (maxXmlDepth == 0) maxXmlDepth = 1024; if (maxTableCells == 0) maxTableCells = 100000; } // CPD-OFF @JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build") public static final class Builder { @JsonProperty("max_archive_size") private long maxArchiveSize = 0; @JsonProperty("max_compression_ratio") private long maxCompressionRatio = 0; @JsonProperty("max_files_in_archive") private long maxFilesInArchive = 0; @JsonProperty("max_nesting_depth") private long maxNestingDepth = 0; @JsonProperty("max_entity_length") private long maxEntityLength = 0; @JsonProperty("max_content_size") private long maxContentSize = 0; @JsonProperty("max_iterations") private long maxIterations = 0; @JsonProperty("max_xml_depth") private long maxXmlDepth = 0; @JsonProperty("max_table_cells") private long maxTableCells = 0; /** Sets the maxArchiveSize field. */ @JsonProperty("max_archive_size") public Builder withMaxArchiveSize(final long value) { this.maxArchiveSize = value; return this; } /** Sets the maxCompressionRatio field. */ @JsonProperty("max_compression_ratio") public Builder withMaxCompressionRatio(final long value) { this.maxCompressionRatio = value; return this; } /** Sets the maxFilesInArchive field. */ @JsonProperty("max_files_in_archive") public Builder withMaxFilesInArchive(final long value) { this.maxFilesInArchive = value; return this; } /** Sets the maxNestingDepth field. */ @JsonProperty("max_nesting_depth") public Builder withMaxNestingDepth(final long value) { this.maxNestingDepth = value; return this; } /** Sets the maxEntityLength field. */ @JsonProperty("max_entity_length") public Builder withMaxEntityLength(final long value) { this.maxEntityLength = value; return this; } /** Sets the maxContentSize field. */ @JsonProperty("max_content_size") public Builder withMaxContentSize(final long value) { this.maxContentSize = value; return this; } /** Sets the maxIterations field. */ @JsonProperty("max_iterations") public Builder withMaxIterations(final long value) { this.maxIterations = value; return this; } /** Sets the maxXmlDepth field. */ @JsonProperty("max_xml_depth") public Builder withMaxXmlDepth(final long value) { this.maxXmlDepth = value; return this; } /** Sets the maxTableCells field. */ @JsonProperty("max_table_cells") public Builder withMaxTableCells(final long value) { this.maxTableCells = value; return this; } /** Builds the SecurityLimits instance. */ public SecurityLimits build() { return new SecurityLimits( maxArchiveSize, maxCompressionRatio, maxFilesInArchive, maxNestingDepth, maxEntityLength, maxContentSize, maxIterations, maxXmlDepth, maxTableCells ); } } // CPD-ON public static SecurityLimits defaultInstance() { throw new UnsupportedOperationException("defaultInstance is not yet bridged via JNI; use the Builder instead."); } }