API Reference

This document is for developers of furtive, it contains the API functions

Furtive Class

Furtive - File Integrity Verification System

class furtive.Furtive(base_dir, manifest_path)[source]

Bases: object

Furtive is an application which stores file state and allows users to verify the state in the future. Example use cases include file archives and file transport.

Parameters:
  • base_dir (str) – Base directory to use for the manifest. Can be a full or relative path.
  • manifest_path (str) – Path to the manifest file. Can be a full or relative path.
compare()[source]

Compare the hashes in the database with the current hashes of files on the file system.

Returns:Dictionary of added, deleted, and changed files.
Return type:dict
create()[source]

Create and save a new manifest.

The contents of the new Manfiest() will be saved to manifest_path.

Returns:None

Sub-Modules

Hasher

Manages the hashing of files

class furtive.hasher.HashDirectory(directory)[source]

Bases: object

Object to manage hashing files in a directory.

This object is responsible for walking the directory tree and adding each file to a list. Once the directory walk has compelted, each file path is passed to hash_task(). After each file has been hashed, this object will then create a Python dictionary of files with their associated hash.

Parameters:directory (str) – Path to directory containing files
Returns:Dictionary of file:hash
Return type:dict
hash_files()[source]

Orchestrates the discovery and hashing of files.

Note: This method only supports the md5 hashing algorithm

furtive.hasher.hash_task(file_path, hash_algorithm='md5')[source]

Responsible for hashing a file.

This function reads in the file file_path in small chuncks the size of the hash algorithm’s block size in order to avoid running out of memory. This means that this function should be able to read any file irregardless of the size.

Parameters:
Returns:

hash of file

Return type:

dict

Manifest

Manifest of files and their hashes

class furtive.manifest.Manifest(directory, manifest_file)[source]

Bases: object

Manifest of files and the associated hashes.

Parameters:
  • directory – directory which will serve as the root for the manifest. All files under the directory will be hashed and added to or compared with the manifest.
  • type – str
  • manifest_file – file location of the manifest file. This is the path which will be used for the create() and compare() methods. If the file exists, the create() method will overwrite it.
create()[source]

Creates a new manifest from the directory by calling furtive.hasher.HashDirectory() and placing the return dictionary in to Manifest.manifest.

is_empty()[source]

Determines if the manifest within memory is empty.

This simply checks to see if the manifest is None.

Returns:True if manifest is empty, False otherwise.
Return type:bool
load()[source]

Load a manifest from the manifest file.

This method will open the manfiest YAML file and load it in to the manifest object variable.

save()[source]

Save the manifest to the manifest file.

Open a YAML file and dump the contents of the manifest to it.