cryptshield 1.1.0__tar.gz → 2.0.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.
Files changed (31) hide show
  1. cryptshield-2.0.0/PKG-INFO +410 -0
  2. cryptshield-2.0.0/README.md +359 -0
  3. {cryptshield-1.1.0 → cryptshield-2.0.0}/pyproject.toml +28 -2
  4. {cryptshield-1.1.0 → cryptshield-2.0.0}/setup.py +2 -1
  5. cryptshield-2.0.0/src/cryptshield/__init__.py +4 -0
  6. cryptshield-2.0.0/src/cryptshield/__main__.py +4 -0
  7. cryptshield-2.0.0/src/cryptshield/cryptshield.py +1956 -0
  8. {cryptshield-1.1.0 → cryptshield-2.0.0}/src/cryptshield/metadata_cleaner.py +118 -117
  9. cryptshield-2.0.0/src/cryptshield.egg-info/PKG-INFO +410 -0
  10. cryptshield-2.0.0/src/cryptshield.egg-info/SOURCES.txt +23 -0
  11. cryptshield-2.0.0/src/cryptshield.egg-info/entry_points.txt +2 -0
  12. {cryptshield-1.1.0 → cryptshield-2.0.0}/src/cryptshield.egg-info/requires.txt +1 -0
  13. cryptshield-2.0.0/tests/test_ancestors.py +270 -0
  14. cryptshield-2.0.0/tests/test_cli.py +303 -0
  15. cryptshield-2.0.0/tests/test_delete.py +337 -0
  16. cryptshield-2.0.0/tests/test_directories.py +423 -0
  17. cryptshield-2.0.0/tests/test_format.py +242 -0
  18. cryptshield-2.0.0/tests/test_glob.py +234 -0
  19. cryptshield-2.0.0/tests/test_nemo.py +256 -0
  20. cryptshield-2.0.0/tests/test_safety_net.py +316 -0
  21. cryptshield-2.0.0/tests/test_transactions.py +571 -0
  22. cryptshield-1.1.0/PKG-INFO +0 -272
  23. cryptshield-1.1.0/README.md +0 -222
  24. cryptshield-1.1.0/src/cryptshield/__init__.py +0 -4
  25. cryptshield-1.1.0/src/cryptshield/cryptshield.py +0 -600
  26. cryptshield-1.1.0/src/cryptshield.egg-info/PKG-INFO +0 -272
  27. cryptshield-1.1.0/src/cryptshield.egg-info/SOURCES.txt +0 -12
  28. {cryptshield-1.1.0 → cryptshield-2.0.0}/LICENSE +0 -0
  29. {cryptshield-1.1.0 → cryptshield-2.0.0}/setup.cfg +0 -0
  30. {cryptshield-1.1.0 → cryptshield-2.0.0}/src/cryptshield.egg-info/dependency_links.txt +0 -0
  31. {cryptshield-1.1.0 → cryptshield-2.0.0}/src/cryptshield.egg-info/top_level.txt +0 -0
