Skip to content

Commit

Permalink
Merge pull request #198 from Shield-Cyber/dev
Browse files Browse the repository at this point in the history
Fixed target/get/targets
  • Loading branch information
oliv10 authored Jan 18, 2024
2 parents 4ea52b1 + 5c079f8 commit bf9a22f
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions app/routes/target/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,21 @@ async def create_target(
LOGGER.error(f"GMP Error: {err}")
return ErrorResponse("Internal Server Error")

@ROUTER.get("/get/{target_id}")
async def get_target(
@ROUTER.get("/get/targets")
async def get_targets(
current_user: Annotated[Auth.User, Depends(Auth.get_current_active_user)],
target_id: str,
tasks: Optional[bool] = None
filter_string: Optional[str] = None,
filter_id: Optional[str] = None,
trash: Optional[bool] = None,
tasks: Optional[bool] = None,
):
"""Request a single target
"""Request a list of targets
Arguments:
target_id: UUID of an existing target
filter_string: Filter term to use for the query
filter_id: UUID of an existing filter to use for the query
trash: Whether to get the trashcan targets instead
tasks: Whether to include list of tasks that use the target
Returns:
Expand All @@ -79,26 +83,22 @@ async def get_target(
with Gmp(connection=UnixSocketConnection()) as gmp:
gmp.authenticate(username=current_user.username, password=Auth.get_admin_password())
try:
return gmp.get_target(target_id=target_id, tasks=tasks)
return gmp.get_targets(filter_string=filter_string,filter_id=filter_id,trash=trash,tasks=tasks)
except Exception as err:
LOGGER.error(f"GMP Error: {err}")
return ErrorResponse("Internal Server Error")
@ROUTER.get("/get/targets")
async def get_targets(

@ROUTER.get("/get/{target_id}")
async def get_target(
current_user: Annotated[Auth.User, Depends(Auth.get_current_active_user)],
filter_string: Optional[str] = None,
filter_id: Optional[str] = None,
trash: Optional[bool] = None,
tasks: Optional[bool] = None,
target_id: str,
tasks: Optional[bool] = None
):
"""Request a list of targets
"""Request a single target
Arguments:
filter_string: Filter term to use for the query
filter_id: UUID of an existing filter to use for the query
trash: Whether to get the trashcan targets instead
target_id: UUID of an existing target
tasks: Whether to include list of tasks that use the target
Returns:
Expand All @@ -107,7 +107,7 @@ async def get_targets(
with Gmp(connection=UnixSocketConnection()) as gmp:
gmp.authenticate(username=current_user.username, password=Auth.get_admin_password())
try:
return gmp.get_targets(filter_string=filter_string,filter_id=filter_id,trash=trash,tasks=tasks)
return gmp.get_target(target_id=target_id, tasks=tasks)
except Exception as err:
LOGGER.error(f"GMP Error: {err}")
return ErrorResponse("Internal Server Error")
Expand Down

0 comments on commit bf9a22f

Please sign in to comment.