@@ -212,6 +212,9 @@ def on_config(self, config):
212
212
pattern = _resolve_pattern (project_config .site_dir )
213
213
self .exclusion_patterns .append (pattern )
214
214
215
+ # Track dotpath inclusion to inform about it later
216
+ contains_dotpath : bool = False
217
+
215
218
# Create self-contained example from project
216
219
files : list [str ] = []
217
220
with ZipFile (archive , "a" , ZIP_DEFLATED , False ) as f :
@@ -228,6 +231,11 @@ def on_config(self, config):
228
231
# Exclude the directory and all subdirectories
229
232
if self ._is_excluded (path ):
230
233
dirnames .remove (name )
234
+ continue
235
+
236
+ # Warn about .dotdirectories
237
+ if _is_dotpath (path , log_warning = True ):
238
+ contains_dotpath = True
231
239
232
240
# Write files to the in-memory archive
233
241
for name in filenames :
@@ -238,6 +246,10 @@ def on_config(self, config):
238
246
if self ._is_excluded (path ):
239
247
continue
240
248
249
+ # Warn about .dotfiles
250
+ if _is_dotpath (path , log_warning = True ):
251
+ contains_dotpath = True
252
+
241
253
# Resolve the relative path to create a matching structure
242
254
path = os .path .relpath (path , os .path .curdir )
243
255
f .write (path , os .path .join (example , path ))
@@ -278,8 +290,11 @@ def on_config(self, config):
278
290
279
291
# Retrieve list of processed files
280
292
for a in f .filelist :
293
+ # Highlight .dotpaths in a more explicit manner
294
+ color = (Fore .LIGHTYELLOW_EX if "/." in a .filename
295
+ else Fore .LIGHTBLACK_EX )
281
296
files .append ("" .join ([
282
- Fore . LIGHTBLACK_EX , a .filename , " " ,
297
+ color , a .filename , " " ,
283
298
_size (a .compress_size )
284
299
]))
285
300
@@ -309,6 +324,14 @@ def on_config(self, config):
309
324
if buffer .nbytes > 1000000 :
310
325
log .warning ("Archive exceeds recommended maximum size of 1 MB" )
311
326
327
+ # Print warning when file contains hidden .dotpaths
328
+ if contains_dotpath :
329
+ log .warning (
330
+ "Archive contains dotpaths, which could contain sensitive "
331
+ "information.\n Please review them at the bottom of the list "
332
+ "and share only necessary data to reproduce the issue."
333
+ )
334
+
312
335
# Aaaaaand done
313
336
sys .exit (1 )
314
337
@@ -488,6 +511,18 @@ def _get_project_config(project_config_file: str):
488
511
489
512
return config
490
513
514
+ # Check if the path is a .dotpath. A warning can also be issued when the param
515
+ # is set. The function also returns a boolean to track results outside it.
516
+ def _is_dotpath (path : str , log_warning : bool = False ) -> bool :
517
+ posix_path = _resolve_pattern (path , return_path = True )
518
+ name = posix_path .rstrip ("/" ).rsplit ("/" , 1 )[- 1 ]
519
+ if name .startswith ("." ):
520
+ if log_warning :
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