$ show hapifhir/org.hl7.fhir.core
This is the HAPI FHIR core library, a multi-module Java implementation of the HL7 FHIR standard. It provides FHIR object models for versions DSTU2, DSTU3, R4, R4B, R5, and an experimental R6, along with cross-version conversion, validation, terminology services, code generation, CLI tooling, and HTTP service endpoints. The architecture is a monolithic Maven project with modules for each FHIR version, a shared convertors module with pairwise converters, a validation engine with picocli-based CLI, and a services layer for rendering and terminology. Key entry points include VersionConvertorFactory for conversion, ValidationEngine for validation, and CLI commands for the validator. The codebase is actively maintained with CI/CD, security scanning, and regular releases to Maven Central. However, it suffers from significant duplication across version modules, some deprecated interfaces, and generated code that may drift from upstream specifications. The project demonstrates strong engineering practices with reusable security utilities (SSRF protection, zip-slip prevention), generic data structure utilities (MergedList, BaseList), and a well-structured conversion pattern using advisors and contexts.
The LLM identified 4 files worth highlighting for reuse:
An OkHttp DNS implementation that validates resolved IP addresses against an SSRF policy, rejecting non-public addresses and closing the DNS rebinding window. This is a self-contained security component that can be extracted and reused in any OkHttp-based HTTP client to prevent server-side request forgery attacks. It demonstrates non-obvious security engineering by addressing the DNS rebinding race condition.
A zip input stream wrapper that prevents zip-slip directory traversal attacks by verifying that each extracted entry's canonical path is within the target output directory. This is a reusable security utility that can be applied to any Java zip extraction code to mitigate path traversal vulnerabilities. It is self-contained and demonstrates defensive file-handling practices.
A custom AbstractList implementation that automatically stamps each added element with the owning object's model context, ensuring consistent parent references in a hierarchical data model. This pattern is reusable for any tree-structured object model where child elements need to maintain a back-reference to their parent. It is self-contained and demonstrates a clean solution to a common object-modeling problem.
A generic utility that merges two lists positionally or via an IMatcher interface, producing left/right MergeNode results. This is a reusable data structure for implementing diff/merge operations on ordered collections. It is self-contained, generic, and can be extracted into any Java project needing list comparison or merging functionality.