secrez 2.1.9 β†’ 2.1.10

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.
package/README.md CHANGED
@@ -370,6 +370,12 @@ Secrez is not intended to compete with password managers, so do not expect it to
370
370
 
371
371
  ## History
372
372
 
373
+ **2.1.10**
374
+
375
+ - add external git change detection to block operations when repository state changes outside of Secrez (e.g., `git pull` in another terminal)
376
+ - fix critical cache bug in git conflict detection that prevented external changes from being detected within 30 seconds
377
+ - improve git conflict detection tests with comprehensive coverage for both git and non-git repositories
378
+
373
379
  **2.1.9**
374
380
 
375
381
  - add `<` parameter to reuse the last used path in commands (e.g., `totp <` will use the last path from previous command)
@@ -876,6 +882,66 @@ Thank you for any contributions! πŸ˜‰
876
882
  ## Test coverage
877
883
 
878
884
  ```
885
+ 162 passing (2m)
886
+ 2 pending
887
+
888
+ --------------------|---------|----------|---------|---------|--------------------------------------
889
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
890
+ --------------------|---------|----------|---------|---------|--------------------------------------
891
+ All files | 80.07 | 67.69 | 80.91 | 79.96 |
892
+ src | 57.62 | 53.75 | 55 | 58.11 |
893
+ Command.js | 74.66 | 74.13 | 78.57 | 75.67 | ...5-62,73,80,93,127,164-172,179-182
894
+ PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
895
+ cliConfig.js | 100 | 100 | 100 | 100 |
896
+ src/commands | 83.06 | 69.43 | 90.82 | 82.94 |
897
+ Alias.js | 88.6 | 78.68 | 100 | 88.46 | 101,112,139,169,173,180,190,213-214
898
+ Bash.js | 75 | 0 | 66.66 | 75 | 18-19
899
+ Cat.js | 98.91 | 88.88 | 100 | 98.91 | 152
900
+ Cd.js | 96.42 | 86.66 | 100 | 96.42 | 44
901
+ Conf.js | 8.64 | 0 | 20 | 8.64 | 98-509
902
+ Contacts.js | 86.06 | 75.6 | 100 | 85.95 | ...5,165,172,184,237,250,260,268-269
903
+ Copy.js | 91.2 | 71.92 | 100 | 91.11 | 115,166,183,205-210,225-226,253
904
+ Ds.js | 90.27 | 82.6 | 100 | 90.14 | 99,108-113,125,147-148
905
+ Edit.js | 12.94 | 0 | 40 | 12.94 | 88-222
906
+ Export.js | 90.17 | 76.92 | 100 | 90.17 | ...3-198,209,227-231,236,248,257,260
907
+ Find.js | 93.58 | 86.66 | 100 | 93.42 | 101,164,200-203,209
908
+ Git.js | 96.15 | 75 | 100 | 96.15 | 61
909
+ Help.js | 100 | 80 | 100 | 100 | 29
910
+ Import.js | 92.41 | 85.38 | 100 | 92.34 | ...7,387,393,441,457-458,466-473,500
911
+ Lcat.js | 100 | 85.71 | 100 | 100 | 54
912
+ Lcd.js | 95.65 | 81.81 | 100 | 95.65 | 50
913
+ Lls.js | 95.45 | 72.72 | 100 | 95.45 | 97
914
+ Lpwd.js | 92.3 | 100 | 100 | 92.3 | 36
915
+ Ls.js | 91.54 | 76.31 | 100 | 91.04 | 103,114-116,130,185
916
+ Mkdir.js | 92.59 | 60 | 100 | 92.59 | 56-57
917
+ Mv.js | 86.59 | 71.66 | 100 | 86.31 | 93-99,133,155-156,165,175-182
918
+ Paste.js | 84.61 | 70.83 | 100 | 84.61 | 72,78,81,89,113,130-131,139
919
+ Pwd.js | 92.3 | 100 | 100 | 92.3 | 33
920
+ Quit.js | 90 | 50 | 100 | 90 | 27
921
+ Rm.js | 90.9 | 76 | 100 | 90.74 | 63,125-126,136,144
922
+ Shell.js | 88.23 | 60 | 100 | 88.23 | 38,55
923
+ Show.js | 72.54 | 45.45 | 57.14 | 74 | ...8,100,106-114,117,123-126,132,145
924
+ Ssh.js | 25 | 0 | 40 | 25 | 72-120
925
+ Tag.js | 96.26 | 91.37 | 100 | 96.22 | 122,171,204-205
926
+ Totp.js | 92.23 | 75 | 100 | 92.23 | 189-190,230,240,282-287,301-302
927
+ Touch.js | 96.36 | 80.64 | 100 | 96.29 | 164,240
928
+ Use.js | 91.66 | 86.95 | 100 | 91.66 | 68,83-84
929
+ Ver.js | 90 | 66.66 | 100 | 90 | 25
930
+ Whoami.js | 83.33 | 60 | 80 | 83.33 | 27,35,48
931
+ index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
932
+ src/prompts | 75 | 33.33 | 50 | 75 |
933
+ MainPromptMock.js | 75 | 33.33 | 50 | 75 | 29-35,44
934
+ src/utils | 67.61 | 62.5 | 54.16 | 67.21 |
935
+ AliasManager.js | 100 | 91.66 | 100 | 100 | 47
936
+ ContactManager.js | 73.33 | 60 | 85.71 | 73.33 | 12,34-36
937
+ Fido2Client.js | 9.61 | 0 | 0 | 9.61 | 8-108
938
+ HelpProto.js | 89.07 | 82.6 | 100 | 88.88 | 49,135-137,153-154,171-176,195
939
+ Logger.js | 63.63 | 56.25 | 36.84 | 62.79 | ...25,37-49,57,65-69,74,84,88,93,105
940
+ --------------------|---------|----------|---------|---------|--------------------------------------
941
+
942
+ > secrez@2.1.10 posttest /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
943
+ > nyc check-coverage --statements 65 --branches 50 --functions 65 --lines 65
944
+
879
945
 
880
946
  ```
