Skip to content

Commit dc5714c

Browse files
authored
πŸ”– From test β†’ Bump version: v1.1.9-test into prod (#43)
Automatically created pull request for release v1.1.9-test into prod branch.
2 parents 32ee0d0 + ddeeeed commit dc5714c

File tree

11 files changed

+973
-40
lines changed

11 files changed

+973
-40
lines changed

β€Ž.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.1.8
2+
current_version = 1.1.9
33
commit = True
44
tag = False
55

β€ŽREADME.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# πŸ—„οΈ Scripts Repository
22

3+
![CI/CD](https://img.shields.io/badge/CI/CD-Pipeline-blue)
4+
![Status](https://img.shields.io/badge/Status-Stable-green.svg)
5+
![Python](https://img.shields.io/badge/Python-3.11%2B-blue.svg)
6+
![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)
7+
38
This repository contains a collection of base Python scripts that are invoked by the CI/CD processes of other repositories, especially the template repository. These scripts are used for formatting, checking files, version control, and updating the year in file headers or documentation.
49

510
## πŸ“š Table of Contents

β€Žcontrol_commit/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def emit(self, record):
9494
)
9595
self.stream.write(msg + self.terminator)
9696
self.flush()
97-
except Exception:
97+
except Exception as e_handle_emit:
98+
logger.debug(f"SafeStreamHandler error: {e_handle_emit}")
9899
self.handleError(record)
99100

100101
safe_console_handler = SafeStreamHandler()

β€Žcrypto_controller/.env.example

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Password KP Settings
2+
## Password Key Pair (API-Token Mode)
3+
# API_URI="https://tu.dominio.com/private-key" <- Uncomment and comment KP_PASSWORD
4+
# API_TOKEN_SECURITY="api_token" <- Uncomment and comment KP_PASSWORD
5+
# API_TIMEOUT=12 <- Uncomment and comment KP_PASSWORD
6+
### OR
7+
## Pasword Key Pair (Local Mode)
8+
KP_PASSWORD="<28 (Chars)>"
9+
10+
# Certificate Vault Settings
11+
CERT_EXPIRATION_YEARS=6
12+
13+
# Expiration Notifications Settings
14+
SMTP_SERVER=smtp.example.com
15+
SMTP_PORT=587
16+
17+
SMTP_PASSWORD=your_email_password
18+
ALERT_RECIPIENT=[email protected]

β€Žcrypto_controller/README.md

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# πŸ” CryptoController
2+
3+
![Status](https://img.shields.io/badge/Status-Stable-green.svg)
4+
![Python](https://img.shields.io/badge/Python-3.11%2B-blue.svg)
5+
![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)
6+
7+
CryptoController is a robust Python application designed for secure key management, encryption, and decryption operations. It leverages hybrid encryption (AES + RSA) to ensure data confidentiality and integrity, making it ideal for applications requiring strong cryptographic safeguards.
8+
9+
## πŸ“š Table of Contents
10+
11+
- [Features](#-features)
12+
- [Installation](#-installation)
13+
- [Configuration](#-configuration)
14+
- [Usage](#-usage)
15+
- [Initialization](#-initialization)
16+
- [Renewing Keys](#-renewing-keys)
17+
- [Encrypting Data](#-encrypting-data)
18+
- [Decrypting Data](#-decrypting-data)
19+
- [Checking Status](#-checking-status)
20+
- [Environment Variables](#-environment-variables)
21+
- [Logging](#-logging)
22+
- [License](#-license)
23+
- [Contact](#-contact)
24+
25+
## ✨ Features
26+
27+
- **Hybrid Encryption:** Combines AES (symmetric) and RSA (asymmetric) encryption for enhanced security.
28+
- **Key Management:** Generates, verifies, and renews RSA key pairs securely.
29+
- **Expiration Handling:** Tracks key expiration dates and sends email alerts before keys expire.
30+
- **Status Reporting:** Provides detailed status reports of the cryptographic setup.
31+
- **Secure Storage:** Stores keys in a protected certificate vault with appropriate permissions.
32+
- **Logging:** Comprehensive logging with rotating file handlers for easy monitoring and debugging.
33+
34+
## πŸ› οΈ Installation
35+
36+
1. **Clone the Repository:**
37+
38+
```bash
39+
cd crypto_controller
40+
```
41+
42+
2. **Create a Virtual Environment**
43+
44+
```bash
45+
python -m venv venv
46+
```
47+
48+
3. **Activate the Virtual Environment**
49+
50+
On Unix or MacOS:
51+
52+
```bash
53+
source venv/bin/activate
54+
```
55+
56+
On Windows:
57+
58+
```bash
59+
.\venv\Scripts\activate
60+
```
61+
62+
- or
63+
64+
```bash
65+
powershell.exe -ExecutionPolicy Bypass -File .\venv\Scripts\Activate.ps1
66+
```
67+
68+
4. **Upgrade pip**
69+
70+
```bash
71+
pip install --upgrade pip
72+
```
73+
74+
5. **Install Dependencies**
75+
76+
```bash
77+
pip install -r requirements.txt
78+
```
79+
80+
- Deactivate the Virtual Environment
81+
82+
When you're done, deactivate the environment:
83+
84+
```bash
85+
deactivate
86+
```
87+
88+
## βš™οΈ Configuration
89+
90+
**Environment Variables**:
91+
92+
Create a .env file in the project root directory and populate it with the following variables:
93+
94+
```bash
95+
# Password KP Settings
96+
## Password Key Pair (API-Token Mode)
97+
# API_URI="https://tu.dominio.com/private-key" <- Uncomment and comment KP_PASSWORD
98+
# API_TOKEN_SECURITY="api_token" <- Uncomment and comment KP_PASSWORD
99+
# API_TIMEOUT=12 <- Uncomment and comment KP_PASSWORD
100+
### OR
101+
## Password Key Pair (Local Mode)
102+
KP_PASSWORD="<28 (Chars)>"
103+
104+
# Certificate Vault Settings
105+
CERT_EXPIRATION_YEARS=6
106+
107+
# Expiration Notifications Settings
108+
SMTP_SERVER=smtp.example.com
109+
SMTP_PORT=587
110+
111+
SMTP_PASSWORD=your_email_password
112+
113+
```
114+
115+
- Descriptions:
116+
- API_URI: Password API mode base URI.
117+
- API_TOKEN_SECURITY: Password API mode token security.
118+
- API_TIMEOUT: Password API mode timeout.
119+
- KP_PASSWORD: Password plain mode, used it or API vars.
120+
- CERT_EXPIRATION_YEARS: Number of years before key expiration.
121+
- SMTP_SERVER: SMTP server address for sending emails.
122+
- SMTP_PORT: SMTP server port.
123+
- SMTP_USER: SMTP server username.
124+
- SMTP_PASSWORD: SMTP server password.
125+
- ALERT_RECIPIENT: Email address to receive expiration alerts.
126+
127+
## πŸš€ Usage
128+
129+
CryptoController supports several operations: init, renew, encrypt, decrypt, and status.
130+
131+
### πŸ“¦ Initialization
132+
133+
Generates a new RSA key pair and sets up the certificate vault.
134+
135+
```bash
136+
python main.py init --log-level DEBUG
137+
```
138+
139+
Options:
140+
--cert-location: Directory to store certificates (default: certs in the current directory).
141+
--key-pair-name: Name of the key pair (default: Crypto-Key-Pair-<YEAR>).
142+
--log-level: Logging level (INFO or DEBUG).
143+
144+
### πŸ”„ Renewing Keys
145+
146+
Renews existing keys by cleaning the vault and generating new keys.
147+
148+
```bash
149+
python main.py renew --log-level DEBUG
150+
```
151+
152+
### πŸ”’ Encrypting Data
153+
154+
Encrypts plain text using hybrid encryption.
155+
156+
```bash
157+
python main.py encrypt "Your sensitive data here" --log-level DEBUG
158+
```
159+
160+
Output: Encrypted Base64 string.
161+
162+
### πŸ”“ Decrypting Data
163+
164+
Decrypts previously encrypted data.
165+
166+
```bash
167+
python main.py decrypt "EncryptedBase64StringHere" --log-level DEBUG
168+
```
169+
170+
Output: Decrypted plain text.
171+
172+
### πŸ“ Checking Status
173+
174+
Retrieves and displays the current status of the CryptoController.
175+
176+
```bash
177+
python main.py status --log-level DEBUG
178+
```
179+
180+
### πŸ“œ Environment Variables
181+
182+
Ensure all required environment variables are set in the .env file:
183+
184+
Password KP Settings:
185+
Password Key Pair (API-Token Mode):
186+
API_URI: Password API mode base URI.
187+
API_TOKEN_SECURITY: Password API mode token security.
188+
API_TIMEOUT: Password API mode timeout.
189+
190+
Pasword Key Pair (Local Mode):
191+
KP_PASSWORD: Password plain mode, used it or API vars.
192+
193+
Certificate Vault Settings:
194+
CERT_EXPIRATION_YEARS: Number of years before key expiration.
195+
196+
Expiration Notifications Settings:
197+
SMTP_SERVER: SMTP server address for sending emails.
198+
SMTP_PORT: SMTP server port.
199+
SMTP_USER: SMTP server username.
200+
SMTP_PASSWORD: SMTP server password.
201+
ALERT_RECIPIENT: Email address to receive expiration alerts.
202+
203+
## πŸ“Š Logging
204+
205+
Logs are maintained in crypto_controller.log with rotating file handlers to prevent excessive file sizes.
206+
207+
Log Levels:
208+
INFO: General operational messages.
209+
DEBUG: Detailed diagnostic information.
210+
211+
## πŸ“« Contact
212+
213+
For any inquiries or support, please open an issue or contact [[email protected]](mailto:[email protected]).
214+
215+
---
216+
217+
## πŸ“œ License
218+
219+
2024 - This project is licensed under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html). You are free to use, modify, and distribute this software under the terms of the GPL-3.0 license. For more details, please refer to the [LICENSE](../LICENSE) file included in this repository.

0 commit comments

Comments
Β (0)