archae 2026.2.1__tar.gz
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.
- archae-2026.2.1/LICENSE +21 -0
- archae-2026.2.1/PKG-INFO +161 -0
- archae-2026.2.1/README.md +108 -0
- archae-2026.2.1/pyproject.toml +110 -0
- archae-2026.2.1/src/archae/__init__.py +5 -0
- archae-2026.2.1/src/archae/__main__.py +9 -0
- archae-2026.2.1/src/archae/cli.py +175 -0
- archae-2026.2.1/src/archae/config.py +133 -0
- archae-2026.2.1/src/archae/default_settings.toml +9 -0
- archae-2026.2.1/src/archae/extractor.py +252 -0
- archae-2026.2.1/src/archae/options.yaml +39 -0
- archae-2026.2.1/src/archae/py.typed +0 -0
- archae-2026.2.1/src/archae/util/__init__.py +1 -0
- archae-2026.2.1/src/archae/util/archiver/__init__.py +6 -0
- archae-2026.2.1/src/archae/util/archiver/base_archiver.py +55 -0
- archae-2026.2.1/src/archae/util/archiver/peazip.py +159 -0
- archae-2026.2.1/src/archae/util/archiver/seven_zip.py +199 -0
- archae-2026.2.1/src/archae/util/archiver/unar.py +158 -0
- archae-2026.2.1/src/archae/util/converter/file_size.py +77 -0
- archae-2026.2.1/src/archae/util/enum/__init__.py +5 -0
- archae-2026.2.1/src/archae/util/enum/byte_scale.py +55 -0
- archae-2026.2.1/src/archae/util/file_tracker.py +93 -0
- archae-2026.2.1/src/archae/util/tool_manager.py +112 -0
archae-2026.2.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2026 Shawn McNaughton
|
|
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.
|
archae-2026.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: archae
|
|
3
|
+
Version: 2026.2.1
|
|
4
|
+
Summary: Archae explodes archives.
|
|
5
|
+
Keywords:
|
|
6
|
+
Author: Shawn McNaughton
|
|
7
|
+
Author-email: Shawn McNaughton <shawngmc@gmail.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright © 2026 Shawn McNaughton
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
30
|
+
Classifier: Environment :: Console
|
|
31
|
+
Classifier: Intended Audience :: Developers
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Programming Language :: Python
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
38
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
39
|
+
Classifier: Typing :: Typed
|
|
40
|
+
Requires-Dist: click
|
|
41
|
+
Requires-Dist: dynaconf>=3.2.12
|
|
42
|
+
Requires-Dist: platformdirs>=4.5.1
|
|
43
|
+
Requires-Dist: python-magic
|
|
44
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
45
|
+
Requires-Dist: rich-click
|
|
46
|
+
Requires-Dist: types-pyyaml>=6
|
|
47
|
+
Requires-Python: >=3.12
|
|
48
|
+
Project-URL: Documentation, https://archae.readthedocs.io/en/stable/
|
|
49
|
+
Project-URL: Changelog, https://archae.readthedocs.io/en/stable/changelog.html
|
|
50
|
+
Project-URL: Source Code, https://github.com/shawngmc/archae
|
|
51
|
+
Project-URL: Issue Tracker, https://github.com/shawngmc/archae/issues
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
|
|
54
|
+
<!-- start docs-include-index -->
|
|
55
|
+
|
|
56
|
+
# Archae
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
[](https://pypi.org/project/archae/)
|
|
61
|
+
[](https://pypi.org/project/archae/)
|
|
62
|
+
[](https://results.pre-commit.ci/latest/github/shawngmc/archae/main)
|
|
63
|
+
[](https://github.com/shawngmc/archae/actions/workflows/test.yml)
|
|
64
|
+
[](https://archae.readthedocs.io/en/latest/?badge=latest)
|
|
65
|
+
[](https://img.shields.io/pypi/l/archae)
|
|
66
|
+
|
|
67
|
+
Archae explodes archives.
|
|
68
|
+
|
|
69
|
+
<!-- end docs-include-index -->
|
|
70
|
+
|
|
71
|
+
## Why
|
|
72
|
+
|
|
73
|
+
Every once and a while, I run into an issue: multiple layers of archives. The reasons vary, but examples would include:
|
|
74
|
+
|
|
75
|
+
- Searching for something in a ZIP of folders that contained a ZIP with a CD image in it
|
|
76
|
+
- Running a malware scan and finding an obscure archive format was missed and not even flagged
|
|
77
|
+
Meanwhile, I want to make sure I don't fill my disk, especially if an archive bomb (more commonly known as a ZIP bomb) has been jammed in somewhere. They're only funny the first time. :D
|
|
78
|
+
|
|
79
|
+
## Features
|
|
80
|
+
|
|
81
|
+
- Uses 7z/peazip/unar (not 7za/7zr) to try to extract archives
|
|
82
|
+
- No substantial limit on the number of archive layers
|
|
83
|
+
- Identifies file types via libmagic
|
|
84
|
+
- Detects duplicate archives
|
|
85
|
+
- Basic archive bomb protections
|
|
86
|
+
- MAX_ARCHIVE_SIZE_BYTES - ensures the uncompressed size of an archive is limited
|
|
87
|
+
- MAX_TOTAL_SIZE_BYTES - ensures the total extracted footprint isn't above a certain size
|
|
88
|
+
- MIN_ARCHIVE_RATIO - ensures very-high-compression-ratio archives are stopped
|
|
89
|
+
- MIN_DISK_FREE_SPACE - minimum free space at the extraction location
|
|
90
|
+
- MAX_DEPTH - allow setting a maximum archive depth to traverse
|
|
91
|
+
|
|
92
|
+
## Installation
|
|
93
|
+
|
|
94
|
+
<!-- start docs-include-installation -->
|
|
95
|
+
|
|
96
|
+
Archae is available on [PyPI](https://pypi.org/project/archae/). Install with [uv](https://docs.astral.sh/uv/) or your package manager of choice:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
uv tool install archae
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
<!-- end docs-include-installation -->
|
|
103
|
+
|
|
104
|
+
## Documentation
|
|
105
|
+
|
|
106
|
+
Check out the [Archae documentation](https://archae.readthedocs.io/en/stable/) for the [User's Guide](https://archae.readthedocs.io/en/stable/usage.html) and [CLI Reference](https://archae.readthedocs.io/en/stable/cli.html).
|
|
107
|
+
|
|
108
|
+
## Usage
|
|
109
|
+
|
|
110
|
+
Configuration values are supplied one of four ways, and any item lower in this list will overwrite a prior one:
|
|
111
|
+
|
|
112
|
+
- Default values are stored in the app
|
|
113
|
+
- A TOML file at ~/.config/archae/ will be created on first run and can override those values (ex. MIN_ARCHIVE_RATIO = 0.005)
|
|
114
|
+
- Env vars starts starting with "ARCHAE\_" are parsed (ex. ARCHAE_MIN_ARCHIVE_RATIO=0.005)
|
|
115
|
+
- Values can be passed in as flags (ex. --min_archive_ratio=0.005)
|
|
116
|
+
|
|
117
|
+
<!-- start docs-include-usage -->
|
|
118
|
+
|
|
119
|
+
Running `archae --help` or `python -m archae --help` shows a list of all of the available options and arguments:
|
|
120
|
+
|
|
121
|
+
<!-- [[[cog
|
|
122
|
+
import cog
|
|
123
|
+
from archae import cli
|
|
124
|
+
from click.testing import CliRunner
|
|
125
|
+
runner = CliRunner()
|
|
126
|
+
result = runner.invoke(cli.cli, ["--help"], terminal_width=88)
|
|
127
|
+
help = result.output.replace("Usage: cli", "Usage: archae")
|
|
128
|
+
cog.outl(f"\n```sh\narchae --help\n{help.rstrip()}\n```\n")
|
|
129
|
+
]]] -->
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
archae --help
|
|
133
|
+
|
|
134
|
+
Usage: archae [OPTIONS] COMMAND [ARGS]...
|
|
135
|
+
|
|
136
|
+
Archae explodes archives.
|
|
137
|
+
|
|
138
|
+
╭─ Options ────────────────────────────────────────────────────────────────────────────╮
|
|
139
|
+
│ --version -v Show the version and exit. │
|
|
140
|
+
│ --help -h Show this message and exit. │
|
|
141
|
+
╰──────────────────────────────────────────────────────────────────────────────────────╯
|
|
142
|
+
╭─ Commands ───────────────────────────────────────────────────────────────────────────╮
|
|
143
|
+
│ extract Extract and analyze an archive. │
|
|
144
|
+
│ listopts List all available configuration options. │
|
|
145
|
+
│ status Show archae status and available tools. │
|
|
146
|
+
╰──────────────────────────────────────────────────────────────────────────────────────╯
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
<!-- [[[end]]] -->
|
|
150
|
+
|
|
151
|
+
<!-- end docs-include-usage -->
|
|
152
|
+
|
|
153
|
+
## TODOs
|
|
154
|
+
|
|
155
|
+
- More archive bomb protections
|
|
156
|
+
- delete_archives_as_exploded - remove archive files to reduce duplication (boolean)
|
|
157
|
+
- Improve archive type detection
|
|
158
|
+
- Separate between extractable and non-extractable archive types
|
|
159
|
+
- Detect password-protected archives
|
|
160
|
+
- Allow supplying archive passwords by hash
|
|
161
|
+
- Add custom magic to detect obscure archive formats
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<!-- start docs-include-index -->
|
|
2
|
+
|
|
3
|
+
# Archae
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
[](https://pypi.org/project/archae/)
|
|
8
|
+
[](https://pypi.org/project/archae/)
|
|
9
|
+
[](https://results.pre-commit.ci/latest/github/shawngmc/archae/main)
|
|
10
|
+
[](https://github.com/shawngmc/archae/actions/workflows/test.yml)
|
|
11
|
+
[](https://archae.readthedocs.io/en/latest/?badge=latest)
|
|
12
|
+
[](https://img.shields.io/pypi/l/archae)
|
|
13
|
+
|
|
14
|
+
Archae explodes archives.
|
|
15
|
+
|
|
16
|
+
<!-- end docs-include-index -->
|
|
17
|
+
|
|
18
|
+
## Why
|
|
19
|
+
|
|
20
|
+
Every once and a while, I run into an issue: multiple layers of archives. The reasons vary, but examples would include:
|
|
21
|
+
|
|
22
|
+
- Searching for something in a ZIP of folders that contained a ZIP with a CD image in it
|
|
23
|
+
- Running a malware scan and finding an obscure archive format was missed and not even flagged
|
|
24
|
+
Meanwhile, I want to make sure I don't fill my disk, especially if an archive bomb (more commonly known as a ZIP bomb) has been jammed in somewhere. They're only funny the first time. :D
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- Uses 7z/peazip/unar (not 7za/7zr) to try to extract archives
|
|
29
|
+
- No substantial limit on the number of archive layers
|
|
30
|
+
- Identifies file types via libmagic
|
|
31
|
+
- Detects duplicate archives
|
|
32
|
+
- Basic archive bomb protections
|
|
33
|
+
- MAX_ARCHIVE_SIZE_BYTES - ensures the uncompressed size of an archive is limited
|
|
34
|
+
- MAX_TOTAL_SIZE_BYTES - ensures the total extracted footprint isn't above a certain size
|
|
35
|
+
- MIN_ARCHIVE_RATIO - ensures very-high-compression-ratio archives are stopped
|
|
36
|
+
- MIN_DISK_FREE_SPACE - minimum free space at the extraction location
|
|
37
|
+
- MAX_DEPTH - allow setting a maximum archive depth to traverse
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
<!-- start docs-include-installation -->
|
|
42
|
+
|
|
43
|
+
Archae is available on [PyPI](https://pypi.org/project/archae/). Install with [uv](https://docs.astral.sh/uv/) or your package manager of choice:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
uv tool install archae
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
<!-- end docs-include-installation -->
|
|
50
|
+
|
|
51
|
+
## Documentation
|
|
52
|
+
|
|
53
|
+
Check out the [Archae documentation](https://archae.readthedocs.io/en/stable/) for the [User's Guide](https://archae.readthedocs.io/en/stable/usage.html) and [CLI Reference](https://archae.readthedocs.io/en/stable/cli.html).
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
Configuration values are supplied one of four ways, and any item lower in this list will overwrite a prior one:
|
|
58
|
+
|
|
59
|
+
- Default values are stored in the app
|
|
60
|
+
- A TOML file at ~/.config/archae/ will be created on first run and can override those values (ex. MIN_ARCHIVE_RATIO = 0.005)
|
|
61
|
+
- Env vars starts starting with "ARCHAE\_" are parsed (ex. ARCHAE_MIN_ARCHIVE_RATIO=0.005)
|
|
62
|
+
- Values can be passed in as flags (ex. --min_archive_ratio=0.005)
|
|
63
|
+
|
|
64
|
+
<!-- start docs-include-usage -->
|
|
65
|
+
|
|
66
|
+
Running `archae --help` or `python -m archae --help` shows a list of all of the available options and arguments:
|
|
67
|
+
|
|
68
|
+
<!-- [[[cog
|
|
69
|
+
import cog
|
|
70
|
+
from archae import cli
|
|
71
|
+
from click.testing import CliRunner
|
|
72
|
+
runner = CliRunner()
|
|
73
|
+
result = runner.invoke(cli.cli, ["--help"], terminal_width=88)
|
|
74
|
+
help = result.output.replace("Usage: cli", "Usage: archae")
|
|
75
|
+
cog.outl(f"\n```sh\narchae --help\n{help.rstrip()}\n```\n")
|
|
76
|
+
]]] -->
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
archae --help
|
|
80
|
+
|
|
81
|
+
Usage: archae [OPTIONS] COMMAND [ARGS]...
|
|
82
|
+
|
|
83
|
+
Archae explodes archives.
|
|
84
|
+
|
|
85
|
+
╭─ Options ────────────────────────────────────────────────────────────────────────────╮
|
|
86
|
+
│ --version -v Show the version and exit. │
|
|
87
|
+
│ --help -h Show this message and exit. │
|
|
88
|
+
╰──────────────────────────────────────────────────────────────────────────────────────╯
|
|
89
|
+
╭─ Commands ───────────────────────────────────────────────────────────────────────────╮
|
|
90
|
+
│ extract Extract and analyze an archive. │
|
|
91
|
+
│ listopts List all available configuration options. │
|
|
92
|
+
│ status Show archae status and available tools. │
|
|
93
|
+
╰──────────────────────────────────────────────────────────────────────────────────────╯
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
<!-- [[[end]]] -->
|
|
97
|
+
|
|
98
|
+
<!-- end docs-include-usage -->
|
|
99
|
+
|
|
100
|
+
## TODOs
|
|
101
|
+
|
|
102
|
+
- More archive bomb protections
|
|
103
|
+
- delete_archives_as_exploded - remove archive files to reduce duplication (boolean)
|
|
104
|
+
- Improve archive type detection
|
|
105
|
+
- Separate between extractable and non-extractable archive types
|
|
106
|
+
- Detect password-protected archives
|
|
107
|
+
- Allow supplying archive passwords by hash
|
|
108
|
+
- Add custom magic to detect obscure archive formats
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv-build"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "archae"
|
|
7
|
+
version = "2026.2.1"
|
|
8
|
+
description = "Archae explodes archives."
|
|
9
|
+
authors = [{name = "Shawn McNaughton", email = "shawngmc@gmail.com"}]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = {file = "LICENSE"}
|
|
12
|
+
keywords = []
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
requires-python = ">=3.12"
|
|
27
|
+
dependencies = [
|
|
28
|
+
"click",
|
|
29
|
+
"dynaconf>=3.2.12",
|
|
30
|
+
"platformdirs>=4.5.1",
|
|
31
|
+
"python-magic",
|
|
32
|
+
"PyYAML>=6.0.3",
|
|
33
|
+
"rich_click",
|
|
34
|
+
"types-PyYAML>=6",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[dependency-groups]
|
|
38
|
+
tests = [
|
|
39
|
+
"pytest",
|
|
40
|
+
]
|
|
41
|
+
docs = [
|
|
42
|
+
"furo",
|
|
43
|
+
"myst-parser",
|
|
44
|
+
"sphinx",
|
|
45
|
+
"sphinx-copybutton",
|
|
46
|
+
"sphinxext-opengraph",
|
|
47
|
+
]
|
|
48
|
+
dev = [
|
|
49
|
+
{ include-group = "tests" },
|
|
50
|
+
{ include-group = "docs" },
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[project.urls]
|
|
54
|
+
Documentation = "https://archae.readthedocs.io/en/stable/"
|
|
55
|
+
Changelog = "https://archae.readthedocs.io/en/stable/changelog.html"
|
|
56
|
+
"Source Code" = "https://github.com/shawngmc/archae"
|
|
57
|
+
"Issue Tracker" = "https://github.com/shawngmc/archae/issues"
|
|
58
|
+
|
|
59
|
+
[project.scripts]
|
|
60
|
+
archae = "archae.__main__:cli"
|
|
61
|
+
|
|
62
|
+
[tool.ruff]
|
|
63
|
+
lint.select = ["ALL"]
|
|
64
|
+
lint.ignore = [
|
|
65
|
+
"E501", # line too long (pycodestyle), handled by ruff-format
|
|
66
|
+
"ANN002", # missing-type-args (flake8-annotations)
|
|
67
|
+
"ANN003", # missing-type-kwargs (flake8-annotations)
|
|
68
|
+
"ANN401", # any-type (flake8-annotations)
|
|
69
|
+
"COM", # flake8-commas, handled by ruff-format
|
|
70
|
+
"CPY", # flake8-copyright
|
|
71
|
+
"ISC001", # single-line-implicit-string-concatenation (flake8-implicit-str-concat)
|
|
72
|
+
"INP", # flake8-no-pep420
|
|
73
|
+
]
|
|
74
|
+
src = ["src", "tests", "docs"]
|
|
75
|
+
|
|
76
|
+
[tool.ruff.lint.per-file-ignores]
|
|
77
|
+
"__init__.py" = [
|
|
78
|
+
"F401", # unused-import (Pyflakes)
|
|
79
|
+
]
|
|
80
|
+
"noxfile.py" = [
|
|
81
|
+
"D100", # undocumented-public-module (pydocstyle)
|
|
82
|
+
"ERA001", # commented-out-code (eradicate)
|
|
83
|
+
]
|
|
84
|
+
"docs/conf.py" = [
|
|
85
|
+
"A001", # builtin-variable-shadowing (flake8-builtins)
|
|
86
|
+
]
|
|
87
|
+
"src/archae/cli.py" = [
|
|
88
|
+
"C901", # complex-structure (mccabe)
|
|
89
|
+
"FBT001", # boolean-type-hint-positional-argument (flake8-boolean-trap)
|
|
90
|
+
"A001", # builtin-variable-shadowing (flake8-builtins)
|
|
91
|
+
"A002", # builtin-argument-shadowing (flake8-builtins)
|
|
92
|
+
"PLR0913", # too-many-arguments (Pylint)
|
|
93
|
+
]
|
|
94
|
+
"tests/**/test_*.py" = [
|
|
95
|
+
"D", # pydocstyle
|
|
96
|
+
"ANN201", # missing-return-type-undocumented-public-function (flake8-annotations)
|
|
97
|
+
"S101", # assert (flake8-bandit)
|
|
98
|
+
"SIM300", # yoda-conditions (flake8-simplify)
|
|
99
|
+
"PLR2004", # magic-value-comparison (Pylint)
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
[tool.ruff.lint.isort]
|
|
103
|
+
known-first-party = [
|
|
104
|
+
"archae",
|
|
105
|
+
"tests",
|
|
106
|
+
]
|
|
107
|
+
lines-between-types = 0
|
|
108
|
+
|
|
109
|
+
[tool.ruff.lint.pydocstyle]
|
|
110
|
+
convention = "google"
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"""Main CLI for archae."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import pathlib
|
|
7
|
+
from importlib import metadata
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import rich_click as click
|
|
11
|
+
|
|
12
|
+
from archae.config import apply_options, get_options
|
|
13
|
+
from archae.extractor import ArchiveExtractor
|
|
14
|
+
from archae.util.tool_manager import ToolManager
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger("archae")
|
|
17
|
+
logger.setLevel(logging.INFO)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@click.group(
|
|
21
|
+
context_settings={"help_option_names": ["-h", "--help"], "show_default": True}
|
|
22
|
+
)
|
|
23
|
+
@click.rich_config(
|
|
24
|
+
help_config=click.RichHelpConfiguration(
|
|
25
|
+
width=88,
|
|
26
|
+
show_arguments=True,
|
|
27
|
+
text_markup=True,
|
|
28
|
+
),
|
|
29
|
+
)
|
|
30
|
+
@click.version_option(metadata.version("archae"), "-v", "--version")
|
|
31
|
+
def cli() -> None:
|
|
32
|
+
"""Archae explodes archives."""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@cli.command()
|
|
36
|
+
@click.argument(
|
|
37
|
+
"archive_path",
|
|
38
|
+
type=click.Path(exists=True, dir_okay=False, readable=True, path_type=pathlib.Path),
|
|
39
|
+
default=Path.cwd() / "extracted",
|
|
40
|
+
help="Archive to examine",
|
|
41
|
+
)
|
|
42
|
+
@click.option(
|
|
43
|
+
"-o",
|
|
44
|
+
"--opt",
|
|
45
|
+
"options",
|
|
46
|
+
nargs=2,
|
|
47
|
+
type=click.Tuple([str, str]),
|
|
48
|
+
multiple=True,
|
|
49
|
+
help="Set config options as key value pairs. Use 'archae listopts' to see available options.",
|
|
50
|
+
)
|
|
51
|
+
@click.option(
|
|
52
|
+
"-e",
|
|
53
|
+
"--extract-dir",
|
|
54
|
+
"extract_dir",
|
|
55
|
+
nargs=1,
|
|
56
|
+
type=click.Path(
|
|
57
|
+
dir_okay=True,
|
|
58
|
+
file_okay=False,
|
|
59
|
+
readable=True,
|
|
60
|
+
writable=True,
|
|
61
|
+
path_type=pathlib.Path,
|
|
62
|
+
),
|
|
63
|
+
default=Path.cwd() / "extracted",
|
|
64
|
+
help="Set config options as key value pairs. Use 'archae listopts' to see available options.",
|
|
65
|
+
)
|
|
66
|
+
def extract(
|
|
67
|
+
archive_path: pathlib.Path,
|
|
68
|
+
options: list[tuple[str, str]] | None,
|
|
69
|
+
extract_dir: pathlib.Path,
|
|
70
|
+
) -> None:
|
|
71
|
+
"""Extract and analyze an archive."""
|
|
72
|
+
# Apply any options from the command line, then convert any convertible settings
|
|
73
|
+
if options:
|
|
74
|
+
apply_options(options)
|
|
75
|
+
|
|
76
|
+
# Locate external tools
|
|
77
|
+
ToolManager.locate_tools()
|
|
78
|
+
extractor = ArchiveExtractor(extract_dir=extract_dir)
|
|
79
|
+
extractor.handle_file(archive_path)
|
|
80
|
+
print_tracked_files(extractor.get_tracked_files())
|
|
81
|
+
print_warnings(extractor.get_warnings())
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@cli.command()
|
|
85
|
+
def listopts() -> None:
|
|
86
|
+
"""List all available configuration options."""
|
|
87
|
+
options = get_options()
|
|
88
|
+
|
|
89
|
+
# Load default settings
|
|
90
|
+
defaults_path = Path(__file__).parent / "default_settings.toml"
|
|
91
|
+
defaults_content = defaults_path.read_text()
|
|
92
|
+
defaults = {}
|
|
93
|
+
in_default_section = False
|
|
94
|
+
for line in defaults_content.split("\n"):
|
|
95
|
+
if line.strip() == "[default]":
|
|
96
|
+
in_default_section = True
|
|
97
|
+
continue
|
|
98
|
+
if in_default_section and line.startswith("["):
|
|
99
|
+
break
|
|
100
|
+
if in_default_section and "=" in line:
|
|
101
|
+
key, value = line.split("=", 1)
|
|
102
|
+
defaults[key.strip()] = value.strip().strip('"')
|
|
103
|
+
|
|
104
|
+
logger.info("Available configuration options:")
|
|
105
|
+
logger.info("------------------------------------------------")
|
|
106
|
+
for option_name, option_def in sorted(options.items()):
|
|
107
|
+
logger.info("%s (%s)", option_name, option_def.get("type", "unknown"))
|
|
108
|
+
logger.info(" %s", option_def.get("help", "No description available"))
|
|
109
|
+
if option_name in defaults:
|
|
110
|
+
logger.info(" Default: %s", defaults[option_name])
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@cli.command()
|
|
114
|
+
def status() -> None:
|
|
115
|
+
"""Show archae status and available tools."""
|
|
116
|
+
logger.info("Archae status:")
|
|
117
|
+
logger.info("Version: %s", metadata.version("archae"))
|
|
118
|
+
ToolManager.locate_tools()
|
|
119
|
+
logger.info("Tools located and ready to use.")
|
|
120
|
+
logger.info("------------------------------------------------")
|
|
121
|
+
|
|
122
|
+
# Show supported extensions
|
|
123
|
+
supported_ext = ToolManager.get_supported_extensions()
|
|
124
|
+
logger.info("Supported file extensions (%d):", len(supported_ext))
|
|
125
|
+
if supported_ext:
|
|
126
|
+
logger.info(" %s", ", ".join(supported_ext))
|
|
127
|
+
else:
|
|
128
|
+
logger.info(" (none)")
|
|
129
|
+
|
|
130
|
+
# Show unsupported extensions
|
|
131
|
+
unsupported_ext = ToolManager.get_unsupported_extensions()
|
|
132
|
+
logger.info("Unsupported file extensions (%d):", len(unsupported_ext))
|
|
133
|
+
if unsupported_ext:
|
|
134
|
+
logger.info(" %s", ", ".join(unsupported_ext))
|
|
135
|
+
else:
|
|
136
|
+
logger.info(" (none)")
|
|
137
|
+
|
|
138
|
+
logger.info("------------------------------------------------")
|
|
139
|
+
|
|
140
|
+
# Show supported MIME types
|
|
141
|
+
supported_mime = ToolManager.get_supported_mime_types()
|
|
142
|
+
logger.info("Supported MIME types (%d):", len(supported_mime))
|
|
143
|
+
if supported_mime:
|
|
144
|
+
logger.info(" %s", ", ".join(supported_mime))
|
|
145
|
+
else:
|
|
146
|
+
logger.info(" (none)")
|
|
147
|
+
|
|
148
|
+
# Show unsupported MIME types
|
|
149
|
+
unsupported_mime = ToolManager.get_unsupported_mime_types()
|
|
150
|
+
logger.info("Unsupported MIME types (%d):", len(unsupported_mime))
|
|
151
|
+
if unsupported_mime:
|
|
152
|
+
logger.info(" %s", ", ".join(unsupported_mime))
|
|
153
|
+
else:
|
|
154
|
+
logger.info(" (none)")
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def print_tracked_files(tracked_files: dict[str, dict]) -> None:
|
|
158
|
+
"""Print the tracked files for debugging purposes."""
|
|
159
|
+
logger.info("------------------------------------------------")
|
|
160
|
+
for hash, info in tracked_files.items():
|
|
161
|
+
logger.info("Hash: %s", hash)
|
|
162
|
+
logger.info(" Size: %s bytes", info.get("size", "Unknown"))
|
|
163
|
+
for path in info.get("paths", []):
|
|
164
|
+
logger.info(" Path: %s", path)
|
|
165
|
+
logger.info(" Metadata:")
|
|
166
|
+
for key, value in info.get("metadata", {}).items():
|
|
167
|
+
logger.info(" %s: %s", key, value)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def print_warnings(warnings: list[str]) -> None:
|
|
171
|
+
"""Print accumulated warnings for debugging purposes."""
|
|
172
|
+
logger.info("------------------------------------------------")
|
|
173
|
+
logger.info("Accumulated Warnings:")
|
|
174
|
+
for warning in warnings: # type: ignore[attr-defined]
|
|
175
|
+
logger.info(warning)
|