MCPcopy
hub / github.com/epinna/tplmap / read

Method read

core/plugin.py:570–599  ·  view source on GitHub ↗
(self, remote_path)

Source from the content-addressed store, hash-verified

568
569 """ Overridable function to read remote files. """
570 def read(self, remote_path):
571
572 action = self.actions.get('read', {})
573 payload = action.get('read')
574 call_name = action.get('call', 'render')
575
576 # Skip if something is missing or call function is not set
577 if not action or not payload or not call_name or not hasattr(self, call_name):
578 return
579
580 # Get remote file md5
581 md5_remote = self.md5(remote_path)
582
583 if not md5_remote:
584 log.warn('Error getting remote file md5, check presence and permission')
585 return
586
587 execution_code = payload % ({ 'path' : remote_path })
588
589 data_b64encoded = getattr(self, call_name)(
590 code = execution_code,
591 )
592 data = base64.b64decode(data_b64encoded)
593
594 if not md5(data) == md5_remote:
595 log.warn('Remote file md5 mismatch, check manually')
596 else:
597 log.info('File downloaded correctly')
598
599 return data
600
601 def write(self, data, remote_path):
602

Callers 7

forward_dataMethod · 0.80
check_template_injectionFunction · 0.80
test_downloadMethod · 0.80
test_uploadMethod · 0.80
test_upload_blindMethod · 0.80
test_downloadMethod · 0.80
test_downloadMethod · 0.80

Calls 3

md5Method · 0.95
md5Function · 0.90
getMethod · 0.80

Tested by 5

test_downloadMethod · 0.64
test_uploadMethod · 0.64
test_upload_blindMethod · 0.64
test_downloadMethod · 0.64
test_downloadMethod · 0.64