(self, path)
| 633 | return f'Replace lines in file <{path}> failed, error: ' + str(e) |
| 634 | |
| 635 | def get_real_path(self, path): |
| 636 | # Check if path is absolute or already starts with output_dir |
| 637 | if os.path.isabs(path): |
| 638 | target_path = path |
| 639 | elif path.startswith(self.output_dir + os.sep) or path.startswith( |
| 640 | self.output_dir): |
| 641 | # Path already includes output_dir as prefix |
| 642 | target_path = path |
| 643 | else: |
| 644 | target_path = os.path.join(self.output_dir, path) |
| 645 | target_path_real = os.path.realpath(target_path) |
| 646 | output_dir_real = os.path.realpath(self.output_dir) |
| 647 | is_in_output_dir = target_path_real.startswith( |
| 648 | output_dir_real + os.sep) or target_path_real == output_dir_real |
| 649 | |
| 650 | if not is_in_output_dir and not self.allow_read_all_files: |
| 651 | logger.warning( |
| 652 | f'Attempt to read file outside output directory blocked: {path} -> {target_path_real}' |
| 653 | ) |
| 654 | return None |
| 655 | else: |
| 656 | return target_path_real |
| 657 | |
| 658 | async def read_abbreviation_file(self, paths: list[str]): |
| 659 | results = {} |
no outgoing calls
no test coverage detected