diff --git a/.gitignore b/.gitignore index acb54dd..f6ce4ab 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ env/ ENV/ env.bak/ venv.bak/ +.env # Project specific caches .pytest_cache/ diff --git a/README.md b/README.md index 90d1f67..b040dd6 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ If you prefer scripts or direct commands, all UI options also work via CLI subco ### 1. Configuring your Artificial Intelligence You can choose which cognitive engine GitAuditor will use (Ollama to run 100% offline, OpenAI or OpenRouter for advanced cloud models). +If you choose **Azure OpenAI**, you must configure your custom resource endpoint (e.g., `https://.services.ai.azure.com/openai/v1`) using the command below. ```bash gitauditor config ``` diff --git a/README_pt.md b/README_pt.md index 1cea63e..7ad20b9 100644 --- a/README_pt.md +++ b/README_pt.md @@ -77,6 +77,7 @@ Se você prefere scripts ou comandos diretos, todas as opções da UI também fu ### 1. Configurando sua Inteligência Artificial Você pode escolher qual motor cognitivo o GitAuditor vai usar (Ollama para rodar 100% offline, OpenAI ou OpenRouter para modelos avançados em nuvem). +Se você escolher **Azure OpenAI**, é obrigatório configurar seu endpoint customizado (ex: `https://.services.ai.azure.com/openai/v1`) executando o comando abaixo. ```bash gitauditor config ``` diff --git a/src/gitauditor/cli.py b/src/gitauditor/cli.py index 30c86a6..8f4b4dc 100644 --- a/src/gitauditor/cli.py +++ b/src/gitauditor/cli.py @@ -11,13 +11,22 @@ from rich.prompt import Prompt from rich.table import Table -lang_to_use = "pt_BR" +import locale + +try: + system_lang = locale.getdefaultlocale()[0] or "en_US" +except Exception: + system_lang = "en_US" + +default_lang = "pt_BR" if system_lang.startswith("pt") else "en_US" +lang_to_use = default_lang + try: config_path = os.path.expanduser("~/.gitauditor.json") if os.path.exists(config_path): with open(config_path) as f: cfg = json.load(f) - lang_to_use = cfg.get("lang", "pt_BR") + lang_to_use = cfg.get("lang", default_lang) except Exception as e: import sys print(f"Aviso: Erro ao carregar config i18n: {e}", file=sys.stderr) diff --git a/src/gitauditor/commands/config_cmd.py b/src/gitauditor/commands/config_cmd.py index 0b93e81..9f9f5db 100644 --- a/src/gitauditor/commands/config_cmd.py +++ b/src/gitauditor/commands/config_cmd.py @@ -84,7 +84,7 @@ def config_command(): current_model = ai_config.get("model", "gpt-4o") ai_config["model"] = Prompt.ask("Qual deployment name (modelo)?", default=current_model) - current_url = ai_config.get("base_url", "https://renansousa-2956-resource.services.ai.azure.com/openai/v1") + current_url = ai_config.get("base_url", "https://.services.ai.azure.com/openai/v1") ai_config["base_url"] = Prompt.ask("URL base do Azure AI", default=current_url) use_default_cred = Prompt.ask("Usar Entra ID (DefaultAzureCredential)? [S/n]", default="s") diff --git a/src/gitauditor/core/ai_api.py b/src/gitauditor/core/ai_api.py index 8454d80..eb7859c 100644 --- a/src/gitauditor/core/ai_api.py +++ b/src/gitauditor/core/ai_api.py @@ -26,7 +26,7 @@ def __init__(self): "base_url", "https://openrouter.ai/api/v1" ) elif self.provider == "azure": - self.base_url = self.ai_config.get("base_url", "https://renansousa-2956-resource.services.ai.azure.com/openai/v1") + self.base_url = self.ai_config.get("base_url", "https://.services.ai.azure.com/openai/v1") else: self.base_url = self.ai_config.get("base_url", "") diff --git a/src/gitauditor/core/policy_engine.py b/src/gitauditor/core/policy_engine.py index 70c13c3..16b6ee2 100644 --- a/src/gitauditor/core/policy_engine.py +++ b/src/gitauditor/core/policy_engine.py @@ -65,6 +65,10 @@ def check_repository(repo_path: str) -> dict[str, Any]: # 4. Critical Security Risks (.env check) # Verify if .env is tracked by git (not just existing on disk) import subprocess + + if not os.path.isdir(repo_path) or not os.path.exists(os.path.join(repo_path, ".git")): + return report + try: res = subprocess.run(["git", "ls-files", ".env"], cwd=repo_path, capture_output=True, text=True, timeout=15) is_env_tracked = res.stdout.strip() != ""