Open
Conversation
12gerts
reviewed
May 6, 2025
PE_parser/parser.py
Outdated
Comment on lines
+9
to
+24
| class OutputFormat(Enum): | ||
| """Перечисление форматов вывода результатов анализа PE файла (text/json).""" | ||
|
|
||
| TEXT = "text" | ||
| JSON = "json" | ||
|
|
||
|
|
||
| class Color: | ||
| """ANSI коды цветов для терминала.""" | ||
|
|
||
| HEADER = '\033[95m' | ||
| RED = '\033[91m' | ||
| PINK = '\033[95m' | ||
| GREEN = '\033[92m' | ||
| END = '\033[0m' | ||
| BOLD = '\033[1m' |
Collaborator
There was a problem hiding this comment.
Suggested change
| class OutputFormat(Enum): | |
| """Перечисление форматов вывода результатов анализа PE файла (text/json).""" | |
| TEXT = "text" | |
| JSON = "json" | |
| class Color: | |
| """ANSI коды цветов для терминала.""" | |
| HEADER = '\033[95m' | |
| RED = '\033[91m' | |
| PINK = '\033[95m' | |
| GREEN = '\033[92m' | |
| END = '\033[0m' | |
| BOLD = '\033[1m' | |
| class OutputFormat(StrEnum): | |
| """Перечисление форматов вывода результатов анализа PE файла (text/json).""" | |
| TEXT = "text" | |
| JSON = "json" | |
| class Color(StrEnum): | |
| """ANSI коды цветов для терминала.""" | |
| HEADER = '\033[95m' | |
| RED = '\033[91m' | |
| PINK = '\033[95m' | |
| GREEN = '\033[92m' | |
| END = '\033[0m' | |
| BOLD = '\033[1m' |
PE_parser/parser.py
Outdated
| print(f"{indent_str}{colorize(name + ':', Color.PINK)} {value}") | ||
|
|
||
|
|
||
| def format_pe_info(pe_file: PEFile, sections: Optional[list[str]] = None) -> dict[str, Any]: |
Collaborator
There was a problem hiding this comment.
Все Optional убрать. Вместо них | None
PE_parser/parser.py
Outdated
| """Форматирует информацию о PE файле в словарь для JSON вывода.""" | ||
| result: dict[str, Any] = {} | ||
|
|
||
| if sections is None or "dos" in sections: |
Collaborator
There was a problem hiding this comment.
все вот эти dos и т.д. тоже вынести в какой-нибудь енам
PE_parser/parser.py
Outdated
| } | ||
| result["DOS Header"] = dos_header | ||
|
|
||
| if sections is None or "pe" in sections: |
Collaborator
There was a problem hiding this comment.
нахрена 100 раз проверять, что sections is None?
PE_parser/parser.py
Outdated
| return result | ||
|
|
||
|
|
||
| def print_pe_info(pe_file: PEFile, sections: Optional[list[str]] = None) -> None: |
Collaborator
There was a problem hiding this comment.
тут комментарии ко всему методу аналогичные с Optional, енамом и проверкой
PE_parser/parser.py
Outdated
| """Перехватывает вывод print для сохранения в буфер.""" | ||
| output_lines.append(" ".join(str(v) for v in values)) | ||
|
|
||
| import builtins |
Collaborator
There was a problem hiding this comment.
откуда импорт посреди взялся вообще????
PE_parser/parser.py
Outdated
Comment on lines
+215
to
+225
| def local_colorize(text: str, color: str) -> str: | ||
| """Локальная версия colorize с настраиваемыми цветами.""" | ||
| return f"{color}{text}{LocalColor.END}" | ||
|
|
||
| def local_print_section_header(title: str) -> None: | ||
| """Локальная версия print_section_header с настраиваемыми цветами.""" | ||
| print(local_colorize(f"\n=== {title} ===", LocalColor.RED + LocalColor.BOLD)) | ||
|
|
||
| def local_print_field(name: str, value: Any, indent: int = 0) -> None: | ||
| """Локальная версия print_field с настраиваемыми цветами.""" | ||
| indent_str = " " * indent |
PE_parser/parser.py
Outdated
Comment on lines
+228
to
+230
| globals()['colorize'] = local_colorize | ||
| globals()['print_section_header'] = local_print_section_header | ||
| globals()['print_field'] = local_print_field |
Collaborator
There was a problem hiding this comment.
а как-то симпатичнее это можно сделать?
PE_parser/parser.py
Outdated
| print_field("", "No imports found", 2) | ||
|
|
||
|
|
||
| def main() -> None: |
| combine_as_imports = true | ||
| include_trailing_comma = true | ||
|
|
||
| [tool.flake8] |
Collaborator
There was a problem hiding this comment.
ну это вранье, оно отсюда не работает
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.