881
947
 
package/coverage.report CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- > secrez@2.1.9 test /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
2
+ > secrez@2.1.10 test /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
3
3
  > cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.test.js test/**/*.test.js test/**/**/*.js --exit
4
4
 
5
5
 
@@ -15,10 +15,6 @@
15
15
  #validate
16
16
  βœ“ should validate the options
17
17
 
18
- #Fido2Client
19
- #configuration
20
- βœ“ should verify that all the scripts exist
21
-
22
18
  #Alias
23
19
  βœ“ should return the help
24
20
  βœ“ create aliases and lists them
@@ -29,10 +25,10 @@
29
25
  #Cat
30
26
  βœ“ should return the help
31
27
  βœ“ should show the content of a file
32
- βœ“ should show either one or all the versions of a file (1019ms)
28
+ βœ“ should show either one or all the versions of a file (1028ms)
33
29
  βœ“ should throw if entry is not a file or file does not exist
34
30
  βœ“ should throw if trying to cat a binary file
35
- βœ“ should show the content of a Yaml file (1028ms)
31
+ βœ“ should show the content of a Yaml file (1021ms)
36
32
 
37
33
  #Cd
38
34
  βœ“ should return the help
@@ -51,6 +47,257 @@
51
47
 
52
48
  #Copy
53
49
  βœ“ should return the help
54
- βœ“ should copy a file to the clipboard (406ms)
55
- βœ“ should copy a string to the clipboard (261ms)
56
-  ELIFECYCLE  Test failed. See above for more details.
50
+ βœ“ should copy a file to the clipboard (415ms)
51
+ βœ“ should copy a string to the clipboard (268ms)
52
+ βœ“ should copy a card to the clipboard (1021ms)
53
+ βœ“ should return an error if the file does not exist or is a folder (125ms)
54
+ βœ“ should throw if copying to clipboard a binary files
55
+
56
+ #Ds
57
+ βœ“ should return the help
58
+ βœ“ should list all datasets
59
+ βœ“ should create a new dataset
60
+ βœ“ should rename a dataset
61
+ βœ“ should delete a dataset
62
+
63
+ #Export
64
+ βœ“ should return the help
65
+ βœ“ should export a file to the current local folder
66
+ βœ“ should export a file encrypted only for the user itself
67
+ βœ“ should export a binary file to the current local folder
68
+ βœ“ should export an encrypted file to the current local folder
69
+ βœ“ should export a file and delete it after 1 second (1203ms)
70
+ βœ“ should return an error if the file does not exist or is a folder
71
+ βœ“ should export a keystore json file if a private_key exists in the entry (763ms)
72
+ βœ“ should export a cryptoenv file if a private_key exists in the entry
73
+ βœ“ should export a cryptoenv file with entire content when no private_key fields exist and user confirms
74
+ βœ“ should throw error when no private_key fields exist and user declines
75
+ βœ“ should throw error when no private_key fields exist and keystore option is used
76
+ βœ“ should display encrypted content in console when using crypto-env with no-export
77
+
78
+ #Find
79
+ βœ“ should return the help
80
+ βœ“ should show find a string in the tree (1021ms)
81
+ βœ“ should find no result without parameters
82
+ βœ“ should skip binary files from search
83
+
84
+ #Git
85
+ βœ“ should return the help
86
+ βœ“ should show git status when --status is used (3518ms)
87
+ βœ“ should show git status by default (3580ms)
88
+ βœ“ should handle conflict risk scenario (5428ms)
89
+ βœ“ should handle non-git repository
90
+ βœ“ should allow normal operations in non-git repository
91
+ Bye bye :o)
92
+ βœ“ should detect external git changes and block operations (16546ms)
93
+
94
+ #Help
95
+ βœ“ should return the help
96
+ βœ“ #execAsync and format
97
+ βœ“ should throw if wrong command
98
+ βœ“ -- to complete coverage
99
+
100
+ #Import
101
+ βœ“ should return the help
102
+ βœ“ should import a file in the current folder
103
+ βœ“ should import an encrypted file
104
+ βœ“ should import an encrypted file encrypted for myself
105
+ βœ“ should import an encrypted binary file and export it again verifying it is fine
106
+ βœ“ should import files recursively
107
+ βœ“ should read a folder and import the only text file
108
+ βœ“ should read a folder and import text and binary files
109
+ βœ“ should simulate the import of two files
110
+ βœ“ should move the imported file
111
+ βœ“ should import a backup from another software spanning the data among folders and files
112
+ βœ“ should import a backup from another software but saving the tags as tags
113
+ βœ“ should import a backup from another software using tags to prefix the paths
114
+ βœ“ should import using tags to prefix the paths, ignoring the tags
115
+ βœ“ should import from a LastPass-like csv setting the path from "grouping" and "name"
116
+ βœ“ should import from a json
117
+ βœ“ should throw importing a malformed backup
118
+ βœ“ should throw importing a CSV indicating wrong fields to generate the path
119
+
120
+ #Lcat
121
+ βœ“ should return the help
122
+ βœ“ cat a file
123
+ βœ“ return en error if trying to cat a binary file
124
+
125
+ #Lcd
126
+ βœ“ should return the help
127
+ βœ“ change to a folder
128
+ βœ“ return en error if changing to a file
129
+
130
+ #Lls
131
+ βœ“ should return the help
132
+ βœ“ should list a folder
133
+ βœ“ return en error if lls-ing a not existing path
134
+ βœ“ return a message if no files are found
135
+
136
+ #Lpwd
137
+ βœ“ should return the help
138
+ βœ“ change to a folder
139
+
140
+ #Ls
141
+ βœ“ should return the help
142
+ βœ“ should return all the datasets
143
+ βœ“ should list folders and files
144
+ βœ“ should list folders and files using wildcards
145
+
146
+ #Mkdir
147
+ βœ“ should return the help
148
+ βœ“ should create a folder
149
+ βœ“ should create a nested folder
150
+ βœ“ should throw if trying to create a child of a file
151
+ βœ“ should throw if wrong parameters
152
+
153
+ #Mv
154
+ βœ“ should return the help
155
+ βœ“ should rename a file (1014ms)
156
+ βœ“ should move a file to another folder
157
+ βœ“ should move many files to another folder
158
+ βœ“ should move a file to another subfolder
159
+ βœ“ should move and rename file to another folder
160
+ βœ“ should move file to another folder using wildcards
161
+ βœ“ should move file to another dataset using wildcards
162
+ βœ“ should move file managing duplicates
163
+ βœ“ should throw if parameters are missed or wrong
164
+ βœ“ should move files from and to other datasets (1047ms)
165
+ βœ“ should move the results of a find
166
+
167
+ #Paste
168
+ βœ“ should return the help
169
+ βœ“ should paste the clipboard content to a new file (50ms)
170
+ βœ“ should paste the clipboard content to an existent file (94ms)
171
+ βœ“ should paste a single field to a yml card (71ms)
172
+
173
+ #Pwd
174
+ βœ“ should return the help
175
+ βœ“ should show the working folder
176
+
177
+ #Quit
178
+ βœ“ should show the content of an external file via bash
179
+
180
+ #Rm
181
+ βœ“ should return the help
182
+ βœ“ should delete a file with one version
183
+ βœ“ should delete many files usign wildcards
184
+ βœ“ should return errors if wrong parameters
185
+ βœ“ should delete some versions of a file (1007ms)
186
+
187
+ #Shell
188
+ βœ“ should return the help
189
+ βœ“ should show the content of an external file via shell
190
+
191
+ #Show
192
+ βœ“ should return the help
193
+ βœ“ should show the field password of a card
194
+
195
+ #Tag
196
+ βœ“ should return the help
197
+ βœ“ should tag a file
198
+ βœ“ should remove a tag
199
+ βœ“ should list all the tags
200
+ βœ“ should show the file tagged as
201
+ βœ“ should show very long file tagged as
202
+
203
+ #Totp
204
+ βœ“ should return the help
205
+ βœ“ should totp a file to the clipboard (409ms)
206
+ βœ“ should read a totp secret from an image and add the totp field to the card (39ms)
207
+ βœ“ should read a totp secret from an image and return the secret
208
+ βœ“ should throw if bad image
209
+ βœ“ should throw if missing parameters
210
+ βœ“ should throw if the yaml is malformed
211
+ βœ“ should read a totp secret from the clipboard (186ms)
212
+
213
+ #Touch
214
+ βœ“ should return the help
215
+ βœ“ should create a file
216
+ βœ“ should create a file with content
217
+ βœ“ should duplicate a file
218
+ βœ“ should throw if trying to duplicate a non existing file
219
+ βœ“ should throw if trying to duplicate a folder
220
+ βœ“ should throw if trying to create a child of a file
221
+ βœ“ should throw if wrong parameters
222
+ βœ“ should create a file and generate a wallet
223
+ New file "/folder2/file1" created.
224
+ βœ“ should generate 5 prefixed wallet (65ms)
225
+ New file "/folder2/file1" created.
226
+ βœ“ should generate a wallet with mnemonic and 2 keys
227
+
228
+ #Use
229
+ βœ“ should return the help
230
+ βœ“ should use a new dataset, creating it if does not exist
231
+
232
+ #Ver
233
+ βœ“ should show the current version
234
+
235
+ #Whoami
236
+ βœ“ should return the help
237
+ βœ“ should see who am I
238
+
239
+ #Fido2Client
240
+ #configuration
241
+ - should verify that all the scripts exist
242
+
243
+
244
+ 162 passing (2m)
245
+ 2 pending
246
+
247
+ --------------------|---------|----------|---------|---------|--------------------------------------
248
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
249
+ --------------------|---------|----------|---------|---------|--------------------------------------
250
+ All files | 80.07 | 67.69 | 80.91 | 79.96 |
251
+ src | 57.62 | 53.75 | 55 | 58.11 |
252
+ Command.js | 74.66 | 74.13 | 78.57 | 75.67 | ...5-62,73,80,93,127,164-172,179-182
253
+ PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
254
+ cliConfig.js | 100 | 100 | 100 | 100 |
255
+ src/commands | 83.06 | 69.43 | 90.82 | 82.94 |
256
+ Alias.js | 88.6 | 78.68 | 100 | 88.46 | 101,112,139,169,173,180,190,213-214
257
+ Bash.js | 75 | 0 | 66.66 | 75 | 18-19
258
+ Cat.js | 98.91 | 88.88 | 100 | 98.91 | 152
259
+ Cd.js | 96.42 | 86.66 | 100 | 96.42 | 44
260
+ Conf.js | 8.64 | 0 | 20 | 8.64 | 98-509
261
+ Contacts.js | 86.06 | 75.6 | 100 | 85.95 | ...5,165,172,184,237,250,260,268-269
262
+ Copy.js | 91.2 | 71.92 | 100 | 91.11 | 115,166,183,205-210,225-226,253
263
+ Ds.js | 90.27 | 82.6 | 100 | 90.14 | 99,108-113,125,147-148
264
+ Edit.js | 12.94 | 0 | 40 | 12.94 | 88-222
265
+ Export.js | 90.17 | 76.92 | 100 | 90.17 | ...3-198,209,227-231,236,248,257,260
266
+ Find.js | 93.58 | 86.66 | 100 | 93.42 | 101,164,200-203,209
267
+ Git.js | 96.15 | 75 | 100 | 96.15 | 61
268
+ Help.js | 100 | 80 | 100 | 100 | 29
269
+ Import.js | 92.41 | 85.38 | 100 | 92.34 | ...7,387,393,441,457-458,466-473,500
270
+ Lcat.js | 100 | 85.71 | 100 | 100 | 54
271
+ Lcd.js | 95.65 | 81.81 | 100 | 95.65 | 50
272
+ Lls.js | 95.45 | 72.72 | 100 | 95.45 | 97
273
+ Lpwd.js | 92.3 | 100 | 100 | 92.3 | 36
274
+ Ls.js | 91.54 | 76.31 | 100 | 91.04 | 103,114-116,130,185
275
+ Mkdir.js | 92.59 | 60 | 100 | 92.59 | 56-57
276
+ Mv.js | 86.59 | 71.66 | 100 | 86.31 | 93-99,133,155-156,165,175-182
277
+ Paste.js | 84.61 | 70.83 | 100 | 84.61 | 72,78,81,89,113,130-131,139
278
+ Pwd.js | 92.3 | 100 | 100 | 92.3 | 33
279
+ Quit.js | 90 | 50 | 100 | 90 | 27
280
+ Rm.js | 90.9 | 76 | 100 | 90.74 | 63,125-126,136,144
281
+ Shell.js | 88.23 | 60 | 100 | 88.23 | 38,55
282
+ Show.js | 72.54 | 45.45 | 57.14 | 74 | ...8,100,106-114,117,123-126,132,145
283
+ Ssh.js | 25 | 0 | 40 | 25 | 72-120
284
+ Tag.js | 96.26 | 91.37 | 100 | 96.22 | 122,171,204-205
285
+ Totp.js | 92.23 | 75 | 100 | 92.23 | 189-190,230,240,282-287,301-302
286
+ Touch.js | 96.36 | 80.64 | 100 | 96.29 | 164,240
287
+ Use.js | 91.66 | 86.95 | 100 | 91.66 | 68,83-84
288
+ Ver.js | 90 | 66.66 | 100 | 90 | 25
289
+ Whoami.js | 83.33 | 60 | 80 | 83.33 | 27,35,48
290
+ index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
291
+ src/prompts | 75 | 33.33 | 50 | 75 |
292
+ MainPromptMock.js | 75 | 33.33 | 50 | 75 | 29-35,44
293
+ src/utils | 67.61 | 62.5 | 54.16 | 67.21 |
294
+ AliasManager.js | 100 | 91.66 | 100 | 100 | 47
295
+ ContactManager.js | 73.33 | 60 | 85.71 | 73.33 | 12,34-36
296
+ Fido2Client.js | 9.61 | 0 | 0 | 9.61 | 8-108
297
+ HelpProto.js | 89.07 | 82.6 | 100 | 88.88 | 49,135-137,153-154,171-176,195
298
+ Logger.js | 63.63 | 56.25 | 36.84 | 62.79 | ...25,37-49,57,65-69,74,84,88,93,105
299
+ --------------------|---------|----------|---------|---------|--------------------------------------
300
+
301
+ > secrez@2.1.10 posttest /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
302
+ > nyc check-coverage --statements 65 --branches 50 --functions 65 --lines 65
303
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secrez",
3
- "version": "2.1.9",
3
+ "version": "2.1.10",
4
4
  "license": "MIT",
5
5
  "nyc": {
6
6
  "include": "src",
@@ -10,7 +10,7 @@
10
10
  "@secrez/core": "~1.0.5",
11
11
  "@secrez/crypto": "~1.0.4",
12
12
  "@secrez/eth": "~0.0.4",
13
- "@secrez/fs": "~1.0.6",
13
+ "@secrez/fs": "~1.0.7",
14
14
  "@secrez/utils": "~1.0.4",
15
15
  "case": "^1.6.3",
16
16
  "chalk": "^3.0.0",
package/src/Command.js CHANGED
@@ -152,7 +152,15 @@ class Command extends PreCommand {
152
152
  // Show the warning message
153
153
  this.Logger.yellow(conflictCheck.message);
154
154
 
155
- // Ask user if they want to continue
155
+ // If bypass is not allowed (e.g., external changes detected), block the operation
156
+ if (!conflictCheck.allowBypass) {
157
+ this.Logger.grey(
158
+ "Operation blocked for data integrity. Please quit and re-enter Secrez."
159
+ );
160
+ return false;
161
+ }
162
+
163
+ // Otherwise, ask user if they want to continue
156
164
  const shouldContinue = await this.useInput({
157
165
  type: "confirm",
158
166
  message: "Do you want to continue anyway?",
package/src/Welcome.js CHANGED
@@ -250,38 +250,46 @@ Thanks.`);
250
250
  }
251
251
 
252
252
  async handleDeprecatedFido2() {
253
- Logger.yellow("FIDO2 second factor authentication is no longer supported in this version.");
253
+ Logger.yellow(
254
+ "FIDO2 second factor authentication is no longer supported in this version."
255
+ );
254
256
  Logger.grey("Removing deprecated FIDO2 configuration...");
255
-
257
+
256
258
  try {
257
259
  const conf = await this.secrez.readConf();
258
260
  const data = conf.data;
259
-
261
+
260
262
  if (data.keys) {
261
263
  // Remove all FIDO2 keys from the configuration
262
264
  delete data.keys;
263
-
265
+
264
266
  // Save the cleaned configuration
265
267
  await this.secrez.saveConf(conf);
266
-
268
+
267
269
  Logger.green("FIDO2 configuration has been removed successfully.");
268
270
  Logger.grey("You can now login with your master password only.");
269
-
271
+
270
272
  // Try to login again with the cleaned configuration
271
273
  let errorCode = await this.login();
272
274
  if (errorCode === 1) {
273
- Logger.red("Login still failed. Please check your password or create a new account.");
275
+ Logger.red(
276
+ "Login still failed. Please check your password or create a new account."
277
+ );
274
278
  // eslint-disable-next-line no-process-exit
275
279
  process.exit(1);
276
280
  }
277
281
  } else {
278
- Logger.red("No FIDO2 keys found, but login still requires second factor. This may indicate a corrupted configuration.");
282
+ Logger.red(
283
+ "No FIDO2 keys found, but login still requires second factor. This may indicate a corrupted configuration."
284
+ );
279
285
  // eslint-disable-next-line no-process-exit
280
286
  process.exit(1);
281
287
  }
282
288
  } catch (e) {
283
289
  Logger.red(`Failed to clean FIDO2 configuration: ${e.message}`);
284
- Logger.grey("You may need to manually remove the keys.json file and create a new account.");
290
+ Logger.grey(
291
+ "You may need to manually remove the keys.json file and create a new account."
292
+ );
285
293
  // eslint-disable-next-line no-process-exit
286
294
  process.exit(1);
287
295
  }