handycode 2.1.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.
handycode/security.py ADDED
@@ -0,0 +1,103 @@
1
+ """
2
+ Проверка безопасности для HandyCode
3
+ """
4
+
5
+ from pathlib import Path
6
+ from typing import List
7
+
8
+
9
+ class SecurityChecker:
10
+ """Проверяет пути и команды на безопасность"""
11
+
12
+ def __init__(self, project_root: Path):
13
+ """Инициализация проверки безопасности"""
14
+ self.project_root = Path(project_root).resolve()
15
+
16
+ # Опасные системные директории
17
+ self.dangerous_dirs = {
18
+ '/', '/etc', '/bin', '/sbin', '/usr/bin', '/usr/sbin',
19
+ '/boot', '/root', '/var', '/tmp', '/dev', '/proc', '/sys',
20
+ '/System', '/Library', '/Windows', '/Program Files',
21
+ '/Program Files (x86)', '/system32',
22
+ }
23
+
24
+ # Опасные команды
25
+ self.dangerous_commands = [
26
+ 'rm -rf /',
27
+ 'rm -rf ~',
28
+ 'rm -rf .',
29
+ 'mkfs.',
30
+ 'dd if=',
31
+ ':(){ :|:& };:',
32
+ 'chmod 777 /',
33
+ 'chown -R',
34
+ '> /dev/sda',
35
+ 'format c:',
36
+ 'del /f /s /q',
37
+ 'shutdown',
38
+ 'reboot',
39
+ 'halt',
40
+ 'poweroff',
41
+ ]
42
+
43
+ # Подозрительные паттерны
44
+ self.suspicious_patterns = [
45
+ 'sudo ',
46
+ 'su ',
47
+ 'passwd',
48
+ 'curl.*|.*sh',
49
+ 'wget.*|.*sh',
50
+ 'eval ',
51
+ 'exec ',
52
+ 'base64.*decode',
53
+ ]
54
+
55
+ def is_safe_path(self, path: str) -> bool:
56
+ """Проверяет безопасность пути к файлу"""
57
+ try:
58
+ full_path = (self.project_root / path).resolve()
59
+
60
+ # Должен быть внутри проекта
61
+ full_path.relative_to(self.project_root)
62
+
63
+ # Проверяем опасные символы
64
+ path_str = str(path)
65
+ dangerous_chars = ['..', '~', '$', '`', '|', '&', ';', '\n', '\r']
66
+ for char in dangerous_chars:
67
+ if char in path_str:
68
+ return False
69
+
70
+ # Проверяем опасные директории
71
+ path_str = str(full_path)
72
+ for dangerous in self.dangerous_dirs:
73
+ if path_str == dangerous or path_str.startswith(dangerous + '/'):
74
+ return False
75
+
76
+ return True
77
+ except (ValueError, OSError):
78
+ return False
79
+
80
+ def is_safe_command(self, command: str) -> bool:
81
+ """Проверяет безопасность команды"""
82
+ command_lower = command.lower().strip()
83
+
84
+ # Проверяем опасные команды
85
+ for dangerous in self.dangerous_commands:
86
+ if dangerous.lower() in command_lower:
87
+ return False
88
+
89
+ # Проверяем подозрительные паттерны
90
+ for pattern in self.suspicious_patterns:
91
+ if pattern.lower() in command_lower:
92
+ # Разрешаем безопасные комбинации
93
+ if 'npm' not in command_lower and 'pip' not in command_lower:
94
+ return False
95
+
96
+ # Блокируем доступ к системным директориям
97
+ for dangerous in ['/etc', '/bin/', '/sbin/', '/usr/', '/boot', '/root', '/var/']:
98
+ if dangerous in command:
99
+ # Разрешаем для пакетных менеджеров
100
+ if not any(safe in command_lower for safe in ['npm', 'pip', 'apt', 'brew', 'yarn']):
101
+ return False
102
+
103
+ return True
handycode/utils.py ADDED
@@ -0,0 +1,92 @@
1
+ """
2
+ Вспомогательные функции для HandyCode
3
+ """
4
+
5
+ import sys
6
+ import os
7
+
8
+
9
+ # Цвета для терминала
10
+ class Colors:
11
+ RESET = '\033[0m'
12
+ RED = '\033[91m'
13
+ GREEN = '\033[92m'
14
+ YELLOW = '\033[93m'
15
+ BLUE = '\033[94m'
16
+ MAGENTA = '\033[95m'
17
+ CYAN = '\033[96m'
18
+ WHITE = '\033[97m'
19
+ BOLD = '\033[1m'
20
+
21
+
22
+ def supports_color():
23
+ """Проверяет поддержку цветов"""
24
+ if os.name == 'nt': # Windows
25
+ try:
26
+ import ctypes
27
+ kernel32 = ctypes.windll.kernel32
28
+ kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
29
+ return True
30
+ except:
31
+ return False
32
+ return hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
33
+
34
+
35
+ def colorize(text, color):
36
+ """Добавляет цвет"""
37
+ if supports_color():
38
+ return f"{color}{text}{Colors.RESET}"
39
+ return text
40
+
41
+
42
+ def print_colored(text, color):
43
+ """Выводит цветной текст"""
44
+ print(colorize(text, color))
45
+
46
+
47
+ def print_header(text):
48
+ """Выводит заголовок"""
49
+ print(colorize(text, Colors.CYAN + Colors.BOLD))
50
+
51
+
52
+ def print_success(text):
53
+ """Выводит успех"""
54
+ print(colorize(text, Colors.GREEN))
55
+
56
+
57
+ def print_error(text):
58
+ """Выводит ошибку"""
59
+ print(colorize(text, Colors.RED))
60
+ return text
61
+
62
+
63
+ def print_warning(text):
64
+ """Выводит предупреждение"""
65
+ print(colorize(text, Colors.YELLOW))
66
+
67
+
68
+ def print_info(text):
69
+ """Выводит информацию"""
70
+ print(colorize(text, Colors.BLUE))
71
+
72
+
73
+ def print_logo():
74
+ """Выводит логотип"""
75
+ from .logo import get_logo
76
+ print(get_logo())
77
+
78
+
79
+ def truncate(text, max_length=100):
80
+ """Обрезает текст"""
81
+ if len(text) <= max_length:
82
+ return text
83
+ return text[:max_length - 3] + "..."
84
+
85
+
86
+ def format_size(size_bytes):
87
+ """Форматирует размер"""
88
+ for unit in ['B', 'KB', 'MB', 'GB']:
89
+ if size_bytes < 1024:
90
+ return f"{size_bytes:.1f} {unit}"
91
+ size_bytes /= 1024
92
+ return f"{size_bytes:.1f} TB"
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: handycode
3
+ Version: 2.1.0
4
+ Summary: AI Code Assistant for DeepSeek
5
+ Home-page: https://github.com/AuraTechno/HandyCode
6
+ Author: AuraTechno
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: requests>=2.28.0
11
+ Dynamic: author
12
+ Dynamic: description
13
+ Dynamic: description-content-type
14
+ Dynamic: home-page
15
+ Dynamic: license-file
16
+ Dynamic: requires-dist
17
+ Dynamic: requires-python
18
+ Dynamic: summary
19
+
20
+ HandyCode - AI Code Assistant
@@ -0,0 +1,18 @@
1
+ handycode/__init__.py,sha256=tUEPfnpoSMj0RuwYX8rCixWkCHUWfOOr6UflLyorQUs,291
2
+ handycode/__main__.py,sha256=RcR6WlHbirmLemE-4CnAvn8cxzTSh4ma3_XxCXABa-4,125
3
+ handycode/assistant.py,sha256=AowdPA72QDe10JBtMKpOSVgBlcYFaJ1MbWtmZLcUGN8,19423
4
+ handycode/cli.py,sha256=UDnRktX4t2AJIvdxxvYWWoYPz9htapnlGTy2WMIJP0s,4243
5
+ handycode/config.py,sha256=Izkb19JkmU8PyiSqFbTfrTVmLMYkVzjjStP71SXn_E0,2398
6
+ handycode/file_manager.py,sha256=ULtCgvi32j2gHvYNb76B0rD6hogjm875kfCP2XjUP7I,9416
7
+ handycode/logo.py,sha256=D9Pxf8S3vOOhRO77Q-PY8kr8minO004r5gkaoCsENO0,10426
8
+ handycode/main.py,sha256=H38Z8kn7KeAtRYFDSk-n9pXDLdSfnMe5ye3fDdao6WA,590
9
+ handycode/models.py,sha256=-el9I6QKlBhdx6bJpEpd6JsiwN38R7cj2AYtkXSCFr4,2436
10
+ handycode/project_templates.py,sha256=SKNvYy-OkylOL06k6vIjO7xF9R23yFzE9Gw4O7bPajg,3544
11
+ handycode/security.py,sha256=4jg1UonjRCuk6brZkjM-nP3EZOjpdEiERcQhsuWIRxs,3665
12
+ handycode/utils.py,sha256=qFDkTNRctoWKpt58X7X2KbjwUrfJ0n336_SyQ8RZkn0,2135
13
+ handycode-2.1.0.dist-info/licenses/LICENSE,sha256=7cNY5JRZrVl8pca2EHe4lQM0M-fQFaxj1KRM2dHfw94,1065
14
+ handycode-2.1.0.dist-info/METADATA,sha256=lRvJvz2ZYJSOsCKEgvBwiawRb7IYQ-VuDojX-0iJQI8,488
15
+ handycode-2.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
16
+ handycode-2.1.0.dist-info/entry_points.txt,sha256=d8cb-dbmZ79idEtsmUL8jCywt-s6sOQsqtOOBqwCmNk,75
17
+ handycode-2.1.0.dist-info/top_level.txt,sha256=eVBqlKEIVG9kl3gqTiJA1XLeOrH452taau4cpfAoEuU,10
18
+ handycode-2.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ handycode = handycode.main:main
3
+ hc = handycode.main:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HandyCode
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ handycode