1mod analyze;
2pub use analyze::*;
3use clap::{Args, Subcommand, ValueEnum};
4
5#[derive(Args, Debug, Clone)]
6pub struct RapxArgs {
7 #[command(subcommand)]
8 pub command: Commands,
9 #[arg(long, help = "specify the timeout seconds in running rapx")]
10 pub timeout: Option<u64>,
11 #[arg(long, help = "specify the tested package in the workspace")]
12 pub test_crate: Option<String>,
13}
14
15#[derive(Debug, Clone, Subcommand)]
18pub enum Commands {
19 #[command(arg_required_else_help = true)]
21 Analyze {
22 #[command(subcommand)]
23 kind: AnalysisKind,
24 },
25 Check {
28 #[arg(
30 short = 'f',
31 num_args=0..=1,
32 default_missing_value = "1",
33 long,
34 )]
35 uaf: Option<usize>,
36
37 #[arg(short = 'm', long)]
39 mleak: bool,
40
41 #[arg(short = 'o', long, default_missing_value = "default")]
43 opt: Option<OptLevel>,
44
45 #[arg(long)]
47 infer: bool,
48
49 #[arg(long)]
51 verify: bool,
52
53 #[arg(long)]
55 verify_std: bool,
56 },
57 #[command(arg_required_else_help = true)]
59 Extract {
60 #[command(subcommand)]
61 kind: ExtractKind,
62 },
63}
64
65#[derive(Debug, Clone, Copy, ValueEnum)]
66pub enum OptLevel {
67 Report,
68 Default,
69 All,
70}
71
72#[derive(Debug, Clone, Copy, Subcommand)]
74pub enum ExtractKind {
75 UnsafeApis,
77 StdUnsafeApis,
79}
80
81impl RapxArgs {
82 pub fn init_env(&self) {
83 let Commands::Check {
84 uaf: Some(level), ..
85 } = self.command
86 else {
87 return;
88 };
89 unsafe {
90 std::env::set_var("MOP", level.to_string());
91 }
92 }
93}