(self, blob: Union[bytes, str], context: Context)
| 71 | yield self.__export_blob(context.node.value, context) |
| 72 | |
| 73 | def __export_blob(self, blob: Union[bytes, str], context: Context) -> ScanLocation: |
| 74 | tmp_dir = tempfile.mkdtemp(prefix="aura_pkg__sandbox_blob_") |
| 75 | file_pth = os.path.join(tmp_dir, "blob") |
| 76 | |
| 77 | location = context.visitor.location.create_child( |
| 78 | parent=context.visitor.location, |
| 79 | new_location=tmp_dir, |
| 80 | cleanup=True, |
| 81 | strip_path=tmp_dir |
| 82 | ) |
| 83 | location.metadata["source"] = "blob" |
| 84 | location.metadata["parent_line"] = context.node.line_no |
| 85 | |
| 86 | if type(blob) == str: |
| 87 | mode = "w" |
| 88 | else: |
| 89 | mode = "wb" |
| 90 | |
| 91 | with open(file_pth, mode) as fd: |
| 92 | fd.write(blob) |
| 93 | fd.flush() |
| 94 | |
| 95 | return location |
| 96 | |
| 97 | |
| 98 | @Analyzer.ID("string_finder") |
no test coverage detected