def parse_subject_label(row): '''Method returns the security label of executing subject given in the input file''' try: _id = row["object"] _owner = parse_owner(row) _readers = parse_readers(row) _writers = parse_writers(row) subject_label = Label(_owner, _readers, _writers) except KeyError as e: return None else: return subject_label
def parse_subject_label(json_file): '''Method returns the security label of executing subject given in the input file''' _input_data = json.load(open(json_file)) try: _owner = parse_owner(_input_data["source_file"]["label"]) _readers = parse_readers(_input_data["source_file"]["label"]) _writers = parse_writers(_input_data["source_file"]["label"]) subject_label = Label(_owner,_readers,_writers) except KeyError as e: return None else: return subject_label
def parse_output_file(row): _output_file = {} try: file = row _name = file["object"] _owner = parse_owner(file) _readers = parse_readers(file) _writers = parse_writers(file) _label = Label(_owner, _readers, _writers) _output_file[_name] = _label except KeyError as e: return None else: return _label
def parse_function_labels(row): _functions = {} try: function = row _name = function["object"] _owner = parse_owner(function) _readers = parse_readers(function) _writers = parse_writers(function) _label = Label(_owner, _readers, _writers) _functions[_name] = _label except KeyError as e: return None else: return _label
def parse_globals(row): '''Method returns a dictionary having global variables as key that is mapped to respective static label ''' _globals = {} try: glob = row _id = glob["object"] _owner = parse_owner(glob) _readers = parse_readers(glob) _writers = parse_writers(glob) _label = Label(_owner, _readers, _writers) _globals[_id] = _label except KeyError as e: return None else: return _label
def parse_output_file(json_file): _input_data = json.load(open(json_file)) _output_file = {} try: for file in _input_data["source_file"]["outputfile"]: _name = file["name"] _owner = parse_owner(file["label"]) _readers = parse_readers(file["label"]) _writers = parse_writers(file["label"]) _label = Label(_owner, _readers, _writers) _output_file[_name] = _label except KeyError as e: return None else: return _output_file
def parse_function_labels(json_file): _input_data = json.load(open(json_file)) _functions = {} try: for function in _input_data["source_file"]["function_label"]: _name = function["name"] _owner = parse_owner(function["label"]) _readers = parse_readers(function["label"]) _writers = parse_writers(function["label"]) _label = Label(_owner, _readers, _writers) _functions[_name] = _label except KeyError as e: return None else: return _functions
def parse_globals(json_file): '''Method returns a dictionary having global variables as key that is mapped to respective static label ''' _input_data = json.load(open(json_file)) _globals={} try: for globals in _input_data["source_file"]["global_vars"]: _id = globals["id"] _owner = parse_owner(globals["label"]) _readers = parse_readers(globals["label"]) _writers = parse_writers(globals["label"]) _label = Label(_owner,_readers,_writers) _globals[_id]=_label except KeyError as e: return None else: return _globals
def __init__(self): self._pc = Label('PC', ['*'], []) self._local = dict() self._downgraded_label = list()
def update_local_label_list(self, id, label_object): new_label = Label(label_object.get_owner(), label_object.get_readers(), label_object.get_writers()) self._local[id] = new_label
def set_pc_label(self, pc_label): self._pc = Label(pc_label.get_owner(), pc_label.get_readers(), pc_label.get_writers())