upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/grasp-audit/src/bin
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-04 06:17:55 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-04 06:17:55 +0000
commit001ca45e385c05b0eaa36d9879e051853aaff107 (patch)
tree603fb85d2563db5b7c418e9fd143d479bd09676e /grasp-audit/src/bin
parentd428baf30feec295870fadda2d335d1e7f89507b (diff)
created POC grasp-auditor
Diffstat (limited to 'grasp-audit/src/bin')
-rw-r--r--grasp-audit/src/bin/grasp-audit.rs95
1 files changed, 95 insertions, 0 deletions
diff --git a/grasp-audit/src/bin/grasp-audit.rs b/grasp-audit/src/bin/grasp-audit.rs
new file mode 100644
index 0000000..6c063db
--- /dev/null
+++ b/grasp-audit/src/bin/grasp-audit.rs
@@ -0,0 +1,95 @@
1//! GRASP Audit CLI Tool
2
3use clap::{Parser, Subcommand};
4use grasp_audit::*;
5
6#[derive(Parser)]
7#[command(name = "grasp-audit")]
8#[command(about = "GRASP audit and compliance testing tool", long_about = None)]
9struct Cli {
10 #[command(subcommand)]
11 command: Commands,
12}
13
14#[derive(Subcommand)]
15enum Commands {
16 /// Run audit tests against a server
17 Audit {
18 /// Relay URL (e.g., ws://localhost:7000)
19 #[arg(short, long)]
20 relay: String,
21
22 /// Mode: ci or production
23 #[arg(short, long, default_value = "ci")]
24 mode: String,
25
26 /// Spec to test (nip01-smoke, all)
27 #[arg(short, long, default_value = "nip01-smoke")]
28 spec: String,
29 },
30}
31
32#[tokio::main]
33async fn main() -> Result<()> {
34 // Initialize logging
35 tracing_subscriber::fmt()
36 .with_env_filter(
37 tracing_subscriber::EnvFilter::from_default_env()
38 .add_directive(tracing::Level::INFO.into())
39 )
40 .init();
41
42 let cli = Cli::parse();
43
44 match cli.command {
45 Commands::Audit { relay, mode, spec } => {
46 let config = match mode.as_str() {
47 "ci" => AuditConfig::ci(),
48 "production" => AuditConfig::production(),
49 _ => return Err(anyhow!("Invalid mode: {}. Use 'ci' or 'production'", mode)),
50 };
51
52 println!("🔍 GRASP Audit Tool");
53 println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
54 println!("Relay: {}", relay);
55 println!("Mode: {}", mode);
56 println!("Spec: {}", spec);
57 println!("Run ID: {}", config.run_id);
58 println!("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
59 println!();
60
61 println!("Connecting to relay...");
62 let client = AuditClient::new(&relay, config).await
63 .map_err(|e| anyhow!("Failed to connect to relay: {}", e))?;
64
65 if !client.is_connected().await {
66 return Err(anyhow!("Could not establish connection to relay"));
67 }
68
69 println!("✓ Connected\n");
70
71 let results = match spec.as_str() {
72 "nip01-smoke" => {
73 println!("Running NIP-01 smoke tests...\n");
74 specs::Nip01SmokeTests::run_all(&client).await
75 }
76 "all" => {
77 println!("Running all tests...\n");
78 specs::Nip01SmokeTests::run_all(&client).await
79 }
80 _ => return Err(anyhow!("Unknown spec: {}. Use 'nip01-smoke' or 'all'", spec)),
81 };
82
83 results.print_report();
84
85 if !results.all_passed() {
86 println!("❌ Some tests failed");
87 std::process::exit(1);
88 } else {
89 println!("✅ All tests passed!");
90 }
91 }
92 }
93
94 Ok(())
95}