(self, path, intermediate)
| 457 | return self.type == PARAM_TYPE_SERVER_FILE and self.file_recursive |
| 458 | |
| 459 | def _validate_recursive_path(self, path, intermediate): |
| 460 | value_string = self.value_to_str(path) |
| 461 | |
| 462 | if not isinstance(path, list): |
| 463 | return 'should be a list, but was: ' + value_string + '(' + str(type(path)) + ')' |
| 464 | |
| 465 | if ('.' in path) or ('..' in path): |
| 466 | return 'Relative path references are not allowed' |
| 467 | |
| 468 | full_path = self._build_list_file_path(path) |
| 469 | |
| 470 | if self.excluded_files_matcher.has_match(full_path): |
| 471 | return 'Path ' + value_string + ' is excluded' |
| 472 | |
| 473 | if not os.path.exists(full_path): |
| 474 | return 'Path ' + value_string + ' does not exist' |
| 475 | |
| 476 | if intermediate: |
| 477 | if not os.access(full_path, os.R_OK): |
| 478 | return 'Path ' + value_string + ' not accessible' |
| 479 | |
| 480 | if not os.path.isdir(full_path): |
| 481 | return 'Path ' + value_string + ' is not a directory' |
| 482 | |
| 483 | else: |
| 484 | dir = path[:-1] |
| 485 | file = path[-1] |
| 486 | |
| 487 | dir_path = self._build_list_file_path(dir) |
| 488 | allowed_files = model_helper.list_files(dir_path, |
| 489 | file_type=self.file_type, |
| 490 | file_extensions=self.file_extensions, |
| 491 | excluded_files_matcher=self.excluded_files_matcher) |
| 492 | if file not in allowed_files: |
| 493 | return 'Path ' + value_string + ' is not allowed' |
| 494 | |
| 495 | def _build_list_file_path(self, child_path): |
| 496 | return os.path.normpath(os.path.join(self._list_files_dir, *child_path)) |
no test coverage detected