gbf_suite/
gbf_result.rs

1use std::time::Duration;
2
3use gbf_core::{
4    decompiler::function_decompiler::FunctionDecompilerErrorContext, utils::Gs2BytecodeAddress,
5};
6use serde::{Deserialize, Serialize};
7
8/// The dynamodb entry for a GraphViz dot file.
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct GbfGraphvizStructureAnalaysisDao {
11    /// The version of the GBF used to generate the dot file.
12    pub gbf_version: String,
13
14    /// The module ID of the module (SHA256 hash of the module).
15    pub module_id: String,
16
17    /// The function address of the function (can be used as a unique identifier).
18    pub function_address: Gs2BytecodeAddress,
19
20    /// The structure analysis step.
21    pub structure_analysis_step: usize,
22
23    /// The S3 key of the dot file.
24    pub dot_key: String,
25}
26
27impl GbfGraphvizStructureAnalaysisDao {
28    pub fn pk_key(&self) -> String {
29        "gbf_version#module_id#function_address".to_string()
30    }
31
32    pub fn pk_val(&self) -> String {
33        format!(
34            "{}#{}#{}",
35            self.gbf_version, self.module_id, self.function_address
36        )
37    }
38
39    pub fn dot_url(&self, bucket: &str) -> String {
40        format!("https://{}.s3.amazonaws.com/{}", bucket, self.dot_key)
41    }
42}
43
44/// The dynamodb entry for a GBF suite result.
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct GbfVersionDao {
47    /// The version of the GBF used.
48    pub gbf_version: String,
49
50    /// The total time it took to run the entire suite.
51    pub total_time: Duration,
52
53    /// Timestamp (e.g., "2025-01-28T12:34:56Z" or an epoch).
54    pub suite_timestamp: u64, // or String for ISO8601
55}
56
57impl GbfVersionDao {
58    pub fn pk_key(&self) -> String {
59        "gbf_version".to_string()
60    }
61
62    pub fn pk_val(&self) -> String {
63        self.gbf_version.clone()
64    }
65}
66
67/// The dynamodb entry for a GBF function result.
68#[derive(Debug, Serialize, Deserialize)]
69pub struct GbfModuleDao {
70    /// GBF version used to decompile the module.
71    pub gbf_version: String,
72
73    /// The module ID of the module (SHA256).
74    pub module_id: String,
75
76    /// The file name of the module.
77    pub file_name: String,
78
79    /// The time it took to load the module.
80    pub module_load_time: Duration,
81
82    /// If the module's decompilation was successful.
83    pub decompile_success: bool,
84}
85
86impl GbfModuleDao {
87    pub fn pk_key(&self) -> String {
88        "gbf_version".to_string()
89    }
90
91    pub fn pk_val(&self) -> String {
92        self.gbf_version.to_string()
93    }
94}
95
96#[derive(Debug, Serialize, Deserialize, Clone)]
97pub struct GbfFunctionDao {
98    /// The GBF version used to decompile the function.
99    pub gbf_version: String,
100
101    /// The module ID to which this function belongs.
102    pub module_id: String,
103
104    /// The function address (unique within the module).
105    pub function_address: Gs2BytecodeAddress,
106
107    /// The name of the function, if known.
108    pub function_name: Option<String>,
109
110    /// Whether the function was decompiled successfully.
111    pub decompile_success: bool,
112
113    /// The result of the decompilation attempt (could be an error).
114    pub decompile_result: Option<String>,
115
116    /// How long it took to decompile this function.
117    pub total_time: Duration,
118
119    /// The S3 key of the dot file.
120    pub dot_key: String,
121}
122
123impl GbfFunctionDao {
124    pub fn pk_key(&self) -> String {
125        "gbf_version#module_id".to_string()
126    }
127
128    pub fn pk_val(&self) -> String {
129        format!("{}#{}", self.gbf_version, self.module_id)
130    }
131
132    pub fn dot_url(&self, bucket: &str) -> String {
133        format!("https://{}.s3.amazonaws.com/{}", bucket, self.dot_key)
134    }
135}
136
137#[derive(Debug, Serialize, Clone)]
138pub struct GbfFunctionErrorDao {
139    /// GBF version
140    pub gbf_version: String,
141
142    /// Module ID
143    pub module_id: String,
144
145    /// The function address that encountered the error.
146    pub function_address: Gs2BytecodeAddress,
147
148    /// The type of error (e.g. structure analysis, parse error, etc.)
149    pub error_type: String,
150
151    /// A human-readable message or summary.
152    pub message: String,
153
154    /// A structured backtrace
155    pub backtrace: GbfSimplifiedBacktrace,
156
157    /// The context of the error.
158    pub context: FunctionDecompilerErrorContext,
159}
160
161impl GbfFunctionErrorDao {
162    pub fn pk_key(&self) -> String {
163        "gbf_version#module_id".to_string()
164    }
165
166    pub fn pk_val(&self) -> String {
167        format!("{}#{}", self.gbf_version, self.module_id)
168    }
169}
170
171#[derive(Debug, Serialize, Deserialize, Clone)]
172pub struct GbfSimplifiedBacktrace {
173    pub frames: Vec<GbfSimplifiedBacktraceFrame>,
174}
175
176#[derive(Debug, Serialize, Deserialize, Clone)]
177pub struct GbfSimplifiedBacktraceFrame {
178    pub function: String,
179    pub file: String,
180    pub line: u32,
181}