womm-cli 4.0.0__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.
- womm/__init__.py +53 -0
- womm/__main__.py +48 -0
- womm/_version.py +10 -0
- womm/assets/copier/meta/copier.yml +15 -0
- womm/assets/copier/meta/template/README.md.jinja +32 -0
- womm/assets/copier/meta/template/copier.yml.jinja +13 -0
- womm/assets/copier/meta/template/template/.gitkeep +0 -0
- womm/assets/copier/official/javascript/copier.yml +104 -0
- womm/assets/copier/official/javascript/template/.gitignore.jinja +35 -0
- womm/assets/copier/official/javascript/template/.nvmrc.jinja +1 -0
- womm/assets/copier/official/javascript/template/.prettierignore.jinja +10 -0
- womm/assets/copier/official/javascript/template/README.md.jinja +81 -0
- womm/assets/copier/official/javascript/template/biome.json.jinja +54 -0
- womm/assets/copier/official/javascript/template/eslint.config.mjs.jinja +51 -0
- womm/assets/copier/official/javascript/template/index.html.jinja +12 -0
- womm/assets/copier/official/javascript/template/package.json.jinja +88 -0
- womm/assets/copier/official/javascript/template/prettier.config.mjs.jinja +8 -0
- womm/assets/copier/official/javascript/template/src/App.jsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/App.tsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/App.vue.jinja +18 -0
- womm/assets/copier/official/javascript/template/src/index.jsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/index.tsx.jinja +11 -0
- womm/assets/copier/official/javascript/template/src/main.js.jinja +21 -0
- womm/assets/copier/official/javascript/template/src/main.ts.jinja +21 -0
- womm/assets/copier/official/javascript/template/tsconfig.json.jinja +35 -0
- womm/assets/copier/official/javascript/template/vite.config.mjs.jinja +10 -0
- womm/assets/copier/official/javascript/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +63 -0
- womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.js.jinja +12 -0
- womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.ts.jinja +12 -0
- womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +4 -0
- womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +27 -0
- womm/assets/copier/official/python/copier.yml +107 -0
- womm/assets/copier/official/python/template/.gitignore.jinja +40 -0
- womm/assets/copier/official/python/template/.pre-commit-config.yaml.jinja +19 -0
- womm/assets/copier/official/python/template/.python-version.jinja +1 -0
- womm/assets/copier/official/python/template/README.md.jinja +83 -0
- womm/assets/copier/official/python/template/pyproject.toml.jinja +114 -0
- womm/assets/copier/official/python/template/{% if framework == 'django' %}manage.py{% endif %}.jinja +23 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/__init__.py.jinja +3 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/asgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/__init__.py.jinja +0 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/apps.py.jinja +10 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/models.py.jinja +1 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/views.py.jinja +8 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/py.typed +0 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/settings.py.jinja +81 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/urls.py.jinja +11 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/wsgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/__init__.py.jinja +3 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/asgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/__init__.py.jinja +0 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/apps.py.jinja +10 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/models.py.jinja +1 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/views.py.jinja +8 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/py.typed +0 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/settings.py.jinja +81 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/urls.py.jinja +11 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/wsgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +78 -0
- womm/assets/copier/official/python/template/{% if with_tests %}tests{% endif %}/test_smoke.py.jinja +16 -0
- womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +8 -0
- womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +28 -0
- womm/bin/refresh_env.cmd +130 -0
- womm/cli.py +111 -0
- womm/commands/__init__.py +30 -0
- womm/commands/core/__init__.py +29 -0
- womm/commands/core/doctor.py +52 -0
- womm/commands/core/path.py +337 -0
- womm/commands/project/__init__.py +31 -0
- womm/commands/project/create.py +128 -0
- womm/commands/project/setup.py +438 -0
- womm/commands/project/template.py +160 -0
- womm/commands/system/__init__.py +31 -0
- womm/commands/system/context/__init__.py +82 -0
- womm/commands/system/context/backup.py +344 -0
- womm/commands/system/context/inventory.py +111 -0
- womm/commands/system/context/registration.py +290 -0
- womm/commands/system/deps.py +165 -0
- womm/commands/system/system.py +130 -0
- womm/exceptions/__init__.py +69 -0
- womm/exceptions/common/__init__.py +55 -0
- womm/exceptions/common/command_service.py +91 -0
- womm/exceptions/common/file_service.py +60 -0
- womm/exceptions/common/security_service.py +44 -0
- womm/exceptions/common/validation_service.py +70 -0
- womm/exceptions/context/__init__.py +27 -0
- womm/exceptions/context/context_service.py +55 -0
- womm/exceptions/project/__init__.py +29 -0
- womm/exceptions/project/project_service.py +59 -0
- womm/exceptions/system/__init__.py +25 -0
- womm/exceptions/system/system_service.py +53 -0
- womm/interfaces/__init__.py +71 -0
- womm/interfaces/context/__init__.py +34 -0
- womm/interfaces/context/menu_interface.py +686 -0
- womm/interfaces/context/registry_interface.py +562 -0
- womm/interfaces/context/script_detector_interface.py +208 -0
- womm/interfaces/context/script_registrar.py +264 -0
- womm/interfaces/core/__init__.py +26 -0
- womm/interfaces/core/doctor_interface.py +102 -0
- womm/interfaces/dependencies/__init__.py +28 -0
- womm/interfaces/dependencies/deps_interface.py +160 -0
- womm/interfaces/project/__init__.py +36 -0
- womm/interfaces/project/create_interface.py +162 -0
- womm/interfaces/project/detection_interface.py +181 -0
- womm/interfaces/project/manager_interface.py +99 -0
- womm/interfaces/project/setup_interface.py +477 -0
- womm/interfaces/project/template_store_interface.py +196 -0
- womm/interfaces/system/__init__.py +32 -0
- womm/interfaces/system/detector_interface.py +84 -0
- womm/interfaces/system/environment_interface.py +110 -0
- womm/interfaces/system/path_interface.py +570 -0
- womm/services/__init__.py +70 -0
- womm/services/common/__init__.py +33 -0
- womm/services/common/base_validation_service.py +450 -0
- womm/services/common/command_runner_service.py +647 -0
- womm/services/common/file_scanner_service.py +483 -0
- womm/services/common/security_validator_service.py +348 -0
- womm/services/context/__init__.py +37 -0
- womm/services/context/backup_entries.py +148 -0
- womm/services/context/parameters.py +515 -0
- womm/services/context/registry_paths.py +56 -0
- womm/services/context/registry_service.py +573 -0
- womm/services/context/validation_service.py +691 -0
- womm/services/dependencies/__init__.py +29 -0
- womm/services/dependencies/probe.py +102 -0
- womm/services/project/__init__.py +48 -0
- womm/services/project/copier_project_creation_service.py +111 -0
- womm/services/project/destination_guard.py +96 -0
- womm/services/project/detection_service.py +354 -0
- womm/services/project/env_utils.py +333 -0
- womm/services/project/javascript_environment_service.py +348 -0
- womm/services/project/python_environment_service.py +245 -0
- womm/services/project/setup_profile_resolver.py +146 -0
- womm/services/project/template_store_service.py +344 -0
- womm/services/project/validation_service.py +418 -0
- womm/services/system/__init__.py +32 -0
- womm/services/system/detector_service.py +704 -0
- womm/services/system/environment_service.py +494 -0
- womm/services/system/path_service.py +642 -0
- womm/shared/__init__.py +30 -0
- womm/shared/configs/__init__.py +51 -0
- womm/shared/configs/context/__init__.py +43 -0
- womm/shared/configs/context/context_config.py +125 -0
- womm/shared/configs/context/context_file_types_config.py +159 -0
- womm/shared/configs/context/context_limits_config.py +187 -0
- womm/shared/configs/context/context_paths_config.py +115 -0
- womm/shared/configs/context/context_types_config.py +65 -0
- womm/shared/configs/context/script_config.py +219 -0
- womm/shared/configs/dependencies/__init__.py +32 -0
- womm/shared/configs/dependencies/runtime_config.py +46 -0
- womm/shared/configs/dependencies/runtime_package_manager_config.py +48 -0
- womm/shared/configs/logging_config.py +89 -0
- womm/shared/configs/project/__init__.py +33 -0
- womm/shared/configs/project/project_config.py +109 -0
- womm/shared/configs/project/project_structure_config.py +88 -0
- womm/shared/configs/project/python_project_config.py +165 -0
- womm/shared/configs/security/__init__.py +26 -0
- womm/shared/configs/security/security_patterns_config.py +242 -0
- womm/shared/configs/system/__init__.py +28 -0
- womm/shared/configs/system/system_detector_config.py +210 -0
- womm/shared/configs/system/system_environment_config.py +101 -0
- womm/shared/models/__init__.py +13 -0
- womm/shared/models/template_source.py +65 -0
- womm/shared/paths.py +192 -0
- womm/shared/results/__init__.py +138 -0
- womm/shared/results/base.py +85 -0
- womm/shared/results/command_results.py +61 -0
- womm/shared/results/context_results.py +345 -0
- womm/shared/results/dependency_results.py +110 -0
- womm/shared/results/doctor_results.py +41 -0
- womm/shared/results/file_results.py +97 -0
- womm/shared/results/project_results.py +163 -0
- womm/shared/results/security_results.py +128 -0
- womm/shared/results/system_results.py +268 -0
- womm/shared/results/template_results.py +43 -0
- womm/shared/runtime.py +36 -0
- womm/ui/__init__.py +31 -0
- womm/ui/common/__init__.py +39 -0
- womm/ui/common/interactive_menu.py +246 -0
- womm/ui/common/logging.py +184 -0
- womm/ui/common/prompts.py +93 -0
- womm/ui/context/__init__.py +31 -0
- womm/ui/context/display.py +485 -0
- womm/ui/context/menu_display.py +189 -0
- womm/ui/context/wizard.py +557 -0
- womm/ui/project/__init__.py +42 -0
- womm/ui/project/create/create_completion_summaries.py +55 -0
- womm/ui/project/project_wizard.py +174 -0
- womm/ui/project/setup/setup_completion_summaries.py +111 -0
- womm/ui/project/templates/template_store_display.py +128 -0
- womm/ui/system/__init__.py +60 -0
- womm/ui/system/display.py +531 -0
- womm/ui/system/path_display.py +387 -0
- womm/utils/__init__.py +23 -0
- womm/utils/common/__init__.py +49 -0
- womm/utils/common/file_scanner_utils.py +110 -0
- womm/utils/common/path_resolver_utils.py +127 -0
- womm/utils/common/safe_fs_utils.py +135 -0
- womm/utils/context/__init__.py +54 -0
- womm/utils/context/core_utils.py +345 -0
- womm/utils/context/icon_utils.py +259 -0
- womm/utils/project/__init__.py +106 -0
- womm/utils/project/asset_utils.py +154 -0
- womm/utils/project/core_utils.py +391 -0
- womm/utils/project/file_utils.py +494 -0
- womm/utils/project/platform_utils.py +170 -0
- womm/utils/project/validation_utils.py +273 -0
- womm/utils/security/__init__.py +46 -0
- womm/utils/security/security_validation_utils.py +258 -0
- womm/utils/system/__init__.py +69 -0
- womm/utils/system/detector_utils.py +299 -0
- womm/utils/system/environment_utils.py +172 -0
- womm/utils/system/path_utils.py +101 -0
- womm_cli-4.0.0.dist-info/METADATA +203 -0
- womm_cli-4.0.0.dist-info/RECORD +218 -0
- womm_cli-4.0.0.dist-info/WHEEL +4 -0
- womm_cli-4.0.0.dist-info/entry_points.txt +2 -0
- womm_cli-4.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# SECURITY PATTERNS CONFIG - Security & File Scanner Configuration
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Centralized security and file scanning configuration for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This config module exposes constants used by security and file scanning utilities:
|
|
11
|
+
- File scanner patterns (extensions, excluded directories)
|
|
12
|
+
- Security-sensitive patterns
|
|
13
|
+
- Dangerous commands and arguments
|
|
14
|
+
- Whitelisted commands
|
|
15
|
+
- Permission validation patterns
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
# ///////////////////////////////////////////////////////////////
|
|
21
|
+
# IMPORTS
|
|
22
|
+
# ///////////////////////////////////////////////////////////////
|
|
23
|
+
# Standard library imports
|
|
24
|
+
from dataclasses import dataclass
|
|
25
|
+
from typing import ClassVar
|
|
26
|
+
|
|
27
|
+
# ///////////////////////////////////////////////////////////////
|
|
28
|
+
# FILE SCANNER CONFIG CLASS
|
|
29
|
+
# ///////////////////////////////////////////////////////////////
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(frozen=True)
|
|
33
|
+
class FileScannerConfig:
|
|
34
|
+
"""File scanner-related configuration (static, read-only).
|
|
35
|
+
|
|
36
|
+
Contains patterns for file scanning operations:
|
|
37
|
+
- File extensions to scan
|
|
38
|
+
- Directories to exclude
|
|
39
|
+
- Security-sensitive file patterns
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
# ///////////////////////////////////////////////////////////
|
|
43
|
+
# PYTHON FILE EXTENSIONS
|
|
44
|
+
# ///////////////////////////////////////////////////////////
|
|
45
|
+
|
|
46
|
+
PYTHON_EXTENSIONS: ClassVar[set[str]] = {".py", ".pyi"}
|
|
47
|
+
|
|
48
|
+
# ///////////////////////////////////////////////////////////
|
|
49
|
+
# EXCLUDED DIRECTORIES
|
|
50
|
+
# ///////////////////////////////////////////////////////////
|
|
51
|
+
|
|
52
|
+
EXCLUDED_DIRS: ClassVar[set[str]] = {
|
|
53
|
+
"__pycache__",
|
|
54
|
+
".git",
|
|
55
|
+
".pytest_cache",
|
|
56
|
+
".mypy_cache",
|
|
57
|
+
".ruff_cache",
|
|
58
|
+
"node_modules",
|
|
59
|
+
".venv",
|
|
60
|
+
"venv",
|
|
61
|
+
"env",
|
|
62
|
+
".env",
|
|
63
|
+
"build",
|
|
64
|
+
"dist",
|
|
65
|
+
"*.egg-info",
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
# ///////////////////////////////////////////////////////////
|
|
69
|
+
# SECURITY-SENSITIVE FILE PATTERNS
|
|
70
|
+
# ///////////////////////////////////////////////////////////
|
|
71
|
+
|
|
72
|
+
SECURITY_SENSITIVE_PATTERNS: ClassVar[list[str]] = [
|
|
73
|
+
"password",
|
|
74
|
+
"secret",
|
|
75
|
+
"key",
|
|
76
|
+
"credential",
|
|
77
|
+
"token",
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# ///////////////////////////////////////////////////////////////
|
|
82
|
+
# SECURITY PATTERNS CONFIG CLASS
|
|
83
|
+
# ///////////////////////////////////////////////////////////////
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@dataclass(frozen=True)
|
|
87
|
+
class SecurityPatternsConfig:
|
|
88
|
+
"""Security-related pattern configuration (static, read-only).
|
|
89
|
+
|
|
90
|
+
Contains patterns for security validation:
|
|
91
|
+
- Dangerous commands and arguments
|
|
92
|
+
- Dangerous file/path patterns
|
|
93
|
+
- Allowed commands whitelist
|
|
94
|
+
- Shell injection patterns
|
|
95
|
+
- Permission validation patterns
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
# ///////////////////////////////////////////////////////////
|
|
99
|
+
# DANGEROUS COMMAND PATTERNS
|
|
100
|
+
# ///////////////////////////////////////////////////////////
|
|
101
|
+
|
|
102
|
+
DANGEROUS_COMMANDS: ClassVar[dict[str, list[str]]] = {
|
|
103
|
+
"rm": ["-rf", "--recursive", "--force"],
|
|
104
|
+
"del": ["/s", "/q", "/f"],
|
|
105
|
+
"format": ["c:", "d:", "/q", "/u"],
|
|
106
|
+
"shutdown": ["/s", "/t", "0"],
|
|
107
|
+
"taskkill": ["/f", "/im", "*"],
|
|
108
|
+
"kill": ["-9", "-f"],
|
|
109
|
+
"chmod": ["777", "000"],
|
|
110
|
+
"chown": ["root:", "sudo:"],
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# ///////////////////////////////////////////////////////////
|
|
114
|
+
# DANGEROUS FILE PATTERNS
|
|
115
|
+
# ///////////////////////////////////////////////////////////
|
|
116
|
+
|
|
117
|
+
DANGEROUS_FILE_PATTERNS: ClassVar[list[str]] = [
|
|
118
|
+
r"\.\./\.\./", # Directory traversal
|
|
119
|
+
r"~/.ssh/", # SSH keys
|
|
120
|
+
r"/etc/", # System files
|
|
121
|
+
r"/var/log/", # Log files
|
|
122
|
+
r"/proc/", # Process files
|
|
123
|
+
r"/sys/", # System files
|
|
124
|
+
r"C:\\Windows\\", # Windows system files
|
|
125
|
+
r"C:\\System32\\", # Windows system files
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
# ///////////////////////////////////////////////////////////
|
|
129
|
+
# ALLOWED COMMANDS (WHITELIST)
|
|
130
|
+
# ///////////////////////////////////////////////////////////
|
|
131
|
+
|
|
132
|
+
ALLOWED_COMMANDS: ClassVar[set[str]] = {
|
|
133
|
+
"python",
|
|
134
|
+
"python3",
|
|
135
|
+
"pip",
|
|
136
|
+
"pip3",
|
|
137
|
+
"node",
|
|
138
|
+
"npm",
|
|
139
|
+
"npx",
|
|
140
|
+
"yarn",
|
|
141
|
+
"git",
|
|
142
|
+
"git-*",
|
|
143
|
+
"ruff",
|
|
144
|
+
"black",
|
|
145
|
+
"isort",
|
|
146
|
+
"mypy",
|
|
147
|
+
"eslint",
|
|
148
|
+
"prettier",
|
|
149
|
+
"echo",
|
|
150
|
+
"cat",
|
|
151
|
+
"ls",
|
|
152
|
+
"dir",
|
|
153
|
+
"mkdir",
|
|
154
|
+
"rmdir",
|
|
155
|
+
"cp",
|
|
156
|
+
"copy",
|
|
157
|
+
"mv",
|
|
158
|
+
"move",
|
|
159
|
+
"grep",
|
|
160
|
+
"find",
|
|
161
|
+
"sort",
|
|
162
|
+
"uniq",
|
|
163
|
+
"head",
|
|
164
|
+
"tail",
|
|
165
|
+
"wc",
|
|
166
|
+
"curl",
|
|
167
|
+
"wget",
|
|
168
|
+
"tar",
|
|
169
|
+
"zip",
|
|
170
|
+
"unzip",
|
|
171
|
+
"chmod",
|
|
172
|
+
"chown", # With restrictions
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
# ///////////////////////////////////////////////////////////
|
|
176
|
+
# DANGEROUS COMMAND REGEX PATTERNS
|
|
177
|
+
# ///////////////////////////////////////////////////////////
|
|
178
|
+
|
|
179
|
+
DANGEROUS_COMMAND_PATTERNS: ClassVar[list[str]] = [
|
|
180
|
+
r"rm\s*-rf", # Recursive force remove
|
|
181
|
+
r"del\s*/[sqf]", # Windows delete with dangerous flags
|
|
182
|
+
r"format\s*[cd]:", # Format drives
|
|
183
|
+
r"shutdown\s*/s", # Shutdown system
|
|
184
|
+
r"taskkill\s*/f", # Force kill processes
|
|
185
|
+
r"kill\s*-[9f]", # Force kill
|
|
186
|
+
r"chmod\s*[07]{3}", # Dangerous permissions
|
|
187
|
+
r"chown\s*root:", # Change to root
|
|
188
|
+
]
|
|
189
|
+
|
|
190
|
+
# ///////////////////////////////////////////////////////////
|
|
191
|
+
# SHELL INJECTION PATTERNS
|
|
192
|
+
# ///////////////////////////////////////////////////////////
|
|
193
|
+
|
|
194
|
+
SHELL_INJECTION_PATTERNS: ClassVar[list[str]] = [
|
|
195
|
+
r"[;&|`$()]", # Shell operators
|
|
196
|
+
r"\.\./", # Directory traversal
|
|
197
|
+
r"~/.ssh/", # SSH keys
|
|
198
|
+
r"/etc/", # System files
|
|
199
|
+
r"C:\\Windows\\", # Windows system files
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
# ///////////////////////////////////////////////////////////
|
|
203
|
+
# SYSTEM DIRECTORY PATHS
|
|
204
|
+
# ///////////////////////////////////////////////////////////
|
|
205
|
+
|
|
206
|
+
SYSTEM_DIRECTORIES: ClassVar[list[str]] = [
|
|
207
|
+
"/", # Root
|
|
208
|
+
"/bin",
|
|
209
|
+
"/sbin",
|
|
210
|
+
"/usr/bin",
|
|
211
|
+
"/usr/sbin",
|
|
212
|
+
"/etc",
|
|
213
|
+
"/var",
|
|
214
|
+
"/proc",
|
|
215
|
+
"/sys",
|
|
216
|
+
"C:\\",
|
|
217
|
+
"C:\\Windows",
|
|
218
|
+
"C:\\System32",
|
|
219
|
+
]
|
|
220
|
+
|
|
221
|
+
# ///////////////////////////////////////////////////////////
|
|
222
|
+
# PERMISSION VALIDATION PATTERNS
|
|
223
|
+
# ///////////////////////////////////////////////////////////
|
|
224
|
+
|
|
225
|
+
# Chmod permission patterns
|
|
226
|
+
CHMOD_ALLOWED_PATTERNS: ClassVar[list[str]] = [
|
|
227
|
+
r"^[0-7]{3,4}$", # Octal permissions
|
|
228
|
+
r"^[ugoa]*[+-=][rwxXst]*$", # Symbolic permissions
|
|
229
|
+
]
|
|
230
|
+
|
|
231
|
+
# Chown owner patterns
|
|
232
|
+
CHOWN_ALLOWED_PATTERNS: ClassVar[list[str]] = [
|
|
233
|
+
r"^[a-zA-Z_][a-zA-Z0-9_]*$", # Username
|
|
234
|
+
r"^[a-zA-Z_][a-zA-Z0-9_]*:[a-zA-Z_][a-zA-Z0-9_]*$", # user:group
|
|
235
|
+
]
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
# ///////////////////////////////////////////////////////////////
|
|
239
|
+
# PUBLIC API
|
|
240
|
+
# ///////////////////////////////////////////////////////////////
|
|
241
|
+
|
|
242
|
+
__all__ = ["FileScannerConfig", "SecurityPatternsConfig"]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# SYSTEM CONFIGS - System Configuration Modules
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
System configuration modules for Works On My Machine.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
# ///////////////////////////////////////////////////////////////
|
|
14
|
+
# IMPORTS
|
|
15
|
+
# ///////////////////////////////////////////////////////////////
|
|
16
|
+
# Local imports
|
|
17
|
+
from .system_detector_config import PackageManagerConfig, SystemDetectorConfig
|
|
18
|
+
from .system_environment_config import SystemEnvironmentConfig
|
|
19
|
+
|
|
20
|
+
# ///////////////////////////////////////////////////////////////
|
|
21
|
+
# PUBLIC API
|
|
22
|
+
# ///////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"PackageManagerConfig",
|
|
26
|
+
"SystemDetectorConfig",
|
|
27
|
+
"SystemEnvironmentConfig",
|
|
28
|
+
]
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# SYSTEM DETECTOR CONFIG - System Detector Configuration
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Centralized system detector configuration for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This config class exposes constants used by system detection utilities and services:
|
|
11
|
+
- Package manager metadata
|
|
12
|
+
- Development environment definitions
|
|
13
|
+
- Editor and shell definitions
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# IMPORTS
|
|
20
|
+
# ///////////////////////////////////////////////////////////////
|
|
21
|
+
# Standard library imports
|
|
22
|
+
from dataclasses import dataclass
|
|
23
|
+
from typing import ClassVar
|
|
24
|
+
|
|
25
|
+
# ///////////////////////////////////////////////////////////////
|
|
26
|
+
# PACKAGE MANAGER CONFIG CLASS
|
|
27
|
+
# ///////////////////////////////////////////////////////////////
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class PackageManagerConfig:
|
|
31
|
+
"""Configuration for system package managers (unified cross-platform).
|
|
32
|
+
|
|
33
|
+
This class provides a unified view of all system package managers
|
|
34
|
+
with platform, priority, and command information.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
SYSTEM_PACKAGE_MANAGERS: ClassVar[dict[str, dict[str, str | int]]] = {
|
|
38
|
+
# Windows package managers
|
|
39
|
+
"winget": {
|
|
40
|
+
"platform": "windows",
|
|
41
|
+
"command": "winget",
|
|
42
|
+
"version_flag": "--version",
|
|
43
|
+
"priority": 1,
|
|
44
|
+
"description": "Microsoft Windows Package Manager",
|
|
45
|
+
},
|
|
46
|
+
"chocolatey": {
|
|
47
|
+
"platform": "windows",
|
|
48
|
+
"command": "choco",
|
|
49
|
+
"version_flag": "--version",
|
|
50
|
+
"priority": 2,
|
|
51
|
+
"description": "Chocolatey Package Manager",
|
|
52
|
+
},
|
|
53
|
+
"scoop": {
|
|
54
|
+
"platform": "windows",
|
|
55
|
+
"command": "scoop",
|
|
56
|
+
"version_flag": "--version",
|
|
57
|
+
"priority": 3,
|
|
58
|
+
"description": "Scoop Package Manager",
|
|
59
|
+
},
|
|
60
|
+
# macOS package managers
|
|
61
|
+
"homebrew": {
|
|
62
|
+
"platform": "darwin",
|
|
63
|
+
"command": "brew",
|
|
64
|
+
"version_flag": "--version",
|
|
65
|
+
"priority": 1,
|
|
66
|
+
"description": "Homebrew Package Manager",
|
|
67
|
+
},
|
|
68
|
+
"macports": {
|
|
69
|
+
"platform": "darwin",
|
|
70
|
+
"command": "port",
|
|
71
|
+
"version_flag": "version",
|
|
72
|
+
"priority": 2,
|
|
73
|
+
"description": "MacPorts Package Manager",
|
|
74
|
+
},
|
|
75
|
+
# Linux package managers
|
|
76
|
+
"apt": {
|
|
77
|
+
"platform": "linux",
|
|
78
|
+
"command": "apt",
|
|
79
|
+
"version_flag": "--version",
|
|
80
|
+
"priority": 1,
|
|
81
|
+
"description": "Advanced Package Tool (Debian/Ubuntu)",
|
|
82
|
+
},
|
|
83
|
+
"dnf": {
|
|
84
|
+
"platform": "linux",
|
|
85
|
+
"command": "dnf",
|
|
86
|
+
"version_flag": "--version",
|
|
87
|
+
"priority": 2,
|
|
88
|
+
"description": "Dandified YUM (Fedora/RHEL)",
|
|
89
|
+
},
|
|
90
|
+
"yum": {
|
|
91
|
+
"platform": "linux",
|
|
92
|
+
"command": "yum",
|
|
93
|
+
"version_flag": "--version",
|
|
94
|
+
"priority": 3,
|
|
95
|
+
"description": "Yellowdog Updater Modified (CentOS/RHEL)",
|
|
96
|
+
},
|
|
97
|
+
"pacman": {
|
|
98
|
+
"platform": "linux",
|
|
99
|
+
"command": "pacman",
|
|
100
|
+
"version_flag": "--version",
|
|
101
|
+
"priority": 2,
|
|
102
|
+
"description": "Pacman Package Manager (Arch Linux)",
|
|
103
|
+
},
|
|
104
|
+
"zypper": {
|
|
105
|
+
"platform": "linux",
|
|
106
|
+
"command": "zypper",
|
|
107
|
+
"version_flag": "--version",
|
|
108
|
+
"priority": 4,
|
|
109
|
+
"description": "Zypper Package Manager (openSUSE)",
|
|
110
|
+
},
|
|
111
|
+
"snap": {
|
|
112
|
+
"platform": "linux",
|
|
113
|
+
"command": "snap",
|
|
114
|
+
"version_flag": "--version",
|
|
115
|
+
"priority": 5,
|
|
116
|
+
"description": "Snap Package Manager (Universal)",
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@classmethod
|
|
121
|
+
def get_by_platform(cls, platform: str) -> dict[str, dict[str, str | int]]:
|
|
122
|
+
"""Get package managers for a specific platform.
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
platform: Platform name (windows, darwin, linux)
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
Dictionary of package managers for the platform
|
|
129
|
+
"""
|
|
130
|
+
return {
|
|
131
|
+
name: config
|
|
132
|
+
for name, config in cls.SYSTEM_PACKAGE_MANAGERS.items()
|
|
133
|
+
if config.get("platform") == platform
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@classmethod
|
|
137
|
+
def get_windows_managers(cls) -> dict[str, dict[str, str | int]]:
|
|
138
|
+
"""Get Windows package managers."""
|
|
139
|
+
return cls.get_by_platform("windows")
|
|
140
|
+
|
|
141
|
+
@classmethod
|
|
142
|
+
def get_macos_managers(cls) -> dict[str, dict[str, str | int]]:
|
|
143
|
+
"""Get macOS package managers."""
|
|
144
|
+
return cls.get_by_platform("darwin")
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def get_linux_managers(cls) -> dict[str, dict[str, str | int]]:
|
|
148
|
+
"""Get Linux package managers."""
|
|
149
|
+
return cls.get_by_platform("linux")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
# ///////////////////////////////////////////////////////////////
|
|
153
|
+
# SYSTEM DETECTOR CONFIG CLASS
|
|
154
|
+
# ///////////////////////////////////////////////////////////////
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@dataclass(frozen=True)
|
|
158
|
+
class SystemDetectorConfig:
|
|
159
|
+
"""System detector configuration (static, read-only).
|
|
160
|
+
|
|
161
|
+
Provides editor, shell, and platform-specific package manager metadata
|
|
162
|
+
for system detection operations.
|
|
163
|
+
"""
|
|
164
|
+
|
|
165
|
+
# ///////////////////////////////////////////////////////////
|
|
166
|
+
# EDITOR DEFINITIONS
|
|
167
|
+
# ///////////////////////////////////////////////////////////
|
|
168
|
+
|
|
169
|
+
EDITORS: ClassVar[dict[str, str]] = {
|
|
170
|
+
"code": "Visual Studio Code",
|
|
171
|
+
"code-insiders": "VS Code Insiders",
|
|
172
|
+
"subl": "Sublime Text",
|
|
173
|
+
"atom": "Atom",
|
|
174
|
+
"vim": "Vim",
|
|
175
|
+
"nvim": "Neovim",
|
|
176
|
+
"emacs": "Emacs",
|
|
177
|
+
"nano": "Nano",
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
# ///////////////////////////////////////////////////////////
|
|
181
|
+
# SHELL DEFINITIONS
|
|
182
|
+
# ///////////////////////////////////////////////////////////
|
|
183
|
+
|
|
184
|
+
SHELLS: ClassVar[dict[str, str]] = {
|
|
185
|
+
"bash": "Bash",
|
|
186
|
+
"zsh": "Zsh",
|
|
187
|
+
"fish": "Fish",
|
|
188
|
+
"powershell": "PowerShell",
|
|
189
|
+
"pwsh": "PowerShell Core",
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
# ///////////////////////////////////////////////////////////
|
|
193
|
+
# RECOMMENDATION TEMPLATES
|
|
194
|
+
# ///////////////////////////////////////////////////////////
|
|
195
|
+
|
|
196
|
+
RECOMMENDATION_TEMPLATES: ClassVar[dict[str, str]] = {
|
|
197
|
+
"package_manager_use": "Use {manager} for installations",
|
|
198
|
+
"package_manager_install": "Install {manager} to facilitate installations",
|
|
199
|
+
"package_manager_none": "No package manager detected - manual installation required",
|
|
200
|
+
"editor_vscode": "VS Code detected - excellent choice for dev-tools",
|
|
201
|
+
"editor_cli": "Command line editor detected - dev-tools compatible",
|
|
202
|
+
"editor_install": "Install VS Code recommended for better integration",
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
# ///////////////////////////////////////////////////////////////
|
|
207
|
+
# PUBLIC API
|
|
208
|
+
# ///////////////////////////////////////////////////////////////
|
|
209
|
+
|
|
210
|
+
__all__ = ["PackageManagerConfig", "SystemDetectorConfig"]
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# SYSTEM ENVIRONMENT CONFIG - System Environment Configuration
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Centralized system environment configuration for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This config class exposes constants used by system environment utilities and services:
|
|
11
|
+
- Refresh script paths
|
|
12
|
+
- Timeouts
|
|
13
|
+
- Shell configuration files
|
|
14
|
+
- Verification settings
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
# ///////////////////////////////////////////////////////////////
|
|
20
|
+
# IMPORTS
|
|
21
|
+
# ///////////////////////////////////////////////////////////////
|
|
22
|
+
# Standard library imports
|
|
23
|
+
from dataclasses import dataclass
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
from typing import ClassVar
|
|
26
|
+
|
|
27
|
+
# ///////////////////////////////////////////////////////////////
|
|
28
|
+
# CLASS DEFINITION
|
|
29
|
+
# ///////////////////////////////////////////////////////////////
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(frozen=True)
|
|
33
|
+
class SystemEnvironmentConfig:
|
|
34
|
+
"""System environment-related configuration (static, read-only)."""
|
|
35
|
+
|
|
36
|
+
# ///////////////////////////////////////////////////////////
|
|
37
|
+
# REFRESH SCRIPT PATHS
|
|
38
|
+
# ///////////////////////////////////////////////////////////
|
|
39
|
+
|
|
40
|
+
REFRESH_ENV_SCRIPT_NAME: ClassVar[str] = "refresh_env.cmd"
|
|
41
|
+
REFRESH_ENV_SCRIPT_RELATIVE_PATH: ClassVar[str] = "bin/refresh_env.cmd"
|
|
42
|
+
|
|
43
|
+
# ///////////////////////////////////////////////////////////
|
|
44
|
+
# TIMEOUTS
|
|
45
|
+
# ///////////////////////////////////////////////////////////
|
|
46
|
+
|
|
47
|
+
VERIFICATION_TIMEOUT: ClassVar[int] = 30 # seconds
|
|
48
|
+
REFRESH_TIMEOUT: ClassVar[int] = 60 # seconds
|
|
49
|
+
|
|
50
|
+
# ///////////////////////////////////////////////////////////
|
|
51
|
+
# SHELL CONFIGURATION FILES
|
|
52
|
+
# ///////////////////////////////////////////////////////////
|
|
53
|
+
|
|
54
|
+
UNIX_SHELL_CONFIG_FILES: ClassVar[list[str]] = [
|
|
55
|
+
".bashrc",
|
|
56
|
+
".zshrc",
|
|
57
|
+
".profile",
|
|
58
|
+
".bash_profile",
|
|
59
|
+
".zprofile",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
# ///////////////////////////////////////////////////////////
|
|
63
|
+
# WINDOWS REGISTRY PATHS
|
|
64
|
+
# ///////////////////////////////////////////////////////////
|
|
65
|
+
|
|
66
|
+
WINDOWS_HKLM_ENVIRONMENT_PATH: ClassVar[str] = (
|
|
67
|
+
r"System\CurrentControlSet\Control\Session Manager\Environment"
|
|
68
|
+
)
|
|
69
|
+
WINDOWS_HKCU_ENVIRONMENT_PATH: ClassVar[str] = "Environment"
|
|
70
|
+
|
|
71
|
+
# ///////////////////////////////////////////////////////////
|
|
72
|
+
# VERIFICATION SETTINGS
|
|
73
|
+
# ///////////////////////////////////////////////////////////
|
|
74
|
+
|
|
75
|
+
DEFAULT_VERIFICATION_COMMAND: ClassVar[str] = "womm"
|
|
76
|
+
VERIFICATION_COMMAND_ARGS: ClassVar[list[str]] = ["--version"]
|
|
77
|
+
|
|
78
|
+
# ///////////////////////////////////////////////////////////
|
|
79
|
+
# STATIC METHODS
|
|
80
|
+
# ///////////////////////////////////////////////////////////
|
|
81
|
+
|
|
82
|
+
@staticmethod
|
|
83
|
+
def get_shell_config_files() -> list[Path]:
|
|
84
|
+
"""Get list of shell configuration files for Unix systems.
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
List[Path]: List of shell configuration file paths that exist
|
|
88
|
+
"""
|
|
89
|
+
home = Path.home()
|
|
90
|
+
config_files = [
|
|
91
|
+
home / config_file
|
|
92
|
+
for config_file in SystemEnvironmentConfig.UNIX_SHELL_CONFIG_FILES
|
|
93
|
+
]
|
|
94
|
+
return [f for f in config_files if f.exists()]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# ///////////////////////////////////////////////////////////////
|
|
98
|
+
# PUBLIC API
|
|
99
|
+
# ///////////////////////////////////////////////////////////////
|
|
100
|
+
|
|
101
|
+
__all__ = ["SystemEnvironmentConfig"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# SHARED MODELS - Domain models shared across layers
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""Immutable domain models shared by services, interfaces and commands."""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from .template_source import TemplateEntry, TemplateOrigin
|
|
12
|
+
|
|
13
|
+
__all__ = ["TemplateEntry", "TemplateOrigin"]
|