T09 · Insecure Skill Coding Practices
- Location
scripts/lib/api_client.py:121- Finding
API Credential Can Be Transmitted to an Arbitrary Configurable Origin
- Content
View full analysis
Dict[str, Any]: """ Make an HTTP request to the CodeAlive API. Args: method: HTTP method (GET, POST, etc.) endpoint: API endpoint path params: URL query parameters body: Request body for POST requests Returns: Parsed JSON response """ url = f"{self.base_url}{endpoint}" # Add query parameters if params: query_string = urllib.parse.urlencode(params, doseq=True) url = f"{url}?{query_string}" # Prepare request headers = { "Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json" } data = None if body: data = json.dumps(body).encode("utf-8") request = urllib.request.Request(url, data=data, headers=headers, method=method) # Make request try: with urllib.request.urlopen(request, timeout=self.timeout) as response: ``` `setup.py:138-145` and `setup.py:179`: ```python def verify_key(api_key: str, base_url: str = DEFAULT_BASE_URL) -> tuple[bool, str]: """Test the API key by fetching data sources. Returns (success, message).""" url = f"{base_url}/api/datasources/alive" headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", } req = urllib.request.Request(url, headers=headers, method="GET") try: with urllib.request.urlopen(req, timeout=15) as re ...[truncated 2603 chars]- Remediation
View remediation
