Eashan Kaushik d9f9dffdf8
fix(agentcore-samples): fix for code scanning: Clear-text logging of sensitive information (#286)
* Potential fix for code scanning

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 65: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update setup_database_access.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 41: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 40: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update setup_cognito.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 39: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update retrieve_api_key.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 34: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 33: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 32: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update oauth_test.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 29: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update get_customer_profile.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 28: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update deploy_agent_runtime.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 25: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update credentials_manager.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 18: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update create-gateway.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 15: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update config.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 14: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update cognito_oauth_setup.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 13: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update auth.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Potential fix for code scanning alert no. 9: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update deploy_agent_runtime.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update retrieve_api_key.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update retrieve_api_key.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

* Update deploy_agent_runtime.py

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>

---------

Signed-off-by: Eashan Kaushik <50113394+EashanKaushik@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-08-25 16:09:11 -04:00
..
2025-07-21 10:45:13 -04:00
2025-07-21 10:45:13 -04:00
2025-07-21 10:45:13 -04:00
2025-07-21 10:45:13 -04:00

Backend Demo Infrastructure

This directory contains the complete demo backend infrastructure for SRE Agent testing and development.

📁 Structure

backend/
├── config_utils.py               # Configuration utilities
├── data/                         # Organized fake data
│   ├── k8s_data/                # Kubernetes mock data
│   ├── logs_data/               # Application logs
│   ├── metrics_data/            # Performance metrics
│   └── runbooks_data/           # Operational procedures
├── openapi_specs/               # API specifications
│   ├── k8s_api.yaml            # Kubernetes API spec
│   ├── logs_api.yaml           # Logs API spec
│   ├── metrics_api.yaml        # Metrics API spec
│   └── runbooks_api.yaml       # Runbooks API spec
├── servers/                     # Mock API implementations
│   ├── k8s_server.py           # Kubernetes API server
│   ├── logs_server.py          # Logs API server
│   ├── metrics_server.py       # Metrics API server
│   ├── runbooks_server.py      # Runbooks API server
│   ├── run_all_servers.py      # Start all servers
│   └── stop_servers.py         # Stop all servers
└── scripts/                    # Operational scripts
    ├── start_demo_backend.sh   # Simplified startup
    └── stop_demo_backend.sh    # Simplified shutdown

🚀 Quick Start

# Start all demo servers with simple Python HTTP servers
./scripts/start_demo_backend.sh

Advanced Startup (Full FastAPI servers)

# Start full-featured servers with FastAPI
cd servers
python run_all_servers.py

🌐 API Endpoints

When running, the demo backend provides these endpoints:

📊 Data Organization

K8s Data (data/k8s_data/)

  • deployments.json - Deployment status and configurations
  • pods.json - Pod states and resource usage
  • events.json - Cluster events and warnings

Logs Data (data/logs_data/)

  • application_logs.json - Application log entries
  • error_logs.json - Error-specific log entries

Metrics Data (data/metrics_data/)

  • performance_metrics.json - Response times, throughput
  • resource_metrics.json - CPU, memory, disk usage

Runbooks Data (data/runbooks_data/)

  • incident_playbooks.json - Incident response procedures
  • troubleshooting_guides.json - Step-by-step guides

🔧 Server Implementations

Simple HTTP Servers (Default)

Basic Python http.server implementations that serve JSON data directly from files.

FastAPI Servers (Advanced)

Full-featured FastAPI servers with:

  • OpenAPI documentation
  • Request validation
  • Response schemas
  • Health endpoints

📋 OpenAPI Specifications

Complete OpenAPI 3.0 specifications for all APIs:

  • Endpoint definitions
  • Request/response schemas
  • Authentication requirements
  • Example data

🛑 Stopping Services

# Simple method
./scripts/stop_demo_backend.sh

# Advanced method  
cd servers
python stop_servers.py

🧪 Testing

Test individual APIs:

# Test K8s API
curl http://localhost:8001/health

# Test with specific endpoints
curl http://localhost:8001/api/v1/namespaces/production/pods
curl http://localhost:8002/api/v1/logs/search?query=error

⚙️ Configuration

The backend uses realistic data scenarios including:

  • Failed database pods
  • Memory pressure warnings
  • Performance degradation patterns
  • Common troubleshooting procedures

This provides a comprehensive testing environment for the SRE Agent system.