fix: address 7 security and reliability issues

- Prevent path traversal in gitignore template names (Critical)
- Fix TOCTOU races in file operations with try/except pattern (High)
- Add timeout to HuggingFace API requests (Medium)
- Add missing %x00 separator in changelog fallback format (Medium)
- Filter unsanitized kwargs before passing to OpenAI SDK (High)
- Use context managers for proper client cleanup in providers (High)
- Exit with non-zero code on commit engine failure (Low)
This commit is contained in:
sankalp committed 2026-06-16 14:43:52 +05:45
1 parent ede489c219
commit 51ede1a7da
8 files changed
+59 -39

No files matched your search

+10 -7
View File
@@ -9,14 +9,17 @@ class OpenaiProvider(BaseProvider):
DISPLAY_NAME = "OpenAI"
DEFAULT_MODEL = "gpt-4o"
# Keys consumed by devgen itself — never forwarded to the SDK.
_DEVGEN_KEYS = frozenset({"debug", "ollama_host", "max_retries", "retry_delay"})
def _generate(self, prompt, api_key, model, **kwargs):
kwargs.pop("debug", None)
client = OpenAI(api_key=api_key)
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
**kwargs,
)
safe_kwargs = {k: v for k, v in kwargs.items() if k not in self._DEVGEN_KEYS}
with OpenAI(api_key=api_key) as client:
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
**safe_kwargs,
)
if not response.choices:
raise RuntimeError(f"OpenAI returned no choices for model {model!r}.")
return response.choices[0].message.content or ""