A command-line interface (CLI) tool to fetch CVE (Common Vulnerabilities and Exposures) and CPE (Common Platform Enumeration) data from NIST's National Vulnerability Database (NVD) API, along with CWE (Common Weakness Enumeration) data from MITRE.
- Multi-format Data Download: Fetch CVE, CPE, CPE Match, and CVE History data using NIST's NVD API 2.0
- Legacy URI Support: Download data using traditional URI-based methods
- Data Merging: Combine multiple data files into consolidated datasets
- Concurrent Processing: Multi-threaded download and processing for improved performance
- Flexible Output: Configurable output directories and file naming
- Query Filtering: Support for date ranges, modification filters, and pagination
- Java 21 or higher
- Maven 3.6 or higher
mvn clean package
This creates an executable JAR file with all dependencies included in the target/
directory.
mvn clean post-clean package
mvn resources:copy-resources@generate-buildconfig
This project uses GitHub Actions for automated:
- CI: Automated testing with coverage validation (70% threshold)
- Code Quality: Formatting checks, SpotBugs security analysis, and PMD analysis
- Automated Releases: When a tag like
v0.1.0
is created, the workflow automatically builds and attaches the executable JAR to the GitHub release
-
Create and push a tag following semantic versioning:
git tag v0.1.0 git push origin v0.1.0
-
Create a GitHub release using the tag - the CI/CD pipeline will automatically build and attach the executable JAR as a release asset.
Test the executable JAR:
java -jar target/nvd-tool-0.1.0-SNAPSHOT.jar --help
The tool provides several commands for different operations:
java -jar nvd-tool-1.0-SNAPSHOT.jar [COMMAND] [OPTIONS]
Download CVE/CPE data from NIST NVD repository and CWE data from MITRE.
java -jar nvd-tool-1.0-SNAPSHOT.jar download [SUBCOMMAND] [OPTIONS]
Download Subcommands:
api
- Download using NVD API 2.0uri
- Download using traditional URI methods
# Download CVE data
java -jar nvd-tool-1.0-SNAPSHOT.jar download api cve [OPTIONS]
# Download CPE data
java -jar nvd-tool-1.0-SNAPSHOT.jar download api cpe [OPTIONS]
# Download CPE Match data
java -jar nvd-tool-1.0-SNAPSHOT.jar download api cpe-match [OPTIONS]
# Download CVE History data
java -jar nvd-tool-1.0-SNAPSHOT.jar download api cve-history [OPTIONS]
Combine multiple downloaded data files.
java -jar nvd-tool-1.0-SNAPSHOT.jar merge [OPTIONS]
-o, --output-dir DIR
- Specify output directory--output-file FILE
- Specify output filename-h, --help
- Show help information-V, --version
- Show version information
java -jar nvd-tool-1.0-SNAPSHOT.jar download api cve \
--output-dir ./data \
--last-mod-start-date 2024-01-01T00:00:00 \
--last-mod-end-date 2024-01-31T23:59:59
java -jar nvd-tool-1.0-SNAPSHOT.jar download api cpe \
--output-dir ./cpe-data \
--results-per-page 500
java -jar nvd-tool-1.0-SNAPSHOT.jar merge \
--input-dir ./data \
--output-file merged-cve-data.json
nvd-tool/
├── src/
│ ├── main/
│ │ ├── java/com/github/phanikb/nvd/
│ │ │ ├── cli/ # Command-line interface classes
│ │ │ ├── api2/ # Generated API 2.0 schema classes
│ │ │ ├── common/ # Common utilities and exceptions
│ │ │ ├── enums/ # Enumeration types
│ │ │ └── utils/ # Utility classes
│ │ └── resources/
│ │ ├── schema/ # JSON schema files
│ │ ├── spotbugs/ # SpotBugs configuration
│ │ └── pmd/ # PMD ruleset
│ └── test/
│ └── java/ # Unit tests
├── target/ # Build artifacts
├── logs/ # Application logs
├── pom.xml # Maven configuration
└── README.md
The project uses jsonschema2pojo-maven-plugin
to generate Java classes from JSON schemas for:
- CVE API 2.0 schema
- CPE API 2.0 schema
- CPE Match API 2.0 schema
- CVE History API 2.0 schema
Key dependencies include:
- PicoCLI: Command-line interface framework
- Apache HttpClient 5: HTTP client for API requests
- Jackson: JSON processing
- Lombok: Boilerplate code reduction
- JUnit 5: Testing framework
- Mockito: Mocking framework for tests
- Log4j 2: Logging framework
Run the test suite:
mvn test
Run code quality checks:
# Spotless formatting check
mvn spotless:check
# Apply Spotless formatting
mvn spotless:apply
# Run SpotBugs analysis
mvn spotbugs:check
# Run PMD analysis
mvn pmd:check
The application uses Log4j 2 for logging. Log files are stored in the logs/
directory with automatic archiving.
- Ensure code follows the project's formatting standards (run
mvn spotless:apply
) - Add appropriate unit tests for new functionality
- Run the full test suite before submitting changes
- Follow the existing code structure and naming conventions
This project is licensed under the terms specified in the LICENSE file.
This tool uses data from the NVD API but is not endorsed or certified by the NVD.
Happy vulnerability hunting! 🔍