vaulttool 2.0.3__tar.gz → 2.1.0__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.
- {vaulttool-2.0.3 → vaulttool-2.1.0}/PKG-INFO +14 -11
- {vaulttool-2.0.3 → vaulttool-2.1.0}/README.md +9 -9
- {vaulttool-2.0.3 → vaulttool-2.1.0}/pyproject.toml +8 -3
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/__init__.py +6 -8
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/cli.py +49 -53
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/config.py +2 -2
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/core.py +534 -296
- vaulttool-2.1.0/vaulttool/tests/test_security_hardening.py +179 -0
- vaulttool-2.1.0/vaulttool/tests/test_source_selection.py +144 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_utils.py +20 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/utils.py +70 -84
- {vaulttool-2.0.3 → vaulttool-2.1.0}/LICENSE +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/__main__.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/conftest.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_checksum_trigger.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_config.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_core.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_decrypt_missing_sources.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_env_config.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_error_aggregation.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_gitignore.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_key_file_validation.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_main_integration.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_priority3_fixes.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_security_and_edge_cases.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_suffix_fallback.py +0 -0
- {vaulttool-2.0.3 → vaulttool-2.1.0}/vaulttool/tests/test_suffix_switch_bug.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vaulttool
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Secure file encryption for secrets/configs
|
|
5
5
|
License: Apache-2
|
|
6
6
|
License-File: LICENSE
|
|
@@ -16,7 +16,10 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
16
16
|
Requires-Dist: cryptography
|
|
17
17
|
Requires-Dist: pyyaml
|
|
18
18
|
Requires-Dist: typer
|
|
19
|
-
Project-URL:
|
|
19
|
+
Project-URL: Changelog, https://github.com/jifox/vaulttool/blob/main/CHANGELOG.md
|
|
20
|
+
Project-URL: Homepage, https://github.com/jifox/vaulttool
|
|
21
|
+
Project-URL: Issues, https://github.com/jifox/vaulttool/issues
|
|
22
|
+
Project-URL: Repository, https://github.com/jifox/vaulttool
|
|
20
23
|
Description-Content-Type: text/markdown
|
|
21
24
|
|
|
22
25
|
# Vault Tool
|
|
@@ -57,7 +60,7 @@ vaulttool refresh
|
|
|
57
60
|
|
|
58
61
|
**Key Concepts:**
|
|
59
62
|
|
|
60
|
-
- Encrypts files with AES-256-
|
|
63
|
+
- Encrypts files with AES-256-GCM (authenticated) + HMAC-SHA256 change detection
|
|
61
64
|
- Creates `.vault` files that are safe to commit to git
|
|
62
65
|
- Uses a single encryption key (store securely, don't commit!)
|
|
63
66
|
- Configure via `.vaulttool.yml` or environment variables
|
|
@@ -137,7 +140,7 @@ vaulttool refresh
|
|
|
137
140
|
- **Detects changes automatically**: Updates encrypted files whenever the original files change.
|
|
138
141
|
- **Restores missing files**: Automatically decrypts files if the original is missing and a `.vault` file exists.
|
|
139
142
|
- **Refreshes plaintext from vaults**: On demand, overwrite existing plaintext from `.vault` files (with `--force`).
|
|
140
|
-
- **Uses AES-256-
|
|
143
|
+
- **Uses AES-256-GCM authenticated encryption**: Detects tampering before any plaintext is written, via Python's cryptography library.
|
|
141
144
|
- **Updates .gitignore for you**: Adds plain text files to `.gitignore` to prevent accidental commits of secrets.
|
|
142
145
|
- **Verifies file integrity**: Uses HMACs to make sure encrypted files are always up to date.
|
|
143
146
|
- **Editor-friendly format**: Encrypted files are base64 encoded, making them easy to copy and paste.
|
|
@@ -171,7 +174,7 @@ VaultTool v2.0.0 represents a **major quality improvement** with comprehensive e
|
|
|
171
174
|
a fixed-size output (the HMAC tag). This tag is unique to both the input data and the key, making it an effective
|
|
172
175
|
way to verify data integrity and authenticity.
|
|
173
176
|
|
|
174
|
-
3. **AES-256-
|
|
177
|
+
3. **AES-256-GCM Encryption (AEAD)**
|
|
175
178
|
- 256-bit encryption key
|
|
176
179
|
- Random IV per encryption
|
|
177
180
|
- PKCS7 padding
|
|
@@ -190,7 +193,7 @@ derive_keys() with HKDF
|
|
|
190
193
|
│
|
|
191
194
|
└─→ HKDF(info="encryption-key") → Encryption Key (32 bytes)
|
|
192
195
|
↓
|
|
193
|
-
Used for AES-256-
|
|
196
|
+
Used for AES-256-GCM encryption
|
|
194
197
|
```
|
|
195
198
|
|
|
196
199
|
## Vault File Format
|
|
@@ -216,7 +219,7 @@ ae5bee7bdc95c4aa85c5e773876fc78c2b8e9f4d3c7a6b5e8d1f0a9c2e4b7d6f
|
|
|
216
219
|
- **Removed OpenSSL requirement**: Now uses Python's `cryptography` library directly
|
|
217
220
|
- **Simpler installation**: Just install VaultTool with pip or Poetry - no system dependencies
|
|
218
221
|
- **Better portability**: Works consistently across all platforms (Linux, macOS, Windows)
|
|
219
|
-
- **Same strong encryption**: Still uses AES-256-
|
|
222
|
+
- **Same strong encryption**: Still uses AES-256-GCM authenticated encryption
|
|
220
223
|
|
|
221
224
|
**Result:** Installation is now as simple as `pip install vaulttool` or `poetry install` - no need to install OpenSSL or other system packages!
|
|
222
225
|
|
|
@@ -375,7 +378,7 @@ vaulttool
|
|
|
375
378
|
|
|
376
379
|
- Python 3.10 or newer
|
|
377
380
|
- Python packages (automatically installed):
|
|
378
|
-
- `cryptography` - For AES-256-
|
|
381
|
+
- `cryptography` - For AES-256-GCM encryption and HMAC
|
|
379
382
|
- `typer` - Command-line interface
|
|
380
383
|
- `pyyaml` - Configuration file parsing
|
|
381
384
|
|
|
@@ -510,7 +513,7 @@ vaulttool:
|
|
|
510
513
|
- "*.vault"
|
|
511
514
|
options:
|
|
512
515
|
suffix: ".vault" # Suffix for encrypted files
|
|
513
|
-
algorithm: "aes-256-cbc" #
|
|
516
|
+
algorithm: "aes-256-cbc" # Deprecated: ignored, encryption is always AES-256-GCM
|
|
514
517
|
key_type: "file" # Key storage type
|
|
515
518
|
key_file: "vault.key" # Path to encryption key file
|
|
516
519
|
```
|
|
@@ -523,7 +526,7 @@ vaulttool:
|
|
|
523
526
|
- **`exclude_patterns`**: Patterns for files to exclude. Defaults to `[*.vault]` (options.suffix).
|
|
524
527
|
- **`options`**: Encryption settings including:
|
|
525
528
|
- `suffix`: File extension for encrypted files (default: `.vault`)
|
|
526
|
-
- `algorithm`: Encryption
|
|
529
|
+
- `algorithm`: Deprecated and ignored. Encryption always uses AES-256-GCM; legacy AES-256-CBC vault files remain readable.
|
|
527
530
|
- `key_file`: Path to encryption key file (must be at least 32 bytes)
|
|
528
531
|
|
|
529
532
|
**Note:** The `openssl_path` option has been removed in v2.0.0 as VaultTool now uses Python's `cryptography` library directly.
|
|
@@ -817,7 +820,7 @@ repos:
|
|
|
817
820
|
|
|
818
821
|
## Related Tools
|
|
819
822
|
|
|
820
|
-
- **[Python Cryptography](https://cryptography.io/)**: The cryptography library used by VaultTool for AES-256-
|
|
823
|
+
- **[Python Cryptography](https://cryptography.io/)**: The cryptography library used by VaultTool for AES-256-GCM encryption and HMAC
|
|
821
824
|
- **[pipx](https://pypa.github.io/pipx/)**: Install and run Python applications in isolated environments
|
|
822
825
|
- **[pre-commit](https://pre-commit.com/)**: Framework for managing Git pre-commit hooks
|
|
823
826
|
- **[Git](https://git-scm.com/)**: Version control system
|
|
@@ -36,7 +36,7 @@ vaulttool refresh
|
|
|
36
36
|
|
|
37
37
|
**Key Concepts:**
|
|
38
38
|
|
|
39
|
-
- Encrypts files with AES-256-
|
|
39
|
+
- Encrypts files with AES-256-GCM (authenticated) + HMAC-SHA256 change detection
|
|
40
40
|
- Creates `.vault` files that are safe to commit to git
|
|
41
41
|
- Uses a single encryption key (store securely, don't commit!)
|
|
42
42
|
- Configure via `.vaulttool.yml` or environment variables
|
|
@@ -116,7 +116,7 @@ vaulttool refresh
|
|
|
116
116
|
- **Detects changes automatically**: Updates encrypted files whenever the original files change.
|
|
117
117
|
- **Restores missing files**: Automatically decrypts files if the original is missing and a `.vault` file exists.
|
|
118
118
|
- **Refreshes plaintext from vaults**: On demand, overwrite existing plaintext from `.vault` files (with `--force`).
|
|
119
|
-
- **Uses AES-256-
|
|
119
|
+
- **Uses AES-256-GCM authenticated encryption**: Detects tampering before any plaintext is written, via Python's cryptography library.
|
|
120
120
|
- **Updates .gitignore for you**: Adds plain text files to `.gitignore` to prevent accidental commits of secrets.
|
|
121
121
|
- **Verifies file integrity**: Uses HMACs to make sure encrypted files are always up to date.
|
|
122
122
|
- **Editor-friendly format**: Encrypted files are base64 encoded, making them easy to copy and paste.
|
|
@@ -150,7 +150,7 @@ VaultTool v2.0.0 represents a **major quality improvement** with comprehensive e
|
|
|
150
150
|
a fixed-size output (the HMAC tag). This tag is unique to both the input data and the key, making it an effective
|
|
151
151
|
way to verify data integrity and authenticity.
|
|
152
152
|
|
|
153
|
-
3. **AES-256-
|
|
153
|
+
3. **AES-256-GCM Encryption (AEAD)**
|
|
154
154
|
- 256-bit encryption key
|
|
155
155
|
- Random IV per encryption
|
|
156
156
|
- PKCS7 padding
|
|
@@ -169,7 +169,7 @@ derive_keys() with HKDF
|
|
|
169
169
|
│
|
|
170
170
|
└─→ HKDF(info="encryption-key") → Encryption Key (32 bytes)
|
|
171
171
|
↓
|
|
172
|
-
Used for AES-256-
|
|
172
|
+
Used for AES-256-GCM encryption
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## Vault File Format
|
|
@@ -195,7 +195,7 @@ ae5bee7bdc95c4aa85c5e773876fc78c2b8e9f4d3c7a6b5e8d1f0a9c2e4b7d6f
|
|
|
195
195
|
- **Removed OpenSSL requirement**: Now uses Python's `cryptography` library directly
|
|
196
196
|
- **Simpler installation**: Just install VaultTool with pip or Poetry - no system dependencies
|
|
197
197
|
- **Better portability**: Works consistently across all platforms (Linux, macOS, Windows)
|
|
198
|
-
- **Same strong encryption**: Still uses AES-256-
|
|
198
|
+
- **Same strong encryption**: Still uses AES-256-GCM authenticated encryption
|
|
199
199
|
|
|
200
200
|
**Result:** Installation is now as simple as `pip install vaulttool` or `poetry install` - no need to install OpenSSL or other system packages!
|
|
201
201
|
|
|
@@ -354,7 +354,7 @@ vaulttool
|
|
|
354
354
|
|
|
355
355
|
- Python 3.10 or newer
|
|
356
356
|
- Python packages (automatically installed):
|
|
357
|
-
- `cryptography` - For AES-256-
|
|
357
|
+
- `cryptography` - For AES-256-GCM encryption and HMAC
|
|
358
358
|
- `typer` - Command-line interface
|
|
359
359
|
- `pyyaml` - Configuration file parsing
|
|
360
360
|
|
|
@@ -489,7 +489,7 @@ vaulttool:
|
|
|
489
489
|
- "*.vault"
|
|
490
490
|
options:
|
|
491
491
|
suffix: ".vault" # Suffix for encrypted files
|
|
492
|
-
algorithm: "aes-256-cbc" #
|
|
492
|
+
algorithm: "aes-256-cbc" # Deprecated: ignored, encryption is always AES-256-GCM
|
|
493
493
|
key_type: "file" # Key storage type
|
|
494
494
|
key_file: "vault.key" # Path to encryption key file
|
|
495
495
|
```
|
|
@@ -502,7 +502,7 @@ vaulttool:
|
|
|
502
502
|
- **`exclude_patterns`**: Patterns for files to exclude. Defaults to `[*.vault]` (options.suffix).
|
|
503
503
|
- **`options`**: Encryption settings including:
|
|
504
504
|
- `suffix`: File extension for encrypted files (default: `.vault`)
|
|
505
|
-
- `algorithm`: Encryption
|
|
505
|
+
- `algorithm`: Deprecated and ignored. Encryption always uses AES-256-GCM; legacy AES-256-CBC vault files remain readable.
|
|
506
506
|
- `key_file`: Path to encryption key file (must be at least 32 bytes)
|
|
507
507
|
|
|
508
508
|
**Note:** The `openssl_path` option has been removed in v2.0.0 as VaultTool now uses Python's `cryptography` library directly.
|
|
@@ -796,7 +796,7 @@ repos:
|
|
|
796
796
|
|
|
797
797
|
## Related Tools
|
|
798
798
|
|
|
799
|
-
- **[Python Cryptography](https://cryptography.io/)**: The cryptography library used by VaultTool for AES-256-
|
|
799
|
+
- **[Python Cryptography](https://cryptography.io/)**: The cryptography library used by VaultTool for AES-256-GCM encryption and HMAC
|
|
800
800
|
- **[pipx](https://pypa.github.io/pipx/)**: Install and run Python applications in isolated environments
|
|
801
801
|
- **[pre-commit](https://pre-commit.com/)**: Framework for managing Git pre-commit hooks
|
|
802
802
|
- **[Git](https://git-scm.com/)**: Version control system
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "vaulttool"
|
|
3
|
-
version = "2.0
|
|
3
|
+
version = "2.1.0"
|
|
4
4
|
description = "Secure file encryption for secrets/configs"
|
|
5
5
|
authors = [{name = "Josef Fuchs"}]
|
|
6
6
|
license = {text = "Apache-2"}
|
|
@@ -12,18 +12,23 @@ dependencies = [
|
|
|
12
12
|
"cryptography"
|
|
13
13
|
]
|
|
14
14
|
|
|
15
|
+
[project.urls]
|
|
16
|
+
Homepage = "https://github.com/jifox/vaulttool"
|
|
17
|
+
Repository = "https://github.com/jifox/vaulttool"
|
|
18
|
+
Issues = "https://github.com/jifox/vaulttool/issues"
|
|
19
|
+
Changelog = "https://github.com/jifox/vaulttool/blob/main/CHANGELOG.md"
|
|
20
|
+
|
|
15
21
|
[project.scripts]
|
|
16
22
|
vaulttool = "vaulttool.cli:app"
|
|
17
23
|
|
|
18
24
|
|
|
19
25
|
[tool.poetry]
|
|
20
26
|
name = "vaulttool"
|
|
21
|
-
version = "2.0
|
|
27
|
+
version = "2.1.0"
|
|
22
28
|
description = "Secure file encryption for secrets/configs"
|
|
23
29
|
authors = ["Josef Fuchs"]
|
|
24
30
|
license = "Apache-2"
|
|
25
31
|
readme = "README.md"
|
|
26
|
-
homepage = "https://github.com/yourusername/vaulttool"
|
|
27
32
|
packages = [
|
|
28
33
|
{ include = "vaulttool" }
|
|
29
34
|
]
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"""VaultTool - Secure file encryption for secrets and configuration files.
|
|
2
2
|
|
|
3
3
|
This package provides secure encryption and management of sensitive files using
|
|
4
|
-
AES-256-
|
|
4
|
+
AES-256-GCM authenticated encryption (legacy AES-256-CBC vaults remain readable).
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import logging
|
|
8
8
|
import sys
|
|
9
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
9
10
|
from typing import Optional
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
#
|
|
14
|
-
|
|
12
|
+
try: # pragma: no cover - depends on how the package is installed
|
|
13
|
+
__version__ = version("vaulttool")
|
|
14
|
+
except PackageNotFoundError: # pragma: no cover
|
|
15
|
+
__version__ = "0.0.0+unknown"
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
def get_logger(name: str = "vaulttool") -> logging.Logger:
|
|
@@ -77,9 +78,6 @@ def setup_logging(
|
|
|
77
78
|
# Prevent propagation to root logger to avoid duplicate messages
|
|
78
79
|
logger.propagate = False
|
|
79
80
|
|
|
80
|
-
global _logger
|
|
81
|
-
_logger = logger
|
|
82
|
-
|
|
83
81
|
return logger
|
|
84
82
|
|
|
85
83
|
|
|
@@ -15,12 +15,13 @@ Available commands:
|
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
17
|
import logging
|
|
18
|
+
import os
|
|
18
19
|
import sys
|
|
19
20
|
import secrets
|
|
20
21
|
from pathlib import Path
|
|
21
22
|
from datetime import datetime
|
|
22
23
|
import typer
|
|
23
|
-
from . import setup_logging,
|
|
24
|
+
from . import setup_logging, __version__
|
|
24
25
|
from .core import VaultTool
|
|
25
26
|
|
|
26
27
|
# Create app with proper help text
|
|
@@ -28,7 +29,7 @@ from .core import VaultTool
|
|
|
28
29
|
app = typer.Typer(
|
|
29
30
|
help="""Secure file encryption for secrets and configuration files.
|
|
30
31
|
|
|
31
|
-
Encrypts sensitive files using AES-256-
|
|
32
|
+
Encrypts sensitive files using AES-256-GCM and manages their encrypted counterparts.
|
|
32
33
|
|
|
33
34
|
\b
|
|
34
35
|
Key Options:
|
|
@@ -83,52 +84,37 @@ def _setup_cli_logging(verbose: bool = False, quiet: bool = False) -> logging.Lo
|
|
|
83
84
|
return setup_logging(level=level, include_timestamp=False)
|
|
84
85
|
|
|
85
86
|
|
|
86
|
-
def
|
|
87
|
-
"""
|
|
88
|
-
logger = get_logger(__name__)
|
|
87
|
+
def _write_private_file(path: Path, content: str, exclusive: bool = False) -> None:
|
|
88
|
+
"""Write a file that is only readable by its owner (mode 0600).
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
logger.debug(f"Retrieved version from importlib.metadata: {pkg_version}")
|
|
94
|
-
return pkg_version
|
|
95
|
-
except ImportError:
|
|
96
|
-
# importlib.metadata not available in older Python versions
|
|
97
|
-
logger.debug("importlib.metadata not available, trying fallback")
|
|
98
|
-
except Exception as e:
|
|
99
|
-
# Package not found or other metadata error
|
|
100
|
-
logger.warning(f"Failed to get version from metadata: {e}")
|
|
90
|
+
The permissions are applied with ``os.open`` at creation time, so the file
|
|
91
|
+
is never world-readable, not even briefly (``write_text`` + ``chmod`` leaves
|
|
92
|
+
such a window open).
|
|
101
93
|
|
|
102
|
-
|
|
94
|
+
Args:
|
|
95
|
+
path: Destination path.
|
|
96
|
+
content: Text to write.
|
|
97
|
+
exclusive: If True, fail instead of overwriting an existing file.
|
|
98
|
+
"""
|
|
99
|
+
flags = os.O_WRONLY | os.O_CREAT | (os.O_EXCL if exclusive else os.O_TRUNC)
|
|
100
|
+
fd = os.open(path, flags, 0o600)
|
|
103
101
|
try:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
for level in range(3): # Check up to 3 levels up
|
|
111
|
-
pyproject_path = current_dir / "pyproject.toml"
|
|
112
|
-
if pyproject_path.exists():
|
|
113
|
-
logger.debug(f"Found pyproject.toml at {pyproject_path}")
|
|
114
|
-
with open(pyproject_path, "r") as f:
|
|
115
|
-
content = f.read()
|
|
116
|
-
# Simple parsing for version
|
|
117
|
-
for line in content.split('\n'):
|
|
118
|
-
if line.strip().startswith('version = "'):
|
|
119
|
-
fallback_version = line.split('"')[1]
|
|
120
|
-
logger.debug(f"Extracted version from pyproject.toml: {fallback_version}")
|
|
121
|
-
return fallback_version
|
|
122
|
-
current_dir = current_dir.parent
|
|
123
|
-
logger.debug(f"Level {level + 1}: No pyproject.toml found, checking parent")
|
|
124
|
-
|
|
125
|
-
except (IOError, OSError) as e:
|
|
126
|
-
logger.warning(f"Failed to read pyproject.toml: {e}")
|
|
127
|
-
except Exception as e:
|
|
128
|
-
logger.warning(f"Unexpected error reading pyproject.toml: {e}")
|
|
102
|
+
if hasattr(os, "fchmod"):
|
|
103
|
+
os.fchmod(fd, 0o600)
|
|
104
|
+
os.write(fd, content.encode("utf-8"))
|
|
105
|
+
os.fsync(fd)
|
|
106
|
+
finally:
|
|
107
|
+
os.close(fd)
|
|
129
108
|
|
|
130
|
-
|
|
131
|
-
|
|
109
|
+
|
|
110
|
+
def _get_version() -> str:
|
|
111
|
+
"""Return the installed VaultTool version.
|
|
112
|
+
|
|
113
|
+
The version is resolved once, at import time, from the installed package
|
|
114
|
+
metadata (see :mod:`vaulttool`), so ``pyproject.toml`` never has to be
|
|
115
|
+
parsed at runtime.
|
|
116
|
+
"""
|
|
117
|
+
return __version__
|
|
132
118
|
|
|
133
119
|
|
|
134
120
|
@app.command("generate-key")
|
|
@@ -219,9 +205,8 @@ Examples:
|
|
|
219
205
|
# Ensure parent directory exists
|
|
220
206
|
key_path.parent.mkdir(parents=True, exist_ok=True)
|
|
221
207
|
|
|
222
|
-
#
|
|
223
|
-
key_path
|
|
224
|
-
key_path.chmod(0o600)
|
|
208
|
+
# Create the key with 0600 permissions from the start
|
|
209
|
+
_write_private_file(key_path, new_key + "\n", exclusive=True)
|
|
225
210
|
|
|
226
211
|
if not quiet:
|
|
227
212
|
typer.echo(f"✅ Successfully created new key file: {key_path}")
|
|
@@ -319,9 +304,8 @@ Examples:
|
|
|
319
304
|
# Read old key
|
|
320
305
|
old_key = key_path.read_text()
|
|
321
306
|
|
|
322
|
-
# Write backup
|
|
323
|
-
backup_path
|
|
324
|
-
backup_path.chmod(0o600)
|
|
307
|
+
# Write backup (0600, never overwrite an existing backup)
|
|
308
|
+
_write_private_file(backup_path, old_key, exclusive=True)
|
|
325
309
|
|
|
326
310
|
if not quiet:
|
|
327
311
|
typer.echo(f" ✅ Old key backed up to: {backup_path}")
|
|
@@ -334,8 +318,7 @@ Examples:
|
|
|
334
318
|
|
|
335
319
|
# Write new key
|
|
336
320
|
try:
|
|
337
|
-
key_path
|
|
338
|
-
key_path.chmod(0o600)
|
|
321
|
+
_write_private_file(key_path, new_key + "\n")
|
|
339
322
|
|
|
340
323
|
if not quiet:
|
|
341
324
|
typer.echo(f" ✅ New key written to: {key_path}")
|
|
@@ -645,7 +628,20 @@ Example:
|
|
|
645
628
|
|
|
646
629
|
try:
|
|
647
630
|
vt = VaultTool()
|
|
648
|
-
vt.check_ignore_task()
|
|
631
|
+
result = vt.check_ignore_task()
|
|
632
|
+
|
|
633
|
+
if not quiet:
|
|
634
|
+
typer.echo("\n" + "=" * 60)
|
|
635
|
+
typer.echo("Check Ignore Summary:")
|
|
636
|
+
typer.echo(f" Total: {result['total']}")
|
|
637
|
+
typer.echo(f" Ignored: {result['ignored']}")
|
|
638
|
+
typer.echo(f" Not ignored: {len(result['not_ignored'])}")
|
|
639
|
+
typer.echo("=" * 60)
|
|
640
|
+
for not_ignored in result["not_ignored"]:
|
|
641
|
+
typer.echo(f" \u26a0 {not_ignored}", err=True)
|
|
642
|
+
|
|
643
|
+
if result["not_ignored"]:
|
|
644
|
+
sys.exit(1)
|
|
649
645
|
except Exception as e:
|
|
650
646
|
typer.echo(f"ERROR: {e}", err=True)
|
|
651
647
|
sys.exit(1)
|
|
@@ -157,8 +157,8 @@ def load_config(path: str = ".vaulttool.yml") -> Dict[str, Any]:
|
|
|
157
157
|
|
|
158
158
|
Example:
|
|
159
159
|
>>> config = load_config()
|
|
160
|
-
>>> print(config['options']['
|
|
161
|
-
'
|
|
160
|
+
>>> print(config['options']['suffix'])
|
|
161
|
+
'.vault'
|
|
162
162
|
|
|
163
163
|
>>> # With environment override:
|
|
164
164
|
>>> os.environ['VAULTTOOL_OPTIONS_KEY_FILE'] = '/custom/key'
|