codedd-cli 0.1.2__py3-none-any.whl → 0.1.5__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 +3 -3
- codedd_cli/__main__.py +44 -3
- codedd_cli/api/client.py +6 -3
- codedd_cli/api/endpoints.py +17 -0
- codedd_cli/auditor/archetype_classifier.py +900 -0
- codedd_cli/auditor/architecture_analyzer.py +162 -16
- codedd_cli/auditor/audit_checkpoint.py +179 -0
- codedd_cli/auditor/file_auditor.py +714 -581
- codedd_cli/auditor/sub_audit_runner.py +775 -601
- codedd_cli/auditor/tier_definitions.py +525 -0
- codedd_cli/auditor/vulnerability_validator.py +134 -19
- codedd_cli/auth/session.py +65 -4
- codedd_cli/cli.py +4 -0
- codedd_cli/commands/ai_docs_cmd.py +1000 -0
- codedd_cli/commands/audit_cmd.py +776 -10
- codedd_cli/commands/audits_cmd.py +12 -1
- codedd_cli/commands/auth_cmd.py +31 -13
- codedd_cli/commands/config_cmd.py +86 -31
- codedd_cli/commands/fix_cmd.py +1576 -0
- codedd_cli/commands/scope_cmd.py +18 -4
- codedd_cli/config/constants.py +15 -0
- codedd_cli/config/fix_session.py +95 -0
- codedd_cli/config/settings.py +69 -9
- codedd_cli/llm/key_manager.py +106 -7
- codedd_cli/scanner/file_classifier.py +0 -9
- {codedd_cli-0.1.2.dist-info → codedd_cli-0.1.5.dist-info}/METADATA +12 -7
- {codedd_cli-0.1.2.dist-info → codedd_cli-0.1.5.dist-info}/RECORD +30 -24
- {codedd_cli-0.1.2.dist-info → codedd_cli-0.1.5.dist-info}/WHEEL +1 -1
- {codedd_cli-0.1.2.dist-info → codedd_cli-0.1.5.dist-info}/entry_points.txt +0 -0
- {codedd_cli-0.1.2.dist-info → codedd_cli-0.1.5.dist-info}/licenses/LICENSE +0 -0
codedd_cli/__init__.py
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"""CodeDD CLI — run code audits from your terminal."""
|
|
2
|
-
|
|
3
|
-
__version__ = "0.1.
|
|
1
|
+
"""CodeDD CLI — run code audits from your terminal."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.5"
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|
|
@@ -36,10 +37,10 @@ class CodeDDClient:
|
|
|
36
37
|
data = resp.json()
|
|
37
38
|
"""
|
|
38
39
|
|
|
39
|
-
def __init__(self, config: ConfigManager | None = None) -> None:
|
|
40
|
+
def __init__(self, config: ConfigManager | None = None, token: str | None = None) -> None:
|
|
40
41
|
self._config = config or ConfigManager()
|
|
41
42
|
self._base_url = self._config.api_url.rstrip("/")
|
|
42
|
-
self._token = TokenManager.retrieve()
|
|
43
|
+
self._token = token if token is not None else TokenManager.retrieve()
|
|
43
44
|
|
|
44
45
|
# For localhost HTTP, disable TLS verification (not applicable anyway)
|
|
45
46
|
# For HTTPS, always verify certificates
|
|
@@ -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
|
-
|
|
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:
|
codedd_cli/api/endpoints.py
CHANGED
|
@@ -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/"
|