Skip to content
This repository was archived by the owner on Nov 16, 2025. It is now read-only.

Commit 6bd99fd

Browse files
committed
Remove security and data classification tools
Deleted security analysis and data classification tools from both Python and Java codebases, including related handlers and tool registrations. This streamlines the codebase by removing unused or deprecated endpoints and features.
1 parent 652d9ed commit 6bd99fd

7 files changed

Lines changed: 1 addition & 488 deletions

File tree

bridge_mcp_ghidra/tools/functions.py

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -4,82 +4,6 @@
44
def register_function_tools(mcp: FastMCP):
55
"""Register function-related tools to the FastMCP instance."""
66

7-
@mcp.tool()
8-
def analyze_control_flow(function_name: str) -> dict:
9-
"""
10-
Analyze control flow complexity, cyclomatic complexity, and basic blocks.
11-
Provides detailed analysis of function complexity and structure.
12-
13-
Args:
14-
function_name: Name of the function to analyze
15-
16-
Returns:
17-
Dictionary with control flow analysis results
18-
"""
19-
20-
if not ghidra_context.validate_function_name(function_name):
21-
raise GhidraValidationError(f"Invalid function name: {function_name}")
22-
23-
return ghidra_context.http_client.safe_get("analyze_control_flow", {"function_name": function_name})
24-
25-
@mcp.tool()
26-
def analyze_function_complexity(function_name: str) -> dict:
27-
"""
28-
Calculate various complexity metrics for a function.
29-
Includes cyclomatic complexity, lines of code, branch count, etc.
30-
31-
Args:
32-
function_name: Name of the function to analyze
33-
34-
Returns:
35-
Dictionary with complexity metrics
36-
"""
37-
38-
if not validate_function_name(function_name):
39-
raise GhidraValidationError(f"Invalid function name: {function_name}")
40-
41-
return ghidra_context.http_client.safe_get("analyze_function_complexity", {"function_name": function_name})
42-
43-
@mcp.tool()
44-
def batch_decompile_functions(function_names: list) -> dict:
45-
"""
46-
Decompile multiple functions in a single request for better performance.
47-
48-
Args:
49-
function_names: List of function names to decompile
50-
51-
Returns:
52-
Dictionary mapping function names to their decompiled code
53-
"""
54-
55-
# Validate all function names
56-
for name in function_names:
57-
if not validate_function_name(name):
58-
raise GhidraValidationError(f"Invalid function name: {name}")
59-
60-
return ghidra_context.http_client.safe_get("batch_decompile", {"functions": ",".join(function_names)})
61-
62-
@mcp.tool()
63-
def batch_rename_functions(renames: dict) -> dict:
64-
"""
65-
Rename multiple functions atomically.
66-
67-
Args:
68-
renames: Dictionary mapping old names to new names
69-
70-
Returns:
71-
Dictionary with rename results and any errors
72-
"""
73-
74-
# Validate all function names
75-
for old_name, new_name in renames.items():
76-
if not validate_function_name(old_name):
77-
raise GhidraValidationError(f"Invalid old function name: {old_name}")
78-
if not validate_function_name(new_name):
79-
raise GhidraValidationError(f"Invalid new function name: {new_name}")
80-
81-
return ghidra_context.http_client.safe_get("batch_rename_functions", {"renames": str(renames)})
82-
837
@mcp.tool()
848
def create_function_signature(name: str, return_type: str, parameters: str = None) -> str:
859
"""
@@ -142,44 +66,6 @@ def disassemble_function(address: str) -> list:
14266

14367
return ghidra_context.http_client.safe_get("disassemble_function", {"address": address})
14468

145-
@mcp.tool()
146-
def find_dead_code(function_name: str) -> list:
147-
"""
148-
Identify potentially unreachable code blocks within a function.
149-
Useful for finding hidden functionality or dead code elimination.
150-
151-
Args:
152-
function_name: Name of the function to analyze
153-
154-
Returns:
155-
List of potentially unreachable code blocks with addresses
156-
"""
157-
if not ghidra_context.validate_function_name(function_name):
158-
raise GhidraValidationError(f"Invalid function name: {function_name}")
159-
160-
return ghidra_context.http_client.safe_get("find_dead_code", {"function_name": function_name})
161-
162-
@mcp.tool()
163-
def find_similar_functions(target_function: str, threshold: float = 0.8) -> list:
164-
"""
165-
Find functions similar to target using structural analysis.
166-
Uses control flow and instruction patterns to identify similar functions.
167-
168-
Args:
169-
target_function: Name of the function to compare against
170-
threshold: Similarity threshold (0.0 to 1.0, higher = more similar)
171-
172-
Returns:
173-
List of similar functions with similarity scores
174-
"""
175-
if not ghidra_context.validate_function_name(target_function):
176-
raise GhidraValidationError(f"Invalid function name: {target_function}")
177-
178-
return ghidra_context.http_client.safe_get("find_similar_functions", {
179-
"target_function": target_function,
180-
"threshold": threshold
181-
})
182-
18369
@mcp.tool()
18470
def get_current_function() -> str:
18571
"""

