codedd-cli 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
codedd_cli/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
- """CodeDD CLI — run code audits from your terminal."""
2
-
3
- __version__ = "0.1.2"
1
+ """CodeDD CLI — run code audits from your terminal."""
2
+
3
+ __version__ = "0.1.4"
codedd_cli/__main__.py CHANGED
@@ -1,10 +1,51 @@
1
1
  """Allow running via ``python -m codedd_cli``."""
2
2
 
3
+ import os
3
4
  import sys
4
5
 
5
- from codedd_cli.api.exceptions import CodeDDConnectionError
6
- from codedd_cli.cli import app
7
- from codedd_cli.utils.display import print_error
6
+
7
+ def _ensure_utf8_io() -> None:
8
+ """
9
+ Reconfigure stdout/stderr to use UTF-8 on Windows.
10
+
11
+ PowerShell and cmd.exe default to the system code page (e.g. cp1252),
12
+ which causes ``UnicodeEncodeError: 'charmap' codec can't encode …``
13
+ whenever Rich prints Unicode symbols. Setting the streams to UTF-8
14
+ early — before any import triggers output — eliminates the need for
15
+ callers to set ``PYTHONIOENCODING=utf-8`` externally.
16
+ """
17
+ if sys.platform != "win32":
18
+ return
19
+
20
+ # Env-var approach: respected by any subprocess we may spawn as well
21
+ os.environ.setdefault("PYTHONIOENCODING", "utf-8")
22
+
23
+ # Reconfigure the existing streams in-place (Python 3.7+)
24
+ for stream_name in ("stdout", "stderr"):
25
+ stream = getattr(sys, stream_name, None)
26
+ if stream is not None and hasattr(stream, "reconfigure"):
27
+ try:
28
+ stream.reconfigure(encoding="utf-8", errors="replace")
29
+ except Exception:
30
+ pass # non-standard stream (e.g. piped / pytest capture)
31
+
32
+ # Enable UTF-8 mode for the Windows console (Python 3.15+ flag;
33
+ # also ensures ctypes-level console code page is set).
34
+ try:
35
+ import ctypes
36
+ kernel32 = ctypes.windll.kernel32 # type: ignore[attr-defined]
37
+ kernel32.SetConsoleOutputCP(65001)
38
+ kernel32.SetConsoleCP(65001)
39
+ except Exception:
40
+ pass
41
+
42
+
43
+ # Apply before importing anything that may write to the console
44
+ _ensure_utf8_io()
45
+
46
+ from codedd_cli.api.exceptions import CodeDDConnectionError # noqa: E402
47
+ from codedd_cli.cli import app # noqa: E402
48
+ from codedd_cli.utils.display import print_error # noqa: E402
8
49
 
9
50
 
10
51
  def main() -> None:
codedd_cli/api/client.py CHANGED
@@ -9,6 +9,7 @@ Wraps ``httpx`` with:
9
9
  - Descriptive User-Agent header
10
10
  """
11
11
 
12
+ import threading
12
13
  import time
13
14
  from typing import Any
14
15
 
@@ -54,6 +55,7 @@ class CodeDDClient:
54
55
  verify=verify_tls,
55
56
  follow_redirects=True,
56
57
  )
58
+ self._lock = threading.Lock()
57
59
 
58
60
  def _build_headers(self) -> dict[str, str]:
59
61
  headers: dict[str, str] = {
@@ -85,7 +87,8 @@ class CodeDDClient:
85
87
 
86
88
  for attempt in range(1, MAX_RETRIES + 1):
87
89
  try:
88
- resp = self._client.request(method, path, **kwargs)
90
+ with self._lock:
91
+ resp = self._client.request(method, path, **kwargs)
89
92
 
90
93
  # Don't retry client errors (4xx)
91
94
  if resp.status_code < 500:
@@ -44,3 +44,20 @@ class Endpoints:
44
44
 
45
45
  # Architecture analysis (Phase 1+2 run locally; server runs Phase 3 + storage)
46
46
  AUDIT_ARCHITECTURE = "/api/cli/audit/architecture/"
47
+
48
+ # LLM model tracking (records which model(s) were used during local file auditing)
49
+ AUDIT_LLM_MODEL = "/api/cli/audit/llm-model/"
50
+
51
+ # Fix workflow
52
+ FIX_OVERVIEW = "/api/cli/fix/overview/"
53
+ FIX_FLAGS_NEXT = "/api/cli/fix/flags/next/"
54
+ FIX_VULNS_NEXT = "/api/cli/fix/vulns/next/"
55
+ FIX_VULNS_AFFECTED_FILES = "/api/cli/fix/vulns/affected-files/"
56
+ FIX_STATUS = "/api/cli/fix/status/"
57
+ FIX_COMMENT = "/api/cli/fix/comment/"
58
+ FIX_RESOLVE = "/api/cli/fix/resolve/"
59
+ FIX_INVALIDATE = "/api/cli/fix/invalidate/"
60
+
61
+ # Fix access control (remediation module)
62
+ FIX_ACCESS_STATUS = "/api/cli/fix/access/status/"
63
+ FIX_ACCESS_TOGGLE = "/api/cli/fix/access/toggle/"