def filter_write(process, file_descriptor, byte_count): if process.is_tracked_descriptor(file_descriptor): path = process.descriptor_path(file_descriptor) return "%s %s to %s" % (T.red("write"), T.bold( "%d bytes" % byte_count), T.underline(path)), byte_count else: return None, None
def format_write(file_descriptor, byte_count): if file_descriptor in file_descriptors: path = file_descriptors[file_descriptor] return "%s %s to %s" % (T.red("write"), T.bold( "%d bytes" % byte_count), T.underline(path)) else: return None
def format_open(path, flags): path = abspath(path) if path in allowed_files: return None elif (flags & O_CREAT) and not exists(path): return "%s %s" % (T.cyan("create file"), T.underline(path)) elif (flags & O_TRUNC) and exists(path): return "%s %s" % (T.red("truncate file"), T.underline(path)) else: return None
def filter_open(process, path, flags): if path in allowed_files: return None, None if (flags & O_CREAT) and not exists(path): operation = "%s %s" % (T.cyan("create file"), T.underline(path)) elif (flags & O_TRUNC) and exists(path): operation = "%s %s" % (T.red("truncate file"), T.underline(path)) else: operation = None if (flags & O_WRONLY) or (flags & O_RDWR) or (flags & O_APPEND) or (operation is not None): # File might be written to later, so we need to track the file descriptor return_value = process.register_path(path) else: return_value = None return operation, return_value
def filter_delete(path): return "%s %s" % (T.red("delete"), T.underline(path)), 0
def format_write(file_descriptor, byte_count): if file_descriptor in file_descriptors: path = file_descriptors[file_descriptor] return "%s %s to %s" % (T.red("write"), T.bold("%d bytes" % byte_count), T.underline(path)) else: return None
def filter_write(process, file_descriptor, byte_count): if process.is_tracked_descriptor(file_descriptor): path = process.descriptor_path(file_descriptor) return "%s %s to %s" % (T.red("write"), T.bold("%d bytes" % byte_count), T.underline(path)), byte_count else: return None, None
def format_delete(path): return "%s %s" % (T.red("delete"), T.underline(path))
def format_delete(path): return "%s %s" % (T.red("delete"), T.underline(abspath(path)))