Apache Commons Text
repository·master·Indexed 18 days ago
https://github.com/apache/commons-textA Java library providing a collection of utilities for text manipulation and processing. It includes features such as ConstantStringLookup for resolving static final fields and support for SBOM and VEX documents for dependency risk management.
What's inside Apache Commons Text
- Apache Commons Text provides a set of utility functions and reusable components designed for processing and manipulating text within a Java environment.
Understand VEX (Vulnerability Exploitability eXchange) for Apache Commons Text
masterApache Commons Text publishes an experimental VEX document to provide information regarding the exploitability of known vulnerabilities within its dependencies.
Exploitability Criteria
Because Apache Commons Text does not bundle its dependencies, a vulnerability in a dependency is only considered exploitable if:
- The vulnerable dependency is included in your consuming project.
- Apache Commons Text is explicitly listed as affected by the vulnerability.
Important Limitations
- Experimental Status: The VEX document is provided as-is and its semantics may change.
- Absence of Data: The absence of a vulnerability entry does not guarantee that Text is unaffected.
- Version Coverage: Only the latest major version of Text is currently assessed. If a version is not listed under the
affectssection, it may still be affected. - Formatting: The
analysisfield within the VEX file uses Markdown formatting.
https://raw.githubusercontent.com/apache/commons-text/refs/heads/master/src/conf/security/VEX.cyclonedx.xmlInstall Apache Commons Text via Maven
masterTo use Apache Commons Text in your Java project, add the following dependency to your
pom.xmlfile. Ensure you use the version compatible with your project requirements (the current version shown is 1.15.0).<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-text</artifactId> <version>1.15.0</version> </dependency>Build Apache Commons Text from source
masterTo build the project from source, you need a Java JDK and Apache Maven installed. The required Java version is specified in the
pom.xmlunder themaven.compiler.sourceproperty.To run the default Maven goal, which executes all tests and checks, run the following command from a command shell:
mvnAccess SBOM (Software Bill of Materials) for Apache Commons Text
masterStarting from version
6.6.0, Apache Commons Text publishes SBOMs in both XML and JSON formats to Maven Central. These documents allow consumers to analyze the software supply chain and manage dependency risk by describing all components and dependencies used in the library.To locate the SBOM in a Maven repository, use the following coordinates:
- Group ID:
org.apache.commons - Artifact ID:
commons-text - Classifier:
cyclonedx - Type:
xmlorjson
Note: The dependency versions listed in the SBOM reflect those used during the build and test process for that specific release. Your own project may use different versions based on your dependency management configuration.
Group ID: org.apache.commons Artifact ID: commons-text Classifier: cyclonedx Type: xml or json- Group ID:
Use ConstantStringLookup to resolve static final fields
masterThe
ConstantStringLookupallows you to resolve the value of astatic finalmember field of a class using its fully-qualified name. This is useful for injecting Java constants into configuration files or text templates.Key Requirements
- The target field must be
staticandfinal. - The input key must follow the format:
apackage.AClass.AFIELD. - The field must be accessible (public).
Usage via StringLookupFactory
You can access this lookup through the
StringLookupFactorysingleton:StringLookupFactory.INSTANCE.constantStringLookup().lookup("java.awt.event.KeyEvent.VK_ESCAPE");Usage via StringSubstitutor
You can use it within a
StringSubstitutor(specifically an interpolator) by using theconstprefix in your substitution expressions:StringSubstitutor.createInterpolator().replace("... ${const:java.awt.event.KeyEvent.VK_ESCAPE} ...");In the examples above, the key
java.awt.event.KeyEvent.VK_ESCAPEis resolved to its string representation, such as"27".// Using StringLookupFactory StringLookupFactory.INSTANCE.constantStringLookup().lookup("java.awt.event.KeyEvent.VK_ESCAPE"); // Using StringSubstitutor StringSubstitutor.createInterpolator().replace("... ${const:java.awt.event.KeyEvent.VK_ESCAPE} ...");- The target field must be