20260605 移除audit rule index和DB trace
This commit is contained in:
@@ -4,9 +4,8 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
use rocksdb::{DB, IteratorMode, Options};
|
||||
use rpki::storage::{
|
||||
ALL_COLUMN_FAMILY_NAMES, CF_AUDIT_RULE_INDEX, CF_MANIFEST_REPLAY_META, CF_RAW_BY_HASH,
|
||||
CF_REPOSITORY_VIEW, CF_RRDP_SOURCE, CF_RRDP_SOURCE_MEMBER, CF_RRDP_URI_OWNER, CF_VCIR,
|
||||
column_family_descriptors,
|
||||
ALL_COLUMN_FAMILY_NAMES, CF_MANIFEST_REPLAY_META, CF_RAW_BY_HASH, CF_REPOSITORY_VIEW,
|
||||
CF_RRDP_SOURCE, CF_RRDP_SOURCE_MEMBER, CF_RRDP_URI_OWNER, CF_VCIR, column_family_descriptors,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
@@ -99,7 +98,7 @@ Output:
|
||||
|
||||
Output groups:
|
||||
- current_repository_view: repository_view + raw_by_hash
|
||||
- current_validation_state: vcir + audit_rule_index
|
||||
- current_validation_state: vcir + manifest_replay_meta
|
||||
- current_rrdp_state: rrdp_source + rrdp_source_member + rrdp_uri_owner
|
||||
"
|
||||
)
|
||||
@@ -183,7 +182,7 @@ fn collect_db_file_stats(db_path: &Path) -> Result<DbFileStats, Box<dyn std::err
|
||||
fn cf_group(cf_name: &str) -> CfGroup {
|
||||
match cf_name {
|
||||
CF_REPOSITORY_VIEW | CF_RAW_BY_HASH => CfGroup::CurrentRepositoryView,
|
||||
CF_VCIR | CF_MANIFEST_REPLAY_META | CF_AUDIT_RULE_INDEX => CfGroup::CurrentValidationState,
|
||||
CF_VCIR | CF_MANIFEST_REPLAY_META => CfGroup::CurrentValidationState,
|
||||
CF_RRDP_SOURCE | CF_RRDP_SOURCE_MEMBER | CF_RRDP_URI_OWNER => CfGroup::CurrentRrdpState,
|
||||
_ => CfGroup::LegacyCompatibility,
|
||||
}
|
||||
@@ -375,10 +374,6 @@ mod tests {
|
||||
cf_group(CF_MANIFEST_REPLAY_META),
|
||||
CfGroup::CurrentValidationState
|
||||
);
|
||||
assert_eq!(
|
||||
cf_group(CF_AUDIT_RULE_INDEX),
|
||||
CfGroup::CurrentValidationState
|
||||
);
|
||||
assert_eq!(cf_group(CF_RRDP_SOURCE), CfGroup::CurrentRrdpState);
|
||||
assert_eq!(cf_group(CF_RRDP_URI_OWNER), CfGroup::CurrentRrdpState);
|
||||
assert_eq!(cf_group("unknown_legacy"), CfGroup::LegacyCompatibility);
|
||||
@@ -390,7 +385,7 @@ mod tests {
|
||||
(CF_REPOSITORY_VIEW, 5),
|
||||
(CF_RAW_BY_HASH, 7),
|
||||
(CF_VCIR, 11),
|
||||
(CF_AUDIT_RULE_INDEX, 13),
|
||||
(CF_MANIFEST_REPLAY_META, 13),
|
||||
(CF_RRDP_SOURCE_MEMBER, 19),
|
||||
]);
|
||||
|
||||
@@ -420,7 +415,7 @@ mod tests {
|
||||
live_sst_size_bytes: 55,
|
||||
live_sst_files: 2,
|
||||
};
|
||||
let audit = CfStats {
|
||||
let replay_meta = CfStats {
|
||||
keys: 5,
|
||||
key_bytes: 50,
|
||||
value_bytes: 500,
|
||||
@@ -433,7 +428,7 @@ mod tests {
|
||||
let grouped = summarize_cf_stats([
|
||||
(CF_REPOSITORY_VIEW, &repo),
|
||||
(CF_VCIR, &vcir),
|
||||
(CF_AUDIT_RULE_INDEX, &audit),
|
||||
(CF_MANIFEST_REPLAY_META, &replay_meta),
|
||||
]);
|
||||
|
||||
assert_eq!(grouped.get(&CfGroup::CurrentRepositoryView), Some(&repo));
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
use rpki::audit_trace::trace_rule_to_root;
|
||||
use rpki::storage::{AuditRuleKind, RocksStore, VcirOutputType};
|
||||
use serde_json::Value;
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() < 3 {
|
||||
eprintln!("usage: trace_arin_missing_vrps <db> <row> [<row> ...]");
|
||||
std::process::exit(2);
|
||||
}
|
||||
|
||||
let store = RocksStore::open(Path::new(&args[1])).expect("open db");
|
||||
let vcirs = store.list_vcirs().expect("list vcirs");
|
||||
|
||||
for row in &args[2..] {
|
||||
let parts: Vec<&str> = row.split(',').collect();
|
||||
if parts.len() != 4 {
|
||||
println!("ROW {row}");
|
||||
println!("ERROR invalid compare row");
|
||||
println!();
|
||||
continue;
|
||||
}
|
||||
let asn: u32 = parts[0]
|
||||
.trim_start_matches("AS")
|
||||
.parse()
|
||||
.expect("parse asn");
|
||||
let prefix = parts[1].to_string();
|
||||
let max_length: u8 = parts[2].parse().expect("parse max length");
|
||||
let mut found = false;
|
||||
|
||||
println!("ROW {row}");
|
||||
for vcir in &vcirs {
|
||||
for output in &vcir.local_outputs {
|
||||
if output.output_type != VcirOutputType::Vrp {
|
||||
continue;
|
||||
}
|
||||
let payload: Value = match serde_json::from_str(&output.payload_json) {
|
||||
Ok(value) => value,
|
||||
Err(_) => continue,
|
||||
};
|
||||
let payload_asn = payload
|
||||
.get("asn")
|
||||
.and_then(|v| v.as_u64())
|
||||
.map(|v| v as u32);
|
||||
let payload_prefix = payload
|
||||
.get("prefix")
|
||||
.and_then(|v| v.as_str())
|
||||
.map(|v| v.to_string());
|
||||
let payload_max = payload
|
||||
.get("max_length")
|
||||
.and_then(|v| v.as_u64())
|
||||
.map(|v| v as u8);
|
||||
if payload_asn == Some(asn)
|
||||
&& payload_prefix.as_ref() == Some(&prefix)
|
||||
&& payload_max == Some(max_length)
|
||||
{
|
||||
found = true;
|
||||
println!("manifest_rsync_uri={}", vcir.manifest_rsync_uri);
|
||||
println!("source_object_uri={}", output.source_object_uri);
|
||||
println!("source_object_hash={}", output.source_object_hash);
|
||||
println!("source_ee_cert_hash={}", output.source_ee_cert_hash);
|
||||
println!("rule_hash={}", output.rule_hash);
|
||||
println!("validation_path_hint={:?}", output.validation_path_hint);
|
||||
|
||||
if let Some(trace) =
|
||||
trace_rule_to_root(&store, AuditRuleKind::Roa, &output.rule_hash)
|
||||
.expect("trace rule")
|
||||
{
|
||||
println!(
|
||||
"trace_leaf_manifest={}",
|
||||
trace
|
||||
.chain_leaf_to_root
|
||||
.first()
|
||||
.map(|node| node.manifest_rsync_uri.as_str())
|
||||
.unwrap_or("")
|
||||
);
|
||||
println!(
|
||||
"trace_source_object_uri={}",
|
||||
trace.resolved_output.source_object_uri
|
||||
);
|
||||
println!("trace_chain_len={}", trace.chain_leaf_to_root.len());
|
||||
for (idx, node) in trace.chain_leaf_to_root.iter().enumerate() {
|
||||
println!("chain[{idx}].manifest={}", node.manifest_rsync_uri);
|
||||
println!(
|
||||
"chain[{idx}].current_manifest={}",
|
||||
node.current_manifest_rsync_uri
|
||||
);
|
||||
println!("chain[{idx}].current_crl={}", node.current_crl_rsync_uri);
|
||||
}
|
||||
}
|
||||
println!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
println!("NOT_FOUND");
|
||||
println!();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user