bridge_mcp_ghidra/tools/globals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ def rename_global_variable(old_name: str, new_name: str) -> str:
8989
return ghidra_context.http_client.safe_post("rename_global_variable", {
9090
"old_name": old_name,
9191
"new_name": new_name
92-
})
92+
})

bridge_mcp_ghidra/tools/security.py

Lines changed: 0 additions & 86 deletions
This file was deleted.

bridge_mcp_ghidra/tools/types.py

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -124,106 +124,6 @@ def clone_data_type(source_type: str, new_name: str) -> str:
124124

125125
return ghidra_context.http_client.safe_post("clone_data_type", {"source_type": source_type, "new_name": new_name})
126126

127-
@mcp.tool()
128-
def create_and_apply_data_type(
129-
address: str,
130-
classification: str,
131-
name: str = None,
132-
comment: str = None,
133-
type_definition: str | dict = None
134-
) -> str:
135-
"""
136-
Apply data type, name, and comment in a single atomic operation.
137-
138-
This tool combines create_struct + apply_data_type + rename_data + set_comment
139-
into one atomic operation, ensuring consistency and reducing round-trips.
140-
141-
Args:
142-
address: Target address (e.g., "0x6fb835b8")
143-
classification: Data classification: "PRIMITIVE", "STRUCTURE", or "ARRAY"
144-
name: Name to apply (optional, only if meaningful)
145-
comment: Comment to apply (optional)
146-
type_definition: JSON string (NOT dict) with type definition:
147-
For PRIMITIVE: '{\"type\": \"dword\"}' # ← Note the quotes
148-
For STRUCTURE: '{\"name\": \"StructName\", \"fields\": [...]}'
149-
For ARRAY: '{\"element_type\": \"dword\", \"count\": 64}'
150-
or '{\"element_struct\": \"StructName\", \"count\": 10}'
151-
152-
IMPORTANT: Must be a JSON string, not a Python dict.
153-
Use json.dumps() if constructing programmatically.
154-
155-
Example (CORRECT):
156-
create_and_apply_data_type(
157-
address=\"0x6fb835b8\",
158-
classification=\"ARRAY\",
159-
name=\"MyArray\",
160-
type_definition='{\"element_type\": \"dword\", \"count\": 7}' # JSON string
161-
)
162-
163-
Example (INCORRECT):
164-
type_definition={\"element_type\": \"dword\", \"count\": 7} # Will fail validation
165-
166-
Returns:
167-
Success message with all operations performed:
168-
\"Successfully applied classification at 0x6fb835b8:
169-
- Created structure: PreTableConfigData (28 bytes)
170-
- Applied data type: PreTableConfigData
171-
- Renamed to: PreFrameThresholdConfig
172-
- Added comment: 28-byte configuration structure...\"
173-
"""
174-
import json
175-
176-
if not validate_hex_address(address):
177-
raise GhidraValidationError(f"Invalid hex address format: {address}")
178-
179-
valid_classifications = ["PRIMITIVE", "STRUCTURE", "ARRAY", "STRING"]
180-
if classification not in valid_classifications:
181-
raise GhidraValidationError(f"Classification must be one of: {', '.join(valid_classifications)}")
182-
183-
# CONTENT VERIFICATION: Check for string misidentification
184-
# Only verify for PRIMITIVE and ARRAY (where misidentification is common)
185-
if classification in ["PRIMITIVE", "ARRAY"]:
186-
verification = _verify_content_before_classification(address)
187-
188-
if verification["is_string"]:
189-
ghidra_context.http_client.logger.warning(
190-
f"String detected at {address} but classification is {classification}. "
191-
f"Detected: \"{verification['detected_string']}\" "
192-
f"(printable ratio: {verification['printable_ratio']:.2f})"
193-
)
194-
ghidra_context.http_client.logger.warning(verification["recommendation"])
195-
196-
# Auto-correct to STRING classification if highly confident
197-
if verification["printable_ratio"] >= 0.8:
198-
ghidra_context.http_client.logger.info(f"Auto-correcting classification from {classification} to STRING")
199-
classification = "STRING"
200-
# Override type_definition with detected string type
201-
if verification["suggested_type"]:
202-
type_definition = json.dumps({"type": verification["suggested_type"]})
203-
204-
data = {
205-
"address": address,
206-
"classification": classification
207-
}
208-
209-
if name:
210-
data["name"] = name
211-
if comment:
212-
data["comment"] = comment
213-
if type_definition:
214-
try:
215-
if not isinstance(type_definition, str):
216-
raise GhidraValidationError(
217-
"type_definition must be a JSON string (use json.dumps() if needed), "
218-
f"got {type(type_definition).__name__}"
219-
)
220-
type_def = json.loads(type_definition)
221-
data["type_definition"] = type_def
222-
except json.JSONDecodeError as e:
223-
raise GhidraValidationError(f"Invalid JSON in type_definition: {str(e)}")
224-
225-
return ghidra_context.http_client.safe_post_json("apply_data_classification", data)
226-
227127
@mcp.tool()
228128
def create_pointer_type(base_type: str, name: str = None) -> str:
229129
"""

0 commit comments

Comments
 (0)