@@ -214,12 +214,16 @@ def on_config(self, config):
214
214
215
215
# Create self-contained example from project
216
216
files : list [str ] = []
217
+ dotpaths : list [str ] = []
217
218
with ZipFile (archive , "a" , ZIP_DEFLATED , False ) as f :
218
219
for abs_root , dirnames , filenames in os .walk (os .getcwd ()):
219
220
# Set and print progress indicator
220
221
indicator = f"Processing: { abs_root } "
221
222
print (indicator , end = "\r " , flush = True )
222
223
224
+ # Track warning to decide if the indicator should be cleared
225
+ warned = False
226
+
223
227
# Prune the folders in-place to prevent their processing
224
228
for name in list (dirnames ):
225
229
# Resolve the absolute directory path
@@ -228,6 +232,12 @@ def on_config(self, config):
228
232
# Exclude the directory and all subdirectories
229
233
if self ._is_excluded (path ):
230
234
dirnames .remove (name )
235
+ continue
236
+
237
+ # Warn about .dotdirectories
238
+ if _warn_on_dotpath (path ):
239
+ warned = True
240
+ dotpaths .append (path )
231
241
232
242
# Write files to the in-memory archive
233
243
for name in filenames :
@@ -238,12 +248,18 @@ def on_config(self, config):
238
248
if self ._is_excluded (path ):
239
249
continue
240
250
251
+ # Warn about .dotfiles
252
+ if _warn_on_dotpath (path ):
253
+ warned = True
254
+ dotpaths .append (path )
255
+
241
256
# Resolve the relative path to create a matching structure
242
257
path = os .path .relpath (path , os .path .curdir )
243
258
f .write (path , os .path .join (example , path ))
244
259
245
260
# Clear the line for the next indicator
246
- print (" " * len (indicator ), end = "\r " , flush = True )
261
+ if not warned :
262
+ print (" " * len (indicator ), end = "\r " , flush = True )
247
263
248
264
# Add information on installed packages
249
265
f .writestr (
@@ -309,6 +325,16 @@ def on_config(self, config):
309
325
if buffer .nbytes > 1000000 :
310
326
log .warning ("Archive exceeds recommended maximum size of 1 MB" )
311
327
328
+ # Print warning when file contains hidden .dotpaths
329
+ if dotpaths :
330
+ print ("List of potentially sensitive files:" )
331
+ for path in dotpaths :
332
+ print (f" - { path } " )
333
+ log .warning (
334
+ "Archive contains potentially sensitive dotfiles.\n Please "
335
+ "review and share only necessary data to reproduce the issue."
336
+ )
337
+
312
338
# Aaaaaand done
313
339
sys .exit (1 )
314
340
@@ -488,6 +514,15 @@ def _get_project_config(project_config_file: str):
488
514
489
515
return config
490
516
517
+ # Check if the path is a .dotpath, and issue a warning when that is the case.
518
+ # The function also returns a boolean to track results outside it.
519
+ def _warn_on_dotpath (path : str ) -> bool :
520
+ if path .rsplit (os .sep , 1 )[- 1 ].startswith ("." ):
521
+ log .warning (f"The following .dotpath will be included: { path } " )
522
+ return True
523
+ return False
524
+
525
+
491
526
# -----------------------------------------------------------------------------
492
527
# Data
493
528
# -----------------------------------------------------------------------------
0 commit comments