libioc.SecureTarfile module

Secure tarfile wrapper that prevents extraction of insecure paths.

class libioc.SecureTarfile.SecureTarfile(file, compression_format=None, logger=None)[source]

Bases: object

Secure tarfile wrapper that mitigates extraction of unsafe paths.

extract(destination)[source]

Extract the tar file.

Parameters

destination (str) – Path to the archive file that is going to be extracted.

Return type

None

file_open_mode = 'r'
property mode

Return the file mode for opening the archive file.

Return type

str

libioc.SecureTarfile.extract(file, destination, compression_format=None, logger=None)[source]

Instantiate SecureTarfile and extract the archive files content.

Parameters
  • file (str) – Path to the source archive file.

  • destination (str) – Path to the extraction destination folder.

  • logger (libioc.Logger.Logger) – Logging is enabled when a Logger instance is provided.

Return type

None