@@ -0,0 +1,410 @@
1
+ Metadata-Version: 2.4
2
+ Name: cryptshield
3
+ Version: 2.0.0
4
+ Summary: Secure Encryption and Deletion Application
5
+ Author: Wilmer Martinez
6
+ License: MIT License
7
+
8
+ Copyright (c) 2023 Wilmer Martinez <https://github.com/wilmerm>
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/wilmerm/cryptshield
29
+ Project-URL: Documentation, https://github.com/wilmerm/cryptshield?tab=readme-ov-file#secure-encryption-and-deletion-application
30
+ Project-URL: Repository, https://github.com/wilmerm/cryptshield
31
+ Project-URL: Issues, https://github.com/wilmerm/cryptshield/issues
32
+ Project-URL: Release, https://github.com/wilmerm/cryptshield/releases
33
+ Keywords: encryption,deletion,secure,application,python,cryptography,cryptshield,guardian,privacy,security,file,folder,data,protection,safety,safeguard,lock,unlock,erase,wipe,shred,scrub,clean,destroy,confidential,sensitive,information,safekeeping,cybersecurity
34
+ Classifier: Development Status :: 5 - Production/Stable
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: Topic :: Security :: Cryptography
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Natural Language :: English
39
+ Classifier: Natural Language :: Spanish
40
+ Classifier: Programming Language :: Python
41
+ Classifier: Programming Language :: Python :: 3.10
42
+ Classifier: Programming Language :: Python :: 3.11
43
+ Classifier: Programming Language :: Python :: 3.12
44
+ Classifier: Programming Language :: Python :: 3.13
45
+ Requires-Python: >=3.10
46
+ Description-Content-Type: text/markdown
47
+ License-File: LICENSE
48
+ Requires-Dist: cryptography
49
+ Requires-Dist: Pillow
50
+ Dynamic: license-file
51
+
52
+ # Secure Encryption, Deletion, and Metadata Cleaning Application
53
+
54
+ This Python application allows you to encrypt files and directories with a password (scrypt key derivation + authenticated streaming encryption), delete them on a best-effort basis with the **shred** command, and clean metadata from various file formats. It is useful for protecting sensitive data. **Secure deletion cannot be guaranteed on every kind of storage; see [Secure deletion limitations](#secure-deletion-limitations).**
55
+
56
+ ## **Main Features**
57
+
58
+ - **Verified Encryption:** Encrypts files and directories with a password. The output is verified (decrypted again and compared with the original) and synchronized to disk before the original is touched.
59
+ - **Best-effort Deletion:** Overwrites and removes files and directories with the **shred** command (see the limitations below).
60
+ - **Metadata Cleaning:** Removes metadata from images, documents, PDFs, and multimedia files while preserving file functionality.
61
+ - **Recursive Processing:** Supports encrypting and deleting files within directories recursively.
62
+ - **User Confirmation Options:** Can be configured to require user confirmation before encrypting or deleting files.
63
+
64
+ ## **Requirements**
65
+
66
+ - Python 3.10 or newer
67
+ - Required libraries (installed automatically by `pip install cryptshield`): `cryptography`, `pillow`
68
+ - Optional libraries for metadata cleaning of PDF, DOCX, XLSX and audio/video files: `PyPDF2`, `python-docx`, `openpyxl`, `mutagen` (not installed automatically; see [Installing from PyPI](#installing-from-pypi))
69
+ - `shred` (GNU coreutils) for deletion. `zip`/`unzip` are **not** needed anymore.
70
+
71
+ ---
72
+
73
+ ## **Usage**
74
+
75
+ ### **Running `cryptshield`**
76
+
77
+ #### Basic syntax:
78
+
79
+ ```sh
80
+ cryptshield <command> [options] [--] <arguments>
81
+ ```
82
+
83
+ #### Examples:
84
+
85
+ ```sh
86
+ # Encrypt a file or directory (asks for the password twice, without echo).
87
+ # The original is deleted only after the output was verified.
88
+ cryptshield encrypt /path/to/file
89
+ cryptshield encrypt --keep /path/to/directory # keep the original
90
+
91
+ # Decrypt (never overwrites existing files)
92
+ cryptshield decrypt /path/to/file.encrypted
93
+ cryptshield decrypt /path/to/directory.zipencrypted
94
+
95
+ # Non-interactive password input (no password on the command line)
96
+ printf '%s\n' "$PASSWORD" | cryptshield encrypt --password-stdin /path/to/file
97
+ cryptshield decrypt --password-file ~/.secrets/pw /path/to/file.encrypted
98
+
99
+ # Encrypt / decrypt a text
100
+ cryptshield encrypt_text "Sample text"
101
+ cryptshield decrypt_text "Q1NIRAIB..."
102
+
103
+ # Best-effort file deletion (paths are literal)
104
+ cryptshield delete /path/to/file
105
+ cryptshield delete -- '-file with [odd] *name*'
106
+ cryptshield delete --glob '/tmp/old/*.log' # explicit wildcards
107
+
108
+ # Clean metadata from files
109
+ cryptshield clean_metadata /path/to/image.jpg /path/to/document.pdf
110
+
111
+ # Clean metadata with essential information preserved
112
+ cryptshield clean_metadata /path/to/file.jpg true true true
113
+
114
+ # Clean metadata without backup (not recommended)
115
+ cryptshield clean_metadata /path/to/file.pdf false false true
116
+ ```
117
+
118
+ ---
119
+
120
+ ## **Encryption, safety guarantees and compatibility**
121
+
122
+ ### Password input
123
+
124
+ Passwords can be typed at a prompt (no echo; asked twice when encrypting), read from the first line of standard input (`--password-stdin`) or of a file (`--password-file FILE`). The legacy positional form `cryptshield encrypt PATH KEY` still works but prints a warning, because command-line arguments are visible in shell history and process listings. The first line of a password file may be at most 65536 bytes including its line terminator; a longer one is refused instead of being silently cut short, because data must never be encrypted under a password nobody typed. A password is always required: **nothing is ever encrypted with a machine-derived default key anymore.** A password that starts with `-` can be given after `--`.
125
+
126
+ ### Encryption format (version 2)
127
+
128
+ * Key derivation: **scrypt** (N = 2^17, r = 8, p = 1, about 128 MiB of memory) with a random 16-byte salt per file. Salt and parameters are stored in a 25-byte header together with an explicit format version; the header is authenticated.
129
+ * Encryption: **ChaCha20-Poly1305** in the standard STREAM construction (64 KiB chunks, counter + "last chunk" nonce, as used by age and Tink). Wrong passwords, corruption, truncation, reordering and appended data are detected. Memory use is constant regardless of file size (apart from the scrypt memory above). Fernet cannot stream, which is why it is not used for new data.
130
+ * KDF parameters read from a file are bounded (2^14 ≤ N ≤ 2^20, r ≤ 16, p ≤ 8, at most 512 MiB of memory) and validated before any key derivation, so a hostile file cannot make the program consume unbounded resources.
131
+ * Directories are stored as ZIP archives (`<dir>.zipencrypted`) that are streamed straight into the encryptor and read back through a decrypting reader: **no plaintext archive is ever written to disk**. Symbolic links, special files and unrepresentable names inside a directory make the operation fail before anything is written.
132
+ * Legacy files (Fernet with an MD5 derived key, including `.zipencrypted` archives made by `zip`) are still decrypted. They have no streaming, so they are loaded in memory while being decrypted. Legacy data that used the old machine-derived default key can still be opened by passing no key to the library functions `decrypt` and `decrypt_text` (the command line always asks for a password).
133
+
134
+ ### What happens during `encrypt`
135
+
136
+ 1. The output is written to a private temporary file next to the destination, flushed and `fsync`ed.
137
+ 2. It is decrypted again from the password and compared (SHA-256, size, archive member list) with the original data.
138
+ 3. It is published **without ever replacing an existing file** (`renameat2(RENAME_NOREPLACE)`, falling back to `link()`/exclusive creation) and the directory is synchronized.
139
+ 4. Only then is the original removed, and only if it is unchanged (stat signature, link count) since it was read. For a directory the whole tree must match the verified snapshot; only the archived files are deleted, never anything else.
140
+
141
+ If any step fails the original is left untouched and temporary files are removed. If only the final deletion fails, the verified output is kept and the command reports it explicitly.
142
+
143
+ `decrypt` follows the same rules in reverse: it decrypts into a temporary file or a private staging directory, verifies and publishes it without overwriting, and only then deletes the encrypted file (`--keep` preserves it). Archives are validated first: absolute paths, `..`, links, special files, duplicate or clashing entries and several top-level entries are rejected. Directories are extracted **next to the encrypted file** (older versions used the current working directory).
144
+
145
+ While encrypting, temporary files only contain ciphertext. While **decrypting**, the temporary file holds the plaintext. Every temporary file is created with mode `0600` and keeps it through verification and publication; only afterwards, through the still-open file descriptor, does it receive its final mode (below). If that last step fails, the published file keeps the private mode `0600`, the command reports an error and the source is **not** deleted. An archive is extracted into a staging directory created with mode `0700`; the members inside get their final modes there, so what keeps them private until publication is that directory, not their own modes. It is removed on failure, on Ctrl-C, and on `SIGHUP`/`SIGTERM` (for example closing the terminal). If the process is killed hard (`SIGKILL`, power loss), a `.cryptshield-*.tmp` file or directory may remain next to the target and, when decrypting, may contain partial plaintext: delete it yourself (it is not shredded automatically).
146
+
147
+ Final permissions: a single decrypted file (and every encrypted output) gets the default permissions of your `umask` once it is published, not the mode of the file that was originally encrypted. Members of a decrypted directory archive keep the permission bits recorded in the archive (owner always at least read for files, and read/write/search for directories; no set-uid/set-gid/sticky bits) and the `umask` is **not** applied to them. Restrict decrypted data yourself if it is sensitive.
148
+
149
+ ### Exit status
150
+
151
+ | Status | Meaning |
152
+ | --- | --- |
153
+ | 0 | Success |
154
+ | 1 | Error (nothing was published, or the operation was refused) |
155
+ | 2 | Invalid command line |
156
+ | 3 | The output is complete and verified, but deleting the original (or the encrypted file) failed or was refused |
157
+
158
+ ### Secure deletion limitations
159
+
160
+ `shred` overwrites a file in place and removes it. **That does not guarantee that the data is unrecoverable** on SSDs and other flash storage (wear levelling and remapped blocks), copy-on-write or log-structured filesystems (btrfs, ZFS, APFS, ...), filesystems with data journalling, snapshots, RAID, network or cloud storage, and backups. Treat deletion as a best-effort measure and use full-disk encryption when you need stronger assurance. CryptShield also refuses to overwrite a file that has several hard links (the other names would be destroyed) and to delete special files; symbolic links are removed without being followed. There is an unavoidable window between checking a path and deleting it in which a local attacker able to modify the directory could swap the path.
161
+
162
+ `cryptshield delete` treats paths literally (a trailing `/` on a symbolic link still refers to the link, which is removed without touching its target); use `--glob` for wildcards.
163
+
164
+ `--glob` supports `*`, `?`, `[...]` and `**` (any number of directories), and names starting with `.` only match a pattern component that also starts with `.` (so `*` skips hidden files and `**` skips hidden directories). **Wildcards never descend into symbolic links**: a link to a directory matched by `*` or `**` is itself a match (and deleting it removes only the link) but its contents are not listed, so a link can neither bring outside files into the result nor create a traversal loop. A symbolic link among the literal leading components of a pattern (`outlink/*.txt`) is refused instead of being followed; give the real path. Every pattern is expanded completely and validated before the first deletion, and a pattern with no matches, or with a directory that cannot be read, is an error. As with any check-then-act sequence, a local attacker who can modify the directories while the command runs could still swap a component for a link between expansion and deletion.
165
+
166
+ Before anything is traversed or changed, every target (including those produced by `--glob`) is validated by `delete`, `encrypt` and `decrypt` alike: empty paths, the filesystem root and any alias of it (`/`, `//`, `/.`, `/..`, a bind mount of `/`), and any path whose last component is `.` or `..` (`.`, `..`, `dir/.`, `dir/..`) are refused, and nothing is processed if one of them is present. Use the real name of the file or directory. Names that merely resemble them, such as `.hidden`, `..hidden` or `...`, are ordinary names and remain valid. A missing path, a refused file or a failed `shred` is reported and the exit status is 3 (the other paths are still processed).
167
+
168
+ ### Compatibility changes
169
+
170
+ * New files use the version 2 format and **cannot be opened by older CryptShield versions** (older files can be opened by this version).
171
+ * A password is mandatory for encryption; the machine-derived default key is only accepted for decrypting legacy data.
172
+ * `cryptshield delete` no longer expands wildcards unless `--glob` is given (shell globbing still works as usual before CryptShield runs).
173
+ * `encrypt`, `decrypt` and `delete` refuse `.`, `..` and the filesystem root (for example `cryptshield encrypt .` no longer works: give the directory's name).
174
+ * `encrypt`, `decrypt` and `delete` refuse a path that goes **through a symbolic link before its last component**: with `outlink -> /elsewhere`, `outlink/file.txt` is refused, while `outlink` itself can still be deleted (the link is removed, never its target) and `encrypt`/`decrypt` still refuse a link given as the file. Only the components written in the path are examined, so a relative name is unaffected by how the current directory was reached. **Compatibility:** a path whose directories include a link, for example `/var/run/x` on systems where `/var/run` is a link to `/run`, a symlinked home or `/tmp`, or a file chosen in Nemo below a linked folder, is refused; give the real path (`readlink -f` on the directory shows it). The refusal is made before anything is traversed, written or deleted, and a batch with one such path processes none of them.
175
+ * This check is made *before* the operation. It does **not** protect against a local attacker who can replace a directory with a link between the check and the operation, which is the residual race described above; closing that window would need descriptor-based (`openat`/`O_NOFOLLOW`) traversal, which CryptShield does not implement.
176
+ * `encrypt`/`decrypt` refuse to overwrite existing files and symbolic links, and `decrypt` only accepts names ending in `.encrypted` or `.zipencrypted`.
177
+ * `encrypt_text` returns/prints a URL-safe base64 text (`Q1NIRA...`) instead of a Fernet token. `encrypt_text`/`decrypt_text` now print their result on the command line.
178
+ * `--keep` (alias `--no-delete`) keeps the original; `--delete` (the default) is accepted explicitly. Previously any third argument meant "delete".
179
+
180
+ ---
181
+
182
+ ## **Metadata Cleaning Feature**
183
+
184
+ The metadata cleaning feature provides secure removal of metadata from various file formats while maintaining the primary functionality of files. This feature complies with DoD 5220.22-M standards for secure deletion.
185
+
186
+ ### **Supported File Formats**
187
+
188
+ - **Images:** JPEG, PNG, TIFF, GIF
189
+ - Removes: EXIF data, GPS coordinates, camera information, comments, timestamps
190
+ - **Documents:** PDF, DOCX, XLSX, PPTX
191
+ - Removes: Author information, creation/modification dates, comments, document properties, edit history
192
+ - **Multimedia:** MP3, MP4, AVI, MOV, WAV, FLAC
193
+ - Removes: ID3 tags, artist, album, comments, metadata
194
+ - **Text Files:** TXT, RTF
195
+ - Removes: File system metadata where applicable
196
+
197
+ ### **Metadata Cleaning Options**
198
+
199
+ 1. **preserve_essential** (true/false): Whether to preserve essential metadata like title and creator
200
+ 2. **backup** (true/false): Whether to create backups before cleaning (recommended)
201
+ 3. **verify** (true/false): Whether to verify metadata removal after cleaning
202
+
203
+ ### **Security Features**
204
+
205
+ - **Secure Backup Management:** Creates temporary backups during processing, removes them after successful verification
206
+ - **Verification Process:** Confirms metadata has been successfully removed
207
+ - **Audit Logging:** Detailed logs of all metadata cleaning operations
208
+ - **DoD 5220.22-M Compliance:** Follows secure deletion standards
209
+ - **Forensic Recovery Prevention:** Ensures metadata cannot be recovered
210
+
211
+ ### **Examples**
212
+
213
+ ```sh
214
+ # Basic metadata cleaning
215
+ cryptshield clean_metadata /path/to/photo.jpg
216
+
217
+ # Clean multiple files
218
+ cryptshield clean_metadata /path/to/photo.jpg /path/to/document.pdf /path/to/music.mp3
219
+
220
+ # Preserve essential metadata (title, creator)
221
+ cryptshield clean_metadata /path/to/document.pdf true
222
+
223
+ # Clean without backup (faster, but less safe)
224
+ cryptshield clean_metadata /path/to/file.jpg false
225
+
226
+ # Full control: preserve_essential=false, backup=true, verify=true
227
+ cryptshield clean_metadata /path/to/file.jpg false true true
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Release Information
233
+
234
+ ### Release notes: version 2.0.0
235
+
236
+ Version 2.0.0 is a **major release with breaking changes** (see "Breaking changes and migration" below). It is distributed on **PyPI**; the Debian package is a separate channel (see [Debian package](#debian-package)).
237
+
238
+ **Highlights**
239
+
240
+ * **Versioned streaming encryption.** New files use format version 2: scrypt key derivation (N = 2^17, r = 8, p = 1, random 16-byte salt) and ChaCha20-Poly1305 in a chunked STREAM construction. The header is authenticated; wrong passwords, corruption, truncation and reordering are detected. Memory use stays constant for large files and directories are streamed without ever writing a plaintext archive.
241
+ * **Backward-compatible decryption.** Legacy data (Fernet with an MD5-derived key, including legacy `.zipencrypted` archives) can still be decrypted. It is never written again.
242
+ * **Verified encryption and safer deletion.** The encrypted output is re-read, decrypted and compared with the original, and synchronized to disk, before the original is removed. The original is removed only if it is unchanged. If deletion fails, the verified output is kept and exit status 3 is returned.
243
+ * **No-overwrite publication.** Results are published without ever replacing an existing file (`renameat2(RENAME_NOREPLACE)`, falling back to `link()`/exclusive creation). `encrypt` and `decrypt` refuse to overwrite existing files and symbolic links.
244
+ * **Password handling and temporary plaintext protection.** Passwords are prompted without echo (twice when encrypting), or read with `--password-stdin` / `--password-file`. Temporary files are created with mode `0600`, decrypted archives are extracted into a `0700` staging directory, and temporary data is removed on failure, Ctrl-C, `SIGHUP` and `SIGTERM`.
245
+ * **Filesystem path restrictions.** `encrypt`, `decrypt` and `delete` refuse empty paths, the filesystem root and its aliases, names ending in `.` or `..`, and paths that go through a symbolic link before the last component. `delete` treats paths literally unless `--glob` is given.
246
+ * **Nemo integration improvements.** The scripts pass the selected paths as separate arguments (never spliced into a command string, newline-safe through Nemo's URI list), hand the password to the terminal through a private `0600` file instead of the command line, verify that file before running, and report failures and partial results.
247
+
248
+ **Breaking changes and migration**
249
+
250
+ * Files encrypted with 2.0.0 **cannot be opened by CryptShield 1.x**. Decrypt them with 2.x. Existing 1.x data keeps working with 2.x; to move it to the new format, decrypt it with `--keep` and encrypt the result again, then remove the old file yourself once you have checked the new one.
251
+ * A password is mandatory for encryption. The machine-derived default key is no longer used for new data (it is only accepted by the library functions `decrypt`/`decrypt_text` for reading legacy data). Passing the password as a positional argument still works but prints a warning; prefer the prompt, `--password-stdin` or `--password-file`.
252
+ * `encrypt_text` returns a URL-safe base64 text (`Q1NIRA...`) instead of a Fernet token. `decrypt_text` still accepts legacy tokens.
253
+ * `encrypt` deletes the original only after verification; use `--keep` (alias `--no-delete`) to keep it. Previously any third argument meant "delete".
254
+ * `decrypt` only accepts names ending in `.encrypted` or `.zipencrypted`, never overwrites, and extracts directories next to the encrypted file (not into the current directory).
255
+ * `cryptshield delete` no longer expands wildcards unless `--glob` is given.
256
+ * `.`, `..`, the filesystem root and paths through a symbolic link directory are refused. Scripts that used `cryptshield encrypt .` or relied on symlinked directories (for example `/var/run/...`, a symlinked home or `/tmp`) must pass the real path.
257
+ * New exit status 3: the output is complete and verified, but deleting the original (or the encrypted file) failed. Scripts that treated any non-zero status identically should handle it.
258
+
259
+ **Documented security limitations**
260
+
261
+ * Secure deletion is **best effort**: `shred` cannot guarantee unrecoverability on SSDs and flash storage, copy-on-write or journalling filesystems, snapshots, RAID, network/cloud storage or backups ([details](#secure-deletion-limitations)).
262
+ * Path checks are made before the operation. A local attacker who can modify directories while the command runs could still swap a component for a link; CryptShield does not implement descriptor-based (`openat`/`O_NOFOLLOW`) traversal.
263
+ * If the process is killed hard (`SIGKILL`, power loss) a `.cryptshield-*.tmp` file or directory may remain and, when decrypting, may contain partial plaintext.
264
+ * The legacy format (Fernet with an MD5-derived key) is weak and is kept read-only for recovery only; it is loaded in memory while decrypted.
265
+ * The test safeguards reduce risk but are not an operating-system security boundary ([details](#test-safeguards-defense-in-depth-not-isolation)).
266
+
267
+ ### Installing from PyPI
268
+
269
+ ```bash
270
+ pip install cryptshield==2.0.0
271
+ ```
272
+
273
+ This installs the required dependencies (`cryptography`, `pillow`) and the `cryptshield` command (also available as `python -m cryptshield`). Metadata cleaning of PDF, DOCX, XLSX and audio/video files additionally needs optional libraries, which are not installed automatically:
274
+
275
+ ```bash
276
+ pip install PyPDF2 python-docx openpyxl mutagen
277
+ ```
278
+
279
+ `shred` (GNU coreutils) must be available for deletion.
280
+
281
+ ### Debian package
282
+
283
+ The Debian package is distributed separately from PyPI. The latest `.deb` published on GitHub is **1.1.1**, which predates the 2.0.0 changes described above (it uses the old format and the old command-line behavior). A 2.0.0 `.deb` has not been published yet.
284
+
285
+ [Download Cryptshield 1.1.1 (.deb)](https://github.com/wilmerm/cryptshield/releases/download/v1.1.1/cryptshield_1.1.1_all.deb)
286
+
287
+ #### Installation of the Debian package (1.1.1)
288
+
289
+ To install the package on your system, run the following command:
290
+
291
+ ```bash
292
+ wget https://github.com/wilmerm/cryptshield/releases/download/v1.1.1/cryptshield_1.1.1_all.deb
293
+
294
+ sudo dpkg -i cryptshield_1.1.1_all.deb
295
+ ```
296
+
297
+ After installation, you can run the `cryptshield` command by simply typing:
298
+
299
+ ```bash
300
+ cryptshield encrypt [FILE] [KEY]
301
+ ```
302
+
303
+ If you encounter any issues with dependencies, you can resolve them using:
304
+
305
+ ```bash
306
+ sudo apt-get install -f
307
+ ```
308
+
309
+ ---
310
+
311
+ ## **Setup**
312
+
313
+ Ensure the required libraries are installed using the following command:
314
+
315
+ ```sh
316
+ pip install -r requirements.txt
317
+ ```
318
+
319
+ `shred` (GNU coreutils) must be available for deletion. Administrator privileges are only needed to delete files you do not own.
320
+
321
+ ### Running the tests
322
+
323
+ ```sh
324
+ python -m venv .venv && . .venv/bin/activate
325
+ pip install -e . -r requirements.txt -r requirements-dev.txt
326
+ python -m pytest
327
+ ```
328
+
329
+ #### Test safeguards (defense in depth, not isolation)
330
+
331
+ Tests build their data in pytest's temporary directory and every test starts in a disposable working directory. Tests that pass dangerous arguments (`/`, `/.`, `..`, a link to `/`) never rely on CryptShield, or on the guard below, to keep them away from the real filesystem: they replace the destructive and traversing primitives with failing stubs or recording fakes, and the tests of the guard itself only run it on top of recording fakes. In addition, an autouse fixture in `tests/conftest.py` makes the primitives that the `cryptshield` module uses to modify or traverse the filesystem refuse any path that does not resolve (symbolic links included, using `realpath` only) inside pytest's temporary directory.
332
+
333
+ These safeguards **do not provide complete filesystem isolation** and are **not an operating-system security boundary**:
334
+
335
+ * only the explicitly listed primitives are checked (`_GUARDS` in `tests/conftest.py`); a new primitive used by the code is unguarded until it is added;
336
+ * native calls made through `ctypes` (the `renameat2` publication path) are not intercepted;
337
+ * child processes (the Nemo scripts, `python -m cryptshield`) are only shielded for `shred`; their other file operations are unchecked, so their paths are test constants inside the temporary directory;
338
+ * the pytest temporary directory is shared by all tests, which are therefore not isolated from one another;
339
+ * some tests deliberately pass absolute or `..` paths, or read real paths such as `/tmp/evil.txt` to prove nothing was written there; they rely on stubs and fakes, not on a temporary working directory;
340
+ * mutation testing of the safeguards is not part of the suite.
341
+
342
+
343
+ ### Installation and `.deb` Package Creation
344
+
345
+ Follow these steps to create and install the `.deb` package for *Cryptshield*:
346
+
347
+ #### 1. Build the Package
348
+ Run:
349
+ ```bash
350
+ dpkg-buildpackage -us -uc
351
+ ```
352
+
353
+ #### 2. Install and Test
354
+ ```bash
355
+ sudo dpkg -i ../cryptshield_<version>_all.deb
356
+ cryptshield
357
+ ```
358
+
359
+ If there are dependency issues, fix them with:
360
+ ```bash
361
+ sudo apt-get install -f
362
+ ```
363
+
364
+ ### Building and Publishing the Library
365
+
366
+ To compile and upload the library to PyPI, follow these steps:
367
+
368
+ 1. Ensure you have the necessary dependencies:
369
+
370
+ ```sh
371
+ pip install build twine
372
+ ```
373
+
374
+ 2. Build the package:
375
+
376
+ ```sh
377
+ python -m build
378
+ ```
379
+
380
+ 3. (Optional) Verify the package:
381
+
382
+ ```sh
383
+ twine check dist/*
384
+ ```
385
+
386
+ 4. Upload the package to PyPI:
387
+
388
+ ```sh
389
+ python -m twine upload dist/*
390
+ ```
391
+
392
+ ---
393
+
394
+ ## **Contributing**
395
+
396
+ If you'd like to contribute to this project or report an issue, feel free to open an issue or submit a pull request on GitHub.
397
+
398
+ ---
399
+
400
+ ## **License**
401
+
402
+ This application is distributed under the **MIT License**.
403
+
404
+ ## Contribution 💗
405
+
406
+ If you find value in this project and would like to show your support, please consider making a donation via PayPal:
407
+
408
+ [Donate on PayPal](https://paypal.me/martinezwilmer?country.x=DO&locale.x=es_XC)
409
+
410
+ Your generosity helps us to continue improving and maintaining this project. We appreciate every contribution, however small. Thanks for being part of our community!