Skip to content

CUI-HTTP

1. Status

2. What is it?

Security-focused HTTP utilities library providing validation pipelines, SSL/TLS context management, and HTTP client handlers with comprehensive attack pattern detection.

3. Maven Coordinates

<dependency>
    <groupId>de.cuioss</groupId>
    <artifactId>cui-http</artifactId>
</dependency>

Test artifact:

<dependency>
    <groupId>de.cuioss</groupId>
    <artifactId>cui-http</artifactId>
    <classifier>generators</classifier>
    <scope>test</scope>
</dependency>

4. Components

4.1. HTTP Security Validation

  • Validation pipelines for paths, parameters, headers

  • Attack pattern detection (path traversal, parameter injection, protocol violations)

  • Configuration via SecurityConfigurationBuilder

4.2. HTTP Client Handlers

  • HttpHandler - Builder-based HTTP client with SSL defaults

  • SecureSSLContextProvider - TLS 1.2+ SSL context

  • HttpStatusFamily - RFC 7231 status classification

4.3. Forwarded / Reverse-Proxy Header Resolution

  • Resolves X-Forwarded-, RFC 7239 Forwarded, and NiFi X-Proxy into one sanitized result

  • Scheme / host / port / context-path / client-IP with configurable per-field precedence

  • Secure-by-default trust model (allowlist, trustAll, trusted-proxy CIDR walk)

  • Built-in sanitization via the security pipelines; transport-agnostic Function<String,String> accessor

4.4. Security Testing

  • Attack databases with CVE patterns and OWASP vectors

  • Test data generators for security validation

  • JUnit 5 integration with ArgumentsProvider

5. Usage Example

// HTTP Client
HttpHandler handler = HttpHandler.builder()
    .uri("https://api.example.com/data")
    .connectionTimeoutSeconds(10)
    .build();

HttpClient client = handler.createHttpClient();
HttpRequest request = handler.requestBuilder()
    .GET()
    .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

// Security Validation
SecurityConfiguration config = SecurityConfiguration.builder()
    .maxPathLength(2048)
    .build();

URLPathValidationPipeline pipeline = new URLPathValidationPipeline(
    config, new SecurityEventCounter());

String validated = pipeline.validate("/api/users/123").orElseThrow();

6. Build Commands

The following standard Maven commands are provided for human contributors:

./mvnw clean install          # Build and install
./mvnw test                   # Run tests
./mvnw -Ppre-commit clean verify  # Pre-commit checks (MANDATORY)
./mvnw -Pcoverage clean verify    # Coverage report
Note
AI coding agents must not hard-code ./mvnw/mvn; they invoke builds via the canonical build-executor commands documented in the "Build Commands" section of CLAUDE.md.

8. Dependencies

  • Java 21+

  • cui-java-tools

  • JSpecify (null-safety)

  • Lombok (code generation)

  • JUnit 5 (test only)

About

Provides a number of http-related utilities

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Sponsor this project

Used by

Contributors

Languages