Skip to content

Added AWS Bedrock Configuration for models Handling.#434

Open
imHax0x90 wants to merge 1 commit into
GreyDGL:mainfrom
imHax0x90:Feat--add-configuration-for-linking-AWS---Bedrock-models-suppliers
Open

Added AWS Bedrock Configuration for models Handling.#434
imHax0x90 wants to merge 1 commit into
GreyDGL:mainfrom
imHax0x90:Feat--add-configuration-for-linking-AWS---Bedrock-models-suppliers

Conversation

@imHax0x90
Copy link
Copy Markdown

Author : @imHax0x90

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces AWS Bedrock as a new backend option for PentestGPT, adding the BedrockBackend class, updating configuration schemas, and extending the setup scripts to support AWS credentials. Review feedback identifies a bug where session resumption is incorrectly marked as supported despite being unimplemented, notes several unused json imports, and suggests refactoring credential validation to allow for standard AWS authentication methods like IAM roles.

Comment on lines +367 to +377
def supports_resume(self) -> bool:
"""Bedrock supports session resume via conversation history."""
return True

async def resume(self, session_id: str) -> bool:
"""Resume a previous session (loads conversation history)."""
# TODO: Implement session persistence for Bedrock
# For now, just reconnect
self._session_id = session_id
await self.connect()
return True
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The BedrockBackend claims to support session resumption by having supports_resume return True, but the resume method is an incomplete stub. It doesn't load the conversation history, causing any resumed session to start from scratch. This is a significant bug that can lead to loss of context in a resumed session.

The TODO comment indicates this is a known issue. Until session persistence is fully implemented for Bedrock, this functionality should be disabled to prevent incorrect behavior.

Suggested change
def supports_resume(self) -> bool:
"""Bedrock supports session resume via conversation history."""
return True
async def resume(self, session_id: str) -> bool:
"""Resume a previous session (loads conversation history)."""
# TODO: Implement session persistence for Bedrock
# For now, just reconnect
self._session_id = session_id
await self.connect()
return True
@property
def supports_resume(self) -> bool:
"""Bedrock does not yet support session resume."""
return False
async def resume(self, session_id: str) -> bool:
"""Resume a previous session (loads conversation history)."""
# TODO: Implement session persistence for Bedrock
raise NotImplementedError("Session resume for Bedrock is not yet implemented.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ad

async def connect(self) -> None:
"""Connect to AWS Bedrock."""
import boto3
import json
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The json module is imported but not used within the connect method. It should be removed to keep the code clean.


async def receive_messages(self) -> AsyncIterator[AgentMessage]:
"""Get messages from Bedrock via Converse API."""
import json
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The json module is imported but not used within the receive_messages method. It should be removed to keep the code clean.

Comment on lines +400 to +404
if not config.aws_access_key_id or not config.aws_secret_access_key:
raise ValueError(
"AWS credentials not configured. "
"Please set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This check forces users to provide AWS credentials explicitly via AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. This prevents leveraging other standard boto3 authentication mechanisms like IAM roles (e.g., on EC2) or shared credential files (~/.aws/credentials), which can be more secure and convenient.

To improve flexibility, I recommend removing this explicit check and allowing boto3 to discover credentials automatically. This would involve:

  1. Removing this if block.
  2. Updating BedrockBackend.__init__ to accept access_key and secret_key as optional (str | None).
  3. Passing these optional keys to boto3.client(), which correctly handles None values by falling back to its default credential provider chain.

@raselmr831-jpg raselmr831-jpg mentioned this pull request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants