Ejemplo n.º 1
0
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
Ejemplo n.º 2
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
def filter_delete(path):
    return "%s %s" % (T.red("delete"), T.underline(path)), 0
Ejemplo n.º 7
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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
def filter_delete(path):
    return "%s %s" % (T.red("delete"), T.underline(path)), 0
Ejemplo n.º 10
0
def format_delete(path):
    return "%s %s" % (T.red("delete"), T.underline(path))
Ejemplo n.º 11
0
def format_delete(path):
    return "%s %s" % (T.red("delete"), T.underline(abspath(path)))