Skip to content

Conversation

@digizeph
Copy link
Member

@digizeph digizeph commented Dec 7, 2025

Summary

This PR refactors the as2org and rpki modules to use bgpkit-commons v0.10's asinfo and rpki modules, replacing custom implementations and removing outdated dependencies.

Breaking Changes

  • Removed rpki read-roa command - Previously parsed individual ROA files using the rpki crate
  • Removed rpki read-aspa command - Previously parsed individual ASPA files using the rpki crate

New Features

rpki roas command

List ROAs from RPKI data (current or historical):

# Current data from Cloudflare
monocle rpki roas --origin 400644

# Historical data from RIPE NCC
monocle rpki roas --origin 400644 --date 2024-01-04

# Historical data from RPKIviews
monocle rpki roas --date 2024-01-04 --source rpkiviews --collector soborost

# JSON output
monocle rpki roas --origin 400644 --date 2024-01-04 --json

rpki aspas command

List ASPAs from RPKI data (current or historical):

# Filter by customer ASN
monocle rpki aspas --customer 15562 --date 2024-01-04

# Filter by provider ASN
monocle rpki aspas --provider 6939 --date 2024-01-04

# JSON output (providers as array)
monocle rpki aspas --customer 15562 --date 2024-01-04 --json

JSON output for all RPKI commands

All RPKI commands now support --json flag:

  • rpki check - Returns validation result and covering ROAs
  • rpki list - Returns ROAs as JSON array
  • rpki summary - Returns summary as JSON array
  • rpki roas - Returns ROAs as JSON array
  • rpki aspas - Returns ASPAs with providers as numeric array

Improvements

  • as2org data source: Now uses bgpkit-commons asinfo module instead of custom CAIDA file parsing
    • SQLite caching preserved for fast repeated queries
    • whois --update reloads data from bgpkit-commons
  • Table formatting: ASPA output groups providers by customer ASN with column width wrapping (60 chars)

Dependencies

  • Added: bgpkit-commons v0.10 with features: asinfo, rpki, countries
  • Removed: rpki crate (was v0.16.1)

Files Changed

  • Cargo.toml - Updated dependencies
  • src/datasets/as2org.rs - Refactored to use bgpkit-commons for data loading
  • src/datasets/rpki/commons.rs - NEW - bgpkit-commons RPKI integration
  • src/datasets/rpki/mod.rs - Updated exports
  • src/datasets/rpki/validator.rs - Added Serialize derives for JSON output
  • src/datasets/rpki/aspa.rs - DELETED
  • src/datasets/rpki/roa.rs - DELETED
  • src/bin/monocle.rs - Updated CLI commands
  • CHANGELOG.md - Added unreleased section
  • README.md - Updated RPKI documentation

Breaking Changes:
- Removed 'rpki read-roa' and 'rpki read-aspa' commands (relied on outdated rpki crate)

New Features:
- New 'rpki roas' command: list ROAs with filters (origin, prefix, date, source)
- New 'rpki aspas' command: list ASPAs with filters (customer, provider, date, source)
- Support for historical RPKI data from RIPE NCC and RPKIviews
- JSON output support for all RPKI commands (--json flag)

Improvements:
- as2org data loading now uses bgpkit-commons asinfo module
- SQLite caching preserved for fast repeated whois queries
- ASPA table output groups providers by customer ASN
- Column width wrapping for better table readability

Dependencies:
- Added bgpkit-commons v0.10 (asinfo, rpki, countries features)
- Removed rpki crate dependency
@digizeph
Copy link
Member Author

digizeph commented Dec 7, 2025

Addresses issue #85

@digizeph digizeph merged commit 72e6c7c into main Dec 7, 2025
5 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR successfully refactors the RPKI and as2org modules to use the bgpkit-commons v0.10 library, consolidating data sources and removing outdated dependencies. The refactoring introduces new commands for querying historical RPKI data while maintaining backward compatibility for existing functionality.

Key Changes

  • RPKI module refactored: Removed rpki read-roa and rpki read-aspa commands that relied on the outdated rpki crate, replacing them with new rpki roas and rpki aspas commands that leverage bgpkit-commons for both current and historical RPKI data
  • as2org data loading modernized: Replaced custom CAIDA file parsing with bgpkit-commons asinfo module while preserving SQLite caching for performance
  • JSON output support: Added --json flag support across all RPKI commands for programmatic access to validation results, ROAs, ASPAs, and summaries

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Cargo.toml Updated dependencies: added bgpkit-commons v0.10 with features, removed rpki crate, bumped bgpkit-broker to v0.10.1
Cargo.lock Dependency resolution updates reflecting the new bgpkit-commons and removal of rpki crate transitive dependencies
src/datasets/rpki/commons.rs New module implementing RPKI data integration using bgpkit-commons with support for current (Cloudflare) and historical (RIPE NCC, RPKIviews) data sources
src/datasets/rpki/validator.rs Added Serialize derives to enable JSON output for validation results and ROA table items
src/datasets/rpki/mod.rs Updated module exports to use new commons module instead of deleted aspa and roa modules
src/datasets/rpki/aspa.rs Deleted file - functionality replaced by bgpkit-commons integration
src/datasets/rpki/roa.rs Deleted file - functionality replaced by bgpkit-commons integration
src/datasets/as2org.rs Refactored to load data from bgpkit-commons instead of parsing CAIDA files, with synthetic org entries for ASes without as2org data
src/bin/monocle.rs Removed old read-roa and read-aspa commands, added new roas and aspas commands with historical data support and JSON output for all RPKI commands
README.md Updated RPKI documentation to reflect new commands, data sources, and JSON output capabilities
CHANGELOG.md Added unreleased section documenting breaking changes, new features, improvements, and dependency updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 395 to 399
#[test]
fn test_creating_db() {
let as2org = As2org::new(&Some("./test.sqlite3".to_string())).unwrap();
// approximately one minute insert time
let _res = as2org.parse_insert_as2org(Some("tests/test-as2org.jsonl.gz"));

as2org.clear_db().unwrap();
}
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test test_creating_db no longer properly tests the parse_insert_as2org functionality since the test data file tests/test-as2org.jsonl.gz is no longer used after the refactor to use bgpkit-commons. The old implementation parsed this file, but the new implementation loads data directly from bgpkit-commons, ignoring the _url parameter.

Consider either:

  1. Removing the now-unused test data file tests/test-as2org.jsonl.gz
  2. Adding integration tests that verify the bgpkit-commons data loading works correctly
  3. Updating test documentation to clarify that this test only verifies DB creation/clearing, not data loading

Copilot uses AI. Check for mistakes.
@digizeph digizeph deleted the feature/bgpkit-commons branch December 18, 2025 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants