git-secret-protector 1.2.2__tar.gz → 1.3.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.
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/PKG-INFO +130 -76
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/README.md +123 -69
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/pyproject.toml +9 -9
- git_secret_protector-1.3.0/src/git_secret_protector/core/settings.py +120 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/crypto/aes_encryption_handler.py +38 -11
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/crypto/aes_key_manager.py +50 -17
- git_secret_protector-1.3.0/src/git_secret_protector/main.py +192 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/services/encryption_manager.py +90 -26
- git_secret_protector-1.3.0/src/git_secret_protector/storage/aws_ssm_storage_manager.py +110 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/storage/gcp_secret_storage_manager.py +56 -20
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/storage/storage_manager_factory.py +12 -4
- git_secret_protector-1.2.2/src/git_secret_protector/core/settings.py +0 -77
- git_secret_protector-1.2.2/src/git_secret_protector/main.py +0 -147
- git_secret_protector-1.2.2/src/git_secret_protector/storage/aws_ssm_storage_manager.py +0 -101
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/__init__.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/context/__init__.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/context/module.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/core/__init__.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/core/git_attributes_parser.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/crypto/__init__.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/error/aes_key_error.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/error/storage_error.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/services/__init__.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/services/key_rotator.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/storage/__init__.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/storage/storage_manager_interface.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/utils/__init__.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/utils/configure_logging.py +0 -0
- {git_secret_protector-1.2.2 → git_secret_protector-1.3.0}/src/git_secret_protector/utils/project_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: git-secret-protector
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: A tool for managing secrets in Git with AWS Parameter Store integration.
|
|
5
5
|
Author: Duc Duong
|
|
6
6
|
Author-email: duc.duong@c0x12c.com
|
|
@@ -10,11 +10,11 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.11
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
-
Requires-Dist: boto3 (>=1.
|
|
14
|
-
Requires-Dist: google-auth (>=2.
|
|
15
|
-
Requires-Dist: google-cloud-secret-manager (>=2.
|
|
16
|
-
Requires-Dist: injector (>=0.
|
|
17
|
-
Requires-Dist: pycryptodome (>=3.
|
|
13
|
+
Requires-Dist: boto3 (>=1.43.27,<2.0.0)
|
|
14
|
+
Requires-Dist: google-auth (>=2.53.0,<3.0.0)
|
|
15
|
+
Requires-Dist: google-cloud-secret-manager (>=2.29.0,<3.0.0)
|
|
16
|
+
Requires-Dist: injector (>=0.24.0,<0.25.0)
|
|
17
|
+
Requires-Dist: pycryptodome (>=3.23.0,<4.0.0)
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
|
|
20
20
|
# git-secret-protector
|
|
@@ -33,11 +33,11 @@ Description-Content-Type: text/markdown
|
|
|
33
33
|
|
|
34
34
|
- pipx ([Download](https://pipx.pypa.io/stable/installation/))
|
|
35
35
|
|
|
36
|
-
You can install the `git-secret-protector` module via pipx:
|
|
36
|
+
- You can install the `git-secret-protector` module via pipx:
|
|
37
37
|
|
|
38
|
-
```sh
|
|
39
|
-
pipx install git-secret-protector
|
|
40
|
-
```
|
|
38
|
+
```sh
|
|
39
|
+
pipx install git-secret-protector
|
|
40
|
+
```
|
|
41
41
|
|
|
42
42
|
## Usage
|
|
43
43
|
|
|
@@ -45,28 +45,36 @@ pipx install git-secret-protector
|
|
|
45
45
|
|
|
46
46
|
#### 1.1. Create .gitattributes file
|
|
47
47
|
|
|
48
|
-
Create a `.gitattributes` file in the root of your repository to define which files should be encrypted.
|
|
49
|
-
|
|
50
|
-
Sample `.gitattributes` file:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
dev/secrets* filter=sample-app-dev diff=sample-app-dev
|
|
48
|
+
- Create a `.gitattributes` file in the root of your repository to define which files should be encrypted.
|
|
54
49
|
|
|
55
|
-
|
|
50
|
+
Sample `.gitattributes` file:
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
```
|
|
53
|
+
dev/secrets* filter=sample-app-dev diff=sample-app-dev
|
|
54
|
+
|
|
55
|
+
prod/secrets* filter=sample-app-prod diff=sample-app-prod
|
|
56
|
+
|
|
57
|
+
.gitattributes !filter !diff
|
|
58
|
+
```
|
|
59
59
|
|
|
60
60
|
#### 1.2. Configure Git Filters
|
|
61
61
|
|
|
62
|
-
Set up the Git clean and smudge filters base on the filters defined in the `.gitattributes` file.
|
|
62
|
+
- Set up the Git clean and smudge filters base on the filters defined in the `.gitattributes` file.
|
|
63
63
|
|
|
64
|
-
```sh
|
|
65
|
-
git-secret-protector setup-filters
|
|
66
|
-
```
|
|
64
|
+
```sh
|
|
65
|
+
git-secret-protector setup-filters
|
|
66
|
+
```
|
|
67
67
|
|
|
68
68
|
This command will configure the Git clean and smudge filters based on the patterns defined in the `.gitattributes` file. The filters will automatically encrypt and decrypt files based on the specified patterns.
|
|
69
69
|
|
|
70
|
+
- You can verify the configured filters in the `.git/config` file, for example:
|
|
71
|
+
|
|
72
|
+
```ini
|
|
73
|
+
[filter "sample-app-dev"]
|
|
74
|
+
clean = git-secret-protector encrypt sample-app-dev
|
|
75
|
+
smudge = git-secret-protector decrypt sample-app-dev
|
|
76
|
+
required = true
|
|
77
|
+
```
|
|
70
78
|
|
|
71
79
|
#### 1.3. Configuration
|
|
72
80
|
|
|
@@ -98,55 +106,104 @@ The `config.ini` file contains settings that customize the behavior of the `git-
|
|
|
98
106
|
|
|
99
107
|
#### 1.4. Set up AES key
|
|
100
108
|
|
|
109
|
+
**Notes:**
|
|
101
110
|
Before executing this command, ensure you have the necessary permissions to manage resources in the using Cloud Secret Storage Services.
|
|
102
111
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
```
|
|
112
|
+
- Command to set up AES key
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
git-secret-protector setup-aes-key <filter_name>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
- Sample command to set up an AES key for the `sample-app-dev` filter:
|
|
106
119
|
|
|
107
|
-
|
|
120
|
+
```sh
|
|
121
|
+
git-secret-protector setup-aes-key sample-app-dev
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### 1.5. Verify filter functionality
|
|
125
|
+
|
|
126
|
+
- Ensure that files are properly encrypted or decrypted by running:
|
|
108
127
|
|
|
109
|
-
```sh
|
|
110
|
-
git-secret-protector
|
|
111
|
-
```
|
|
128
|
+
```sh
|
|
129
|
+
git-secret-protector status
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The status will display the files managed by the filter and their encryption status.
|
|
112
133
|
|
|
113
134
|
### 2. Installation Steps for Team Members
|
|
114
135
|
|
|
115
136
|
#### 2.1. Pull AES Key and IV
|
|
116
137
|
|
|
138
|
+
**Notes**
|
|
117
139
|
Before encrypting or decrypting files, it's necessary to retrieve the relevant AES keys from the Cloud Secret Storage Service for filters:
|
|
118
140
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
141
|
+
- Command to pull AES key
|
|
142
|
+
```sh
|
|
143
|
+
git-secret-protector pull-aes-key <filter_name>
|
|
144
|
+
```
|
|
122
145
|
|
|
123
146
|
This command fetches the latest AES data key and IV from the Cloud Secret Storage Service for the designated filter and caches them locally for subsequent operations. This step ensures that you have the correct keys for encryption or decryption tasks related to the specified filter.
|
|
124
147
|
|
|
125
148
|
#### 2.2. Configure Git Filters
|
|
126
149
|
|
|
127
|
-
Set up the Git clean and smudge filters base on the filters defined in the `.gitattributes` file.
|
|
150
|
+
- Set up the Git clean and smudge filters base on the filters defined in the `.gitattributes` file.
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
git-secret-protector setup-filters
|
|
154
|
+
```
|
|
128
155
|
|
|
129
|
-
|
|
130
|
-
git-secret-protector setup-filters
|
|
131
|
-
```
|
|
156
|
+
Refer to [1.2. Configure Git Filters](#12-configure-git-filters) for instructions to verify if filters have been configured properly.
|
|
132
157
|
|
|
133
158
|
#### 2.2. Decrypt secret files
|
|
134
159
|
|
|
135
|
-
|
|
160
|
+
- Command to decrypt secret files:
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
git-secret-protector decrypt-files <filter_name>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 3. Common Usages
|
|
167
|
+
|
|
168
|
+
#### 3.1. Add a File to a filter's managed list
|
|
169
|
+
|
|
170
|
+
- **Add the file**
|
|
171
|
+
|
|
172
|
+
Update the `.gitattributes` file to include the file under a path that matches a filter pattern. For example, to add `live/dev/secret.auto.tfvars`, update the `.gitattributes` file as follows:
|
|
136
173
|
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
```
|
|
174
|
+
```text
|
|
175
|
+
live/dev/secret*.auto.tfvars filter=sample-app-dev diff=sample-app-dev
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
- **Encrypt the file**
|
|
140
179
|
|
|
141
|
-
|
|
180
|
+
Use the following command to encrypt the file under the specified filter:
|
|
142
181
|
|
|
143
|
-
|
|
182
|
+
```sh
|
|
183
|
+
git-secret-protector encrypt-files <filter>
|
|
184
|
+
```
|
|
185
|
+
Replace `<filter>` with the name of the filter (e.g., `sample-app-dev`).
|
|
186
|
+
|
|
187
|
+
- **Verify encryption**
|
|
188
|
+
|
|
189
|
+
Confirm that the file has been encrypted by running:
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
git-secret-protector status
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Sample output
|
|
196
|
+
```
|
|
197
|
+
Filter: sample-app-dev
|
|
198
|
+
./live/dev/secrets.auto.tfvars: Encrypted
|
|
199
|
+
./config/slack/secrets.tf: Encrypted
|
|
200
|
+
Filter: sample-app-prod
|
|
201
|
+
...
|
|
202
|
+
```
|
|
144
203
|
|
|
145
|
-
|
|
204
|
+
- **Review before creating pull requests**
|
|
146
205
|
|
|
147
|
-
|
|
148
|
-
git-secret-protector status
|
|
149
|
-
```
|
|
206
|
+
Inspect the pull request to ensure encrypted files are included. Verify everything is correct before clicking the `Create pull request` button.
|
|
150
207
|
|
|
151
208
|
#### 3.2. Key Rotation
|
|
152
209
|
|
|
@@ -164,7 +221,7 @@ In case you need to rotate the AES key due to security reasons or a team member
|
|
|
164
221
|
- Update the local cache.
|
|
165
222
|
|
|
166
223
|
|
|
167
|
-
- Post-Rotation Code Reset
|
|
224
|
+
- Post-Rotation Code Reset
|
|
168
225
|
|
|
169
226
|
After rotating the keys, it is necessary to clear the Git cache and re-checkout all files. This step ensures that the smudge filters are triggered, allowing the files to be decrypted with the new key.
|
|
170
227
|
|
|
@@ -178,7 +235,7 @@ In case you need to rotate the AES key due to security reasons or a team member
|
|
|
178
235
|
|
|
179
236
|
### 4. Logging
|
|
180
237
|
|
|
181
|
-
Logs are stored in the
|
|
238
|
+
Logs are stored in the `.git_secret_protector/logs/` directory by default, and you can configure the log level and file rotation in the `config.ini` file.
|
|
182
239
|
|
|
183
240
|
## Development
|
|
184
241
|
|
|
@@ -192,7 +249,6 @@ Logs are stored in the `logs/` directory by default, and you can configure the l
|
|
|
192
249
|
|
|
193
250
|
- **Integration Tests**: Located in the `tests/integration` directory, these tests interact with Secret Store in cloud and should be run manually.
|
|
194
251
|
|
|
195
|
-
|
|
196
252
|
```sh
|
|
197
253
|
poetry run pytest tests/integration
|
|
198
254
|
```
|
|
@@ -211,30 +267,29 @@ If you encounter any issues while using the `git-secret-protector` tool, try the
|
|
|
211
267
|
|
|
212
268
|
If the filters are not configured correctly, you might encounter errors when encrypting or decrypting files.
|
|
213
269
|
|
|
214
|
-
**Solution**:
|
|
270
|
+
- **Solution**:
|
|
215
271
|
Re-setup the filters based on your `.gitattributes` file.
|
|
216
272
|
|
|
217
|
-
```sh
|
|
218
|
-
git-secret-protector setup-filters
|
|
219
|
-
```
|
|
273
|
+
```sh
|
|
274
|
+
git-secret-protector setup-filters
|
|
275
|
+
```
|
|
220
276
|
|
|
221
277
|
#### 2. Missing or Incorrect AES Key
|
|
222
278
|
|
|
223
|
-
If you fail to encrypt or decrypt files due to a missing or incorrect AES key, you will need to ensure that the keys are
|
|
224
|
-
correctly fetched from the Cloud Secret Storage Service.
|
|
279
|
+
If you fail to encrypt or decrypt files due to a missing or incorrect AES key, you will need to ensure that the keys are correctly fetched from the Cloud Secret Storage Service.
|
|
225
280
|
|
|
226
|
-
**Solution**:
|
|
281
|
+
- **Solution**:
|
|
227
282
|
Pull the latest AES keys from the Cloud Secret Storage Service for the relevant filters.
|
|
228
283
|
|
|
229
|
-
```sh
|
|
230
|
-
git-secret-protector pull-aes-key <filter_name>
|
|
231
|
-
```
|
|
284
|
+
```sh
|
|
285
|
+
git-secret-protector pull-aes-key <filter_name>
|
|
286
|
+
```
|
|
232
287
|
|
|
233
288
|
#### 3. Permissions Issues
|
|
234
289
|
|
|
235
290
|
Lack of necessary permissions can result in errors while accessing Cloud Secret Storage Services.
|
|
236
291
|
|
|
237
|
-
**Solution**:
|
|
292
|
+
- **Solution**:
|
|
238
293
|
Ensure that you have the required permissions to manage resources in your Cloud Secret Storage Service.
|
|
239
294
|
|
|
240
295
|
### Example Issue: File Decryption Failure
|
|
@@ -244,24 +299,23 @@ You receive an error when trying to decrypt files using the `decrypt-files` comm
|
|
|
244
299
|
|
|
245
300
|
**Solution**:
|
|
246
301
|
|
|
247
|
-
|
|
302
|
+
- Ensure that you have pulled the latest AES keys:
|
|
248
303
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
304
|
+
```sh
|
|
305
|
+
git-secret-protector pull-aes-key <filter_name>
|
|
306
|
+
```
|
|
252
307
|
|
|
253
|
-
|
|
308
|
+
- Check if the filters are correctly set up:
|
|
254
309
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
310
|
+
```sh
|
|
311
|
+
git-secret-protector setup-filters
|
|
312
|
+
```
|
|
258
313
|
|
|
259
|
-
|
|
314
|
+
- Attempt to decrypt the files again:
|
|
260
315
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
316
|
+
```sh
|
|
317
|
+
git-secret-protector decrypt-files <filter_name>
|
|
318
|
+
```
|
|
264
319
|
|
|
265
|
-
If the issue persists, verify your configurations in the `config.ini` file, and consult the logs located in the `logs/`
|
|
266
|
-
directory for more detailed error information.
|
|
320
|
+
If the issue persists, verify your configurations in the `config.ini` file, and consult the logs located in the `logs/` directory for more detailed error information.
|
|
267
321
|
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
- pipx ([Download](https://pipx.pypa.io/stable/installation/))
|
|
16
16
|
|
|
17
|
-
You can install the `git-secret-protector` module via pipx:
|
|
17
|
+
- You can install the `git-secret-protector` module via pipx:
|
|
18
18
|
|
|
19
|
-
```sh
|
|
20
|
-
pipx install git-secret-protector
|
|
21
|
-
```
|
|
19
|
+
```sh
|
|
20
|
+
pipx install git-secret-protector
|
|
21
|
+
```
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
@@ -26,28 +26,36 @@ pipx install git-secret-protector
|
|
|
26
26
|
|
|
27
27
|
#### 1.1. Create .gitattributes file
|
|
28
28
|
|
|
29
|
-
Create a `.gitattributes` file in the root of your repository to define which files should be encrypted.
|
|
30
|
-
|
|
31
|
-
Sample `.gitattributes` file:
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
dev/secrets* filter=sample-app-dev diff=sample-app-dev
|
|
29
|
+
- Create a `.gitattributes` file in the root of your repository to define which files should be encrypted.
|
|
35
30
|
|
|
36
|
-
|
|
31
|
+
Sample `.gitattributes` file:
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
```
|
|
34
|
+
dev/secrets* filter=sample-app-dev diff=sample-app-dev
|
|
35
|
+
|
|
36
|
+
prod/secrets* filter=sample-app-prod diff=sample-app-prod
|
|
37
|
+
|
|
38
|
+
.gitattributes !filter !diff
|
|
39
|
+
```
|
|
40
40
|
|
|
41
41
|
#### 1.2. Configure Git Filters
|
|
42
42
|
|
|
43
|
-
Set up the Git clean and smudge filters base on the filters defined in the `.gitattributes` file.
|
|
43
|
+
- Set up the Git clean and smudge filters base on the filters defined in the `.gitattributes` file.
|
|
44
44
|
|
|
45
|
-
```sh
|
|
46
|
-
git-secret-protector setup-filters
|
|
47
|
-
```
|
|
45
|
+
```sh
|
|
46
|
+
git-secret-protector setup-filters
|
|
47
|
+
```
|
|
48
48
|
|
|
49
49
|
This command will configure the Git clean and smudge filters based on the patterns defined in the `.gitattributes` file. The filters will automatically encrypt and decrypt files based on the specified patterns.
|
|
50
50
|
|
|
51
|
+
- You can verify the configured filters in the `.git/config` file, for example:
|
|
52
|
+
|
|
53
|
+
```ini
|
|
54
|
+
[filter "sample-app-dev"]
|
|
55
|
+
clean = git-secret-protector encrypt sample-app-dev
|
|
56
|
+
smudge = git-secret-protector decrypt sample-app-dev
|
|
57
|
+
required = true
|
|
58
|
+
```
|
|
51
59
|
|
|
52
60
|
#### 1.3. Configuration
|
|
53
61
|
|
|
@@ -79,55 +87,104 @@ The `config.ini` file contains settings that customize the behavior of the `git-
|
|
|
79
87
|
|
|
80
88
|
#### 1.4. Set up AES key
|
|
81
89
|
|
|
90
|
+
**Notes:**
|
|
82
91
|
Before executing this command, ensure you have the necessary permissions to manage resources in the using Cloud Secret Storage Services.
|
|
83
92
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
```
|
|
93
|
+
- Command to set up AES key
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
git-secret-protector setup-aes-key <filter_name>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- Sample command to set up an AES key for the `sample-app-dev` filter:
|
|
87
100
|
|
|
88
|
-
|
|
101
|
+
```sh
|
|
102
|
+
git-secret-protector setup-aes-key sample-app-dev
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### 1.5. Verify filter functionality
|
|
106
|
+
|
|
107
|
+
- Ensure that files are properly encrypted or decrypted by running:
|
|
89
108
|
|
|
90
|
-
```sh
|
|
91
|
-
git-secret-protector
|
|
92
|
-
```
|
|
109
|
+
```sh
|
|
110
|
+
git-secret-protector status
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The status will display the files managed by the filter and their encryption status.
|
|
93
114
|
|
|
94
115
|
### 2. Installation Steps for Team Members
|
|
95
116
|
|
|
96
117
|
#### 2.1. Pull AES Key and IV
|
|
97
118
|
|
|
119
|
+
**Notes**
|
|
98
120
|
Before encrypting or decrypting files, it's necessary to retrieve the relevant AES keys from the Cloud Secret Storage Service for filters:
|
|
99
121
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
122
|
+
- Command to pull AES key
|
|
123
|
+
```sh
|
|
124
|
+
git-secret-protector pull-aes-key <filter_name>
|
|
125
|
+
```
|
|
103
126
|
|
|
104
127
|
This command fetches the latest AES data key and IV from the Cloud Secret Storage Service for the designated filter and caches them locally for subsequent operations. This step ensures that you have the correct keys for encryption or decryption tasks related to the specified filter.
|
|
105
128
|
|
|
106
129
|
#### 2.2. Configure Git Filters
|
|
107
130
|
|
|
108
|
-
Set up the Git clean and smudge filters base on the filters defined in the `.gitattributes` file.
|
|
131
|
+
- Set up the Git clean and smudge filters base on the filters defined in the `.gitattributes` file.
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
git-secret-protector setup-filters
|
|
135
|
+
```
|
|
109
136
|
|
|
110
|
-
|
|
111
|
-
git-secret-protector setup-filters
|
|
112
|
-
```
|
|
137
|
+
Refer to [1.2. Configure Git Filters](#12-configure-git-filters) for instructions to verify if filters have been configured properly.
|
|
113
138
|
|
|
114
139
|
#### 2.2. Decrypt secret files
|
|
115
140
|
|
|
116
|
-
|
|
141
|
+
- Command to decrypt secret files:
|
|
142
|
+
|
|
143
|
+
```sh
|
|
144
|
+
git-secret-protector decrypt-files <filter_name>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 3. Common Usages
|
|
148
|
+
|
|
149
|
+
#### 3.1. Add a File to a filter's managed list
|
|
150
|
+
|
|
151
|
+
- **Add the file**
|
|
152
|
+
|
|
153
|
+
Update the `.gitattributes` file to include the file under a path that matches a filter pattern. For example, to add `live/dev/secret.auto.tfvars`, update the `.gitattributes` file as follows:
|
|
117
154
|
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
```
|
|
155
|
+
```text
|
|
156
|
+
live/dev/secret*.auto.tfvars filter=sample-app-dev diff=sample-app-dev
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
- **Encrypt the file**
|
|
121
160
|
|
|
122
|
-
|
|
161
|
+
Use the following command to encrypt the file under the specified filter:
|
|
123
162
|
|
|
124
|
-
|
|
163
|
+
```sh
|
|
164
|
+
git-secret-protector encrypt-files <filter>
|
|
165
|
+
```
|
|
166
|
+
Replace `<filter>` with the name of the filter (e.g., `sample-app-dev`).
|
|
167
|
+
|
|
168
|
+
- **Verify encryption**
|
|
169
|
+
|
|
170
|
+
Confirm that the file has been encrypted by running:
|
|
171
|
+
|
|
172
|
+
```sh
|
|
173
|
+
git-secret-protector status
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Sample output
|
|
177
|
+
```
|
|
178
|
+
Filter: sample-app-dev
|
|
179
|
+
./live/dev/secrets.auto.tfvars: Encrypted
|
|
180
|
+
./config/slack/secrets.tf: Encrypted
|
|
181
|
+
Filter: sample-app-prod
|
|
182
|
+
...
|
|
183
|
+
```
|
|
125
184
|
|
|
126
|
-
|
|
185
|
+
- **Review before creating pull requests**
|
|
127
186
|
|
|
128
|
-
|
|
129
|
-
git-secret-protector status
|
|
130
|
-
```
|
|
187
|
+
Inspect the pull request to ensure encrypted files are included. Verify everything is correct before clicking the `Create pull request` button.
|
|
131
188
|
|
|
132
189
|
#### 3.2. Key Rotation
|
|
133
190
|
|
|
@@ -145,7 +202,7 @@ In case you need to rotate the AES key due to security reasons or a team member
|
|
|
145
202
|
- Update the local cache.
|
|
146
203
|
|
|
147
204
|
|
|
148
|
-
- Post-Rotation Code Reset
|
|
205
|
+
- Post-Rotation Code Reset
|
|
149
206
|
|
|
150
207
|
After rotating the keys, it is necessary to clear the Git cache and re-checkout all files. This step ensures that the smudge filters are triggered, allowing the files to be decrypted with the new key.
|
|
151
208
|
|
|
@@ -159,7 +216,7 @@ In case you need to rotate the AES key due to security reasons or a team member
|
|
|
159
216
|
|
|
160
217
|
### 4. Logging
|
|
161
218
|
|
|
162
|
-
Logs are stored in the
|
|
219
|
+
Logs are stored in the `.git_secret_protector/logs/` directory by default, and you can configure the log level and file rotation in the `config.ini` file.
|
|
163
220
|
|
|
164
221
|
## Development
|
|
165
222
|
|
|
@@ -173,7 +230,6 @@ Logs are stored in the `logs/` directory by default, and you can configure the l
|
|
|
173
230
|
|
|
174
231
|
- **Integration Tests**: Located in the `tests/integration` directory, these tests interact with Secret Store in cloud and should be run manually.
|
|
175
232
|
|
|
176
|
-
|
|
177
233
|
```sh
|
|
178
234
|
poetry run pytest tests/integration
|
|
179
235
|
```
|
|
@@ -192,30 +248,29 @@ If you encounter any issues while using the `git-secret-protector` tool, try the
|
|
|
192
248
|
|
|
193
249
|
If the filters are not configured correctly, you might encounter errors when encrypting or decrypting files.
|
|
194
250
|
|
|
195
|
-
**Solution**:
|
|
251
|
+
- **Solution**:
|
|
196
252
|
Re-setup the filters based on your `.gitattributes` file.
|
|
197
253
|
|
|
198
|
-
```sh
|
|
199
|
-
git-secret-protector setup-filters
|
|
200
|
-
```
|
|
254
|
+
```sh
|
|
255
|
+
git-secret-protector setup-filters
|
|
256
|
+
```
|
|
201
257
|
|
|
202
258
|
#### 2. Missing or Incorrect AES Key
|
|
203
259
|
|
|
204
|
-
If you fail to encrypt or decrypt files due to a missing or incorrect AES key, you will need to ensure that the keys are
|
|
205
|
-
correctly fetched from the Cloud Secret Storage Service.
|
|
260
|
+
If you fail to encrypt or decrypt files due to a missing or incorrect AES key, you will need to ensure that the keys are correctly fetched from the Cloud Secret Storage Service.
|
|
206
261
|
|
|
207
|
-
**Solution**:
|
|
262
|
+
- **Solution**:
|
|
208
263
|
Pull the latest AES keys from the Cloud Secret Storage Service for the relevant filters.
|
|
209
264
|
|
|
210
|
-
```sh
|
|
211
|
-
git-secret-protector pull-aes-key <filter_name>
|
|
212
|
-
```
|
|
265
|
+
```sh
|
|
266
|
+
git-secret-protector pull-aes-key <filter_name>
|
|
267
|
+
```
|
|
213
268
|
|
|
214
269
|
#### 3. Permissions Issues
|
|
215
270
|
|
|
216
271
|
Lack of necessary permissions can result in errors while accessing Cloud Secret Storage Services.
|
|
217
272
|
|
|
218
|
-
**Solution**:
|
|
273
|
+
- **Solution**:
|
|
219
274
|
Ensure that you have the required permissions to manage resources in your Cloud Secret Storage Service.
|
|
220
275
|
|
|
221
276
|
### Example Issue: File Decryption Failure
|
|
@@ -225,23 +280,22 @@ You receive an error when trying to decrypt files using the `decrypt-files` comm
|
|
|
225
280
|
|
|
226
281
|
**Solution**:
|
|
227
282
|
|
|
228
|
-
|
|
283
|
+
- Ensure that you have pulled the latest AES keys:
|
|
229
284
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
285
|
+
```sh
|
|
286
|
+
git-secret-protector pull-aes-key <filter_name>
|
|
287
|
+
```
|
|
233
288
|
|
|
234
|
-
|
|
289
|
+
- Check if the filters are correctly set up:
|
|
235
290
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
291
|
+
```sh
|
|
292
|
+
git-secret-protector setup-filters
|
|
293
|
+
```
|
|
239
294
|
|
|
240
|
-
|
|
295
|
+
- Attempt to decrypt the files again:
|
|
241
296
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
297
|
+
```sh
|
|
298
|
+
git-secret-protector decrypt-files <filter_name>
|
|
299
|
+
```
|
|
245
300
|
|
|
246
|
-
If the issue persists, verify your configurations in the `config.ini` file, and consult the logs located in the `logs/`
|
|
247
|
-
directory for more detailed error information.
|
|
301
|
+
If the issue persists, verify your configurations in the `config.ini` file, and consult the logs located in the `logs/` directory for more detailed error information.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "git-secret-protector"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.3.0"
|
|
4
4
|
description = "A tool for managing secrets in Git with AWS Parameter Store integration."
|
|
5
5
|
authors = ["Duc Duong <duc.duong@c0x12c.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -8,17 +8,17 @@ packages = [{ include = "git_secret_protector", from = "src" }]
|
|
|
8
8
|
|
|
9
9
|
[tool.poetry.dependencies]
|
|
10
10
|
python = ">=3.10,<3.14"
|
|
11
|
-
boto3 = "^1.
|
|
12
|
-
pycryptodome = "^3.
|
|
13
|
-
google-cloud-secret-manager = "^2.
|
|
14
|
-
injector = "^0.
|
|
15
|
-
google-auth = "^2.
|
|
11
|
+
boto3 = "^1.43.27"
|
|
12
|
+
pycryptodome = "^3.23.0"
|
|
13
|
+
google-cloud-secret-manager = "^2.29.0"
|
|
14
|
+
injector = "^0.24.0"
|
|
15
|
+
google-auth = "^2.53.0"
|
|
16
16
|
|
|
17
17
|
[tool.poetry.group.dev.dependencies]
|
|
18
|
-
pytest = "^
|
|
18
|
+
pytest = "^9.0.3"
|
|
19
19
|
mock = "^5.1.0"
|
|
20
|
-
pyinstaller = "^6.
|
|
21
|
-
tomlkit = "^0.
|
|
20
|
+
pyinstaller = "^6.20.0"
|
|
21
|
+
tomlkit = "^0.15.0"
|
|
22
22
|
|
|
23
23
|
[tool.poetry.scripts]
|
|
24
24
|
git-secret-protector = "git_secret_protector.main:main"
|