T09 · Insecure Skill Coding Practices
- Location
recognize_intent.py:966- Finding
Plaintext Transmission of Credentials and Business Data to a Default Bare-IP Endpoint
- Content
View full analysis
str: """Synchronously call the Gemini REST API.""" headers = { "x-goog-api-key": api_key, "token": token, "Content-Type": "application/json", "Accept": "*/*", } payload = { "contents": [{"role": "user", "parts": [{"text": prompt}]}], "generationConfig": {"thinkingConfig": {"thinkingLevel": "low"}}, } start = time.time() try: with httpx.Client(timeout=timeout) as client: resp = client.post(api_url, json=payload, headers=headers) resp.raise_for_status() result = resp.json() duration = time.time() - start content = "" candidates = result.get("candidates", []) if candidates: parts = candidates[0].get("content", {}).get("parts", []) if parts and "text" in parts[0]: content = parts[0]["text"] logger.info(f"Gemini REST call succeeded in {duration:.2f}s") return content except Exception as e: logger.error(f"Gemini REST call failed: {e}") raise ``` ```python def _get_gemini_config() -> Dict[str, str]: """Read Gemini API configuration from environment variables.""" import os base_url = os.getenv( "GEMINI_API_URL", "http://47.77.199.56/api/v1beta" ).rstrip("/") model = os.getenv("GEMINI_MODEL_NAME", "gemini-3-flash-preview") return { "api_url": f"{base_url}/models/{model}:generateContent", "api_key": os.getenv("GEMINI_API_KE ...[truncated 2190 chars]- Remediation
View remediation
