Skip to content

Updated gui_agents/s1/aci/LinuxOSACI.py to fix security vulnerability [python.lang.security.audit.eval-detected.eval-detected] #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions gui_agents/s1/aci/LinuxOSACI.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ast
import base64
import logging
import os
Expand Down Expand Up @@ -147,7 +148,7 @@ def filter_nodes(self, tree, show_all=False):
if node.tag not in exclude_tags:
if show_all:
if node.attrib.get(f"{{{state_ns}}}visible") == "true":
coords: Tuple[int, int] = eval(
coords: Tuple[int, int] = ast.literal_eval(
node.get(
"{{{:}}}screencoord".format(component_ns), "(-1, -1)"
)
Expand All @@ -157,7 +158,7 @@ def filter_nodes(self, tree, show_all=False):
# if show_all is false, only show elements that are currently showing on screen
else:
if node.attrib.get(f"{{{state_ns}}}showing") == "true":
coords: Tuple[int, int] = eval(
coords: Tuple[int, int] = ast.literal_eval(
node.get(
"{{{:}}}screencoord".format(component_ns), "(-1, -1)"
)
Expand Down Expand Up @@ -228,10 +229,10 @@ def add_ocr_elements(
# Get the bounding boxes of the elements in the linearized accessibility tree
tree_bboxes = []
for node in preserved_nodes:
coordinates: Tuple[int, int] = eval(
coordinates: Tuple[int, int] = ast.literal_eval(
node.get("{{{:}}}screencoord".format(component_ns), "(-1, -1)")
)
sizes: Tuple[int, int] = eval(
sizes: Tuple[int, int] = ast.literal_eval(
node.get("{{{:}}}size".format(component_ns), "(-1, -1)")
)
tree_bboxes.append(
Expand Down Expand Up @@ -366,10 +367,10 @@ def click(
hold_keys:List, list of keys to hold while clicking
"""
node = self.find_element(element_id)
coordinates: Tuple[int, int] = eval(
coordinates: Tuple[int, int] = ast.literal_eval(
node.get("{{{:}}}screencoord".format(component_ns), "(-1, -1)")
)
sizes: Tuple[int, int] = eval(
sizes: Tuple[int, int] = ast.literal_eval(
node.get("{{{:}}}size".format(component_ns), "(-1, -1)")
)

Expand Down Expand Up @@ -419,10 +420,10 @@ def type(

if node is not None:
# If a node is found, retrieve its coordinates and size
coordinates = eval(
coordinates = ast.literal_eval(
node.get("{{{:}}}screencoord".format(component_ns), "(-1, -1)")
)
sizes = eval(node.get("{{{:}}}size".format(component_ns), "(-1, -1)"))
sizes = ast.literal_eval(node.get("{{{:}}}size".format(component_ns), "(-1, -1)"))

# Calculate the center of the element
x = coordinates[0] + sizes[0] // 2
Expand Down Expand Up @@ -476,15 +477,15 @@ def drag_and_drop(self, drag_from_id: int, drop_on_id: int, hold_keys: List = []
"""
node1 = self.find_element(drag_from_id)
node2 = self.find_element(drop_on_id)
coordinates1 = eval(
coordinates1 = ast.literal_eval(
node1.get("{{{:}}}screencoord".format(component_ns), "(-1, -1)")
)
sizes1 = eval(node1.get("{{{:}}}size".format(component_ns), "(-1, -1)"))
sizes1 = ast.literal_eval(node1.get("{{{:}}}size".format(component_ns), "(-1, -1)"))

coordinates2 = eval(
coordinates2 = ast.literal_eval(
node2.get("{{{:}}}screencoord".format(component_ns), "(-1, -1)")
)
sizes2 = eval(node2.get("{{{:}}}size".format(component_ns), "(-1, -1)"))
sizes2 = ast.literal_eval(node2.get("{{{:}}}size".format(component_ns), "(-1, -1)"))

# Calculate the center of the element
x1 = coordinates1[0] + sizes1[0] // 2
Expand Down Expand Up @@ -519,10 +520,10 @@ def scroll(self, element_id: int, clicks: int):
except:
node = self.find_element(0)
# print(node.attrib)
coordinates = eval(
coordinates = ast.literal_eval(
node.get("{{{:}}}screencoord".format(component_ns), "(-1, -1)")
)
sizes = eval(node.get("{{{:}}}size".format(component_ns), "(-1, -1)"))
sizes = ast.literal_eval(node.get("{{{:}}}size".format(component_ns), "(-1, -1)"))

# Calculate the center of the element
x = coordinates[0] + sizes[0] // 2
Expand Down