@@ -212,6 +212,9 @@ def on_config(self, config):
212212 pattern = _resolve_pattern (project_config .site_dir )
213213 self .exclusion_patterns .append (pattern )
214214
215+ # Track dotpath inclusion to inform about it later
216+ contains_dotpath : bool = False
217+
215218 # Create self-contained example from project
216219 files : list [str ] = []
217220 with ZipFile (archive , "a" , ZIP_DEFLATED , False ) as f :
@@ -228,6 +231,11 @@ def on_config(self, config):
228231 # Exclude the directory and all subdirectories
229232 if self ._is_excluded (path ):
230233 dirnames .remove (name )
234+ continue
235+
236+ # Warn about .dotdirectories
237+ if _is_dotpath (path , log_warning = True ):
238+ contains_dotpath = True
231239
232240 # Write files to the in-memory archive
233241 for name in filenames :
@@ -238,6 +246,10 @@ def on_config(self, config):
238246 if self ._is_excluded (path ):
239247 continue
240248
249+ # Warn about .dotfiles
250+ if _is_dotpath (path , log_warning = True ):
251+ contains_dotpath = True
252+
241253 # Resolve the relative path to create a matching structure
242254 path = os .path .relpath (path , os .path .curdir )
243255 f .write (path , os .path .join (example , path ))
@@ -278,8 +290,11 @@ def on_config(self, config):
278290
279291 # Retrieve list of processed files
280292 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 )
281296 files .append ("" .join ([
282- Fore . LIGHTBLACK_EX , a .filename , " " ,
297+ color , a .filename , " " ,
283298 _size (a .compress_size )
284299 ]))
285300
@@ -309,6 +324,14 @@ def on_config(self, config):
309324 if buffer .nbytes > 1000000 :
310325 log .warning ("Archive exceeds recommended maximum size of 1 MB" )
311326
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+
312335 # Aaaaaand done
313336 sys .exit (1 )
314337
@@ -488,6 +511,18 @@ def _get_project_config(project_config_file: str):
488511
489512 return config
490513
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+
491526# -----------------------------------------------------------------------------
492527# Data
493528# -----------------------------------------------------------------------------
0 commit comments