index
int64
repo_name
string
branch_name
string
path
string
content
string
import_graph
string
12,138
g2-inc/openc2-oif-orchestrator
refs/heads/master
/base/modules/utils/root/sb_utils/message/pysmile/encode.py
#!/usr/bin/env python """ SMILE Encode """ import copy import decimal import logging import struct from typing import ( Callable, Dict, Type, Union ) from . import util from .constants import ( BYTE_MARKER_END_OF_CONTENT, BYTE_MARKER_END_OF_STRING, HEADER_BIT_HAS_RAW_BINARY, HEADER_BIT_HAS_SHARED_NAMES, HEADER_BIT_HAS_SHARED_STRING_VALUES, HEADER_BYTE_1, HEADER_BYTE_2, HEADER_BYTE_3, HEADER_BYTE_4, MAX_SHARED_NAMES, MAX_SHARED_STRING_LENGTH_BYTES, MAX_SHARED_STRING_VALUES, MAX_SHORT_NAME_ASCII_BYTES, MAX_SHORT_NAME_UNICODE_BYTES, MAX_SHORT_VALUE_STRING_BYTES, TOKEN_BYTE_BIG_DECIMAL, TOKEN_BYTE_BIG_INTEGER, TOKEN_BYTE_FLOAT_32, TOKEN_BYTE_FLOAT_64, TOKEN_BYTE_INT_32, TOKEN_BYTE_INT_64, TOKEN_BYTE_LONG_STRING_ASCII, TOKEN_KEY_EMPTY_STRING, TOKEN_KEY_LONG_STRING, TOKEN_LITERAL_EMPTY_STRING, TOKEN_LITERAL_END_ARRAY, TOKEN_LITERAL_END_OBJECT, TOKEN_LITERAL_FALSE, TOKEN_LITERAL_NULL, TOKEN_LITERAL_START_ARRAY, TOKEN_LITERAL_START_OBJECT, TOKEN_LITERAL_TRUE, TOKEN_MISC_BINARY_7BIT, TOKEN_MISC_BINARY_RAW, TOKEN_MISC_LONG_TEXT_ASCII, TOKEN_PREFIX_KEY_ASCII, TOKEN_PREFIX_KEY_SHARED_LONG, TOKEN_PREFIX_KEY_SHARED_SHORT, TOKEN_PREFIX_SHARED_STRING_LONG, TOKEN_PREFIX_SHARED_STRING_SHORT, TOKEN_PREFIX_SMALL_INT, TOKEN_PREFIX_TINY_ASCII ) log = logging.getLogger() if not log.handlers: log.addHandler(logging.NullHandler()) def _utf_8_encode(s): try: return s.encode("UTF-8") except UnicodeEncodeError: return s class SMILEEncodeError(Exception): pass class SharedStringNode: """ Helper class used for keeping track of possibly shareable String references (for field names and/or short String values) """ def __init__(self, value, index, nxt): self.value = value self.index = index self.next = nxt class SmileEncoder: """ To simplify certain operations, we require output buffer length to allow outputting of contiguous 256 character UTF-8 encoded String value. Length of the longest UTF-8 code point (from Java char) is 3 bytes, and we need both initial token byte and single-byte end marker so we get following value. Note: actually we could live with shorter one; absolute minimum would be for encoding 64-character Strings. """ _encoders: Dict[Type, Callable] def __init__(self, shared_keys: bool = True, shared_values: bool = True, encode_as_7bit: bool = True): """ SmileEncoder Initializer :param encode_as_7bit: (optional - Default: `True`) Encode raw data as 7-bit :param shared_keys: (optional - Default: `True`) Shared Key String References :param shared_values: (optional - Default: `True`) Shared Value String References """ # Encoded data self.output = bytearray() # Shared Key Strings self.shared_keys = [] # Shared Value Strings self.shared_values = [] self.share_keys = bool(shared_keys) self.share_values = bool(shared_values) self.encode_as_7bit = bool(encode_as_7bit) # Encoder Switch self._encoders = { bool: lambda b: self.write_true() if b else self.write_false(), dict: self._encode_dict, float: self.write_number, int: self.write_number, list: self._encode_array, str: self.write_string, tuple: self._encode_array, set: self._encode_array, None: self.write_null } def write_header(self) -> None: """ Method that can be called to explicitly write Smile document header. Note that usually you do not need to call this for first document to output, but rather only if you intend to write multiple root-level documents with same generator (and even in that case this is optional thing to do). As a result usually only {@link SmileFactory} calls this method. """ last = HEADER_BYTE_4 if self.share_keys: last |= HEADER_BIT_HAS_SHARED_NAMES if self.share_values: last |= HEADER_BIT_HAS_SHARED_STRING_VALUES if not self.encode_as_7bit: last |= HEADER_BIT_HAS_RAW_BINARY self.write_bytes(HEADER_BYTE_1, HEADER_BYTE_2, HEADER_BYTE_3, int(last)) def write_ender(self) -> None: """ Write optional end marker (BYTE_MARKER_END_OF_CONTENT - 0xFF) """ self.write_byte(BYTE_MARKER_END_OF_CONTENT) # Encoding writers def write_7bit_binary(self, data: Union[bytes, str], offset: int = 0) -> None: l = len(data) self.write_positive_vint(l) while l >= 7: i = data[offset] offset += 1 for x in range(1, 7): self.write_byte(int((i >> x) & 0x7F)) i = (i << 8) | (data[offset + x] & 0xFF) offset += 1 self.write_bytes(int((i >> 7) & 0x7F), int(i & 0x7F)) l -= 7 # and then partial piece, if any if l > 0: i = data[offset] offset += 1 self.write_byte(int(i >> 1) & 0x7F) if l > 1: i = ((i & 0x01) << 8) | (data[offset] & 0xFF) offset += 1 # 2nd self.write_byte(int(i >> 2) & 0x7F) if l > 2: i = ((i & 0x03) << 8) | (data[offset] & 0xFF) offset += 1 # 3rd self.write_byte(int(i >> 3) & 0x7F) if l > 3: i = ((i & 0x07) << 8) | (data[offset] & 0xFF) offset += 1 # 4th self.write_byte(int(i >> 4) & 0x7F) if l > 4: i = ((i & 0x0F) << 8) | (data[offset] & 0xFF) offset += 1 # 5th self.write_byte(int(i >> 5) & 0x7F) if l > 5: i = ((i & 0x1F) << 8) | (data[offset] & 0xFF) offset += 1 # 6th self.write_byte(int(i >> 6) & 0x7F) self.write_byte(int(i & 0x3F)) # last 6 bits else: self.write_byte(int(i & 0x1F)) # last 5 bits else: self.write_byte(int(i & 0x0F)) # last 4 bits else: self.write_byte(int(i & 0x07)) # last 3 bits else: self.write_byte(int(i & 0x03)) # last 2 bits else: self.write_byte(int(i & 0x01)) # last bit def write_big_number(self, i: str) -> None: """ Write Big Number :param i: Big Number """ if i is None: self.write_null() else: self.write_byte(TOKEN_BYTE_BIG_INTEGER) self.write_7bit_binary(bytearray(str(i))) def write_binary(self, data: bytes) -> None: """ Write Data :param data: Data """ if data is None: self.write_null() return if self.encode_as_7bit: self.write_byte(TOKEN_MISC_BINARY_7BIT) self.write_7bit_binary(data) else: self.write_byte(TOKEN_MISC_BINARY_RAW) self.write_positive_vint(len(data)) self.write_bytes(data) def write_boolean(self, state: bool) -> None: """ Write Boolean :param state: Bool state """ self.write_byte(state and TOKEN_LITERAL_TRUE or TOKEN_LITERAL_FALSE) def write_byte(self, c: Union[bytes, int, str]) -> None: """ Write byte :param c: byte """ if isinstance(c, (bytearray, bytes)): pass elif isinstance(c, str): c = c.encode("utf-8") elif isinstance(c, float): c = str(c) elif isinstance(c, int): c = struct.pack("B", c) else: raise ValueError(f"Invalid type for param 'c' - {type(c)}!") self.output.extend(c) def write_bytes(self, *args: Union[bytes, int, str]) -> None: """ Write bytes :param args: args """ for arg in args: self.write_byte(arg) def write_decimal_number(self, num: str) -> None: """ Write decimal :param num: String of a decimal number """ if num is None: self.write_null() else: self.write_number(decimal.Decimal(num)) def write_end_array(self) -> None: """ Write end array token """ self.write_byte(TOKEN_LITERAL_END_ARRAY) def write_end_object(self) -> None: """ Write end object token """ self.write_byte(TOKEN_LITERAL_END_OBJECT) def write_false(self) -> None: """ Write True Value """ self.write_byte(TOKEN_LITERAL_FALSE) def write_field_name(self, name: Union[bytes, str]) -> None: """ Write Field Name :param name: Name """ str_len = len(name) if not name: self.write_byte(TOKEN_KEY_EMPTY_STRING) return # First: is it something we can share? if self.share_keys: ix = self._find_seen_name(name) if ix >= 0: self.write_shared_name_reference(ix) return if str_len > MAX_SHORT_NAME_UNICODE_BYTES: # can not be a 'short' String; off-line (rare case) self.write_non_short_field_name(name) return if str_len <= MAX_SHORT_NAME_ASCII_BYTES: self.write_bytes(int((TOKEN_PREFIX_KEY_ASCII - 1) + str_len), name) else: self.write_bytes(TOKEN_KEY_LONG_STRING, name, BYTE_MARKER_END_OF_STRING) if self.share_keys: self._add_seen_name(name) def write_integral_number(self, num: str, neg: bool = False) -> None: """ Write Int :param num: String of an integral number :param neg: Is the value negative """ if num is None: self.write_null() else: num_len = len(num) if neg: num_len -= 1 # try: if num_len <= 18: self.write_number(int(num)) else: self.write_big_number(num) def write_non_shared_string(self, text: Union[bytes, str]) -> None: """ Helper method called to handle cases where String value to write is known to be long enough not to be shareable :param text: Text """ if len(text) <= MAX_SHORT_VALUE_STRING_BYTES: self.write_bytes(int(TOKEN_PREFIX_TINY_ASCII - 1) + len(text), text) else: self.write_bytes(TOKEN_MISC_LONG_TEXT_ASCII, text, BYTE_MARKER_END_OF_STRING) def write_non_short_field_name(self, name: str) -> None: """ Write nonshort field name :param name: Name """ self.write_byte(TOKEN_KEY_LONG_STRING) try: utf_8_name = name.encode("utf-8") except UnicodeEncodeError: utf_8_name = name self.write_bytes(utf_8_name) if self.share_keys: self._add_seen_name(name) self.write_byte(BYTE_MARKER_END_OF_STRING) def write_null(self) -> None: """ Generated source for method writeNull """ self.write_byte(TOKEN_LITERAL_NULL) def write_number(self, num: Union[int, float, str, decimal.Decimal]) -> None: """ Write Number :param num: number """ def w_decimal(d: Union[float, decimal.Decimal]) -> None: if isinstance(d, decimal.Decimal): self.write_byte(TOKEN_BYTE_BIG_DECIMAL) scale = d.as_tuple().exponent self.write_signed_vint(scale) self.write_7bit_binary(bytearray(str(d.to_integral_value()))) else: try: d = util.float_to_bits(d) self.write_bytes( TOKEN_BYTE_FLOAT_32, int(d & 0x7F), *[(d >> 7*i) & 0x7F for i in range(1, 5)] ) except struct.error: d = util.float_to_raw_long_bits(d) self.write_bytes( TOKEN_BYTE_FLOAT_64, int(d & 0x7F), *[(d >> 7*i) & 0x7F for i in range(1, 10)] ) def w_int(i: int) -> None: # First things first: let's zigzag encode number i = util.zigzag_encode(i) if util.is_int32(i): # tiny (single byte) or small (type + 6-bit value) number? if 0x3F >= i >= 0: if i <= 0x1F: self.write_byte(int(TOKEN_PREFIX_SMALL_INT + i)) else: # nope, just small, 2 bytes (type, 1-byte zigzag value) for 6 bit value self.write_bytes(TOKEN_BYTE_INT_32, int(0x80 + i)) return # Ok: let's find minimal representation then b0 = int(0x80 + (i & 0x3F)) i >>= 6 if i <= 0x7F: # 13 bits is enough (== 3 byte total encoding) self.write_bytes(TOKEN_BYTE_INT_32, int(i), b0) return b1 = int(i & 0x7F) i >>= 7 if i <= 0x7F: self.write_bytes(TOKEN_BYTE_INT_32, int(i), b1, b0) return b2 = int(i & 0x7F) i >>= 7 if i <= 0x7F: self.write_bytes(TOKEN_BYTE_INT_32, int(i), b2, b1, b0) return # no, need all 5 bytes b3 = int(i & 0x7F) self.write_bytes(TOKEN_BYTE_INT_32, int(i >> 7), b3, b2, b1, b0) else: # 4 can be extracted from lower int b0 = int(0x80 + (i & 0x3F)) # sign bit set in the last byte b1 = int((i >> 6) & 0x7F) b2 = int((i >> 13) & 0x7F) b3 = int((i >> 20) & 0x7F) # fifth one is split between ints: i = util.bsr(i, 27) b4 = int(i & 0x7F) # which may be enough? i = int(i >> 7) if i == 0: self.write_bytes(TOKEN_BYTE_INT_64, b4, b3, b2, b1, b0) return if i <= 0x7F: self.write_bytes(TOKEN_BYTE_INT_64, int(i), b4, b3, b2, b1, b0) return b5 = int(i & 0x7F) i >>= 7 if i <= 0x7F: self.write_bytes(TOKEN_BYTE_INT_64, int(i), b5, b4, b3, b2, b1, b0) return b6 = int(i & 0x7F) i >>= 7 if i <= 0x7F: self.write_bytes(TOKEN_BYTE_INT_64, int(i), b6, b5, b4, b3, b2, b1, b0) return b7 = int((i & 0x7F)) i >>= 7 if i <= 0x7F: self.write_bytes(TOKEN_BYTE_INT_64, int(i), b7, b6, b5, b4, b3, b2, b1, b0) return b8 = int(i & 0x7F) i >>= 7 # must be done, with 10 bytes! (9 * 7 + 6 == 69 bits; only need 63) self.write_bytes(TOKEN_BYTE_INT_64, int(i), b8, b7, b6, b5, b4, b3, b2, b1, b0) def w_str(s: str) -> None: if not s: self.write_null() else: s = s.strip("-") if s.isdigit(): self.write_integral_number(s, s.startswith("-")) else: self.write_decimal_number(s) writer = { float: w_decimal, int: w_int, str: w_str, decimal.Decimal: w_decimal }.get(type(num), None) if writer: writer(num) def write_positive_vint(self, i: int) -> None: """ Helper method for writing a 32-bit positive (really 31-bit then) value Value is NOT zigzag encoded (since there is no sign bit to worry about) :param i: Int """ # At most 5 bytes (4 * 7 + 6 bits == 34 bits) b0 = int(0x80 + (i & 0x3F)) i >>= 6 if i <= 0x7F: # 6 or 13 bits is enough (== 2 or 3 byte total encoding) if i > 0: self.write_byte(int(i)) self.write_byte(b0) return b1 = int(i & 0x7F) i >>= 7 if i <= 0x7F: self.write_bytes(int(i), b1, b0) else: b2 = int(i & 0x7F) i >>= 7 if i <= 0x7F: self.write_bytes(int(i), b2, b1, b0) else: b3 = int(i & 0x7F) self.write_bytes(int(i >> 7), b3, b2, b1, b0) def write_start_array(self) -> None: """ Write start array token """ self.write_byte(TOKEN_LITERAL_START_ARRAY) def write_start_object(self) -> None: """ Write start object token """ self.write_byte(TOKEN_LITERAL_START_OBJECT) def write_shared_name_reference(self, ix: int) -> None: """ Write Shared Name Ref :param ix: Index """ if ix >= len(self.shared_keys) - 1: raise ValueError(f"Trying to write shared name with index {ix} but have only seen {len(self.shared_keys)}!") if ix < 64: self.write_byte(int(TOKEN_PREFIX_KEY_SHARED_SHORT + ix)) else: self.write_bytes(int(TOKEN_PREFIX_KEY_SHARED_LONG + (ix >> 8)), int(ix)) def write_shared_string_value_reference(self, ix: int) -> None: """ Write shared string :param int ix: Index """ if ix > len(self.shared_values) - 1: raise ValueError(f"Internal error: trying to write shared String value with index {ix}; but have only seen {len(self.shared_values)} so far!") if ix < 31: # add 1, as byte 0 is omitted self.write_byte(TOKEN_PREFIX_SHARED_STRING_SHORT + 1 + ix) else: self.write_bytes(TOKEN_PREFIX_SHARED_STRING_LONG + (ix >> 8), int(ix)) def write_signed_vint(self, i: int) -> None: """ Helper method for writing 32-bit signed value, using "zig zag encoding" (see protocol buffers for explanation -- basically, sign bit is moved as LSB, rest of value shifted left by one) coupled with basic variable length encoding :param i: Signed int """ self.write_positive_vint(util.zigzag_encode(i)) def write_string(self, text: str) -> None: """ Write String :param text: String text """ if text is None: self.write_null() return if not text: self.write_byte(TOKEN_LITERAL_EMPTY_STRING) return # Longer string handling off-lined if len(text) > MAX_SHARED_STRING_LENGTH_BYTES: self.write_non_shared_string(text) return # Then: is it something we can share? if self.share_values: ix = self._find_seen_string_value(text) if ix >= 0: self.write_shared_string_value_reference(ix) return if len(text) <= MAX_SHORT_VALUE_STRING_BYTES: if self.share_values: self._add_seen_string_value(text) self.write_bytes(int(TOKEN_PREFIX_TINY_ASCII - 1) + len(text), text) else: self.write_bytes(TOKEN_BYTE_LONG_STRING_ASCII, text, BYTE_MARKER_END_OF_STRING) def write_string_field(self, name: str, value: str) -> None: """ Write String Field :param name: Name :param value: Value """ self.write_field_name(name) self.write_string(value) def write_true(self) -> None: """ Write True Value """ self.write_byte(TOKEN_LITERAL_TRUE) # Helper methods def _add_seen_name(self, name: Union[bytes, str]) -> None: # if self.seen_name_count == len(self.shared_keys): if self.shared_keys: if len(self.shared_keys) == MAX_SHARED_NAMES: # self.seen_name_count = 0 self.shared_keys = [None] * len(self.shared_keys) else: old = copy.copy(self.shared_keys) self.shared_keys = [None] * MAX_SHARED_NAMES mask = MAX_SHARED_NAMES - 1 for node in old: while node: ix = util.hash_string(node.value) & mask next_node = node.next try: node.next = self.shared_keys[ix] except IndexError: node.next = None self.shared_keys[ix] = node node = next_node # ref = self.seen_name_count if _is_valid_back_ref(len(self.shared_keys)): ix = util.hash_string(name) & (len(self.shared_keys) - 1) self.shared_keys[ix] = SharedStringNode(name, ref, self.shared_keys[ix]) # self.seen_name_count = ref + 1 def _add_seen_string_value(self, text: str) -> None: # if self.seen_string_count == len(self.shared_values): if self.shared_values: if self.seen_string_count == MAX_SHARED_STRING_VALUES: self.seen_string_count = 0 self.shared_values = [None] * len(self.shared_values) else: old = copy.copy(self.shared_values) self.shared_values = [None] * MAX_SHARED_STRING_VALUES mask = MAX_SHARED_STRING_VALUES - 1 for node in old: while node: ix = util.hash_string(node.value) & mask next_node = node.next try: node.next = self.shared_values[ix] except IndexError: node.next = None self.shared_values[ix] = node node = next_node # ref = self.seen_string_count if _is_valid_back_ref(len(self.shared_values)): ix = util.hash_string(text) & (len(self.shared_values) - 1) self.shared_values[ix] = SharedStringNode(text, ref, self.shared_values[ix]) # self.seen_string_count = ref + 1 def _find_seen_name(self, name: Union[bytes, str]) -> int: n_hash = util.hash_string(name) try: head = self.shared_keys[n_hash & (len(self.shared_keys) - 1)] except IndexError: return -1 if head is None: return -1 if head.value is name: return head.index node = head while node: if node.value is name: return node.index node = node.next node = head while node: if node.value == name and util.hash_string(node.value) == n_hash: return node.index node = node.next def _find_seen_string_value(self, text: str) -> int: hash_ = util.hash_string(text) try: head = self.shared_values[hash_ & (len(self.shared_values) - 1)] except IndexError: return -1 if head is None: return -1 node = head while node: if node.value is text: return node.index node = node.next node = head while node: if util.hash_string(node.value) == hash_ and node.value == text: return node.index node = node.next # Actual encoding def _encode_array(self, arr: Union[list, tuple, set]) -> None: self.write_start_array() for idx in arr: self._iter_encode(idx) self.write_end_array() def _encode_dict(self, d: dict) -> None: self.write_start_object() for k, v in d.items(): if k is None: k = "null" elif isinstance(k, bool): k = "true" if k else "false" elif isinstance(k, int): k = str(k) elif isinstance(k, float): k = self._floatstr(k) elif not isinstance(k, str): raise TypeError(f"Key {k} is not a string") self.write_field_name(k) self._iter_encode(v) self.write_end_object() def _floatstr(self, flt: float) -> str: """ Convert a Python float into a JSON float string :param float flt: Floating point number :returns: JSON String representation of the float :rtype: str """ _inf = float("inf") if flt != flt: text = "NaN" elif flt == _inf: text = "Infinity" elif flt == -_inf: text = "-Infinity" else: return repr(flt) return text def _iter_encode(self, obj: Union[dict, list, set, tuple]) -> None: encoder = self._encoders.get(type(obj), None) if encoder: encoder(obj) else: self._iter_encode(obj) def encode(self, py_obj: Union[dict, list, set, tuple], header: bool = True, ender: bool = False) -> bytes: """ SMILE Encode object :param dict|list|set|tuple py_obj: The object to be encoded :param bool header: (optional - Default: `True`) :param bool ender: (optional - Default: `False`) :returns: SMILE encoded data """ if isinstance(py_obj, (set, tuple)): py_obj = list(py_obj) elif not isinstance(py_obj, (dict, list)): raise ValueError(f"Invalid type for 'obj' paramater. Must be one of dict, list, set, or tuple; given {type(py_obj)}") if header: self.write_header() self._iter_encode(py_obj) if ender: self.write_ender() return bytes(self.output) @classmethod def encode_obj(cls, py_obj: Union[list, dict], header: bool = True, ender: bool = False, shared_keys: bool = True, shared_vals: bool = True, bin_7bit: bool = True) -> bytes: """ SMILE Encode object :param list|dict py_obj: The object to be encoded :param bool header: (optional - Default: `True`) :param bool ender: (optional - Default: `False`) :param bool bin_7bit: (optional - Default: `True`) Encode raw data as 7-bit :param bool shared_keys: (optional - Default: `True`) Shared Key String References :param bool shared_vals: (optional - Default: `True`) Shared Value String References :returns: SMILE encoded data """ if isinstance(py_obj, (tuple, set)): py_obj = list(py_obj) elif not isinstance(py_obj, (list, dict)): raise ValueError("Invalid type for \"obj\" paramater. Must be one of dict, list, set, or tuple") enc_obj = cls(shared_keys, shared_vals, bin_7bit) return enc_obj.encode(py_obj, header, ender) def _is_valid_back_ref(index): """ Helper method used to ensure that we do not use back-reference values that would produce illegal byte sequences (ones with byte 0xFE or 0xFF). Note that we do not try to avoid null byte (0x00) by default, although it would be technically possible as well. :param int index: Index :returns: Valid back ref :rtype: bool """ return (index & 0xFF) < 0xFE def encode(py_obj: Union[list, dict], header: bool = True, ender: bool = False, shared_keys: bool = True, shared_vals: bool = True, bin_7bit: bool = True) -> bytes: """ SMILE Encode object :param dict|list|set|tuple py_obj: The object to be encoded :param bool header: (optional - Default: `True`) :param bool ender: (optional - Default: `False`) :param bool bin_7bit: (optional - Default: `True`) Encode raw data as 7-bit :param bool shared_keys: (optional - Default: `True`) Shared Key String References :param bool shared_vals: (optional - Default: `True`) Shared Value String References :returns: SMILE encoded data """ return SmileEncoder.encode_obj(py_obj, header, ender, shared_keys, shared_vals, bin_7bit)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,139
g2-inc/openc2-oif-orchestrator
refs/heads/master
/base/modules/utils/twisted/sb_utils/__init__.py
""" Screaming Bunny Utils Twisted namespace """ from pkgutil import extend_path __path__ = extend_path(__path__, __name__) from .twisted_tools import PikaFactory, PikaProtocol __all__ = [ # Twisted Tools 'PikaFactory', 'PikaProtocol' ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,140
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/transport/https/HTTPS/main.py
import re from datetime import datetime from flask import Flask, request, make_response from sb_utils import Producer, decode_msg, encode_msg, default_encode, safe_json app = Flask(__name__) @app.route("/", methods=["POST"]) def result(): encode = re.search(r"(?<=\+)(.*?)(?=\;)", request.headers["Content-type"]).group(1) # message encoding corr_id = request.headers["X-Request-ID"] # correlation ID status = request.headers['Status'] profile, device_socket = request.headers["From"].rsplit("@", 1) # profile used, device IP:port data = safe_json({ "headers": dict(request.headers), "content": safe_json(request.data.decode('utf-8')) }) print(f"Received {status} response from {profile}@{device_socket} - {data}") print("Writing to buffer.") producer = Producer() producer.publish( message=decode_msg(request.data, encode), # message being decoded headers={ "socket": device_socket, "correlationID": corr_id, "profile": profile, "encoding": encode, "transport": "https" }, exchange="orchestrator", routing_key="response" ) return make_response( # Body encode_msg({ "status": 200, "status_text": "received" }, encode), # Status Code 200, # Headers { "Content-type": f"application/openc2-rsp+{encode};version=1.0", "Status": 200, # Numeric status code supplied by Actuator's OpenC2-Response "X-Request-ID": corr_id, "Date": f"{datetime.utcnow():%a, %d %b %Y %H:%M:%S GMT}", # RFC7231-7.1.1.1 -> Sun, 06 Nov 1994 08:49:37 GMT # "From": f"{profile}@{device_socket}", # "Host": f"{orc_id}@{orc_socket}", } ) if __name__ == "__main__": ssl = ( "/opt/transport/HTTPS/certs/server.crt", # Cert Path "/opt/transport/HTTPS/certs/server.key" # Key Path ) app.run(ssl_context=ssl, host="0.0.0.0", port=5000, debug=False)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,141
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/utils/messageQueue.py
""" Combination of AMQP Consumer/Producer as class for easier access within the Orchestrator code """ from sb_utils import safe_cast, Consumer, FrozenDict, Producer class MessageQueue: _auth = FrozenDict({ 'username': 'guest', 'password': 'guest' }) _exchange = 'orchestrator' _consumerKey = 'response' _producerExchange = 'transport' def __init__(self, hostname='127.0.0.1', port=5672, auth=_auth, exchange=_exchange, consumer_key=_consumerKey, producer_exchange=_producerExchange, callbacks=None): """ Message Queue - holds a consumer class and producer class for ease of use :param hostname: server ip/hostname to connect :param port: port the AMQP Queue is listening :param exchange: name of the default exchange :param consumer_key: key to consumer :param producer_exchange: ... :param callbacks: list of functions to call on message receive """ self._exchange = exchange if isinstance(exchange, str) else self._exchange self._consumerKey = consumer_key if isinstance(consumer_key, str) else self._consumerKey self._producerExchange = producer_exchange if isinstance(producer_exchange, str) else self._producerExchange self._publish_opts = dict( host=hostname, port=safe_cast(port, int) ) self._consume_opts = dict( host=hostname, port=safe_cast(port, int), exchange=self._exchange, routing_key=self._consumerKey, callbacks=callbacks ) self.producer = Producer(**self._publish_opts) self.consumer = Consumer(**self._consume_opts) def send(self, msg, headers, exchange=_producerExchange, routing_key=None): """ Publish a message to the specified que and transport :param msg: message to be published :param headers: header information for the message being sent :param exchange: exchange name :param routing_key: routing key name :return: None """ headers = headers or {} exchange = exchange if exchange == self._producerExchange else self._producerExchange if routing_key is None: raise ValueError('Routing Key cannot be None') self.producer.publish( message=msg, headers=headers, exchange=exchange, routing_key=routing_key ) def register_callback(self, fun): """ Register a function for when a message is received from the message queue :param fun: function to register :return: None """ self.consumer.add_callback(fun) def shutdown(self): """ Shutdown the connection to the queue """ self.consumer.shutdown() self.consumer.join()
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,142
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/webApp/routing.py
from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter, URLRouter from django.urls import path from .sockets import SocketConsumer application = ProtocolTypeRouter({ # (http->django views is added by default) 'websocket': AuthMiddlewareStack( URLRouter([ path('', SocketConsumer), ]) ) })
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,143
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/orchestrator/views/__init__.py
from .api import api_favicon, api_root from .gui import gui_redirect from .handlers import bad_request, page_not_found, permission_denied, server_error __all__ = [ # API 'api_favicon', 'api_root', # GUI 'gui_redirect', # Handlers 'bad_request', 'page_not_found', 'permission_denied', 'server_error', ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,144
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/account/views/apiviews.py
import bleach import coreapi import coreschema from django.contrib.auth.models import Group, User from rest_framework import permissions from rest_framework.exceptions import ParseError from rest_framework.response import Response from rest_framework.views import APIView # Local imports import utils from actuator.models import ActuatorGroup class ActuatorAccess(APIView): """ API endpoint that allows users actuator access to be viewed or edited. """ permission_classes = (permissions.IsAdminUser, ) schema = utils.OrcSchema( manual_fields=[ coreapi.Field( "username", required=True, location="path", schema=coreschema.String( description='Username to list the accessible actuators' ) ) ], put_fields=[ coreapi.Field( "actuators", required=True, location="body", schema=coreschema.Array( items=coreschema.String(), min_items=1, unique_items=True ) ) ] ) def get(self, request, username, *args, **kwargs): # pylint: disable=unused-argument """ API endpoint that lists the actuators a users can access """ username = bleach.clean(username) rtn = [g.name for g in ActuatorGroup.objects.filter(users__in=[User.objects.get(username=username)])] return Response(rtn) def put(self, request, username, *args, **kwargs): # pylint: disable=unused-argument """ API endpoint that adds actuators to a users access """ username = bleach.clean(username) user = User.objects.get(username=username) if user is None: return ParseError(detail='User cannot be found', code=404) rtn = [] for actuator in request.data.get('actuators', []): actuator = bleach.clean(actuator) group = Group.objects.exclude(actuatorgroup__isnull=True).filter(name=actuator).first() if group: rtn.append(group.name) user.groups.add(group) return Response(rtn)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,145
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/device/views/viewsets.py
from django.db.utils import IntegrityError from django.contrib.auth.models import User from rest_framework import filters, status, viewsets from rest_framework.decorators import action from rest_framework.exceptions import PermissionDenied from rest_framework.permissions import IsAdminUser, IsAuthenticated from rest_framework.response import Response from ..models import Device, DeviceSerializer class DeviceViewSet(viewsets.ModelViewSet): """ API endpoint that allows Actuators to be viewed or edited. """ permission_classes = (IsAuthenticated,) serializer_class = DeviceSerializer lookup_field = 'device_id' queryset = Device.objects.order_by('name') filter_backends = (filters.OrderingFilter,) ordering_fields = ('name', 'host', 'port', 'protocol', 'serialization', 'type') permissions = { 'create': (IsAdminUser,), 'destroy': (IsAdminUser,), 'partial_update': (IsAdminUser,), 'update': (IsAdminUser,), } def get_permissions(self): """ Instantiates and returns the list of permissions that this view requires. """ return [permission() for permission in self.permissions.get(self.action, self.permission_classes)] def list(self, request, *args, **kwargs): """ Return a list of all actuators that the user has permissions for """ self.pagination_class.page_size_query_param = 'length' self.pagination_class.max_page_size = 100 queryset = self.filter_queryset(self.get_queryset()) # TODO: set permissions ''' if not request.user.is_staff: # Standard User user_devices = DeviceGroup.objects.filter(users__in=[request.user]) user_devices = list(g.devices.values_list('name', flat=True) for g in user_devices) queryset = queryset.filter(name__in=user_devices) # | queryset.exclude(name__in=user_devices) ''' # pylint: disable=pointless-string-statement page = self.paginate_queryset(queryset) if page is not None: serializer = self.get_serializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = self.get_serializer(queryset, many=True) return Response(serializer.data) def retrieve(self, request, *args, **kwargs): """ Return a specific actuators that the user has permissions for """ device = self.get_object() # TODO: set permissions ''' if not request.user.is_staff: # Standard User user_devices = DeviceGroup.objects.filter(users__in=[request.user]) user_devices = list(g.devices.values_list('name', flat=True) for g in user_devices) if device is not None and device.name not in user_devices: raise PermissionDenied(detail='User not authorised to access device', code=401) ''' # pylint: disable=pointless-string-statement serializer = self.get_serializer(device) return Response(serializer.data) def create(self, request, *args, **kwargs): """ Create a device if the user has permission """ serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) try: self.perform_create(serializer) except IntegrityError as e: response = dict( IntegrityError=str(e).replace('key', 'field') ) return Response(response, status=status.HTTP_400_BAD_REQUEST) headers = self.get_success_headers(serializer.data) return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers) def update(self, request, *args, **kwargs): """ Update a specific device that a user has permission for """ partial = kwargs.pop('partial', False) device = self.get_object() serializer = self.get_serializer(device, data=request.data, partial=partial) serializer.is_valid(raise_exception=True) try: self.perform_update(serializer) except IntegrityError as e: response = dict( IntegrityError=str(e).replace('key', 'field') ) return Response(response, status=status.HTTP_400_BAD_REQUEST) if getattr(device, '_prefetched_objects_cache', None): # If 'prefetch_related' has been applied to a queryset, # need to forcibly invalidate the prefetch cache on the instance device._prefetched_objects_cache = {} return Response(serializer.data) @action(methods=['GET'], detail=False) def users(self, request, *args, **kwargs): """ API endpoint that allows for Device user retrieval """ device = self.get_object() if not request.user.is_staff: device_groups = list(g.name for g in request.user.groups.exclude(devicegroup__isnull=True)) if device.name not in device_groups: raise PermissionDenied(detail='User not authorised to access device', code=401) rtn = dict( users=list(u.username for u in User.objects.filter(groups__name=f'Device: {device.name}')) ) return Response(rtn)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,146
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/webApp/templatetags/var_dump.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django import template from django.template.defaultfilters import linebreaksbr from django.utils.html import escape from django.utils.safestring import mark_safe from pprint import pformat register = template.Library() @register.filter def var_dump(var): """ Dumps the value of the given object :param var: var to dump its value :return: dumped value of the given var """ if hasattr(var, '__dict__'): d = dict( __str__=str(var), __unicode__=str(var).encode('utf-8', 'strict'), __repr__=repr(var) ) d.update(var.__dict__) var = d output = f"{pformat(var)}\n" return output @register.filter def dump(var): """ Wrapper function for var_dump :param var: var object to dump :return: dumped value of the given var """ return mark_safe(linebreaksbr(escape(var_dump(var))))
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,147
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/orchestrator/views/api.py
import importlib import os from django.conf import settings from django.http import FileResponse from dynamic_preferences.registries import global_preferences_registry from inspect import isfunction from rest_framework import permissions from rest_framework.decorators import api_view, permission_classes from rest_framework.response import Response # Local imports from orchestrator.models import Serialization, Protocol from command.models import SentHistory, ResponseHistory global_preferences = global_preferences_registry.manager() def get_stats(): """ Gather stats from each installed app if the view has a function name defined as `settings.STATS_FUN` """ stats_results = {} for installed_app in settings.INSTALLED_APPS: app_views = getattr(importlib.import_module(installed_app), 'views', None) stats_view = getattr(app_views, settings.STATS_FUN, None) if stats_view and isfunction(stats_view): stats_results[installed_app] = stats_view() return stats_results @api_view(["GET"]) @permission_classes((permissions.AllowAny,)) def api_favicon(request): favicon = os.path.join(settings.STATIC_ROOT, 'favicon.ico') return FileResponse(favicon, 'rb') @api_view(['GET']) @permission_classes((permissions.AllowAny,)) def api_root(request): """ Orchestrator basic information """ rtn = dict( message="Hello, {}. You're at the orchestrator api index.".format(request.user.username or 'guest'), commands=dict( sent=SentHistory.objects.count(), responses=ResponseHistory.objects.count() ), name=global_preferences.get('orchestrator__name', 'N/A'), id=global_preferences.get('orchestrator__id', 'N/A'), protocols={k: bool(v) for k, v in Protocol.objects.values_list('name', 'pub_sub', named=True)}, serializations=Serialization.objects.values_list('name', flat=True), # app_stats=get_stats() ) return Response(rtn)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,148
g2-inc/openc2-oif-orchestrator
refs/heads/master
/base/modules/utils/root/sb_utils/__init__.py
""" Screaming Bunny Utils Root Namespace """ from pkgutil import extend_path __path__ = extend_path(__path__, __name__) from .amqp_tools import Consumer, Producer from .general import prefixUUID, default_decode, default_encode, safe_cast, safe_json, toStr from .ext_dicts import FrozenDict, ObjectDict, QueryDict from .message import decode_msg, encode_msg from .message_obj import Message __all__ = [ # AMQP Tools 'Consumer', 'Producer', # General Utils 'default_decode', 'default_encode', 'prefixUUID', 'safe_cast', 'safe_json', 'toStr', # Extended Dictionaries 'FrozenDict', 'ObjectDict', 'QueryDict', # Message Utils 'Message', 'decode_msg', 'encode_msg' ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,149
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/utils/__init__.py
from sb_utils import decode_msg, encode_msg, FrozenDict, safe_cast # Local imports from .general import isHex, prefixUUID, randBytes, to_str from .messageQueue import MessageQueue from .model import get_or_none, ReadOnlyModelAdmin from .permissions import IsAdminOrIsSelf from .schema import OrcSchema __all__ = [ "decode_msg", "encode_msg", "get_or_none", "isHex", "randBytes", "prefixUUID", "safe_cast", "to_str", "FrozenDict", "IsAdminOrIsSelf", "OrcSchema", "MessageQueue", "ReadOnlyModelAdmin" ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,150
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/webApp/sockets.py
import json from channels.generic.websocket import JsonWebsocketConsumer from django.contrib.auth.models import AnonymousUser from django.http import HttpRequest, JsonResponse, QueryDict from django.urls import resolve from rest_framework.request import Request from urllib.parse import parse_qsl, urlparse from .status_codes import Socket_Close_Codes from utils import FrozenDict, to_str class SocketConsumer(JsonWebsocketConsumer): def connect(self): self.accept() # pretty_print(self.scope, "-<>-") self.send(text_data=json.dumps({ "message": "connected" })) def disconnect(self, close_code): close_status = Socket_Close_Codes.get(close_code, ("", "")) print(f"Socket Disconnect: {close_code}\n--> Name: {close_status[0]}\n--> Desc: {close_status[1]}") def receive(self, text_data=None): payload = json.loads(text_data) # print(f"Request for: {payload.get("method", "GET")} -> {payload.get("endpoint", "/")}") request = self.create_dja_request(payload) view_func, args, kwargs = request.resolver_match try: view_rtn = view_func(request) except Exception as e: print(e) try: request = self.create_drf_request(request) view_rtn = view_func(request) except Exception as e: print(e) view_rtn = FrozenDict( status_code=500, data=dict() ) rtn_type = "success" if view_rtn.status_code in [200, 201, 204, 304] else "failure" rtn_data = view_rtn.data if rtn_type == "success" else dict(response=view_rtn.data) rtn_data = json.loads(JsonResponse(rtn_data).content) rtn_type = payload.get("types", {}).get(rtn_type, "oops...") rtn_state = rtn_type["type"] if type(rtn_type) is dict else rtn_type meta = rtn_type.get("meta", {}) if type(rtn_state) is dict else {} meta.update( status_code=view_rtn.status_code ) try: self.send_json(dict( type=rtn_state, payload=rtn_data, meta=meta )) except Exception as e: print(e) self.send_json(dict( type=rtn_state, payload={}, meta=meta )) def create_dja_request(self, data={}): print("Create Django Request") request = HttpRequest() headers = {to_str(kv[0]): to_str(kv[1]) for kv in self.scope.get("headers", {})} host, port = headers.get("host", "").split(":") url = urlparse(data.get("endpoint", "")) try: resolver = resolve(url.path + ("" if url.path.endswith("/") else "/")) except Exception as e: print(f"URL Resolve failed: {url.path}") resolver = ( lambda r: FrozenDict( status_code=404, data=dict( message="page not found" ), ), (), {} ) params = dict( # accepted_renderer="rest_framework.renderers.JSONRenderer", body=b"", # bytes(request_body, "utf-8"), content_type="application/json", content_params={}, encoding=None, # FILES - MultiValueDict method=data.get("method", "GET"), path=url.path, path_info=url.path, resolver_match=resolver, scheme="http", session=self.scope.get("session", None), # site=shortcuts.get_current_site(request), user=self.scope.get("user", AnonymousUser), # TODO: Verify this is valid in this instance url_conf=None, GET=QueryDict(mutable=True), META=dict( CONTENT_LENGTH=0, CONTENT_TYPE="application/json", HTTP_ACCEPT="application/json", HTTP_ACCEPT_ENCODING=headers.get("accept-encoding", ""), HTTP_ACCEPT_LANGUAGE=headers.get("accept-language", ""), HTTP_HOST=host, # HTTP_REFERER – The referring page, if any. HTTP_USER_AGENT=headers.get("user-agent", ""), HTTP_AUTHORIZATION=f"JWT {data.get('jwt', '')}", REMOTE_ADDR=host, REMOTE_HOST=host, REMOTE_USER=self.scope.get("user", AnonymousUser), REQUEST_METHOD=data.get("method", "GET"), SERVER_NAME=self.scope.get("server", ["", ""])[0], SERVER_PORT=self.scope.get("server", ["", ""])[1], QUERY_STRING=url.query, ), POST=QueryDict(mutable=True), COOKIES=self.scope.get("session", {}), ) if params["method"].lower() == "get" and url.query: request_query = dict(parse_qsl(url.query)) request.GET.update(request_query) request_data = data.get("data", {}) if len(request_data.keys()) >= 1: request_body = json.dumps(request_data) update_request = dict( _body=bytes(request_body, "utf-8"), body=bytes(request_body, "utf-8"), data=request_data ) if params["method"].lower() in ["post", "put"]: tmp_qrydict = QueryDict(mutable=True) if params["method"].lower() == "post": tmp_qrydict.update(request_data) update_request.update(dict( raw_post_data=request.POST.urlencode(), )) if params["method"].lower() == "put": tmp_qrydict.update(request_data) update_request.update({ params["method"]: tmp_qrydict }) params.update(update_request) for key, val in params.items(): try: setattr(request, key, val) except Exception as e: # print(f"--- {e} - {key}: {val}") pass request.META["CONTENT_LENGTH"] = len(to_str(params.get("body", ""))) return request def create_drf_request(self, dja_request: HttpRequest): print("Create Django Rest Request") request = Request(dja_request) params = dict() for key, val in params.items(): try: setattr(request, key, val) except Exception as e: # print(f"--- {e} - {key}: {val}") pass return request def send_all_json(self, json_data={}): print(f'Send to all {len(self._clients)} Clients') for client in self._clients: client.send_json(json_data)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,151
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/orchestrator/migrations/0002_protocol_port.py
# Generated by Django 2.2 on 2019-05-07 14:52 import django.core.validators from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('orchestrator', '0001_initial'), ] operations = [ migrations.AddField( model_name='protocol', name='port', field=models.IntegerField(default=8080, help_text='Port of the transport', validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(65535)]), ), ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,152
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/es_mirror/field.py
import uuid from elasticsearch_dsl.field import ( Boolean, Binary, Byte, Completion, CustomField, Date, DateRange, Double, DoubleRange, Field, Float, FloatRange, GeoPoint, GeoShape, HalfFloat, Integer, IntegerRange, Ip, IpRange, Join, Keyword, Long, LongRange, Murmur3, Nested, Object, Percolator, RangeField, RankFeature, ScaledFloat, Short, Text, TokenCount ) class UUID(Text): name = 'uuid' _coerce = True def _deserialize(self, data): return str(data) def _serialize(self, data): if data is None: return None return uuid.UUID(data) if isinstance(data, str) else data __all__ = [ 'Boolean', 'Binary', 'Byte', 'Completion', 'CustomField', 'Date', 'DateRange', 'Double', 'DoubleRange', 'Field', 'Float', 'FloatRange', 'GeoPoint', 'GeoShape', 'HalfFloat', 'Integer', 'IntegerRange', 'Ip', 'IpRange', 'Join', 'Keyword', 'Long', 'LongRange', 'Murmur3', 'Nested', 'Object', 'Percolator', 'RangeField', 'RankFeature', 'ScaledFloat', 'Short', 'Text', 'TokenCount', 'UUID' ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,153
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/utils/__init__.py
from .general import prefixUUID, safe_cast, to_str from .model import get_or_none, ReadOnlyModelAdmin from .orchestrator_api import OrchestratorAPI from .permissions import IsAdminOrIsSelf from .schema import OrcSchema from sb_utils import FrozenDict, safe_cast __all__ = [ 'FrozenDict', 'get_or_none', 'IsAdminOrIsSelf', 'OrchestratorAPI', 'OrcSchema', 'prefixUUID', 'ReadOnlyModelAdmin', 'safe_cast', 'schema_merge', 'to_str' ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,154
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/webApp/templatetags/jsonify.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals import json from django.core.serializers import serialize from django.db.models.query import QuerySet from django.utils.safestring import mark_safe from django.template import Library register = Library() @register.filter(is_safe=True) def jsonify(val): """ JSON stringify the given value :param val: object to JSON stringify :return: stringified JSON """ if isinstance(val, QuerySet): return mark_safe(serialize('json', val)) return mark_safe(json.dumps(val)) @register.filter def pretty_json(val, ind=2): """ Pretty format JSON data :param val: Key/Value object :param ind: spaces to use as indent :return: pretty formatted key/value object """ if not isinstance(val, dict): val = json.loads(val) return mark_safe(json.dumps(val, indent=ind))
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,155
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/conformance/tests/slpf_tests.py
""" OpenC2 Stateless Packet Filtering Profile (SLPF) Conformance """ from test_setup import SetupTestCase class SLPF_UnitTests(SetupTestCase): """ SLPF OpenC2 Conformance Tests """ profile = "SLPF" def test_allow_ip(self): print("Test SLPF Allow:IP...")
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,156
g2-inc/openc2-oif-orchestrator
refs/heads/master
/base/modules/utils/root/sb_utils/ext_dicts.py
import copy from typing import ( Any, List, Sequence ) from .general import safe_cast class ObjectDict(dict): """ Dictionary that acts like a object d = ObjectDict() d['key'] = 'value' SAME AS d.key = 'value' """ def __getattr__(self, key: Any) -> Any: """ Get an key as if an attribute - ObjectDict.key - SAME AS - ObjectDict['key'] :param key: key to get value of :return: value of given key """ if key in self: return self[key] raise AttributeError(f"No such attribute {key}") def __setattr__(self, key: Any, val: Any) -> None: """ Set an key as if an attribute - d.key = 'value' - SAME AS - d['key'] = 'value' :param key: key to create/override :param val: value to set :return: None """ self[key] = self.__class__(val) if isinstance(val, dict) else val def __delattr__(self, key: Any) -> None: """ Remove a key as if an attribute - del d.key - SAME AS - del d['key'] :param key: key to remove/delete :return: None """ if key in self: del self[key] else: raise AttributeError(f"No such attribute: {key}") class FrozenDict(ObjectDict): """ Immutable/Frozen dictionary """ _hash: hash def __hash__(self) -> hash: """ Create a hash for the FrozenDict :return: object hash """ if self._hash is None: self._hash = hash(tuple(sorted(self.items()))) return self._hash def _immutable(self, *args, **kwargs) -> None: """ Raise an error for an attempt to alter the FrozenDict :param args: positional args :param kwargs: key/value args :return: None :raise TypeError """ raise TypeError('cannot change object - object is immutable') __setitem__ = _immutable __delitem__ = _immutable pop = _immutable popitem = _immutable clear = _immutable update = _immutable setdefault = _immutable class QueryDict(ObjectDict): """ Nested Key traversal dictionary d = QueryDict() d['192']['168']['1']['100'] = 'test.domain.local' SAME AS d['192.168.1.100'] = 'test.domain.local' """ separator: str = "." def __init__(self, seq: Sequence = None, **kwargs) -> None: """ Initialize an QueryDict :param seq: initial Sequence data :param kwargs: key/value parameters """ if seq: ObjectDict.__init__(self, seq, **kwargs) else: ObjectDict.__init__(self, **kwargs) for k, v in self.items(): if isinstance(v, dict) and not isinstance(v, self.__class__): ObjectDict.__setitem__(self, k, QueryDict(v)) elif isinstance(v, (list, tuple)): ObjectDict.__setitem__(self, k, type(v)(QueryDict(i) if isinstance(i, dict) else i for i in v)) # Override Functions def get(self, path: str, default: Any = None, sep: str = None) -> Any: """ Get a key/path from the QueryDict :param path: key(s) to get the value of separated by the separator character :param default: default value if the pey/path is not found :param sep: separator character to use, default - '.' :return: value of key/path or default """ sep = sep if sep else self.separator path = self._pathSplit(str(path), sep) if any(k.startswith(sep.join(path)) for k in self.compositeKeys()): rtn = self for key in path: if isinstance(rtn, ObjectDict): rtn = ObjectDict.__getitem__(rtn, key) elif isinstance(rtn, (list, tuple)) and len(rtn) > safe_cast(key, int, key): rtn = rtn[safe_cast(key, int, key)] else: raise AttributeError(f"Unknown type {type(rtn)}, cannot get value") return rtn return default def set(self, path: str, val: Any, sep: str = None) -> None: """ Set a key/path in the QueryDict object :param path: key/path to set :param val: value to set :param sep: separator character to use, default - '.' :return: None """ sep = sep if sep else self.separator keys = self._pathSplit(str(path), sep) if isinstance(val, dict): val = QueryDict(val) elif isinstance(val, (list, tuple)): val = type(val)(QueryDict(i) if isinstance(i, dict) else i for i in val) obj = self for idx, key in enumerate(keys): key = safe_cast(key, int, key) next_key = safe_cast(keys[idx + 1], int, keys[idx + 1]) if len(keys) > idx + 1 else "" end = len(keys) == idx + 1 if end: if isinstance(obj, list) and isinstance(key, int): if len(obj) <= key: obj.append(val) else: obj[key] = val elif isinstance(obj, ObjectDict): ObjectDict.__setitem__(obj, key, val) else: print(f"Other - {type(obj)}") elif key in obj: obj = obj[key] elif isinstance(obj, list) and isinstance(key, int): if len(obj) <= key: obj.append([] if isinstance(next_key, int) else ObjectDict()) obj = obj[-1] else: obj = obj[key] elif isinstance(obj, ObjectDict): obj = obj.setdefault(key, [] if isinstance(next_key, int) else ObjectDict()) else: obj = obj.setdefault(key, [] if isinstance(next_key, int) else ObjectDict()) def delete(self, path: str, sep: str = None) -> None: """ Delete a key/path in the QueryDict object :param path: key/path to delete :param sep: separator character to use, default - '.' :return: None """ sep = sep if sep else self.separator path = self._pathSplit(path, sep) if any(k.startswith(sep.join(path)) for k in self.compositeKeys()): ref = self for idx, key in enumerate(path): key = safe_cast(key, int, key) end = len(path) == idx + 1 if end: if isinstance(ref, list) and isinstance(key, int): if len(ref) > key: ref.remove(ref[key]) elif isinstance(ref, ObjectDict): ObjectDict.__delitem__(ref, key) else: print(f"Other - {type(ref)}") elif key in ref: ref = ref[key] elif isinstance(ref, list) and isinstance(key, int): if len(ref) > key: ref = ref[key] else: raise KeyError(f"{sep.join(path[:idx])} does not exist") else: print(f"Other - {type(ref)}") def __contains__(self, path: str) -> bool: """ Verify if a key is in the MultiKeyDict - 'key0' in d and 'key1' in d['key0'] - SAME AS - 'key0.key1' in d :param path: path to verify if contained :return: if MultiKeyDict contains the given key """ keys = self._pathSplit(path) return path in self._compositeKeys(self) if len(keys) > 1 else ObjectDict.__contains__(self, path) def __deepcopy__(self, memo): """ Copy the QueryDict without referencing the original data :param memo: ... :return: copy of QueryDict """ return QueryDict(copy.deepcopy(dict(self), memo)) __getattr__ = get __getitem__ = get __setattr__ = set __setitem__ = set __delattr__ = delete __delitem__ = delete # Custom Functions def compositeKeys(self, sep: str = None) -> List[str]: """ Compiled list of keys :param sep: key separator character :return: list of composite keys """ sep = sep if sep else self.separator return self._compositeKeys(self, sep) # Helper Functions def _compositeKeys(self, obj: Any, sep: str = None) -> List[str]: """ Determine the composite keys of the given object :param obj: object to get the composite keys :param sep: path separator character :return: list of keys """ sep = sep if sep else self.separator rtn = [] key_vals = {} if isinstance(obj, self.__class__): key_vals = obj.items() elif isinstance(obj, (list, tuple)): key_vals = enumerate(obj) for key, val in key_vals: val_keys = self._compositeKeys(val, sep) rtn.extend([f"{key}{sep}{k}" for k in val_keys] if len(val_keys) > 0 else [key]) return rtn def _pathSplit(self, path: str, sep: str = None) -> List[str]: """ Split the path based on the separator character :param path: path to split :param sep: separator character :return: list of separated keys """ sep = sep if sep else self.separator return list(filter(None, path.split(sep)))
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,157
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/device/migrations/0003_device_multi_actuator.py
# Generated by Django 2.2 on 2019-05-17 14:40 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('device', '0002_auto_20190416_1225'), ] operations = [ migrations.AddField( model_name='device', name='multi_actuator', field=models.BooleanField(default=True, help_text='Device can have multiple actuators or is its own actuator'), ), ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,158
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/webApp/views/handlers.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals import json from django.http import HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound, HttpResponseServerError from django.template import loader from tracking import log _browser_search = ( "IE", "Firefox", "Chrome", "Opera", "Safari" ) def is_browser(request): user_agent = request.META.get('HTTP_USER_AGENT', '') return any(s in user_agent for s in _browser_search) def get_error_msg(exception): exception_repr = exception.__class__.__name__ try: message = exception.args[0] except (AttributeError, IndexError): pass else: if isinstance(message, str): exception_repr = message return exception_repr def exception_response(request, code=400, exception=None, *args, **kwargs): code = code if code in [400, 403, 404, 500] else 400 exception_repr = get_error_msg(exception) log.error(usr=request.user, msg=f'{code} - {exception_repr}') context = dict( message='Error 400 - Bad Request', request_path=request.path, exception=exception_repr ) if is_browser(request): template = loader.get_template(f'error/{code}.html') rtn = dict( content=template.render(context, request), content_type='text/html' ) else: rtn = dict( content=json.dumps(context), content_type='application/json' ) return rtn def bad_request(request, exception, *args, **kwargs): """ Catch all 400 - Bad Request """ return HttpResponseBadRequest(**exception_response(request, 400, exception)) def permission_denied(request, exception, *args, **kwargs): """ Catch all 403 - Forbidden/Permission Denied """ return HttpResponseForbidden(**exception_response(request, 400, exception)) def page_not_found(request, exception, *args, **kwargs): """ Catch all 404 - Not Found """ return HttpResponseNotFound(**exception_response(request, 400, exception)) def server_error(request, *args, **kwargs): """ Catch all 500 - Server Error """ return HttpResponseServerError(**exception_response(request, 400, Exception('Server Error')))
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,159
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/command/admin.py
from django.contrib import admin from .models import SentHistory, ResponseHistory class ResponseInline(admin.TabularInline): """ Command Response InLine admin """ model = ResponseHistory readonly_fields = ('command', 'received_on', 'actuator', 'response', 'received_on') class SentHistoryAdmin(admin.ModelAdmin): """ Command Sent admin """ list_display = ('command_id', '_coap_id', 'user', 'received_on', 'command') filter_horizontal = ('actuators', ) readonly_fields = ('received_on', 'actuators') inlines = [ResponseInline, ] class ResponseHistoryAdmin(admin.ModelAdmin): """ Command Response admin """ list_display = ('command', 'received_on', 'actuator', 'response') readonly_fields = ('received_on', ) # Register models admin.site.register(SentHistory, SentHistoryAdmin) admin.site.register(ResponseHistory, ResponseHistoryAdmin)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,160
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/actuator/views/__init__.py
from .viewsets import ActuatorViewSet __all__ = [ # Viewsets 'ActuatorViewSet', ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,161
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/actuator/migrations/0001_initial.py
# Generated by Django 2.2 on 2019-04-04 18:39 import actuator.models from django.conf import settings from django.db import migrations, models import django.db.models.deletion import jsonfield.fields import uuid class Migration(migrations.Migration): initial = True dependencies = [ ('device', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Actuator', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('actuator_id', models.UUIDField(default=uuid.uuid4, help_text='Unique UUID of the actuator', unique=True)), ('name', models.CharField(default=actuator.models.defaultName, help_text='Unique display name of the actuator', max_length=30, unique=True)), ('schema', jsonfield.fields.JSONField(blank=True, help_text='Schema of the actuator', null=True)), ('profile', models.CharField(default='N/A', help_text='Profile of the actuator, set from the profile', max_length=60)), ('device', models.ForeignKey(blank=True, default=None, help_text='Device the actuator is located on', null=True, on_delete=django.db.models.deletion.CASCADE, to='device.Device')), ], ), migrations.CreateModel( name='ActuatorProfile', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(help_text='Unique name of the group', max_length=80, unique=True)), ('actuators', models.ManyToManyField(blank=True, help_text='Actuators of the groups profile', to='actuator.Actuator')), ], options={ 'verbose_name': 'profile', 'verbose_name_plural': 'profiles', }, ), migrations.CreateModel( name='ActuatorGroup', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(help_text='Unique name of the group', max_length=80, unique=True)), ('actuators', models.ManyToManyField(blank=True, help_text='Actuators available to users in the group', to='actuator.Actuator')), ('users', models.ManyToManyField(blank=True, help_text='Users in the group', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'group', 'verbose_name_plural': 'groups', }, ), ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,162
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/tracking/models.py
from django.db import models from django.conf import settings from django.utils import timezone from rest_framework import serializers from . import _DB_LEVELS class RequestLog(models.Model): """ Logs Django requests """ user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, blank=True, help_text="User that requested the page", null=True ) requested_at = models.DateTimeField( db_index=True, default=timezone.now, help_text="Time the initial request was received" ) response_ms = models.PositiveIntegerField( default=0, help_text="Time it took to process the request in milliseconds" ) path = models.CharField( db_index=True, help_text="URL path for the request", max_length=200 ) view = models.CharField( db_index=True, blank=True, help_text="Method that was called to process the request", max_length=200, null=True ) view_method = models.CharField( db_index=True, blank=True, help_text="HTTP Method of the request", max_length=30, null=True, ) remote_addr = models.GenericIPAddressField( blank=True, help_text="Remote IP Address of the system that made the requested", null=True, ) host = models.URLField( blank=True, help_text="Host of the system that received the request", null=True, ) method = models.CharField( help_text="HTTP Method of the request", max_length=10 ) query_params = models.TextField( blank=True, help_text="Data received in the URL as Query Parameters", null=True ) data = models.TextField( blank=True, help_text="Data received in the Body/JSON of the request", null=True ) response = models.TextField( blank=True, help_text="Data sent back to the remote system", null=True ) errors = models.TextField( blank=True, help_text="Errors raised in processing the request", null=True ) status_code = models.PositiveIntegerField( blank=True, help_text="HTTP response status code", null=True ) class Meta: verbose_name = 'Request Log' def __str__(self): return f'Request - {self.method} {self.path}' class EventLog(models.Model): """ Logs Specified Events """ user = models.ForeignKey( settings.AUTH_USER_MODEL, blank=True, help_text="User that caused the event", null=True, on_delete=models.SET_NULL ) occurred_at = models.DateTimeField( default=timezone.now, help_text="Time the event occurred" ) level = models.CharField( choices=_DB_LEVELS, help_text="Level of severity the event", max_length=1 ) message = models.TextField( blank=True, help_text="Event message", null=True ) class Meta: verbose_name = 'Event Log' def __str__(self): lvl = [l[1] for l in _DB_LEVELS if l[0] == self.level][0] return f'Event - {lvl} - {self.occurred_at}' class RequestLogSerializer(serializers.ModelSerializer): """ Model Serializer for Logs """ user = serializers.SlugRelatedField( allow_null=True, read_only=True, slug_field='username' ) requested_at = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S %z') remote_addr = serializers.IPAddressField() class Meta: model = RequestLog fields = ('id', 'user', 'requested_at', 'response_ms', 'path', 'status_code', 'view', 'view_method', 'remote_addr', 'host', 'method', 'query_params', 'data', 'response', 'errors', 'status_code') class EventLogSerializer(serializers.ModelSerializer): """ Model Serializer for Events """ user = serializers.SlugRelatedField( allow_null=True, read_only=True, slug_field='username' ) occurred_at = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S %z') class Meta: model = EventLog fields = ('id', 'user', 'occurred_at', 'level', 'message')
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,163
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/device/views/__init__.py
from .viewsets import DeviceViewSet __all__ = [ 'DeviceViewSet', ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,164
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/conformance/tests/test_setup.py
""" Conformance Test Setup """ import unittest # Local imports from sb_utils import FrozenDict class SetupTestSuite(unittest.TestSuite): """ Basic OpenC2 TestSuite Class """ _testKwargs: dict def __init__(self, tests: tuple = (), **kwargs): super(SetupTestSuite, self).__init__(tests=tests) self._testKwargs = kwargs def run(self, result, debug=False): topLevel = False if getattr(result, '_testRunEntered', False) is False: result._testRunEntered = topLevel = True for index, test in enumerate(self): if result.shouldStop: break if unittest.suite._isnotsuite(test): self._tearDownPreviousClass(test, result) self._handleModuleFixture(test, result) self._handleClassSetUp(test, result) result._previousTestClass = test.__class__ if (getattr(test.__class__, '_classSetupFailed', False) or getattr(result, '_moduleSetUpFailed', False)): continue if not debug: test(result, **self._testKwargs) else: test.debug(**self._testKwargs) if self._cleanup: self._removeTestAtIndex(index) if topLevel: self._tearDownPreviousClass(None, result) self._handleModuleTearDown(result) result._testRunEntered = False return result class SetupTestCase(unittest.TestCase): """ OpenC2 TestCase setup class """ actuator: FrozenDict ''' FrozenDict - immutable dictionary with object like attribute access Actuator: FrozenDict[ actuator_id: UUIDv4 name: str device: FrozenDict[ device_id: UUIDv3 name: str transport: Tuple[ FrozenDict[ transport_id: str, host: str port: int protocol: str serialization: List[str] topic: str channel: str pub_sub: bool ] ] nodes: str ] schema: FrozenDict schema_format: str -> OneOf(jadn, json) profile: str ] ''' profile: str = None def __init__(self, methodName: str = 'runTest', **kwargs): super(SetupTestCase, self).__init__(methodName=methodName) self._setupKwargs(**kwargs) def _setupKwargs(self, **kwargs): self.actuator = kwargs.get('actuator', None) def debug(self, **kwargs): self._setupKwargs(**kwargs) super(SetupTestCase, self).debug() def __call__(self, *args, **kwargs): self._setupKwargs(**kwargs) return self.run(*args)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,165
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/tracking/conf.py
from django.apps import AppConfig from django.conf import settings from . import LEVELS, REQUEST_LEVELS class TrackingConfig(AppConfig): name = 'tracking' URL_PREFIXES = [ # "^/(?!admin)" # Don"t log /admin/* ".*" # Log Everything ] EVENT_LEVELS = [l[0].upper() for l in LEVELS] REQUEST_LEVELS = [getattr(REQUEST_LEVELS, err) for err in REQUEST_LEVELS] SENSITIVE_FIELDS = [] def __init__(self, app_name, app_module): super(TrackingConfig, self).__init__(app_name, app_module) self._prefix = TrackingConfig.Meta.prefix global_settings = {n: getattr(settings, n) for n in dir(settings) if n.startswith(self._prefix)} for s in global_settings: delattr(settings, s) if len(global_settings.keys()) == 1 and self._prefix in global_settings: global_settings = global_settings.get(self._prefix) # Validate URL Prefixes prefxs = global_settings.get('URL_PREFIXES', self.URL_PREFIXES) if not isinstance(prefxs, (list, tuple)): raise ValueError(f"{self._prefix}_URL_PREFIXES is improperly formatted, expected list/tuple got {type(prefxs)}") if not all(isinstance(url, str) for url in prefxs): raise ValueError(f"{self._prefix}_URL_PREFIXES is improperly formatted, values should be regex strings") setattr(settings, f"{self._prefix}_URL_PREFIXES", prefxs) # Validate Event Levels evt_lvls = global_settings.get('EVENT_LEVELS', self.EVENT_LEVELS) if not isinstance(evt_lvls, (list, tuple)): raise ValueError(f"{self._prefix}_EVENT_LEVELS is improperly formatted, expected list/tuple got {type(prefxs)}") if not all(isinstance(lvl, str) and len(lvl) == 1 for lvl in evt_lvls): raise ValueError(f"{self._prefix}_EVENT_LEVELS is improperly formatted, values should be single character string") setattr(settings, f"{self._prefix}_EVENT_LEVELS", evt_lvls) # Validate Request Levels rqst_lvls = global_settings.get('REQUEST_LEVELS', self.REQUEST_LEVELS) if not isinstance(rqst_lvls, (list, tuple)): raise ValueError(f"{self._prefix}_REQUEST_LEVELS is improperly formatted, expected list/tuple got {type(prefxs)}") if not all(isinstance(lvl, (list, range, tuple)) for lvl in rqst_lvls): raise ValueError(f"{self._prefix}_REQUEST_LEVELS is improperly formatted, values should be list/range/tuple") setattr(settings, f"{self._prefix}_REQUEST_LEVELS", rqst_lvls) # Validate Sensitive fields sensitive_fields = global_settings.get('SENSITIVE_FIELDS', self.SENSITIVE_FIELDS) if not isinstance(sensitive_fields, (list, tuple)): raise ValueError(f"{self._prefix}_SENSITIVE_FIELDS is improperly formatted, expected list/tuple got {type(prefxs)}") if not all(isinstance(field, str) for field in sensitive_fields): raise ValueError(f"{self._prefix}_SENSITIVE_FIELDS is improperly formatted, values should be str") setattr(settings, f"{self._prefix}_SENSITIVE_FIELDS", sensitive_fields) class Meta: prefix = 'TRACKING'
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,166
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/orchestrator/middleware.py
import json from django.http import QueryDict from django.http.multipartparser import MultiValueDict from django.utils.deprecation import MiddlewareMixin class RESTMiddleware(MiddlewareMixin): """ REST API Middleware for proper handling of REST HTTP methods """ def process_request(self, request): """ Process REST request :param request: request instance :return: None """ request.PUT = QueryDict('') request.DELETE = QueryDict('') method = request.META.get('REQUEST_METHOD', '').upper() if method == 'PUT': self.handle_PUT(request) elif method == 'DELETE': self.handle_DELETE(request) def handle_DELETE(self, request): """ Handle REST DELETE request :param request: request instance :return: None """ request.DELETE, request._files = self.parse_request(request) def handle_PUT(self, request): """ Handle REST PUT request :param request: request instance :return: None """ request.PUT, request._files = self.parse_request(request) if not hasattr(request, 'data'): request.data = dict(request.PUT.dict()) def parse_request(self, request): """ Parse data sent with request :param request: request instance :return: processed request data """ if request.META.get('CONTENT_TYPE', '').startswith('multipart'): return self.parse_multipart(request) if request.META.get('CONTENT_TYPE', '').endswith('json'): return self.parse_json(request), MultiValueDict() return self.parse_form(request), MultiValueDict() def parse_json(self, request): """ Parse request as json data :param request: request instance :return: processed data """ data = QueryDict('', mutable=True) try: data.update(json.loads(request.body)) except json.JSONDecodeError: if request.body not in ['', b'', None]: data = QueryDict(request.body) return data.copy() def parse_form(self, request): """ Parse request as form data :param request: request instance :return: processed data """ try: return QueryDict(request.raw_post_data) except AttributeError as e: print(f'Form Parse Error: {e}') return QueryDict(request.body) def parse_multipart(self, request): """ Parse request as multipart from data :param request: request instance :return: processed data """ return request.parse_file_upload(request.META, request)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,167
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/command/documents.py
from es_mirror.document import Document, InnerDoc from es_mirror.field import ( Date, Integer, Nested, Object, Text ) class UserDocument(InnerDoc): username = Text() email = Text() class DeviceDocument(InnerDoc): name = Text() device_id = Text() class ActuatorDocument(InnerDoc): name = Text() actuator_id = Text() device = Object(DeviceDocument) class OpenC2_CommandDocument(InnerDoc): action = Text() target = Object(dynamic=True) args = Object(dynamic=True) actuator = Object(dynamic=True) command_id = Text() class OpenC2_ResponseDocument(InnerDoc): status = Integer() status_text = Text() results = Object(dynamic=True) class CommandDocument(Document): command_id = Text() user = Object(UserDocument) received_on = Date(default_timezone='UTC') actuators = Nested(ActuatorDocument) command = Object(OpenC2_CommandDocument) class Index: name = 'commands' settings = { 'number_of_shards': 1, 'number_of_replicas': 0 } class ResponseDocument(Document): command = Text() received_on = Date(default_timezone='UTC') actuator = Object(ActuatorDocument) response = Object(OpenC2_ResponseDocument) class Index: name = 'responses' settings = { 'number_of_shards': 1, 'number_of_replicas': 0 } def prepare_command(self, instance): return instance.command.command_id
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,168
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/command/views/stats.py
from ..models import SentHistory, ResponseHistory def app_stats(): return dict( sent=SentHistory.objects.count(), responses=ResponseHistory.objects.count() )
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,169
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/orchestrator/settings.py
import datetime import os import re # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DATA_DIR = os.path.join(BASE_DIR, 'data') FIXTURE_DIRS = [ os.path.join(DATA_DIR, 'fixtures') ] if not os.path.isdir(DATA_DIR): os.mkdir(DATA_DIR) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'vcj0le7zphvkzdcmnh7)i2sd(+ba2@k4pahqss&nbbpk4cpk@y' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = not os.getenv('DJANGO_ENV') == 'prod' ALLOWED_HOSTS = ['*'] IP = '0.0.0.0' PORT = "8080" SOCKET = f'{IP}:{PORT}' APPEND_SLASH = True # Application definition INSTALLED_APPS = [ # Custom Modules - MUST BE IN DEPENDENCY ORDER!! 'orchestrator', 'es_mirror', 'device', 'actuator', 'account', 'command', 'conformance', 'backup', 'tracking', # Default Modules 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # REST API 'rest_framework', 'rest_framework.authtoken', # Swagger REST API View 'rest_framework_swagger', # DataTables AJAX Addin 'rest_framework_datatables', # Dynamic config from database 'dynamic_preferences', # Dynamic user config - uncomment to enable # 'dynamic_preferences.users.apps.UserPreferencesConfig', # CORS (Cross-Origin Resource Sharing) 'corsheaders', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'orchestrator.middleware.RESTMiddleware', 'tracking.middleware.LoggingMiddleware' ] CORS_ORIGIN_ALLOW_ALL = True ROOT_URLCONF = 'orchestrator.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(DATA_DIR, 'templates') ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.request', 'dynamic_preferences.processors.global_preferences' ] } } ] WSGI_APPLICATION = 'orchestrator.wsgi.application' # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases # MySQL/MariaDB DATABASES = { 'default': { 'ENGINE': 'mysql.connector.django', 'NAME': os.environ.get('DATABASE_NAME', 'orchestrator'), 'USER': os.environ.get('DATABASE_USER', 'orc_root'), 'PASSWORD': os.environ.get('DATABASE_PASSWORD', '0Rch35Tr@t0r'), 'HOST': os.environ.get('DATABASE_HOST', 'localhost'), 'PORT': os.environ.get('DATABASE_PORT', '3306'), 'CON_MAX_AGE': 5 } } # Password validation # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ {'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'}, {'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'}, {'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'}, {'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'} ] # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ STATIC_URL = '/static/' # Central location for all static files STATIC_ROOT = os.path.join(DATA_DIR, "static") STATICFILES_DIRS = [] if DEBUG: # App Static Dirs for app in INSTALLED_APPS: app_static_dir = os.path.join(BASE_DIR, app, 'static') if os.path.isdir(app_static_dir): STATICFILES_DIRS.append(app_static_dir) MEDIA_URL = '/uploads/' # Email Config - maybe... # https://docs.djangoproject.com/en/2.0/topics/email/ # Auth Config LOGIN_URL = '/account/login/' LOGIN_REDIRECT_URL = '/' LOGOUT_URL = '/account/logout/' # Dynamic Preferences DYNAMIC_PREFERENCES = { 'REGISTRY_MODULE': 'preferences_registry' } # JWT JWT_AUTH = { 'JWT_SECRET_KEY': SECRET_KEY, 'JWT_GET_USER_SECRET_KEY': None, 'JWT_PUBLIC_KEY': None, 'JWT_PRIVATE_KEY': None, 'JWT_ALGORITHM': 'HS512', 'JWT_VERIFY': True, 'JWT_VERIFY_EXPIRATION': True, 'JWT_LEEWAY': 0, 'JWT_EXPIRATION_DELTA': datetime.timedelta(minutes=30), 'JWT_AUDIENCE': None, 'JWT_ISSUER': None, 'JWT_ALLOW_REFRESH': True, 'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=7), # 'JWT_PAYLOAD_HANDLER': 'rest_framework_jwt.utils.jwt_payload_handler', # Original 'JWT_PAYLOAD_HANDLER': 'orchestrator.jwt_handlers.jwt_payload_handler', # Custom 'JWT_PAYLOAD_GET_USER_ID_HANDLER': 'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler', 'JWT_PAYLOAD_GET_USERNAME_HANDLER': 'rest_framework_jwt.utils.jwt_get_username_from_payload_handler', 'JWT_RESPONSE_PAYLOAD_HANDLER': 'rest_framework_jwt.utils.jwt_response_payload_handler', # Original # 'JWT_RESPONSE_PAYLOAD_HANDLER': 'orchestrator.jwt_handlers.jwt_response_payload_handler', # Custom 'JWT_AUTH_HEADER_PREFIX': 'JWT', 'JWT_AUTH_COOKIE': None, # Not listed in docs, but in example..... 'JWT_ENCODE_HANDLER': 'rest_framework_jwt.utils.jwt_encode_handler', 'JWT_DECODE_HANDLER': 'rest_framework_jwt.utils.jwt_decode_handler', } # Rest API REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.TokenAuthentication', 'rest_framework_jwt.authentication.JSONWebTokenAuthentication', 'rest_framework.authentication.SessionAuthentication' ), 'DEFAULT_PARSER_CLASSES': [ 'rest_framework.parsers.JSONParser' ], 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.AllowAny' ], 'DEFAULT_RENDERER_CLASSES': [ 'rest_framework.renderers.JSONRenderer', 'rest_framework.renderers.BrowsableAPIRenderer', 'rest_framework_datatables.renderers.DatatablesRenderer', ], 'DEFAULT_FILTER_BACKENDS': [ 'rest_framework_datatables.filters.DatatablesFilterBackend', ], 'DEFAULT_PAGINATION_CLASS': 'rest_framework_datatables.pagination.DatatablesPageNumberPagination', 'PAGE_SIZE': 10, 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema', 'DATETIME_FORMAT': "%Y-%m-%dT%H:%M:%S.%fZ" } # Logging IGNORE_LOGS = ( r'^pyexcel_io.*', r'^lml.*' ) LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'ignore_logs': { '()': 'django.utils.log.CallbackFilter', 'callback': lambda r: not any([re.match(reg, r.name) for reg in IGNORE_LOGS]) } }, 'formatters': { 'requests': { 'format': '%{sctime} [{levelname}] {name}: {message}', 'style': '{', }, 'stream': { 'format': '{levelname} {module} {message}', 'style': '{', }, 'verbose': { 'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}', 'style': '{', }, }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'level': 'DEBUG', 'formatter': 'stream', 'filters': ['ignore_logs'] }, 'requests': { 'class': 'logging.StreamHandler', 'level': 'DEBUG', 'formatter': 'requests', 'filters': ['ignore_logs'] } }, 'loggers': { 'django.request': { 'handlers': ['requests'], 'level': 'DEBUG', 'propagate': False } }, 'root': { 'handlers': ['console'], 'level': 'DEBUG' } } # Tracking from tracking import REQUEST_LEVELS # pylint: disable=wrong-import-position TRACKING = { 'URL_PREFIXES': [ '^/(?!admin)' # Don't log /admin/* ], 'REQUEST_LEVELS': [ REQUEST_LEVELS.Redirect, REQUEST_LEVELS.Client_Error, REQUEST_LEVELS.Server_Error ] } # Elasticsearch Model Mirroring ES_MIRROR = { 'host': os.environ.get('ES_HOST', None), 'prefix': os.environ.get('ES_PREFIX', ''), } # Message Queue QUEUE = { 'hostname': os.environ.get('QUEUE_HOST', 'localhost'), 'port': os.environ.get('QUEUE_PORT', 5672), 'auth': { 'username': os.environ.get('QUEUE_USER', 'guest'), 'password': os.environ.get('QUEUE_PASSWORD', 'guest') }, 'exchange': 'orchestrator', 'consumer_key': 'response', 'producer_exchange': 'transport' } MESSAGE_QUEUE = None # Valid Schema Formats SCHEMA_FORMATS = ( 'jadn', 'json' ) # App stats function STATS_FUN = 'app_stats' # GUI Configuration ADMIN_GUI = True
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,170
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/device/migrations/0002_auto_20190416_1225.py
# Generated by Django 2.2 on 2019-04-16 12:25 import django.core.validators from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('device', '0001_initial'), ] operations = [ migrations.AlterField( model_name='transport', name='port', field=models.IntegerField(default=8080, help_text='Port of the device', validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(65535)]), ), ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,171
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/conformance/views/__init__.py
from .viewsets import ConformanceViewSet, UnitTests __all__ = [ # ViewSets 'ConformanceViewSet', 'UnitTests' ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,172
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/es_mirror/__init__.py
default_app_config = 'es_mirror.apps.EsMirrorConfig'
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,173
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/tracking/log.py
from . import EVENT_LEVELS, LEVEL_EVENTS from .conf import settings, TrackingConfig from .models import EventLog def log(level=EVENT_LEVELS.Info, usr=None, msg=''): """ Log a message at the specified level :param level: level of the error :param usr: user that caused the message :param msg: message to log :return: None """ level = level if level in EVENT_LEVELS else EVENT_LEVELS.Info usr = None if getattr(usr, 'is_anonymous', True) else usr if level in getattr(settings, f"{TrackingConfig.Meta.prefix}_EVENT_LEVELS"): print(f"{LEVEL_EVENTS.get(level, '')} Log: {usr} - {msg}") EventLog.objects.create( user=usr, level=level, message=msg ) def debug(usr=None, msg=''): """ Log debug message :param usr: user that caused the message :param msg: message to log """ log(EVENT_LEVELS.Debug, usr, msg) def error(usr=None, msg=''): """ Log error message :param usr: user that caused the message :param msg: message to log """ log(EVENT_LEVELS.Error, usr, msg) def fatal(usr=None, msg=''): """ Log fatal message :param usr: user that caused the message :param msg: message to log """ log(EVENT_LEVELS.Fatal, usr, msg) def info(usr=None, msg=''): """ Log info message :param usr: user that caused the message :param msg: message to log """ log(EVENT_LEVELS.Info, usr, msg) def trace(usr=None, msg=''): """ Log trace message :param usr: user that caused the message :param msg: message to log """ log(EVENT_LEVELS.Trace, usr, msg) def warn(usr=None, msg=''): """ Log warning message :param usr: user that caused the message :param msg: message to log """ log(EVENT_LEVELS.Warn, usr, msg)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,174
g2-inc/openc2-oif-orchestrator
refs/heads/master
/logger/server/syslog.py
#!/usr/bin/env python import logging import os import time import urllib3 from datetime import datetime, timezone from elasticsearch import Elasticsearch from elasticsearch.exceptions import TransportError from logging.handlers import RotatingFileHandler from syslog_rfc5424_parser import SyslogMessage, ParseError # https://github.com/EasyPost/syslog-rfc5424-parser try: from queue import Queue except ImportError: import Queue # Testing from twisted.internet import reactor from twisted.internet.protocol import DatagramProtocol from twisted.internet.task import LoopingCall # Based on - https://gist.github.com/marcelom/4218010 from sb_utils import ObjectDict """ Tiny Syslog Server in Python. This is a tiny syslog server that is able to receive UDP based syslog entries on a specified port and save them to a file. That's it... it does nothing else... There are a few configuration parameters. """ # Generic Config reactor.singleton = ObjectDict( DEFAULT_LOG='syslog.log', HOST="0.0.0.0", UDP_PORT=514, HOST_PORT=os.environ.get('HOST_PORT', 514), LOG_DIR=os.path.join('/', 'var', 'log', 'syslog'), # NO USER SERVICEABLE PARTS BELOW HERE... COUNT=ObjectDict( RECEIVED=0, PROCESSED=0, FORWARDED=0 ), LOG_COUNT=0, LOG_PREFIX=os.environ.get('LOG_PREFIX', 'logger'), # ElasticSearch Config ES=ObjectDict( HOST=os.environ.get('ES_HOST', None), PORT=os.environ.get('ES_PORT', '9200'), RETRIES=os.environ.get('ES_TRIES', 60), QUEUE=Queue(), CONN=None ), APP_LOGS={}, LOG_LEVELS=dict( crit=logging.CRITICAL, err=logging.ERROR, warn=logging.WARNING, info=logging.INFO, debug=logging.DEBUG, notset=logging.NOTSET ) ) def openLog(app): tmp_log = logging.getLogger(app) tmp_log.setLevel(logging.DEBUG) LOG_NAME = f'{app}.log' if app.startswith(f'{reactor.singleton.LOG_PREFIX}_') else f'{reactor.singleton.LOG_PREFIX}_{app}.log' # Rotatin after 10 MB handler = RotatingFileHandler(os.path.join(reactor.singleton.LOG_DIR, LOG_NAME), maxBytes=10485760, backupCount=5) tmp_log.addHandler(handler) reactor.singleton.APP_LOGS[app] = tmp_log def connectElasticsearch(): ES = reactor.singleton.ES if ES.HOST is not None: while ES.RETRIES > 0: try: http = urllib3.PoolManager() rsp = http.request('GET', f'{ES.HOST}:{ES.PORT}', retries=False, timeout=1.0) print(f'{datetime.now(timezone.utc):%Y.%m.%d %H:%M:%S%z} - Connected to ElasticSearch at {ES.HOST}:{ES.PORT}', flush=True) break except Exception as e: print(f'{datetime.now(timezone.utc):%Y.%m.%d %H:%M:%S%z} - ElasticSearch at {ES.HOST}:{ES.PORT} not up', flush=True) ES.RETRIES -= 1 time.sleep(2) if ES.RETRIES > 0: ES_CONN = Elasticsearch(f'{ES.HOST}:{ES.PORT}') while True: if not ES.QUEUE.empty(): msg = ES.QUEUE.get() try: rsp = ES_CONN.index(**msg) reactor.singleton.COUNT.FORWARDED += 1 except (TransportError, Exception) as e: print(f'{datetime.now(timezone.utc):%Y.%m.%d %H:%M:%S%z} - Log Error: {e}', flush=True) ES.QUEUE.put(msg) else: time.sleep(1) else: print(f'{datetime.now(timezone.utc):%Y.%m.%d %H:%M:%S%z} - ElasticSearch at {ES.HOST}:{ES.PORT} not up, max retries reached', flush=True) reactor.singleton.ES.HOST = None while not ES.QUEUE.empty(): msg = ES.QUEUE.get() time.sleep(0.5) class SyslogUDPHandler(DatagramProtocol): def datagramReceived(self, data, addr): data = bytes.decode(data.strip()) try: message = SyslogMessage.parse(data).as_dict() message['hostname'] = reactor.singleton.LOG_PREFIX msg = message.get('msg', None) if msg not in ['', ' ', None]: reactor.singleton.COUNT.RECEIVED += 1 appName = message.get('appname', 'default') level = message.get('severity', 'info') if appName not in reactor.singleton.APP_LOGS: openLog(appName) log_msg = f"{message.get('timestamp', datetime.now())} - {level} - {msg}" reactor.singleton.APP_LOGS[appName].log(reactor.singleton.LOG_LEVELS.get(level), log_msg) reactor.singleton.COUNT.PROCESSED += 1 if reactor.singleton.ES.HOST is not None: reactor.singleton.ES.QUEUE.put(dict( index=f'log_{reactor.singleton.LOG_PREFIX}-{datetime.now():%Y.%m.%d}', doc_type='log', body=message )) except ParseError as e: print(f"Error {e.__class__.__name__} - {getattr(e, 'message', e)}", flush=True) def stats(): COUNT = reactor.singleton.COUNT print(f'{datetime.now(timezone.utc):%Y.%m.%d %H:%M:%S%z} - Received {COUNT.RECEIVED:,}, Processed {COUNT.PROCESSED:,}, Forwarded {COUNT.FORWARDED:,}', flush=True) if __name__ == "__main__": print("Starting Syslog forwarding to ElasticSearch", flush=True) for log in os.listdir(reactor.singleton.LOG_DIR): name, ext = os.path.splitext(log) if ext == '.log': openLog(name) if 'default' not in reactor.singleton.APP_LOGS: openLog('default') print(f'Syslog UDP Listening {reactor.singleton.HOST}:{reactor.singleton.HOST_PORT}', flush=True) udpServer = SyslogUDPHandler() reactor.listenUDP(reactor.singleton.UDP_PORT, udpServer) reactor.callInThread(connectElasticsearch) status = LoopingCall(stats) status.start(60) try: reactor.run() except (IOError, SystemExit): raise except KeyboardInterrupt: print(f'{datetime.now(timezone.utc):%Y.%m.%d %H:%M:%S%z} - Crtl+C Pressed. Shutting down.', flush=True)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,175
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/account/views/viewsets.py
import base64 import bleach import coreschema from django.contrib.auth.models import User from django.core.exceptions import PermissionDenied from django.http import Http404 from rest_framework import filters, permissions, status, viewsets from rest_framework.compat import coreapi from rest_framework.decorators import action from rest_framework.response import Response # Local imports from command.models import SentHistory, HistorySerializer from utils import get_or_none, IsAdminOrIsSelf, OrcSchema from ..models import UserSerializer, PasswordSerializer class UserViewSet(viewsets.ModelViewSet): """ API endpoint that allows users to be viewed or edited. """ permission_classes = (permissions.IsAdminUser, ) serializer_class = UserSerializer lookup_field = 'username' queryset = User.objects.all().order_by('-date_joined') filter_backends = (filters.OrderingFilter,) ordering_fields = ('last_name', 'first_name', 'username', 'email_address', 'active') @action(methods=['POST'], detail=False, permission_classes=[IsAdminOrIsSelf], serializer_class=PasswordSerializer) def change_password(self, request, username=None): # pylint: disable=unused-argument """ Change user password, passwords sent as base64 encoded strings """ serializer = PasswordSerializer(data=request.data) user = self.get_object() if serializer.is_valid(): if not user.check_password(base64.b64decode(serializer.data.get('old_password'))): return Response({'old_password': ['Wrong password.']}, status=status.HTTP_400_BAD_REQUEST) # set_password also hashes the password that the user will get user.set_password(base64.b64decode(serializer.data.get('new_password_1'))) user.save() return Response({'status': 'password changed'}, status=status.HTTP_200_OK) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) class UserHistoryViewSet(viewsets.ReadOnlyModelViewSet): """ API endpoint that allows users to view their history """ permission_classes = (permissions.IsAdminUser,) serializer_class = HistorySerializer lookup_field = 'command_id' queryset = SentHistory.objects.order_by('-received_on') schema = OrcSchema( manual_fields=[ coreapi.Field( "username", required=True, location="path", schema=coreschema.String( description='Username to list the command history' ) ) ] ) def list(self, request, *args, **kwargs): # pylint: disable=unused-argument """ Return a list of a users command history """ username = kwargs.get('username', None) self.pagination_class.page_size_query_param = 'length' self.pagination_class.max_page_size = 100 queryset = self.filter_queryset(self.get_queryset()) username = bleach.clean(username) if request.user.is_staff: # Admin User user = get_or_none(User, username=username) if user is None: raise Http404 queryset = queryset.filter(user=user) else: # Standard User if request.user.username == username: queryset = queryset.filter(user=request.user) else: raise PermissionDenied page = self.paginate_queryset(queryset) if page is not None: serializer = self.get_serializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = self.get_serializer(queryset, many=True) return Response(serializer.data) def retrieve(self, request, *args, **kwargs): """ Return a specific user's command """ username = kwargs.get('username', None) instance = self.get_object() if not request.user.is_staff: # Standard User username = bleach.clean(username) if request.user.username != username or request.user != instance.user: raise PermissionDenied serializer = self.get_serializer(instance) return Response(serializer.data)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,176
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/tracking/views/gui.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.contrib.auth.decorators import login_required, permission_required from django.shortcuts import render, reverse @login_required @permission_required('logs.can_view') def gui_root(request): page_args = { 'page_title': 'Logs' } return render(request, 'tracking/index.html', page_args) @login_required @permission_required('logs.can_view') def gui_requests(request): page_args = { 'page_title': 'Request Logs' } return render(request, 'tracking/request.html', page_args) @login_required @permission_required('logs.can_view') def gui_events(request): page_args = { 'page_title': 'Event Logs' } return render(request, 'tracking/event.html', page_args)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,177
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/transport/mqtt/MQTT/callbacks.py
# callbacks.py import json import os import paho.mqtt.client as mqtt import paho.mqtt.publish as publish import re from sb_utils import Consumer, Producer, encode_msg, decode_msg, safe_cast # maintains a list of active devices we can receive responses from ACTIVE_CONNECTIONS = [] class Callbacks(object): required_device_keys = {"encoding", "profile", "socket"} @staticmethod def on_connect(client, userdata, flags, rc): """ MQTT Callback for when client receives connection-acknowledgement response from MQTT server. :param client: Class instance of connection to server :param userdata: User-defined data passed to callbacks :param flags: Response flags sent by broker :param rc: Connection result, Successful = 0 """ print(f"Connected with result code {rc}") # Subscribing in on_connect() allows us to renew subscriptions if disconnected if isinstance(userdata, list): for topic in userdata: if not isinstance(topic, str): print("Error in on_connect. Expected topic to be type a list of strings.") client.subscribe(topic.lower(), qos=1) print(f"Listening on {topic.lower()}") @staticmethod def on_message(client, userdata, msg): """ MQTT Callback for when a PUBLISH message is received from the server. :param client: Class instance of connection to server. :param userdata: User-defined data passed to callbacks :param msg: Contains payload, topic, qos, retain """ payload = json.loads(msg.payload) payload_header = payload.get("header", {}) encoding = re.search(r"(?<=\+)(.*?)(?=;)", payload_header.get("content_type", "")).group(1) orc_id, broker_socket = payload_header.get("from", "").rsplit("@", 1) corr_id = payload_header.get("correlationID", "") # copy necessary headers header = { "socket": broker_socket, "correlationID": corr_id, "orchestratorID": orc_id, "encoding": encoding, } # Connect and publish to internal buffer exchange = "orchestrator" route = "response" producer = Producer( os.environ.get("QUEUE_HOST", "localhost"), os.environ.get("QUEUE_PORT", "5672") ) producer.publish( headers=header, message=decode_msg(payload.get("body", ""), encoding), exchange=exchange, routing_key=route ) print(f"Received: {payload} \nPlaced message onto exchange [{exchange}] queue [{route}].") @ staticmethod def send_mqtt(body, message): """ AMQP Callback when we receive a message from internal buffer to be published :param body: Contains the message to be sent. :param message: Contains data about the message as well as headers """ # check for certs if TLS is enabled if os.environ.get("MQTT_TLS_ENABLED", False) and os.listdir("/opt/transport/MQTT/certs"): tls = dict( ca_certs=os.environ.get("MQTT_CAFILE", None), certfile=os.environ.get("MQTT_CLIENT_CERT", None), keyfile=os.environ.get("MQTT_CLIENT_KEY", None) ) else: tls = None # iterate through all devices within the list of destinations for device in message.headers.get("destination", []): # check that all necessary parameters exist for device key_diff = Callbacks.required_device_keys.difference({*device.keys()}) if len(key_diff) == 0: encoding = device.get("encoding", "json") ip, port = device.get("socket", "localhost:1883").split(":") # iterate through actuator profiles to send message to for actuator in device.get("profile", []): payload = { "header": format_header(message.headers, device, actuator), "body": encode_msg(json.loads(body), encoding) } print(f"Sending {ip}:{port} - {payload}") try: publish.single( actuator, payload=json.dumps(payload), qos=1, hostname=ip, port=safe_cast(port, int, 1883), will={ "topic": actuator, "payload": json.dumps(payload), "qos": 1 }, tls=tls ) print(f"Placed payload onto topic {actuator} Payload Sent: {payload}") except Exception as e: print(f"There was an error sending command to {ip}:{port} - {e}") send_error_response(e, payload["header"]) return get_response(ip, port, message.headers.get("source", {}).get("orchestratorID", "")) else: err_msg = f"Missing required header data to successfully transport message - {', '.join(key_diff)}" send_error_response(err_msg, payload["header"]) def send_error_response(e, header): """ If error occurs before leaving the transport on the orchestrator side, then send back a message response to the internal buffer indicating so. :param e: Exception thrown :param header: Include headers which would have been sent for Orchestrator to read. """ producer = Producer( os.environ.get("QUEUE_HOST", "localhost"), os.environ.get("QUEUE_PORT", "5672") ) err = json.dumps(str(e)) print(f"Send error response: {err}") producer.publish( headers=header, message=err, exchange="orchestrator", routing_key="response" ) def get_response(ip, port, orc_id): """ Waits for response from actuator at server at given ip:port :param ip: IP Address specified from destination sent from orchestrator :param port: Port specified from destination sent from orchestrator :param orc_id: Indicates where message was sent from - used in topic to receive responses """ # if we are already connected to an ip, don"t try to connect again if ip not in ACTIVE_CONNECTIONS: ACTIVE_CONNECTIONS.append(ip) client = mqtt.Client() print(f"New connection: {ip}:{port}") try: client.connect(ip, int(port)) except Exception as e: print(f"ERROR: Connection to {ip}:{port} has been refused - {e}") response_topic = f"{orc_id}/response" client.user_data_set([response_topic]) client.on_connect = Callbacks.on_connect client.on_message = Callbacks.on_message client.loop_start() def format_header(header, device, actuator): """ Takes relevant info from header and organizes it into a format that the orchestrator is expecting :param header: Header data received from device containing data to trace back the original command """ broker_socket = header.get("source", {}).get("transport", {}).get("socket", "") orc_id = header.get("source", {}).get("orchestratorID", "") return { "to": f"{actuator}@{broker_socket}", "from": f"{orc_id}@{broker_socket}", "correlationID": header.get("source", {}).get("correlationID", ""), "created": header.get("source", {}).get("date", ""), "content_type": f"application/openc2-cmd+{device.get('encoding', 'json')};version=1.0", }
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,178
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/orchestrator/migrations/0001_initial.py
# Generated by Django 2.2 on 2019-04-04 18:39 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Protocol', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(help_text='Name of the Protocol', max_length=30)), ('pub_sub', models.BooleanField(default=False, help_text='Protocol is Pub/Sub')), ], ), migrations.CreateModel( name='Serialization', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(help_text='Name of the Serialization', max_length=30)), ], ), ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,179
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/actuator/urls.py
from django.urls import include, path from rest_framework import routers from . import views router = routers.DefaultRouter() router.register('', views.ActuatorViewSet) urlpatterns = [ # Actuator Router path('', include(router.urls), name='actuator.root'), ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,180
g2-inc/openc2-oif-orchestrator
refs/heads/master
/base/modules/script_utils.py
# Utility functions for update_subs and configure import fnmatch import importlib import io import os import re import shutil import stat import subprocess import sys from getpass import getpass try: input = raw_input except NameError: pass # Classes class FrozenDict(dict): def __init__(self, *args, **kwargs): self._hash = None super(FrozenDict, self).__init__(*args, **kwargs) def __hash__(self): if self._hash is None: self._hash = hash(tuple(sorted(self.items()))) # iteritems() on py2 return self._hash def __getattr__(self, item): return self.get(item, None) def _immutable(self, *args, **kws): raise TypeError('cannot change object - object is immutable') __setitem__ = _immutable __delitem__ = _immutable pop = _immutable popitem = _immutable clear = _immutable update = _immutable setdefault = _immutable class ConsoleStyle: def __init__(self, verbose=False, log=None): import colorama colorama.init() self._verbose = verbose if isinstance(verbose, bool) else False self._logFile = log if isinstance(verbose, (str, io.TextIOWrapper)) else None self._encoding = sys.getdefaultencoding() self._format_regex = re.compile(r"\[\d+m", flags=re.MULTILINE) self._textStyles = FrozenDict({ # Styles "RESET": colorama.Fore.RESET, "NORMAL": colorama.Style.NORMAL, "DIM": colorama.Style.DIM, "BRIGHT": colorama.Style.BRIGHT, # Text Colors "FG_BLACK": colorama.Fore.BLACK, "FG_BLUE": colorama.Fore.BLUE, "FG_CYAN": colorama.Fore.CYAN, "FG_GREEN": colorama.Fore.GREEN, "FG_MAGENTA": colorama.Fore.MAGENTA, "FG_RED": colorama.Fore.RED, "FG_WHITE": colorama.Fore.WHITE, "FG_YELLOW": colorama.Fore.YELLOW, "FG_RESET": colorama.Fore.RESET, # Background Colors "BG_BLACK": colorama.Back.BLACK, "BG_BLUE": colorama.Back.BLUE, "BG_CYAN": colorama.Back.CYAN, "BG_GREEN": colorama.Back.GREEN, "BG_MAGENTA": colorama.Back.MAGENTA, "BG_RED": colorama.Back.RED, "BG_WHITE": colorama.Back.WHITE, "BG_YELLOW": colorama.Back.YELLOW, "BG_RESET": colorama.Back.RESET, }) def _toStr(self, txt): return txt.decode(self._encoding, "backslashreplace") if hasattr(txt, "decode") else txt def colorize(self, txt, *styles): txt = self._toStr(txt) self._log(txt) color_text = "".join([self._textStyles.get(s.upper(), "") for s in styles]) + txt return f"\033[0m{color_text}\033[0m" def _log(self, txt): if self._logFile: if isinstance(self._logFile, str): with open(self._logFile, 'a') as f: f.write(f"{self._format_regex.sub('', self._toStr(txt))}\n") elif isinstance(self._logFile, io.TextIOWrapper): self._logFile.write(f"{self._format_regex.sub('', self._toStr(txt))}\n") # Headers def underline(self, txt): print(self.colorize(txt, "UNDERLINE", "BOLD")) def h1(self, txt): tmp = self.colorize(f"\n{txt}", "UNDERLINE", "BOLD", "FG_CYAN") print(tmp) def h2(self, txt): print(self.colorize(f"\n{txt}", "UNDERLINE", "BOLD", "FG_WHITE")) def debug(self, txt): print(self.colorize(txt, "FG_WHITE")) def info(self, txt): print(self.colorize(f"> {txt}", "FG_WHITE")) def success(self, txt): print(self.colorize(txt, "FG_GREEN")) def error(self, txt): print(self.colorize(f"x {txt}", "FG_RED")) def warn(self, txt): print(self.colorize(f"-> {txt}", "FG_YELLOW")) def bold(self, txt): print(self.colorize(txt, "BOLD")) def note(self, txt): print(f"{self.colorize('Note:', 'UNDERLINE', 'BOLD', 'FG_CYAN')} {self.colorize(txt, 'FG_CYAN')}") def default(self, txt): txt = self._toStr(txt) print(self.colorize(txt)) def verbose(self, style, txt): if style is not "verbose" and hasattr(self, style) and callable(getattr(self, style)): if self._verbose: getattr(self, style)(txt) else: self._log(txt) # Config CONFIG = FrozenDict( DefaultBranch="master", EmptyString=("", b"", None), Remove=FrozenDict( Dirs=(".git", ".idea"), Files=(".git", ".gitlab-ci.yml", "dev-compose.yaml", ".gitmodules", ".pipeline_trigger*") ), MinVersions=FrozenDict( Docker=(18, 0, 0), DockerCompose=(1, 20, 0) ) ) # Functions def checkRequiredArguments(opts, parser): missing_options = [] for option in parser.option_list: if re.match(r'^\[REQUIRED\]', option.help) and eval('opts.' + option.dest) is None: missing_options.extend(option._long_opts) if len(missing_options) > 0: parser.error('Missing REQUIRED parameters: ' + str(missing_options)) def set_rw(operation, name, exc): os.chmod(name, stat.S_IWRITE) os.remove(name) def install_pkg(package): try: importlib.import_module(package[0]) except ImportError: print(f'{package[1]} not installed') try: pkg_install = subprocess.Popen([sys.executable, "-m", "pip", "install", package[1]], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = pkg_install.communicate() except Exception as e: print(e) finally: setattr(sys.modules[__name__], package[0], importlib.import_module(package[0])) def import_mod(mod=None): if mod not in sys.modules: setattr(sys.modules[__name__], mod, importlib.import_module(mod)) def recursive_find(rootdir='.', patterns=('*', ), directory=False): results = [] for (base, dirs, files) in os.walk(rootdir): search = dirs if directory else files matches = [fnmatch.filter(search, pattern) for pattern in patterns] matches = [v for sl in matches for v in sl] results.extend(os.path.join(base, f) for f in matches) return results def git_lsremote(url): import_mod('git') remote_refs = {} g = git.cmd.Git() for ref in g.ls_remote(url).split('\n'): hash_ref_list = ref.split('\t') remote_refs[hash_ref_list[1]] = hash_ref_list[0] return remote_refs def update_repo(repo_url, repo_path, branch="master"): import_mod('git') if os.path.isdir(repo_path): shutil.rmtree(repo_path, onerror=set_rw) try: branch = branch if f"refs/heads/{branch}" in git_lsremote(repo_url) else CONFIG.DefaultBranch repo = git.Repo.clone_from(repo_url, repo_path, branch=branch) except git.cmd.GitCommandError as e: return e os.chdir(repo_path) for f in recursive_find(patterns=CONFIG.Remove.Files): os.remove(f) for d in recursive_find(patterns=CONFIG.Remove.Dirs, directory=True): shutil.rmtree(d, onerror=set_rw) os.chdir('../') def check_docker(console=None): msg = "Checking installed docker version" console.h2(msg) if isinstance(console, ConsoleStyle) else print(msg) installed_docker = subprocess.Popen(["docker", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = installed_docker.communicate() if err in CONFIG.EmptyString: installed_version = re.search(r"\d{,2}\.\d{,2}\.\d{,2}", str(out)).group() version = tuple(int(n) for n in installed_version.split(".")) msg = f"required min docker: {version_str(CONFIG.MinVersions.Docker)}" console.info(msg) if isinstance(console, ConsoleStyle) else print(msg) if CONFIG.MinVersions.Docker <= version: msg = f"installed docker version: {installed_version}" console.note(msg) if isinstance(console, ConsoleStyle) else print(msg) else: msg = f"Need to upgrade docker package to {version_str(CONFIG.MinVersions.Docker)}+" console.error(msg) if isinstance(console, ConsoleStyle) else print(msg) exit(1) else: msg = "Failed to parse docker version" console.error(msg) if isinstance(console, ConsoleStyle) else print(msg) exit(1) def check_docker_compose(console=None): msg = "Checking installed docker-compose version" console.h2(msg) if isinstance(console, ConsoleStyle) else print(msg) installed_compose = subprocess.Popen(["docker-compose", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = installed_compose.communicate() if err in CONFIG.EmptyString: installed_version = re.search(r"\d{,2}\.\d{,2}\.\d{,2}", str(out)).group() version = tuple(int(n) for n in installed_version.split(".")) msg = f"required min docker-compose: {version_str(CONFIG.MinVersions.DockerCompose)}" console.info(msg) if isinstance(console, ConsoleStyle) else print(msg) if CONFIG.MinVersions.DockerCompose <= version: msg = f"installed docker-compose version: {installed_version}" console.note(msg) if isinstance(console, ConsoleStyle) else print(msg) else: msg = f"Need to upgrade docker-compose to {version_str(CONFIG.MinVersions.DockerCompose)}+" console.error(msg) if isinstance(console, ConsoleStyle) else print(msg) exit(1) else: msg = "Failed to parse docker-compose version" console.error(msg) if isinstance(console, ConsoleStyle) else print(msg) exit(1) def build_image(docker_sys=None, console=None, **kwargs): import_mod('docker') if docker_sys is None: msg = f"docker_sys arg is required" console.error(msg) if isinstance(console, ConsoleStyle) else print(msg) exit(1) img = None try: img = docker_sys.images.build(**kwargs) except docker.errors.ImageNotFound as e: msg = f"Cannot build image, base image not found: {e}" console.error(msg) if isinstance(console, ConsoleStyle) else print(msg) exit(1) except docker.errors.APIError as e: msg = f"Docker API error: {e}" console.error(msg) if isinstance(console, ConsoleStyle) else print(msg) exit(1) except TypeError as e: msg = "Cannot build image, path nor fileobj args are not specified" console.error(msg) if isinstance(console, ConsoleStyle) else print(msg) exit(1) except KeyboardInterrupt: msg = "Keyboard Interrupt" console.error(msg) if isinstance(console, ConsoleStyle) else print(msg) exit(1) msg = "".join(line.get("stream", "") for line in img[1]) console.verbose("default", msg) if isinstance(console, ConsoleStyle) else print(msg) return img def human_size(size, units=(" bytes", "KB", "MB", "GB", "TB", "PB", "EB")): """ Returns a human readable string reprentation of bytes""" return f"{size:,d}{units[0]}" if size < 1024 else human_size(size >> 10, units[1:]) def version_str(ver): return ".".join(str(x) for x in ver) def prompt(msg, err_msg, isvalid, password=False): res = None password = password if type(password) == bool else False while res is None: if password: res = getpass() else: res = input(str(msg)+': ') if not isvalid(res): print(str(err_msg)) res = None return res
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,181
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from rest_framework import permissions, status, viewsets from rest_framework.exceptions import PermissionDenied from rest_framework.response import Response from ..models import Orchestrator, OrchestratorSerializer, OrchestratorAuth, OrchestratorAuthSerializer from utils import get_or_none class OrchestratorViewSet(viewsets.ModelViewSet): """ API endpoint that allows logs to be viewed """ permission_classes = (permissions.IsAuthenticated, ) serializer_class = OrchestratorSerializer lookup_field = 'orc_id' queryset = Orchestrator.objects.order_by('-name') permissions = { 'create': (permissions.IsAdminUser,), 'destroy': (permissions.IsAdminUser,), 'partial_update': (permissions.IsAdminUser,), 'update': (permissions.IsAdminUser,), } def get_permissions(self): """ Instantiates and returns the list of permissions that this view requires. """ return [permission() for permission in self.permissions.get(self.action, self.permission_classes)] class OrchestratorAuthViewSet(viewsets.ModelViewSet): """ API endpoint that allows logs to be viewed """ permission_classes = (permissions.IsAuthenticated, ) serializer_class = OrchestratorAuthSerializer lookup_field = 'orc_id' queryset = OrchestratorAuth.objects.order_by('-user') def create(self, request, *args, **kwargs): data = request.data if not request.user.is_staff: data['user'] = request.user.username serializer = self.get_serializer(data=data) serializer.is_valid(raise_exception=True) self.perform_create(serializer) headers = self.get_success_headers(serializer.data) return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers) def list(self, request, *args, **kwargs): """ Return a list of all auth tokens that the user has permissions for """ queryset = self.filter_queryset(self.get_queryset()) if not request.user.is_staff: # Standard User queryset = queryset.filter(user=request.user) page = self.paginate_queryset(queryset) if page is not None: serializer = self.get_serializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = self.get_serializer(queryset, many=True) return Response(serializer.data) def retrieve(self, request, *args, **kwargs): """ Return a specific auth toekn that the user has permissions for """ auth = self.get_object() if not request.user.is_staff: # Standard User if auth is not None and auth.user is not request.user: raise PermissionDenied(detail='User not authorised to access auth token', code=401) serializer = self.get_serializer(auth) return Response(serializer.data) def update(self, request, *args, **kwargs): auth = self.get_object() if not request.user.is_staff: # Standard User if auth is not None and auth.user is not request.user: raise PermissionDenied(detail='User not authorised to update auth token', code=401) return super(OrchestratorAuthViewSet, self).update(request, *args, **kwargs) def destroy(self, request, *args, **kwargs): auth = self.get_object() if not request.user.is_staff: # Standard User if auth is not None and auth.user is not request.user: raise PermissionDenied(detail='User not authorised to delete auth token', code=401) return super(OrchestratorAuthViewSet, self).destroy(request, *args, **kwargs)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,182
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/command/migrations/0001_initial.py
# Generated by Django 2.2 on 2019-04-04 18:39 from django.conf import settings from django.db import migrations, models import django.db.models.deletion import django.utils.timezone import jsonfield.fields import uuid class Migration(migrations.Migration): initial = True dependencies = [ ('actuator', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='SentHistory', fields=[ ('command_id', models.UUIDField(default=uuid.uuid4, editable=False, help_text='Unique UUID of the command', primary_key=True, serialize=False)), ('received_on', models.DateTimeField(default=django.utils.timezone.now, help_text='Time the command was received')), ('command', jsonfield.fields.JSONField(blank=True, help_text='Command that was received', null=True)), ('actuators', models.ManyToManyField(help_text='Actuators the command was sent to', to='actuator.Actuator')), ('user', models.ForeignKey(help_text='User that sent the command', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name_plural': 'Sent History', }, ), migrations.CreateModel( name='ResponseHistory', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('received_on', models.DateTimeField(default=django.utils.timezone.now, help_text='Time the respose was received')), ('response', jsonfield.fields.JSONField(blank=True, help_text='Response that was received', null=True)), ('actuator', models.ForeignKey(help_text='Actuator response was received from', null=True, on_delete=django.db.models.deletion.PROTECT, to='actuator.Actuator')), ('command', models.ForeignKey(help_text='Command that was received', on_delete=django.db.models.deletion.CASCADE, to='command.SentHistory')), ], options={ 'verbose_name_plural': 'Response History', }, ), ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,183
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/transport/https/HTTPS/https_transport.py
import re import urllib3 from datetime import datetime from sb_utils import Producer, Consumer, default_encode, decode_msg, encode_msg, safe_json def process_message(body, message): """ Callback when we receive a message from internal buffer to publish to waiting flask. :param body: Contains the message to be sent. :param message: Contains data about the message as well as headers """ http = urllib3.PoolManager(cert_reqs="CERT_NONE") producer = Producer() body = body if isinstance(body, dict) else safe_json(body) rcv_headers = message.headers orc_socket = rcv_headers["source"]["transport"]["socket"] # orch IP:port orc_id = rcv_headers["source"]["orchestratorID"] # orchestrator ID corr_id = rcv_headers["source"]["correlationID"] # correlation ID for device in rcv_headers["destination"]: device_socket = device["socket"] # device IP:port encoding = device["encoding"] # message encoding if device_socket and encoding and orc_socket: for profile in device["profile"]: print(f"Sending command to {profile}@{device_socket}") try: rsp = http.request( method="POST", url=f"https://{device_socket}", body=encode_msg(body, encoding), # command being encoded headers={ "Content-type": f"application/openc2-cmd+{encoding};version=1.0", # "Status": ..., # Numeric status code supplied by Actuator's OpenC2-Response "X-Request-ID": corr_id, "Date": f"{datetime.utcnow():%a, %d %b %Y %H:%M:%S GMT}", # RFC7231-7.1.1.1 -> Sun, 06 Nov 1994 08:49:37 GMT "From": f"{orc_id}@{orc_socket}", "Host": f"{profile}@{device_socket}", } ) rsp_headers = dict(rsp.headers) if "Content-type" in rsp_headers: rsp_enc = re.sub(r"^application/openc2-(cmd|rsp)\+", "", rsp_headers["Content-type"]) rsp_enc = re.sub(r"(;version=\d+\.\d+)?$", "", rsp_enc) else: rsp_enc = "json" rsp_headers = { "socket": device_socket, "correlationID": corr_id, "profile": profile, "encoding": rsp_enc, "transport": "https" } data = { "headers": rsp_headers, "content": decode_msg(rsp.data.decode("utf-8"), rsp_enc) } print(f"Response from request: {rsp.status} - {safe_json(data)}") producer.publish(message=data["content"], headers=rsp_headers, exchange="orchestrator", routing_key="response") except Exception as err: err = str(getattr(err, "message", err)) rcv_headers["error"] = True producer.publish(message=err, headers=rcv_headers, exchange="orchestrator", routing_key="response") print(f"HTTPS error: {err}") else: response = "Destination/Encoding/Orchestrator Socket of command not specified" rcv_headers["error"] = True producer.publish(message=str(response), headers=rcv_headers, exchange="orchestrator", routing_key="response") print(response) if __name__ == "__main__": print("Connecting to RabbitMQ...") try: consumer = Consumer( exchange="transport", routing_key="https", callbacks=[process_message], debug=True ) except Exception as err: print(f"Consumer Error: {err}") consumer.shutdown()
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,184
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/tracking/admin.py
from django.contrib import admin from .models import EventLog, RequestLog class RequestLogAdmin(admin.ModelAdmin): """ Request Log model admin """ date_hierarchy = 'requested_at' list_display = ( 'id', 'requested_at', 'response_ms', 'status_code', 'user', 'method', 'path', 'remote_addr', 'host' ) list_filter = ('method', 'status_code') search_fields = ('path', 'user__email',) raw_id_fields = ('user', ) class EventLogAdmin(admin.ModelAdmin): """ Event Log model admin """ date_hierarchy = 'occurred_at' list_display = ( 'id', 'user', 'occurred_at', 'level', 'message' ) list_filter = ('level', ) # Register Models admin.site.register(RequestLog, RequestLogAdmin) admin.site.register(EventLog, EventLogAdmin)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,185
g2-inc/openc2-oif-orchestrator
refs/heads/master
/base/modules/utils/root/sb_utils/message_obj.py
import struct import uuid from datetime import datetime from enum import Enum from typing import ( List, Union ) from .message import decode_msg, encode_msg class ContentType(Enum): """ The content format of an OpenC2 Message """ Binn = 1 BSON = 2 CBOR = 3 JSON = 4 MsgPack = 5 S_Expression = 6 # smile = 7 XML = 8 UBJSON = 9 YAML = 10 VPack = 11 class MessageType(Enum): """ The type of an OpenC2 Message """ Command = 1 # The Message content is an OpenC2 Command Response = 2 # The Message content is an OpenC2 Response class Message: """ Message parameter holding class """ # to - Authenticated identifier(s) of the authorized recipient(s) of a message recipients: List[str] # from - Authenticated identifier of the creator of or authority for execution of a message origin: str # Creation date/time of the content. created: datetime # The type of OpenC2 Message msg_type: MessageType # Populated with a numeric status code in Responses status: int # A unique identifier created by the Producer and copied by Consumer into all Responses, in order to support reference to a particular Command, transaction, or event chain request_id: uuid.UUID # Media Type that identifies the format of the content, including major version # Incompatible content formats must have different content_types # Content_type application/openc2 identifies content defined by OpenC2 language specification versions 1.x, i.e., all versions that are compatible with version 1.0 content_type: ContentType # Message body as specified by content_type and msg_type content: dict __slots__ = ("recipients", "origin", "created", "msg_type", "status", "request_id", "content_type", "content") def __init__(self, recipients: Union[str, List[str]] = "", origin: str = "", created: datetime = None, msg_type: MessageType = None, status: int = None, request_id: uuid.UUID = None, content_type: ContentType = None, content: dict = None): self.recipients = (recipients if isinstance(recipients, list) else [recipients]) if recipients else [] self.origin = origin self.created = created or datetime.utcnow() self.msg_type = msg_type or MessageType.Command self.status = status or 404 self.request_id = request_id or uuid.uuid4() self.content_type = content_type or ContentType.JSON self.content = content or {} def __setattr__(self, key, val): if key in self.__slots__: object.__setattr__(self, key, val) return raise AttributeError("Cannot set an unknown attribute") def __str__(self): return f"Open Message: <{self.msg_type.name}; {self.content}>" @classmethod def load(cls, m: bytes) -> 'Message': msg = m.split(b"\xF5\xBE") print(len(msg)) if len(msg) != 8: raise ValueError("The OpenC2 message was not properly loaded") [recipients, origin, created, msg_type, status, request_id, content_type, content] = msg return cls( recipients=list(filter(None, map(bytes.decode, recipients.split(b"\xF5\xBD")))), origin=origin.decode(), created=datetime.fromtimestamp(float(".".join(map(str, struct.unpack('LI', created))))), msg_type=MessageType(struct.unpack("B", msg_type)[0]), status=struct.unpack("I", status)[0], request_id=uuid.UUID(bytes=request_id), content_type=ContentType(struct.unpack("B", content_type)[0]), content=decode_msg(content, 'cbor', raw=True) ) @property def serialization(self) -> str: return self.content_type.name # message encoding @property def dict(self) -> dict: return dict( recipients=self.recipients, origin=self.origin, created=self.created, msg_type=self.msg_type, status=self.status, request_id=self.request_id, content_type=self.content_type, content=self.content ) @property def list(self) -> list: return [ self.recipients, self.origin, self.created, self.msg_type, self.status, self.request_id, self.content_type, self.content ] def serialize(self) -> Union[bytes, str]: return encode_msg(self.content, self.content_type.name.lower(), raw=True) def dump(self) -> bytes: return b"\xF5\xBE".join([ # §¥ b"\xF5\xBD".join(map(str.encode, self.recipients)), # §¢ self.origin.encode(), struct.pack('LI', *map(int, str(self.created.timestamp()).split("."))), struct.pack("B", self.msg_type.value), struct.pack("I", self.status), self.request_id.bytes, struct.pack("B", self.content_type.value), encode_msg(self.content, 'cbor', raw=True) ])
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,186
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/utils/general.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals import sys import uuid def prefixUUID(pre='PREFIX', max=30): uid_max = max - (len(pre) + 10) uid = str(uuid.uuid4()).replace('-', '')[:uid_max] return f'{pre}-{uid}'[:max] def safe_cast(val, to_type, default=None): try: return to_type(val) except (ValueError, TypeError): return default def to_str(s): """ Convert a given type to a default string :param s: item to convert to a string :return: converted string """ return s.decode(sys.getdefaultencoding(), "backslashreplace") if hasattr(s, "decode") else str(s)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,187
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/webApp/management/commands/makemigrations_apps.py
import os import sys from django.conf import settings from django.core.management import ManagementUtility from django.core.management.base import BaseCommand class Command(BaseCommand): """ Custom django command - makemigrations_apps Make migrations for the custom apps available to the Django app """ def handle(self, *args, **kwargs): """ Handle command execution :param args: :param kwargs: :return: None """ args = [sys.argv[0], 'makemigrations'] for app in settings.INSTALLED_APPS: app_dir = os.path.join(settings.BASE_DIR, app) if os.path.isdir(app_dir): args.append(app) utility = ManagementUtility(args) utility.execute()
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,188
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/tracking/urls/__init__.py
from django.urls import include, path from .api import urlpatterns as api_patterns from .gui import urlpatterns as gui_patterns urlpatterns = [ # API Patterns path('api/', include(api_patterns), name='log.api'), # GUI Patterns path('', include(gui_patterns), name='log.gui') ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,189
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/device/urls.py
from django.urls import include, path from rest_framework import routers from . import views router = routers.DefaultRouter() router.register('', views.DeviceViewSet) urlpatterns = [ # Device Router path('', include(router.urls), name='device.root'), ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,190
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/orchestrator/preferences_registry.py
import ipaddress import os import re import uuid from django.forms import ValidationError from dynamic_preferences.admin import GlobalPreferenceAdmin, PerInstancePreferenceAdmin from dynamic_preferences.types import StringPreference from dynamic_preferences.preferences import Section from dynamic_preferences.registries import global_preferences_registry as global_registry GlobalPreferenceAdmin.has_add_permission = lambda *args, **kwargs: False GlobalPreferenceAdmin.has_delete_permission = lambda *args, **kwargs: False PerInstancePreferenceAdmin.has_add_permission = lambda *args, **kwargs: False PerInstancePreferenceAdmin.has_delete_permission = lambda *args, **kwargs: False orchestrator = Section("orchestrator") # Validation Functions def is_valid_hostname(hostname): """ Validate a hostname :param hostname: hostname to validate :return: bool - valid hostname """ if len(hostname) > 255: return False if hostname[-1] == ".": hostname = hostname[:-1] # strip exactly one dot from the right, if present allowed = re.compile(r"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE) return all(allowed.match(x) for x in hostname.split(".")) def is_valid_ipv4_address(address): """ Validate an IPv4 Address :param address: IP Address to validate :return: bool - valid address """ try: ipaddress.IPv4Address(address) except ValueError: # not a valid address return False return True def is_valid_ipv6_address(address): """ Validate an IPv6 Address :param address: IP Address to validate :return: bool - valid address """ try: ipaddress.IPv6Address(address) except ValueError: # not a valid address return False return True # Orchestrator section @global_registry.register class OrchestratorName(StringPreference): """ Dynamic Preference for Orchestrator Name """ section = orchestrator name = "name" help_text = "The name of the orchestrator" default = "Jazzy Ocelot" @global_registry.register class OrchestratorID(StringPreference): """ Dynamic Preference for Orchestrator ID """ section = orchestrator name = "id" help_text = "The uuid of the orchestrator" default = "" def __init__(self, *args, **kwargs): """ Initialize the ID of the orchestrator :param args: positional args :param kwargs: key/value args """ super(StringPreference, self).__init__(*args, **kwargs) if self.default in ("", " ", None): self.default = str(uuid.uuid4()) def validate(self, value): """ Validate the ID when updated :param value: new value to validate :return: None/exception """ try: uuid.UUID(value, version=4) except Exception as e: raise ValidationError(str(e)) @global_registry.register class OrchestratorHost(StringPreference): """ Dynamic Preference for Orchestrator Hostname/IP """ section = orchestrator name = "host" help_text = "The hostname/ip of the orchestrator" _default = os.environ.get("ORC_IP", "127.0.0.1") _val_host_addr = any([is_valid_hostname(_default), is_valid_ipv4_address(_default), is_valid_ipv6_address(_default)]) default = _default if _val_host_addr else "127.0.0.1" def validate(self, value): """ Validate the Hostname/IP when updated :param value: new value to validate :return: None/exception """ if not any([is_valid_hostname(value), is_valid_ipv4_address(value), is_valid_ipv6_address(value)]): raise ValidationError("The host is not a valid Hostname/IPv4/IPv6")
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,191
g2-inc/openc2-oif-orchestrator
refs/heads/master
/configure.py
#!/usr/bin/env python import atexit import os import re import shutil import sys from datetime import datetime from optparse import OptionParser from base.modules.script_utils import ( # Functions build_image, check_docker, check_docker_compose, checkRequiredArguments, human_size, install_pkg, # Classes ConsoleStyle, FrozenDict ) if sys.version_info < (3, 6): print("PythonVersionError: Minimum version of v3.6+ not found") exit(1) # Option Parsing parser = OptionParser() parser.add_option("-f", "--log-file", dest="log_file", help="Write logs to LOG_FILE") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Verbose output of container/GUI build") (options, args) = parser.parse_args() checkRequiredArguments(options, parser) log_file = None init_now = datetime.now() if options.log_file: name, ext = os.path.splitext(options.log_file) ext = ".log" if ext is "" else ext fn = f"{name}-{init_now:%Y.%m.%d_%H.%M.%S}{ext}" # log_file = open(fn, "w+") log_file = open(options.log_file, "w+") log_file.write(f"Configure run at {init_now:%Y.%m.%d_%H:%M:%S}\n\n") log_file.flush() atexit.register(log_file.close) # Script Vars ItemCount = 1 RootDir = os.path.dirname(os.path.realpath(__file__)) CONFIG = FrozenDict( WorkDir=RootDir, Requirements=( ("docker", "docker"), ("colorama", "colorama"), ("yaml", "pyyaml") ), ImagePrefix="g2inc", Logging=FrozenDict( Default=( ("orchestrator", "-p orchestrator -f orchestrator-compose.yaml -f orchestrator-compose.log.yaml"), ), Central=( ("orchestrator", "-p orchestrator -f orchestrator-compose.yaml"), ) ), Composes=tuple(file for file in os.listdir(RootDir) if re.match(r"^\w*?-compose(\.\w*?)?\.yaml$", file)) ) # Utility Functions def get_count(): global ItemCount c = ItemCount ItemCount += 1 return c if __name__ == "__main__": os.chdir(CONFIG.WorkDir) print("Installing Requirements") for PKG in CONFIG.Requirements: install_pkg(PKG) Stylize = ConsoleStyle(options.verbose, log_file) import docker Stylize.h1(f"[Step {get_count()}]: Check Docker Environment") check_docker(Stylize) check_docker_compose(Stylize) system = docker.from_env() try: system.info() except Exception as e: Stylize.error("Docker connection failed, check that docker is running") exit(1) # -------------------- Build Base Images -------------------- # Stylize.h1(f"[Step {get_count()}]: Build Base Images ...") Stylize.info("Building base alpine python3 image") build_image( docker_sys=system, console=Stylize, path="./base", dockerfile="./Dockerfile_alpine-python3", tag=f"{CONFIG.ImagePrefix}/oif-python", rm=True ) # -------------------- Build Compose Images -------------------- # Stylize.h1(f"[Step {get_count()}]: Creating compose images ...") from yaml import load try: from yaml import CLoader as Loader except ImportError: from yaml import Loader compose_images = [] Stylize.h1(f"Build images ...") for compose in CONFIG.Composes: with open(f"./{compose}", "r") as orc_compose: for service, opts in load(orc_compose.read(), Loader=Loader)["services"].items(): if "build" in opts and opts["image"] not in compose_images: compose_images.append(opts["image"]) Stylize.info(f"Building {opts['image']} image") build_image( docker_sys=system, console=Stylize, rm=True, path=opts["build"]["context"], dockerfile=opts["build"].get("dockerfile", "Dockerfile"), tag=opts["image"] ) # -------------------- Cleanup Images -------------------- # Stylize.h1(f"[Step {get_count()}]: Cleanup unused images ...") try: rm_images = system.images.prune() Stylize.info(f"Space reclaimed {human_size(rm_images.get('SpaceReclaimed', 0))}") if rm_images["ImagesDeleted"]: for image in rm_images["ImagesDeleted"]: Stylize.verbose("info", f"Image deleted: {image.get('Deleted', 'IMAGE')}") except docker.errors.APIError as e: Stylize.error(f"Docker API error: {e}") exit(1) except KeyboardInterrupt: Stylize.error("Keyboard Interrupt") exit(1) Stylize.success("\nConfiguration Complete") for key, opts in CONFIG.Logging.items(): Stylize.info(f"{key} logging") for opt in opts: Stylize.info(f"-- Run 'docker-compose {opt[1]} up' to start the {opt[0]} compose")
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,192
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/tracking/urls/api.py
from django.urls import include, path from rest_framework import routers from .. import views router = routers.DefaultRouter() router.register('event', views.EventLogViewSet) router.register('request', views.RequestLogViewSet) urlpatterns = [ # Routers path('', include(router.urls)) ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,193
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/utils/general.py
""" General Utilities """ import random import string import sys import uuid from typing import Any valid_hex = set(string.hexdigits) valid_hex.add(" ") def prefixUUID(pre: str = "PREFIX", max_length: int = 30) -> str: """ Create a unique name with a prefix and a UUID string :param pre: prefix to use :param max_length: max length of the unique name :return: unique name with the given prefix """ if len(pre) > max_length: raise ValueError(f"max_length is greater than the length of the prefix: {len(pre)}") uid_max = max_length - len(pre) uid = str(uuid.uuid4()).replace("-", "")[:uid_max] if pre in ["", " ", None]: return f"{uid}"[:max_length] return f"{pre}-{uid}"[:max_length] def to_str(s: Any) -> str: """ Convert a given type to a default string :param s: item to convert to a string :return: converted string """ return s.decode(sys.getdefaultencoding(), "backslashreplace") if hasattr(s, "decode") else str(s) def randBytes(b: int = 2) -> bytes: """ Get a random number of bytes :param b: number of bytes generate :return: random number of bytes requested """ return bytes([random.getrandbits(8) for _ in range(b)]) def isHex(val: str) -> bool: """ Determine if the given value is a valid hexadecimal string :param val: string to validate :return: bool - valid/invalid hexadecimal """ val = ''.join(val.split("0x")) return len(set(val) - valid_hex) == 0
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,194
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/es_mirror/settings.py
import logging from django.conf import settings SETTINGS = dict( host=None, prefix='', timeout=60 ) SETTINGS.update(getattr(settings, 'ES_MIRROR', {})) # elastic logger config es_logger = logging.getLogger('elasticsearch') es_logger.setLevel(logging.WARNING)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,195
g2-inc/openc2-oif-orchestrator
refs/heads/master
/update_subs.py
#!/usr/bin/env python import atexit import os import re import sys from datetime import datetime from optparse import OptionParser from pathlib import Path from base.modules.script_utils import ( # Functions checkRequiredArguments, install_pkg, recursive_find, update_repo, # Classes ConsoleStyle, FrozenDict ) if sys.version_info < (3, 6): print('PythonVersionError: Minimum version of v3.6+ not found') exit(1) # Option Parsing parser = OptionParser() parser.add_option("-u", "--url_base", dest="url_base", default="", help="[REQUIRED] Base URL for git repo") parser.add_option("-r", "--repo_branch", dest="repo_branch", default="master", help="Branch to clone from the repo") parser.add_option("-l", "--log_file", dest="log_file", help="Write logs to LOG_FILE") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Verbose output of container build") (options, args) = parser.parse_args() checkRequiredArguments(options, parser) log_file = None init_now = datetime.now() if options.log_file: name, ext = os.path.splitext(options.log_file) ext = '.log' if ext is '' else ext fn = f'{name}-{init_now:%Y.%m.%d_%H.%M.%S}{ext}' log_file = open(options.log_file, 'w+') log_file.write(f'Configure run at {init_now:%Y.%m.%d_%H:%M:%S}\n\n') log_file.flush() atexit.register(log_file.close) # Script Config ItemCount = 1 if options.url_base.startswith("http"): Base_URL = options.url_base if options.url_base.endswith("/") else options.url_base + '/' else: Base_URL = options.url_base if options.url_base.endswith(":") else options.url_base + ':' CONFIG = FrozenDict( RootDir=os.path.dirname(os.path.realpath(__file__)), Requirements=( ('git', 'gitpython'), ('colorama', 'colorama') ), BaseRepo=f"{Base_URL}ScreamingBunny", ImageReplace=( ("base", r"gitlab.*?docker:alpine( as.*)?", r"alpine\g<1>\nRUN apk upgrade --update && apk add --no-cache dos2unix && rm /var/cache/apk/*"), ("python3", r"gitlab.*plus:alpine-python3( as.*)?", fr"g2inc/oif-python\g<1>\nRUN apk upgrade --update && apk add --no-cache dos2unix && rm /var/cache/apk/*"), ), Repos=FrozenDict( Orchestrator=('Core', 'GUI'), Transport=('HTTPS', 'MQTT', 'CoAP'), ) ) # Utility Classes (Need Config) class Stage: def __init__(self, name='Stage', root=CONFIG.RootDir): self.name = name self.root = root if root.startswith(CONFIG.RootDir) else os.path.join(CONFIG.RootDir, root) def __enter__(self): Stylize.h1(f"[Step {get_count()}]: Update {self.name}") return self._mkdir_chdir() def __exit__(self, type, value, traceback): global ItemCount ItemCount += 1 os.chdir(CONFIG.RootDir) Stylize.success(f'Updated {self.name}') def _mkdir_chdir(self): Path(self.root).mkdir(parents=True, exist_ok=True) os.chdir(self.root) return self.root # Utility Functions def get_count(): global ItemCount c = ItemCount ItemCount += 1 return c if __name__ == '__main__': os.chdir(CONFIG.RootDir) print('Installing Requirements') for PKG in CONFIG.Requirements: install_pkg(PKG) Stylize = ConsoleStyle(options.verbose, log_file) import git Stylize.default('') if sys.platform in ["win32", "win64"]: # Windows 32/64-bit git.Git.USE_SHELL = True Stylize.underline('Starting Update') # -------------------- Modules -------------------- # with Stage('Modules', 'base/modules'): Stylize.h2("Updating Utilities") update_repo(f"{CONFIG.BaseRepo}/Utils.git", 'utils', options.repo_branch) # -------------------- Orchestrator -------------------- # with Stage('Orchestrator', 'orchestrator'): for repo in CONFIG.Repos.Orchestrator: Stylize.h2(f"Updating {repo}") update_repo(f"{CONFIG.BaseRepo}/Orchestrator/{repo}.git", repo.lower(), options.repo_branch) # -------------------- Orchestrator Transport -------------------- # with Stage(f'Orchestrator Transport', os.path.join('orchestrator', 'transport')): for transport in CONFIG.Repos.Transport: Stylize.h2(f"Updating Orchestrator {transport}") update_repo(f"{CONFIG.BaseRepo}/Orchestrator/Transport/{transport}.git", transport.lower(), options.repo_branch) # -------------------- Logger -------------------- # with Stage('Logger'): Stylize.h2("Updating Logger") update_repo(f"{CONFIG.BaseRepo}/Logger.git", 'logger', options.repo_branch) # -------------------- Dockerfile -------------------- # with Stage('Dockerfiles'): for dockerfile in recursive_find(patterns=['Dockerfile']): with open(dockerfile, 'r') as f: tmpFile = f.read() for (name, orig_img, repl_img) in CONFIG.ImageReplace: if re.search(orig_img, tmpFile): Stylize.info(f'Updating {dockerfile}') Stylize.bold(f'- Found {name} image, updating for public repo\n') tmpFile = re.sub(orig_img, repl_img, tmpFile) with open(dockerfile, 'w') as f: f.write(tmpFile) break Stylize.info("Run `configure.py` from the public folder to create the base containers necessary to run the OIF Orchestrator")
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,196
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/conformance/migrations/0001_initial.py
# Generated by Django 2.2.10 on 2020-03-09 15:14 from django.db import migrations, models import django.db.models.deletion import django.utils.timezone import jsonfield.fields import uuid class Migration(migrations.Migration): initial = True dependencies = [ ('actuator', '0002_auto_20190417_1319'), ] operations = [ migrations.CreateModel( name='ConformanceTest', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('test_id', models.UUIDField(default=uuid.uuid4, help_text='Unique UUID of the test', unique=True)), ('test_time', models.DateTimeField(default=django.utils.timezone.now, help_text='Time the test was run')), ('tests_run', jsonfield.fields.JSONField(blank=True, help_text='Tests that were selected for conformance', null=True)), ('test_results', jsonfield.fields.JSONField(blank=True, help_text='Tests results', null=True)), ('actuator_tested', models.ForeignKey(help_text='Actuator tests were run against', on_delete=django.db.models.deletion.CASCADE, to='actuator.Actuator')), ], ), ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,197
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/webApp/views/api.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from rest_framework import permissions from rest_framework.decorators import api_view, permission_classes from rest_framework.response import Response @api_view(['GET']) @permission_classes((permissions.AllowAny,)) def api_root(request): """ Orchestrator basic information """ attrs = {} for attr in dir(request): try: attrs[attr] = getattr(request, attr) except Exception as e: print(e) rtn = dict( message="Hello, {}. You're at the orchestrator gui api index.".format(request.user.username or 'guest'), commands=dict( sent=0, responses=0 ), name='GUI Server', id='', protocols=[], serializations=[] ) return Response(rtn)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,198
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/actuator/admin.py
from django.contrib import admin # Local imports from utils import ReadOnlyModelAdmin from .models import Actuator, ActuatorGroup, ActuatorProfile class ActuatorAdmin(admin.ModelAdmin): """ Actuator admin """ readonly_fields = ('actuator_id', 'profile', 'schema_format') list_display = ('name', 'device', 'profile', 'schema_format') class ActuatorGroupAdmin(admin.ModelAdmin): """ Actuator Group admin """ list_display = ('name', 'user_count', 'actuator_count') filter_horizontal = ('users', 'actuators') class ActuatorProfileAdmin(ReadOnlyModelAdmin, admin.ModelAdmin): """ Actuator Profile admin """ list_display = ('name', 'actuator_count') filter_horizontal = ('actuators', ) def get_readonly_fields(self, request, obj=None): """ Set name and actuator fields to read only if user is not the superuser :param request: request instance :param obj: ... :return: tuple - read only fields """ if request.user.is_superuser: return () return 'name', 'actuators' # Register models admin.site.register(Actuator, ActuatorAdmin) admin.site.register(ActuatorGroup, ActuatorGroupAdmin) admin.site.register(ActuatorProfile, ActuatorProfileAdmin)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,199
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/conformance/models.py
import uuid from django.db import models from django.utils import timezone from drf_queryfields import QueryFieldsMixin from jsonfield import JSONField from rest_framework import serializers # Local imports from actuator.models import Actuator, ActuatorSerializer class ConformanceTest(models.Model): """ Conformance Test instance base """ test_id = models.UUIDField( default=uuid.uuid4, help_text="Unique UUID of the test", unique=True ) actuator_tested = models.ForeignKey( Actuator, on_delete=models.CASCADE, help_text="Actuator tests were run against" ) test_time = models.DateTimeField( default=timezone.now, help_text="Time the test was run" ) tests_run = JSONField( blank=True, help_text="Tests that were selected for conformance", null=True ) test_results = JSONField( blank=True, help_text="Tests results", null=True ) class ConformanceTestSerializer(QueryFieldsMixin, serializers.ModelSerializer): """ Actuator API Serializer """ test_id = serializers.UUIDField(format='hex_verbose') actuator_tested = ActuatorSerializer(read_only=True) test_time = serializers.DateTimeField() tests_run = serializers.JSONField() test_results = serializers.JSONField() class Meta: model = ConformanceTest fields = ('test_id', 'actuator_tested', 'test_time', 'tests_run', 'test_results') read_only_fields = fields
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,200
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/actuator/apps.py
from django.apps import AppConfig class ActuatorConfig(AppConfig): name = 'actuator'
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,201
g2-inc/openc2-oif-orchestrator
refs/heads/master
/base/modules/utils/root/sb_utils/message/pybinn/decoder.py
""" Implementation of BINNDecoder """ import io from datetime import datetime, timedelta from functools import partial from struct import unpack from typing import ( Callable, Dict, Union ) from . import datatypes as types class BINNDecoder: """ BINN <https://github.com/liteserver/binn> decoder for Python """ _decoders: Dict[bytes, Callable] def __init__(self, buffer=None, fp=None, *custom_decoders): # pylint: disable=keyword-arg-before-vararg if buffer: self._buffer = io.BytesIO(buffer) if fp: self._buffer = fp self._custom_decoders = custom_decoders self._decoders = { types.BINN_STRING: self._decode_str, types.BINN_UINT8: partial(self._unpack, 'B', 1), types.BINN_INT8: partial(self._unpack, 'b', 1), types.BINN_UINT16: partial(self._unpack, 'H', 2), types.BINN_INT16: partial(self._unpack, 'h', 2), types.BINN_UINT32: partial(self._unpack, 'I', 4), types.BINN_INT32: partial(self._unpack, 'i', 4), types.BINN_UINT64: partial(self._unpack, 'L', 8), types.BINN_INT64: partial(self._unpack, 'l', 8), types.BINN_FLOAT64: partial(self._unpack, 'd', 8), types.BINN_BLOB:self._decode_bytes, types.BINN_DATETIME: self._decode_datetime, types.BINN_LIST: self._decode_list, types.BINN_OBJECT: self._decode_dict, types.BINN_MAP: self._decode_dict, types.PYBINN_MAP: self._decode_dict, types.BINN_TRUE: lambda: True, types.BINN_FALSE: lambda: False, types.BINN_NULL: lambda: None } def decode(self): """ Decode date from buffer """ binntype = self._buffer.read(1) decoder = self._decoders.get(binntype, None) if decoder and binntype in (types.BINN_OBJECT, types.BINN_MAP, types.PYBINN_MAP): return decoder(binntype) if decoder: return decoder() # if type was not found, try using custom decoders for decoder in self._custom_decoders: if not issubclass(type(decoder), CustomDecoder): raise TypeError("Type {} is not CustomDecoder.") if binntype == decoder.datatype: return self._decode_custom_type(decoder) raise TypeError(f"Invalid data format: {binntype}") def _decode_str(self): size = self._from_varint() value = self._buffer.read(size).decode('utf8') # Ready null terminator byte to advance position self._buffer.read(1) return value def _decode_bytes(self): size = unpack('I', self._buffer.read(4))[0] return self._buffer.read(size) def _decode_datetime(self): timestamp = float(unpack('d', self._buffer.read(8))[0]) # datetime.utcfromtimestamp method in python3.3 has rounding issue (https://bugs.python.org/issue23517) return datetime(1970, 1, 1) + timedelta(seconds=timestamp) def _decode_list(self): # read container size self._from_varint() count = self._from_varint() result = [] for _ in range(count): result.append(self.decode()) return result def _decode_dict(self, binntype): # read container size self._from_varint() count = self._from_varint() result = {} for _ in range(count): if binntype == types.BINN_OBJECT: key_size = unpack('B', self._buffer.read(1))[0] key = self._buffer.read(key_size).decode('utf8') if binntype == types.BINN_MAP: key = unpack('I', self._buffer.read(4))[0] if binntype == types.PYBINN_MAP: key = self._buffer.read(types.PYBINN_MAP_SIZE) result[key] = self.decode() return result def _decode_custom_type(self, decoder): size = self._from_varint() return decoder.getobject(self._buffer.read(size)) def _from_varint(self): value = unpack('B', self._buffer.read(1))[0] if value & 0x80: self._buffer.seek(self._buffer.tell() - 1) value = unpack('>I', self._buffer.read(4))[0] value &= 0x7FFFFFFF return value # Switch Helpers def _unpack(self, fmt: str, rb: int) -> Union[int, float]: return unpack(fmt, self._buffer.read(rb))[0] class CustomDecoder: """ Base class for handling decoding user types """ def __init__(self, data_type): # check if custom data type is not BINN type if data_type in types.ALL: raise Exception(f"Data type {data_type} is defined as internal type.") self.datatype = data_type def getobject(self, data_bytes): """ Decode object from bytes """ raise NotImplementedError()
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,202
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/utils/permissions.py
""" Django View Permission Utilities """ from rest_framework import permissions class IsAdminOrIsSelf(permissions.BasePermission): """ Object-level permission to only allow owners of an object to edit it. Only functional for User model functions """ def has_object_permission(self, request, view, obj): return obj == request.user or request.user.is_staff or request.user.is_superuser
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,203
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/tracking/views/__init__.py
from .api import api_root from .gui import gui_events, gui_requests, gui_root from .viewsets import EventLogViewSet, RequestLogViewSet __all__ = [ # API 'api_root', # GUI 'gui_events', 'gui_requests', 'gui_root', # Viewsets 'EventLogViewSet', 'RequestLogViewSet' ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,204
g2-inc/openc2-oif-orchestrator
refs/heads/master
/base/modules/utils/root/sb_utils/amqp_tools.py
""" amqp_tools.py Implements wrapper for kombu module to more-easily read/write from message queue. """ import kombu # handles interaction with AMQP server import socket # identify exceptions that occur with timeout import datetime # print time received message import os # to determine localhost on a given machine from functools import partial from inspect import isfunction from multiprocessing import Event, Process from typing import Union class Consumer(Process): """ The Consumer class reads messages from message queue and determines what to do with them. """ HOST = os.environ.get("QUEUE_HOST", "localhost") PORT = os.environ.get("QUEUE_PORT", 5672) EXCHANGE = "transport" ROUTING_KEY = "*" def __init__(self, host: str = HOST, port: int = PORT, exchange: str = EXCHANGE, routing_key: str = ROUTING_KEY, callbacks: Union[list, tuple] = None, debug: bool = False): """ Consume message from queue exchange. :param host: host running RabbitMQ :param port: port which handles AMQP (default 5672) :param exchange: specifies where to read messages from :param routing_key: :param callbacks: list of callback functions which are called upon receiving a message :param debug: print debugging messages """ super().__init__() self._exit = Event() self._url = f"amqp://{host}:{port}" self._exchange_name = exchange self._callbacks = () self._debug = debug if isinstance(callbacks, (list, tuple)): for func in callbacks: self.add_callback(func) # Initialize connection we are consuming from based on defaults/passed params self._conn = kombu.Connection(hostname=host, port=port, userid="guest", password="guest", virtual_host="/") self._exchange = kombu.Exchange(self._exchange_name, type="topic") self._routing_key = routing_key # At this point, consumers are reading messages regardless of queue name # so I am just setting it to be the same as the exchange. self._queue = kombu.Queue(name=self._routing_key, exchange=self._exchange, routing_key=self._routing_key) # Start consumer as an independent process self.start() if self._debug: print(f"Connected to {self._url}") def run(self) -> None: """ Runs the consumer until stopped. """ with kombu.Consumer(self._conn, queues=self._queue, callbacks=[self._on_message], accept=["text/plain", "application/json"]): if self._debug: print(f"Connected to {self._url} on exchange [{self._exchange_name}], routing_key [{self._routing_key}] and waiting to consume...") while not self._exit.is_set(): try: self._conn.drain_events(timeout=5) except socket.timeout: pass except KeyboardInterrupt: self.shutdown() def _on_message(self, body, message): """ Default option for a consumer callback, prints out message and message data. :param body: contains the body of the message sent :param message: contains meta data about the message sent (ie. delivery_info) """ if self._debug: print(f"Message Received @ {datetime.datetime.now()}") message.ack() for func in self._callbacks: func(body, message) def add_callback(self, fun): """ Add a function to the list of callback functions. :param fun: function to add to callbacks """ if isfunction(fun) or isinstance(fun, partial): if fun in self._callbacks: raise ValueError("Duplicate function found in callbacks") self._callbacks = (*self._callbacks, fun) def get_exchanges(self): """ Get a list of exchange names on the queue :return: list of exchange names """ exchanges = self._conn.get_manager().get_exchanges() return list(filter(None, [exc.get("name", "")for exc in exchanges])) def get_queues(self): """ Get a list of queue names on the queue :return: list of queue names """ queues = self._conn.get_manager().get_queues() return list(filter(None, [que.get("name", "") for que in queues])) def get_binds(self): """ Get a list of exchange/topic bindings :return: list of exchange/topic bindings """ binds = [] manager = self._conn.get_manager() for queue in self.get_queues(): for bind in manager.get_queue_bindings(vhost="/", qname=queue): binds.append({ "exchange": bind.get("source", ""), "routing_key": bind.get("routing_key", "") }) return binds def shutdown(self): """ Shutdown the consumer and cleanly close the process """ self._exit.set() print("The consumer has shutdown.") class Producer: """ The Producer class writes messages to the message queue to be consumed. """ HOST = os.environ.get("QUEUE_HOST", "localhost") PORT = os.environ.get("QUEUE_PORT", 5672) EXCHANGE = "transport" ROUTING_KEY = "*" def __init__(self, host: str = HOST, port: int = PORT, debug: bool = False): """ Sets up connection to broker to write to. :param host: hostname for the queue server :param port: port for the queue server :param debug: print debugging messages """ self._url = f"amqp://{host}:{port}" self._debug = debug self._conn = kombu.Connection(hostname=host, port=port, userid="guest", password="guest", virtual_host="/") def publish(self, message: Union[dict, str] = "", headers: dict = None, exchange: str = EXCHANGE, routing_key: str = ROUTING_KEY): """ Publish a message to th AMQP Queue :param message: message to be published :param headers: header key-values to publish with the message :param exchange: specifies the top level specifier for message publish :param routing_key: determines which queue the message is published to """ self._conn.connect() queue = kombu.Queue(routing_key, kombu.Exchange(exchange, type="topic"), routing_key=routing_key) queue.maybe_bind(self._conn) queue.declare() producer = kombu.Producer(self._conn.channel()) producer.publish( message, headers=headers or {}, exchange=queue.exchange, routing_key=queue.routing_key, declare=[queue] ) producer.close() self._conn.release()
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,205
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/device/migrations/0004_remove_device_multi_actuator.py
# Generated by Django 2.2.7 on 2019-12-20 13:45 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('device', '0003_device_multi_actuator'), ] operations = [ migrations.RemoveField( model_name='device', name='multi_actuator', ), ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,206
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/account/views/viewsets.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals import base64 from django.contrib.auth.models import User from rest_framework import permissions, status, viewsets from rest_framework.decorators import detail_route from rest_framework.response import Response from ..models import UserSerializer, PasswordSerializer from utils import IsAdminOrIsSelf class UserViewSet(viewsets.ModelViewSet): """ API endpoint that allows users to be viewed or edited. """ permission_classes = (permissions.IsAdminUser, ) serializer_class = UserSerializer lookup_field = 'username' queryset = User.objects.all().order_by('-date_joined') @detail_route(methods=['post'], permission_classes=[IsAdminOrIsSelf], url_path='change_password') def change_password(self, request, username=None): """ Change user password passwords sent as base64 encoded strings """ serializer = PasswordSerializer(data=request.data) user = self.get_object() if serializer.is_valid(): if not user.check_password(base64.b64decode(serializer.data.get('old_password'))): return Response({'old_password': ['Wrong password.']}, status=status.HTTP_400_BAD_REQUEST) # set_password also hashes the password that the user will get user.set_password(base64.b64decode(serializer.data.get('new_password_1'))) user.save() return Response({'status': 'password changed'}, status=status.HTTP_200_OK) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,207
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/transport/coap/COAP/coap_client.py
import json from coapthon import defines from coapthon.client.helperclient import HelperClient from coapthon.messages.option import Option from coapthon.utils import generate_random_token from sb_utils import encode_msg, safe_cast, Consumer class CoapClient(HelperClient): def post(self, path, payload, callback=None, timeout=5, no_response=False, **kwargs): """ Perform a POST on a certain path. :param path: the path :param payload: the request payload :param callback: the callback function to invoke upon response :param timeout: the timeout of the request :return: the response """ request = kwargs.pop("request", self.mk_request(defines.Codes.POST, path)) request.payload = payload request.token = generate_random_token(2) request.version = 1 if no_response: request.add_no_response() request.type = defines.Types["NON"] for k, v in kwargs.items(): if hasattr(request, k): setattr(request, k, v) return self.send_request(request, callback, timeout) def send_coap(body, message): """ AMQP Callback when we receive a message from internal buffer to be published :param body: Contains the message to be sent. :param message: Contains data about the message as well as headers """ # Set destination and build requests for multiple potential endpoints. for device in message.headers.get("destination", {}): host, port = device["socket"].split(":", 1) encoding = device["encoding"] # Check necessary headers exist if host and port and encoding: path = "transport" client = CoapClient(server=(host, safe_cast(port, int, 5683))) request = client.mk_request(defines.Codes.POST, path) response = client.post( path=path, payload=encode_msg(json.loads(body), encoding), request=build_request(request, message.headers.get("source", {}), device) ) if response: print(f"Response from device: {response}") client.stop() else: # send error back to orch print(f"Error: not enough data - {host}, {port}, {encoding}") def build_request(request, headers, device): """ Helper method to organized required headers into the CoAP Request. :param request: Request being build :param headers: Data from AMQP message which contains data to forward OpenC2 Command. :param device: Device specific data from headers sent by O.I.F. """ orc_host, orc_port = headers["transport"]["socket"].split(":", 1) # location of orchestrator-side CoAP server request.source = (orc_host, safe_cast(orc_port, int, 5683)) dev_host, dev_port = device["socket"].split(":", 1) # location of device-side CoAP server request.destination = (dev_host, safe_cast(dev_port, int, 5683)) encoding = f"application/{device['encoding']}" # Content Serialization request.content_type = defines.Content_types[encoding] # using application/json, TODO: add define to openc2+json request.mid = int("0x" + headers["correlationID"], 16) # 16-bit correlationID request.timestamp = headers["date"] # time message was sent from orchestrator # Add OIF-unique value used for routing to the desired actuator profile = Option() profile.number = 8 profile.value = device.get("profile", "")[0] request.add_option(profile) source_socket = Option() source_socket.number = 3 source_socket.value = headers["transport"]["socket"] request.add_option(source_socket) return request if __name__ == "__main__": # Begin consuming messages from internal message queue try: consumer = Consumer( exchange="transport", routing_key="coap", callbacks=[send_coap] ) except Exception as e: print(f"Consumer error: {e}") consumer.shutdown()
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,208
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/account/views/__init__.py
from .api import actuatorDelete from .apiviews import ActuatorAccess from .viewsets import UserViewSet, UserHistoryViewSet __all__ = [ # API 'actuatorDelete', # APIViews 'ActuatorAccess', # Viewsets 'UserViewSet', 'UserHistoryViewSet', ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,209
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/webApp/management/commands/loaddata_apps.py
import os import sys from django.conf import settings from django.core.management import ManagementUtility from django.core.management.base import BaseCommand from threading import Thread class Command(BaseCommand): """ Custom django command - loaddata_apps Load data for the custom apps available to the Django app """ def handle(self, *args, **kwargs): """ Handle command execution :param args: :param kwargs: :return: None """ args = (sys.argv[0], 'loaddata') for app in settings.INSTALLED_APPS: app_dir = os.path.join(settings.BASE_DIR, app) if os.path.isdir(app_dir): print(f'Loading Fixtures for {app}') utility = ManagementUtility([*args, app]) p = Thread(target=utility.execute) p.start() p.join() print('')
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,210
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/backup/views/__init__.py
from .api import ( backupRoot ) from .import_export import ( ActuatorImportExport, DeviceImportExport ) __all__ = [ # API 'backupRoot', # APIViews # Import/Export 'ActuatorImportExport', 'DeviceImportExport' ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,211
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/actuator/views/viewsets.py
import bleach from rest_framework import viewsets, filters from rest_framework.decorators import action from rest_framework.exceptions import PermissionDenied from rest_framework.permissions import IsAdminUser, IsAuthenticated from rest_framework.response import Response from ..models import Actuator, ActuatorGroup, ActuatorSerializer class ActuatorViewSet(viewsets.ModelViewSet): """ API endpoint that allows Actuators to be viewed or edited. """ permission_classes = (IsAuthenticated,) serializer_class = ActuatorSerializer lookup_field = 'actuator_id' queryset = Actuator.objects.order_by('name') filter_backends = (filters.OrderingFilter,) ordering_fields = ('actuator_id', 'name', 'profile', 'type') permissions = { 'create': (IsAdminUser,), 'destroy': (IsAdminUser,), 'partial_update': (IsAdminUser,), 'retrieve': (IsAuthenticated,), 'update': (IsAdminUser,), } def get_permissions(self): """ Instantiates and returns the list of permissions that this view requires. """ return [permission() for permission in self.permissions.get(self.action, self.permission_classes)] def list(self, request, *args, **kwargs): """ Return a list of all actuators that the user has permissions for """ self.pagination_class.page_size_query_param = 'length' self.pagination_class.max_page_size = 100 queryset = self.filter_queryset(self.get_queryset()) # TODO: set permissions ''' if not request.user.is_staff: # Standard User user_actuators = ActuatorGroup.objects.filter(users__in=[request.user]) user_actuators = list(g.actuators.values_list('name', flat=True) for g in user_actuators) queryset = queryset.filter(name__in=user_actuators) ''' # pylint: disable=pointless-string-statement page = self.paginate_queryset(queryset) if page is not None: serializer = self.get_serializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = self.get_serializer(queryset, many=True) return Response(serializer.data) def retrieve(self, request, *args, **kwargs): """ Return a specific actuators that the user has permissions for """ actuator = self.get_object() # TODO: set permissions ''' if not request.user.is_staff: # Standard User user_actuators = ActuatorGroup.objects.filter(users__in=[request.user]) user_actuators = list(g.actuators.values_list('name', flat=True) for g in user_actuators) if actuator is not None and actuator.name not in user_actuators: raise PermissionDenied(detail='User not authorised to access actuator', code=401) ''' # pylint: disable=pointless-string-statement serializer = self.get_serializer(actuator) return Response(serializer.data) @action(methods=['PATCH'], detail=False) def refresh(self, request, *args, **kwargs): """ API endpoint that allows Actuator data to be refreshed """ instance = self.get_object() valid_refresh = ['all', 'info', 'schema'] refresh = bleach.clean(kwargs.get('refresh', 'info')) if instance is not None: if refresh not in valid_refresh: refresh = 'info' # TODO: refresh actuator data # print('Valid instance') # print('refresh') return Response({ 'refresh': refresh }) @action(methods=['GET'], detail=False) def profile(self, request, *args, **kwargs): """ API endpoint that allows for Actuator profile retrieval """ actuator = self.get_object() if not request.user.is_staff: # Standard User actuator_groups = [g.name for g in ActuatorGroup.objects.filter(actuator=actuator).filter(users__in=[request.user])] if len(actuator_groups) == 0: raise PermissionDenied(detail='User not authorised to access actuator', code=401) rtn = { 'schema': actuator.schema } return Response(rtn) @action(methods=['GET'], detail=False) def users(self, request, *args, **kwargs): """ API endpoint that allows for Actuator user retrieval """ actuator = self.get_object() if not request.user.is_staff: # Standard User actuator_groups = [g.name for g in ActuatorGroup.objects.filter(actuator=actuator).filter(users__in=[request.user])] if len(actuator_groups) == 0: raise PermissionDenied(detail='User not authorised to access actuator', code=401) group_users = [[u.username for u in ag.users.all()] for ag in ActuatorGroup.objects.filter(actuator=actuator)] rtn = { 'users': sum(group_users, []) } return Response(rtn)
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,212
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/utils/orchestrator_api.py
import atexit import json import re import websocket from functools import partial from simple_rest_client.api import API from simple_rest_client.resource import Resource from sb_utils import FrozenDict, safe_cast class RootResource(Resource): _base_url = "" actions = dict( info=dict(method="GET", url=f"{_base_url}"), api=dict(method="GET", params={"format": "corejson"}, url=f"{_base_url}/schema") ) class AccountResource(Resource): _base_url = "/account" actions = dict( info=dict(method="GET", url=f"{_base_url}"), # Basic CRUD list=dict(method="GET", url=f"{_base_url}"), create=dict(method="POST", url=f"{_base_url}"), retrieve=dict(method="GET", url=f"{_base_url}/{{}}"), update=dict(method="PUT", url=f"{_base_url}/{{}}"), partial_update=dict(method="PATCH", url=f"{_base_url}/{{}}"), destroy=dict(method="DELETE", url=f"{_base_url}/{{}}"), # JWT jwt=dict(method="POST", url=f"{_base_url}/jwt"), jwt_refresh=dict(method="POST", url=f"{_base_url}/jwt/refresh"), jwt_verify=dict(method="POST", url=f"{_base_url}/jwt/verify"), # User Actuator get_actuator=dict(method="GET", url=f"{_base_url}/{{}}/actuator"), add_actuators=dict(method="PUT", url=f"{_base_url}/{{}}/actuator"), delete_actuators=dict(method="DELETE", url=f"{_base_url}/{{}}/actuator/{{}}"), # Password Update change_password=dict(method="POST", url=f"{_base_url}/{{}}/change_password"), # User Commands history=dict(method="GET", url=f"{_base_url}/{{}}/history"), history_command=dict(method="POST", url=f"{_base_url}/{{}}/history/{{}}"), ) class ActuatorResource(Resource): _base_url = "/actuator" actions = dict( info=dict(method="GET", url=f"{_base_url}"), # Basic CRUD list=dict(method="GET", url=f"{_base_url}"), create=dict(method="POST", url=f"{_base_url}"), retrieve=dict(method="GET", url=f"{_base_url}/{{}}"), update=dict(method="PUT", url=f"{_base_url}/{{}}"), partial_update=dict(method="PATCH", url=f"{_base_url}/{{}}"), destroy=dict(method="DELETE", url=f"{_base_url}/{{}}"), # Custom Functions profile=dict(method="GET", url=f"{_base_url}/{{}}/profile"), refresh=dict(method="PATCH", url=f"{_base_url}/{{}}/refresh"), users=dict(method="GET", url=f"{_base_url}/{{}}/users") ) class CommandResource(Resource): _base_url = "/command" actions = dict( info=dict(method="GET", url=f"{_base_url}"), # Basic CRUD list=dict(method="GET", url=f"{_base_url}"), create=dict(method="POST", url=f"{_base_url}"), retrieve=dict(method="GET", url=f"{_base_url}/{{}}"), update=dict(method="PUT", url=f"{_base_url}/{{}}"), partial_update=dict(method="PATCH", url=f"{_base_url}/{{}}"), destroy=dict(method="DELETE", url=f"{_base_url}/{{}}"), # Send Command send=dict(method="PUT", url=f"{_base_url}/send") ) class DeviceResource(Resource): _base_url = "/device" actions = dict( info=dict(method="GET", url=f"{_base_url}"), # Basic CRUD list=dict(method="GET", url=f"{_base_url}"), create=dict(method="POST", url=f"{_base_url}"), retrieve=dict(method="GET", url=f"{_base_url}/{{}}"), update=dict(method="PUT", url=f"{_base_url}/{{}}"), partial_update=dict(method="PATCH", url=f"{_base_url}/{{}}"), destroy=dict(method="DELETE", url=f"{_base_url}/{{}}"), # Custom Functions users=dict(method="GET", url=f"{_base_url}/{{}}/users") ) class LogResource(Resource): _base_url = "/log" actions = dict( events=dict(method="GET", url=f"{_base_url}/event"), event=dict(method="GET", url=f"{_base_url}/event/{{}}"), requests=dict(method="GET", url=f"{_base_url}/request/{{}}"), request=dict(method="GET", url=f"{_base_url}/request/{{}}") ) class OrchestratorAPI(object): def __init__(self, root="http://localhost:8080", ws=False): ws = ws if isinstance(ws, bool) else False self._root_url = root if root.endswith("/") else f"{root}/" self._socket_url = re.sub(r"^https?", "ws", self._root_url) self._webSocket = None self._api = dict( root=RootResource, account=AccountResource, actuator=ActuatorResource, command=CommandResource, device=DeviceResource, log=LogResource ) self.api = self._socket() if ws else self._rest() atexit.register(self._close) def __getattr__(self, item): if item in self.api: return self.api[item] else: super(OrchestratorAPI, self).__getattribute__(item) def _rest(self): api = API( api_root_url=self._root_url, # base api url headers={ # default headers "Content-Type": "application/json" }, timeout=2, # default timeout in seconds append_slash=True, # append slash to final url json_encode_body=True, # encode body as json ) for name, cls in self._api.items(): api.add_resource(resource_name=name, resource_class=cls) _api = {} for resource in api.get_resource_list(): res = getattr(api, resource) _api[resource] = FrozenDict({act: getattr(res, act) for act in res.actions}) return FrozenDict(_api) def _socket(self): self._webSocket = websocket.create_connection(self._socket_url, timeout=2) init_msg = self._webSocket.recv() api = dict() for name, cls in self._api.items(): res = {} for act, args in getattr(cls, "actions", {}).items(): res[act] = partial(self._socketMsg, act, args) api[name] = FrozenDict(res) return api def _socketMsg(self, action, act_args, *args, **kwargs): auth = kwargs.get("headers", {}).get("Authorization", "") token = re.sub(r"^JWT\s+", "", auth) if auth.startswith("JWT") else "" url = f"api{act_args['url'].format(*args)}" url_params = act_args.get('params', {}) if len(url_params) > 0: url += f"?{'&'.join(f'{k}={v}' for k, v in url_params.items())}" rtn = dict( body={}, method=act_args["method"], status_code=500, url=f"{self._root_url}{url}", # Extra Options meta={} ) try: self._webSocket.send(json.dumps(dict( endpoint=url, method=act_args["method"], jwt=token, data=kwargs.get("body", {}), types=dict( success=f"@@socket/{action.upper()}_SUCCESS", failure=f"@@socket/{action.upper()}_FAILURE" ) ))) try: rslt = json.loads(self._webSocket.recv()) except ValueError as e: rslt = {} rtn.update( body=rslt.get('payload', {}), status_code=safe_cast(rslt.get('meta', {}).get("status_code", 200), int, 200), # Extra Options meta=rslt.get('meta', {}) ) return FrozenDict(rtn) except Exception as e: print(e) rtn.update( status_code=500, ) return FrozenDict(rtn) def _close(self): if hasattr(self._webSocket, 'close'): try: self._webSocket.close() except Exception as e: print(f"{e.__class__.__name__} - {e}") __all__ = [ "OrchestratorAPI" ]
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,213
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/core/orc_server/conformance/tests/utils.py
""" Unittest Utilities """ import inspect import os import unittest from typing import ( Dict, List, Tuple, Union ) from .test_setup import SetupTestSuite, SetupTestCase test_dirs = [ os.path.dirname(os.path.realpath(__file__)), # Local Dir # "./tests" # Custom Dir ] def inherits_from(child, parents: Union[Tuple[type, ...], type]): parents = tuple(p.__name__ for p in ((parents, ) if isinstance(parents, type) else parents)) if inspect.isclass(child): bases = [c.__name__ for c in inspect.getmro(child)[1:]] if any([p in bases for p in parents]): return True return False def load_test_suite() -> SetupTestSuite: suite = SetupTestSuite() for d in test_dirs: suite.addTests(unittest.defaultTestLoader.discover(start_dir=d, pattern=f"*_tests.py")) return get_tests(suite) def tests_in_suite(suite: unittest.TestSuite) -> Dict[str, Dict[str, Union[str, Dict[str, str]]]]: rtn = {} for test in suite: if unittest.suite._isnotsuite(test): t = test.id().split(".")[-2:] f = getattr(test, t[1]) rtn.setdefault(t[0], dict( profile=test.profile, doc=(getattr(test, "__doc__", "") or "").strip(), tests={} ))["tests"][t[1]] = (getattr(f, "__doc__", "") or "").strip() else: rtn.update(tests_in_suite(test)) return rtn def _load_tests(s: unittest.TestSuite, t: Union[Dict[str, List[str]], List[str]], **kwargs) -> list: rtn = [] test_list = [] if isinstance(t, dict): for c, ts in t.items(): c = c if c.endswith("_UnitTests") else f"{c}_UnitTests" test_list.extend([f"{c}{f'.{f}' if f else ''}" for f in ts] if ts else [c]) else: test_list.extend(t) for test in s: if unittest.suite._isnotsuite(test): f = test.id().split(".")[-2:] cls = test.__class__ if not inherits_from(cls, SetupTestCase): cls = type( cls.__name__, (SetupTestCase, ), { "__doc__": getattr(cls, "__doc__", ""), "profile": getattr(cls, "profile", "Unknown"), f[1]: getattr(test.__class__, f[1]) } ) for t in test_list: t = t.split(".") if (t[0] == f[0] and len(t) == 1) or (t[0] == f[0] and t[1] == f[1]): rtn.append(cls(f[1], **kwargs)) else: rtn.extend(_load_tests(test, test_list)) return rtn def get_tests(suite: unittest.TestSuite, tests: Dict[str, List[str]] = None, **kwargs) -> SetupTestSuite: tests = tests or {k: [] for k in tests_in_suite(suite)} rtn = SetupTestSuite(**kwargs) rtn.addTests(_load_tests(suite, tests, **kwargs)) return rtn class TestResults(unittest.TextTestResult): _testReport: dict def __init__(self, stream, descriptions, verbosity): super().__init__(stream, descriptions, verbosity) self._testReport = {} def getReport(self, verbose: bool = False) -> dict: """ Returns the run tests as a list of the form of a dict """ rtn = dict( stats=dict( Overall=self._getStats(self._testReport, True) ) ) for profile, tests in self._testReport.items(): rtn[profile] = {} for key, val in tests.items(): if verbose: rtn[profile][key] = {k: v if isinstance(v, str) else "" for k, v in val.items()} else: rtn[profile][key] = list(val.keys()) rtn["stats"][profile] = self._getStats(rtn[profile]) print("") return rtn def addError(self, test: unittest.case.TestCase, err) -> None: super().addError(test, err) self._addReport("error", test, err) def addFailure(self, test: unittest.case.TestCase, err) -> None: super().addFailure(test, err) self._addReport("failure", test, err) def addSuccess(self, test: unittest.case.TestCase) -> None: super().addSuccess(test) self._addReport("success", test) def addExpectedFailure(self, test: unittest.case.TestCase, err) -> None: super().addExpectedFailure(test, err) self._addReport("expected_failure", test, err) def addSkip(self, test: unittest.case.TestCase, reason: str) -> None: super().addSkip(test, reason) self._addReport("skipped", test, reason) def addUnexpectedSuccess(self, test: unittest.case.TestCase) -> None: super().addUnexpectedSuccess(test) self._addReport("unexpected_success", test) def addSubTest(self, test, subtest, err): subparams = ", ".join([f"{k}='{v}'" for k, v in subtest.params.items()]) subtest._testMethodName = f"{test._testMethodName} subTest({subparams})" subtest.profile = test.profile if err is None: self.addSuccess(subtest) else: self.addFailure(subtest, err) super(TestResults, self).addSubTest(test, subtest, err) # add to total number of tests run self.testsRun += 1 # Helper Functions def _addReport(self, category: str, test: unittest.case.TestCase, err: Union[tuple, str] = None) -> None: profile = getattr(test, "profile", "Unknown") val = err or test if isinstance(val, tuple): exctype, value, _ = err val = f"{exctype.__name__}: {value}" self._testReport.setdefault(profile, {}).setdefault(category, {})[test._testMethodName] = val def _getStats(self, results: dict, overall: bool = False) -> Dict[str, int]: stats = ("error", "failure", "success", "expected_failure", "skipped", "unexpected_success") rtn = dict( total=0, error=0, failure=0, success=0, expected_failure=0, skipped=0, unexpected_success=0 ) if overall: for p in results: for s in stats: c = len(results[p].get(s, {})) rtn[s] += c rtn["total"] += c else: for s in stats: c = len(results.get(s, {})) rtn[s] += c rtn["total"] += c return rtn
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,214
g2-inc/openc2-oif-orchestrator
refs/heads/master
/orchestrator/gui/server/gui_server/webApp/models.py
from django.conf import settings from django.db.models.signals import post_save from django.dispatch import receiver
{"/orchestrator/core/orc_server/command/views/actions.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/webApp/urls.py": ["/orchestrator/gui/server/gui_server/webApp/__init__.py"], "/orchestrator/core/orc_server/account/models.py": ["/orchestrator/core/orc_server/account/exceptions.py"], "/base/modules/utils/root/sb_utils/message/serialize.py": ["/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/__init__.py"], "/base/modules/utils/root/sb_utils/message/__init__.py": ["/base/modules/utils/root/sb_utils/message/serialize.py"], "/orchestrator/core/orc_server/conformance/views/viewsets.py": ["/orchestrator/core/orc_server/conformance/models.py", "/orchestrator/core/orc_server/conformance/tests/__init__.py"], "/orchestrator/core/orc_server/tracking/middleware.py": ["/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/gui/server/gui_server/orchestrator/admin.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/command/views/viewsets.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/models.py"], "/orchestrator/gui/server/gui_server/tracking/log.py": ["/orchestrator/gui/server/gui_server/tracking/models.py", "/orchestrator/gui/server/gui_server/tracking/settings.py"], "/orchestrator/core/orc_server/es_mirror/utils/__init__.py": ["/orchestrator/core/orc_server/es_mirror/utils/general.py"], "/orchestrator/core/orc_server/backup/views/import_export.py": ["/orchestrator/core/orc_server/backup/utils/__init__.py"], "/orchestrator/core/orc_server/command/processors.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/es_mirror/decorators.py": ["/orchestrator/core/orc_server/es_mirror/apps.py"], "/orchestrator/core/orc_server/command/models.py": ["/orchestrator/core/orc_server/command/documents.py"], "/orchestrator/core/orc_server/command/views/__init__.py": ["/orchestrator/core/orc_server/command/views/actions.py", "/orchestrator/core/orc_server/command/views/viewsets.py"], "/orchestrator/core/orc_server/conformance/tests/__init__.py": ["/orchestrator/core/orc_server/conformance/tests/utils.py"], "/orchestrator/core/orc_server/backup/utils/__init__.py": ["/orchestrator/core/orc_server/backup/utils/xls.py"], "/base/modules/utils/root/sb_utils/message/helpers.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/orchestrator/admin.py": ["/orchestrator/core/orc_server/orchestrator/models.py"], "/orchestrator/core/orc_server/device/admin.py": ["/orchestrator/core/orc_server/device/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/api.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/core/orc_server/orchestrator/urls.py": ["/orchestrator/core/orc_server/orchestrator/__init__.py"], "/orchestrator/core/orc_server/es_mirror/document.py": ["/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/es_mirror/apps.py": ["/orchestrator/core/orc_server/es_mirror/settings.py", "/orchestrator/core/orc_server/es_mirror/utils/__init__.py"], "/orchestrator/core/orc_server/conformance/admin.py": ["/orchestrator/core/orc_server/conformance/models.py"], "/base/modules/utils/twisted/sb_utils/__init__.py": ["/base/modules/utils/twisted/sb_utils/twisted_tools.py"], "/orchestrator/gui/server/gui_server/webApp/routing.py": ["/orchestrator/gui/server/gui_server/webApp/sockets.py"], "/orchestrator/core/orc_server/orchestrator/views/__init__.py": ["/orchestrator/core/orc_server/orchestrator/views/api.py", "/orchestrator/core/orc_server/orchestrator/views/gui.py"], "/orchestrator/core/orc_server/device/views/viewsets.py": ["/orchestrator/core/orc_server/device/models.py"], "/base/modules/utils/root/sb_utils/__init__.py": ["/base/modules/utils/root/sb_utils/amqp_tools.py", "/base/modules/utils/root/sb_utils/general.py", "/base/modules/utils/root/sb_utils/ext_dicts.py", "/base/modules/utils/root/sb_utils/message/__init__.py", "/base/modules/utils/root/sb_utils/message_obj.py"], "/orchestrator/core/orc_server/utils/__init__.py": ["/orchestrator/core/orc_server/utils/general.py", "/orchestrator/core/orc_server/utils/messageQueue.py", "/orchestrator/core/orc_server/utils/model.py", "/orchestrator/core/orc_server/utils/permissions.py"], "/orchestrator/gui/server/gui_server/utils/__init__.py": ["/orchestrator/gui/server/gui_server/utils/general.py", "/orchestrator/gui/server/gui_server/utils/model.py", "/orchestrator/gui/server/gui_server/utils/orchestrator_api.py", "/orchestrator/gui/server/gui_server/utils/schema.py"], "/base/modules/utils/root/sb_utils/ext_dicts.py": ["/base/modules/utils/root/sb_utils/general.py"], "/orchestrator/core/orc_server/command/admin.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/actuator/views/__init__.py": ["/orchestrator/core/orc_server/actuator/views/viewsets.py"], "/orchestrator/core/orc_server/device/views/__init__.py": ["/orchestrator/core/orc_server/device/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/conf.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/orchestrator/core/orc_server/command/views/stats.py": ["/orchestrator/core/orc_server/command/models.py"], "/orchestrator/core/orc_server/conformance/views/__init__.py": ["/orchestrator/core/orc_server/conformance/views/viewsets.py"], "/orchestrator/core/orc_server/tracking/log.py": ["/orchestrator/core/orc_server/tracking/__init__.py", "/orchestrator/core/orc_server/tracking/conf.py"], "/orchestrator/core/orc_server/account/views/viewsets.py": ["/orchestrator/core/orc_server/account/models.py"], "/orchestrator/gui/server/gui_server/orchestrator/views/viewsets.py": ["/orchestrator/gui/server/gui_server/orchestrator/models.py"], "/orchestrator/gui/server/gui_server/tracking/admin.py": ["/orchestrator/gui/server/gui_server/tracking/models.py"], "/base/modules/utils/root/sb_utils/message_obj.py": ["/base/modules/utils/root/sb_utils/message/__init__.py"], "/orchestrator/core/orc_server/tracking/urls/__init__.py": ["/orchestrator/core/orc_server/tracking/urls/api.py"], "/configure.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/tracking/urls/api.py": ["/orchestrator/core/orc_server/tracking/__init__.py"], "/update_subs.py": ["/base/modules/script_utils.py"], "/orchestrator/core/orc_server/actuator/admin.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/tracking/views/__init__.py": ["/orchestrator/core/orc_server/tracking/views/api.py", "/orchestrator/core/orc_server/tracking/views/viewsets.py"], "/orchestrator/gui/server/gui_server/account/views/viewsets.py": ["/orchestrator/gui/server/gui_server/account/models.py"], "/orchestrator/core/orc_server/account/views/__init__.py": ["/orchestrator/core/orc_server/account/views/api.py", "/orchestrator/core/orc_server/account/views/apiviews.py", "/orchestrator/core/orc_server/account/views/viewsets.py"], "/orchestrator/core/orc_server/backup/views/__init__.py": ["/orchestrator/core/orc_server/backup/views/api.py", "/orchestrator/core/orc_server/backup/views/import_export.py"], "/orchestrator/core/orc_server/actuator/views/viewsets.py": ["/orchestrator/core/orc_server/actuator/models.py"], "/orchestrator/core/orc_server/conformance/tests/utils.py": ["/orchestrator/core/orc_server/conformance/tests/test_setup.py"]}
12,225
ppiazi/korea_univ_gscit_notice_bot
refs/heads/master
/BotMain.py
# -*- coding: utf-8 -*- """ Copyright 2016 Joohyun Lee(ppiazi@gmail.com) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from telegram.ext import Updater import logging import datetime __VERSION__ = "0.0.2" DEFAULT_LIST_NUM = 3 NOTICE_CHECK_PERIOD_H = 6 MSG_START = "고려대학교 컴퓨터정보통신대학원 공지사항 봇 %s\n만든이 : 39기 이주현(ppiazi@gmail.com)\nhttps://github.com/ppiazi/korea_univ_gscit_notice_bot" % __VERSION__ MSG_HELP = """ 버전 : %s /list <num of notices> : 입력 개수만큼 공지사항을 보여줌. 인자가 없으면 기본 개수로 출력. /help : 도움말을 보여줌. /status : 현재 봇 상태를 보여줌.""" MSG_NOTICE_USAGE_ERROR = "입력된 값이 잘못되었습니다." MSG_NOTICE_FMT = "ID : %d\n날짜 : %s\n제목 : %s\n작성자 : %s\nURL : %s\n" MSG_STATUS = "* 현재 사용자 : %d\n* 최신 업데이트 : %s\n* 공지사항 개수 : %d" # Enable logging logging.basicConfig( # filename="./BotMain.log", format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) logger = logging.getLogger("BOT_MAIN") job_queue = None # Global DB g_bot = None g_notice_reader = None g_notice_list = [] g_last_notice_date = "2016-03-01 00:00:00" import NoticeReader from BotMainDb import ChatIdDb g_chat_id_db = ChatIdDb() def start(bot, update): checkChatId(update.message.chat_id) sendBotMessage(bot, update.message.chat_id, MSG_START) def checkChatId(chat_id): global g_chat_id_db g_chat_id_db.getChatIdInfo(chat_id) def help(bot, update): checkChatId(update.message.chat_id) sendBotMessage(bot, update.message.chat_id, MSG_HELP % __VERSION__) def sendBotMessage(bot, chat_id, msg): try: bot.sendMessage(chat_id, text=msg) except Exception as e: logger.error(e) g_chat_id_db.removeChatId(chat_id) def status(bot, update): """ 현재 bot의 상태 정보를 전송한다. :param bot: :param update: :return: """ global g_last_notice_date global g_notice_list global g_chat_id_db l = g_chat_id_db.getAllChatIdDb() s = g_chat_id_db.getChatIdInfo(update.message.chat_id) checkChatId(update.message.chat_id) sendBotMessage(bot, update.message.chat_id, MSG_STATUS % (len(l), str(s), len(g_notice_list))) def checkNotice(bot): """ 주기적으로 Notice를 읽어 최신 정보가 있으면, 사용자들에게 전송한다. :return: """ global g_notice_list global g_chat_id_db updateNoticeList() # dict_chat_id = updateListenerList(bot) l = g_chat_id_db.getAllChatIdDb() for n_item in g_notice_list: tmp_msg_1 = makeNoticeSummary(g_notice_list.index(n_item), n_item) # logger.info(tmp_msg_1) for t_chat_id in l.keys(): temp_date_str = l[t_chat_id] if n_item['published'] > temp_date_str: logger.info("sendMessage to %d (%s : %s)" % (t_chat_id, n_item['published'], n_item['title'])) sendBotMessage(bot, t_chat_id, tmp_msg_1) g_chat_id_db.updateChatId(t_chat_id, n_item['published']) def updateNoticeList(): """ 공지사항을 읽어와 내부 데이터를 최신화한다. :param bot: :return: """ global g_notice_list global g_last_notice_date logger.info("Try to reread notice list") logger.info("Last Notice Date : %s" % g_last_notice_date) g_notice_list = g_notice_reader.readAll() def makeNoticeSummary(i, n_item): """ 각 공지사항 별 요약 Text를 만들어 반환한다. :param i: :param n_item: :return: """ tmp_msg_1 = MSG_NOTICE_FMT % (i, n_item['published'], n_item['title'], n_item['author'], n_item['link']) return tmp_msg_1 def listNotice(bot, update, args): """ 공지사항을 읽어 텔레그렘으로 전송한다. :param bot: :param update: :param args: 읽어드릴 공지사항 개수(최신 args개) :return: 없음. """ global g_notice_list global g_chat_id_db checkChatId(update.message.chat_id) chat_id = update.message.chat_id # args[0] should contain the time for the timer in seconds if len(args) == 0: num = DEFAULT_LIST_NUM else: try: num = int(args[0]) except: num = DEFAULT_LIST_NUM sendBotMessage(bot, chat_id, MSG_NOTICE_USAGE_ERROR) sendBotMessage(bot, chat_id, MSG_HELP) if num < 0: sendBotMessage(bot, chat_id, MSG_NOTICE_USAGE_ERROR) num = DEFAULT_LIST_NUM i = 0 if num >= len(g_notice_list): num = g_notice_list last_date = "" tmp_msg = "" for n_item in g_notice_list[num * -1:]: tmp_msg_1 = makeNoticeSummary(g_notice_list.index(n_item), n_item) tmp_msg = tmp_msg + tmp_msg_1 + "\n" last_date = n_item['published'] i = i + 1 if i == num: break logger.info(tmp_msg) sendBotMessage(bot, chat_id, tmp_msg) g_chat_id_db.updateChatId(chat_id, last_date) def readNotice(bot, update, args): """ 특정 공지사항의 내용을 읽어 반환한다. :param bot: :param update: :param args: :return: """ global g_dict_chat_id g_dict_chat_id[update.message.chat_id] = 1 pass def handleNormalMessage(bot, update, error): checkChatId(update.message.chat_id) def error(bot, update, error): logger.warn('Update "%s" caused error "%s"' % (update, error)) def main(): global g_notice_reader global g_bot g_notice_reader = NoticeReader.KoreaUnivGscitNoticeReader() print("Korea University GSCIT Homepage Notice Bot V%s" % __VERSION__) global job_queue f = open("bot_token.txt", "r") BOT_TOKEN = f.readline() f.close() updater = Updater(BOT_TOKEN) job_queue = updater.job_queue g_bot = updater.bot # Get the dispatcher to register handlers dp = updater.dispatcher # on different commands - answer in Telegram dp.addTelegramCommandHandler("start", start) dp.addTelegramCommandHandler("help", help) dp.addTelegramCommandHandler("h", help) dp.addTelegramCommandHandler("list", listNotice) dp.addTelegramCommandHandler("l", listNotice) dp.addTelegramCommandHandler("read", readNotice) dp.addTelegramCommandHandler("r", readNotice) dp.addTelegramCommandHandler("status", status) dp.addTelegramCommandHandler("s", status) # on noncommand i.e message - echo the message on Telegram dp.addTelegramMessageHandler(handleNormalMessage) # log all errors dp.addErrorHandler(error) # init db updateNoticeList() job_queue.put(checkNotice, 60*60*NOTICE_CHECK_PERIOD_H, repeat=True) # Start the Bot updater.start_polling() # Block until the you presses Ctrl-C or the process receives SIGINT, # SIGTERM or SIGABRT. This should be used most of the time, since # start_polling() is non-blocking and will stop the bot gracefully. updater.idle() if __name__ == '__main__': main()
{"/BotMain.py": ["/NoticeReader.py", "/BotMainDb.py"], "/NoticeReader.py": ["/BotMain.py"], "/BotMainDb.py": ["/BotMain.py"]}
12,226
ppiazi/korea_univ_gscit_notice_bot
refs/heads/master
/NoticeReader.py
# -*- coding: utf-8 -*- """ Copyright 2016 Joohyun Lee(ppiazi@gmail.com) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import feedparser from BotMain import logger FEED_URL = "http://wizard.korea.ac.kr/rssList.jsp?siteId=gscit&boardId=861704" class KoreaUnivGscitNoticeReader: def __init__(self, feed_url=FEED_URL): self.feed_url = feed_url def readAll(self): try: logger.info("Try to open %s" % self.feed_url) self.rss_reader = feedparser.parse(self.feed_url) self.feed_list = self.rss_reader['items'] # published 값으로 descending 정렬하기 위함임. # 간혹 published 값으로 정렬되지 않은 경우가 있음. temp_dict = {} for i in self.feed_list: temp_dict[i['published'] + i['title']] = i keylist = list(temp_dict.keys()) keylist.sort() final_list = [] for key in keylist: final_list.append(temp_dict[key]) logger.info("Successfully read %d items." % len(self.feed_list)) except: logger.error("%s is not valid." % self.feed_url) self.rss_reader = None self.feed_list = None final_list = None return final_list
{"/BotMain.py": ["/NoticeReader.py", "/BotMainDb.py"], "/NoticeReader.py": ["/BotMain.py"], "/BotMainDb.py": ["/BotMain.py"]}
12,227
ppiazi/korea_univ_gscit_notice_bot
refs/heads/master
/BotMainDb.py
# -*- coding: utf-8 -*- """ Copyright 2016 Joohyun Lee(ppiazi@gmail.com) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import datetime from BotMain import logger import pickle DEFAULT_CHAT_ID_DB = "chat_id.db" class ChatIdDb: def __init__(self): self._db = {} self._load() def _load(self): try: f = open(DEFAULT_CHAT_ID_DB, "rb") # 파일이 있다면, 기존 사용자를 로드한다. self._db = pickle.load(f) except Exception as e: logger.error(e) self._save() def _save(self): f = open(DEFAULT_CHAT_ID_DB, "wb") pickle.dump(self._db, f) f.close() def getAllChatIdDb(self): return self._db def getChatIdInfo(self, chat_id): """ 주어진 chat_id를 확인하여, 1.기존에 있는 사용자면 사용자 정보를 반환한다. 2.기존에 없는 사용자면 새롭게 등록한다. :param chat_id: :return: chat_id에 해당하는 정보를 반환함. """ self.updateChatId(chat_id) return self._db[chat_id] def updateChatId(self, chat_id, update_time = None): try: self._db[chat_id] = self._db[chat_id] if update_time != None: self._db[chat_id] = update_time except Exception as e: if update_time == None: logger.info("New Commer : %d" % (chat_id)) d = datetime.datetime.today() td = datetime.timedelta(days=90) d = d - td self._db[chat_id] = str(d) else: self._db[chat_id] = update_time self._save() def removeChatId(self, chat_id): del self._db[chat_id] self._save()
{"/BotMain.py": ["/NoticeReader.py", "/BotMainDb.py"], "/NoticeReader.py": ["/BotMain.py"], "/BotMainDb.py": ["/BotMain.py"]}
12,233
2-propanol/BTF_helper
refs/heads/main
/btf_helper/btfnpz.py
import numpy as np class Btfnpz: """.btf.npzファイルから角度や画像を取り出す 角度は全て度数法(degree)を用いている。 .btf.npzファイルに含まれる角度情報の並べ替えはしない。 角度情報の取得には`angles_set`(Pythonの`set`)の他、 `angles_list`(`flags.writeable`を`False`にセットした`np.ndarray`)が利用できる。 画像の実体はopencvと互換性のあるndarray形式(BGR, channels-last)で出力する。 .btf.npzファイル要件: `np.savez`もしくは`np.savez_compressed`で 画像を`images`、角度情報を`angles`のキーワード引数で格納している.btf.npzファイル。 Attributes: npz_filepath (str): コンストラクタに指定した.btf.npzファイルパス。 img_shape (tuple[int,int,int]): btfファイルに含まれている画像のshape。 angles_set (set[tuple[float,float,float,float]]): .btf.npzファイルに含まれる画像の角度条件の集合。 Example: >>> btf = Btfnpz("example.btf") >>> print(btf.img_shape) (512, 512, 3) >>> angles_list = list(btf.angles_set) >>> print(angles_list[0]) (45.0, 255.0, 0.0, 0.0) >>> print(btf.angles_list[0]) (45.0, 255.0, 0.0, 0.0) >>> image = btf.angles_to_image(*angles_list[0]) >>> print(image.shape) (512, 512, 3) >>> print(btf.image_list[0].shape) (512, 512, 3) """ def __init__(self, npz_filepath: str) -> None: """使用するzipファイルを指定する""" self.npz_filepath = npz_filepath self.__npz = np.load(npz_filepath) self.image_list = self.__npz["images"] self.image_list.flags.writeable = False self.angles_list = self.__npz["angles"] self.angles_list.flags.writeable = False del self.__npz self.img_shape = self.image_list.shape[1:] self.angles_set = frozenset({tuple(angles) for angles in self.angles_list}) def angles_to_image(self, tl: float, pl: float, tv: float, pv: float) -> np.ndarray: """`tl`, `pl`, `tv`, `pv`の角度条件の画像をndarray形式で返す""" for i, angles in enumerate(self.angles_list): if np.allclose(angles, np.array((tl, pl, tv, pv))): return self.image_list[i] raise ValueError( f"condition ({tl}, {pl}, {tv}, {pv}) does not exist in '{self.npz_filepath}'." )
{"/btf_helper/__init__.py": ["/btf_helper/btfnpz.py", "/btf_helper/btfzip.py"]}
12,234
2-propanol/BTF_helper
refs/heads/main
/btf_helper/__init__.py
from .btfnpz import Btfnpz from .btfzip import Btfzip
{"/btf_helper/__init__.py": ["/btf_helper/btfnpz.py", "/btf_helper/btfzip.py"]}
12,235
2-propanol/BTF_helper
refs/heads/main
/btf_helper/btfzip.py
from collections import Counter from decimal import Decimal from sys import stderr from typing import Tuple from zipfile import ZipFile import cv2 import numpy as np from simplejpeg import decode_jpeg # PEP484 -- Type Hints: # Type Definition Syntax: # The numeric tower: # when an argument is annotated as having type `float`, # an argument of type `int` is acceptable class Btfzip: """画像ファイルを格納したzipファイルから角度と画像を取り出す(小数点角度と画像拡張子指定対応) 角度は全て度数法(degree)を用いている。 zipファイルに含まれる角度情報の順番は保証せず、並べ替えもしない。 `angles_set`には`list`ではなく、順序の無い`set`を用いている。 画像の実体はopencvと互換性のあるndarray形式(BGR, channels-last)で出力する。 zipファイル要件: f"tl{float}{angle_sep}pl{float}{angle_sep}tv{float}{angle_sep}pv{float}.{file_ext}" を格納している。 例) "tl20.25_pl10_tv11.5_pv0.exr" Attributes: zip_filepath (str): コンストラクタに指定したzipファイルパス。 angles_set (set[tuple[float,float,float,float]]): zipファイルに含まれる画像の角度条件の集合。 Example: >>> btf = Btfzip("Colorchecker.zip") >>> angles_list = list(btf.angles_set) >>> image = btf.angles_to_image(*angles_list[0]) >>> print(image.shape) (256, 256, 3) >>> print(angles_list[0]) (0, 0, 0, 0) """ def __init__( self, zip_filepath: str, file_ext: str = ".exr", angle_sep: str = " " ) -> None: """使用するzipファイルを指定する 指定したzipファイルに角度条件の重複がある場合、 何が重複しているか表示し、`RuntimeError`を投げる。 """ self.zip_filepath = zip_filepath self.__z = ZipFile(zip_filepath) # NOTE: ARIES4軸ステージの分解能は0.001度 self.DECIMAL_PRECISION = Decimal("1E-3") # ファイルパスは重複しないので`filepath_set`はsetで良い filepath_set = {path for path in self.__z.namelist() if path.endswith(file_ext)} self.__angles_vs_filepath_dict = { self._filename_to_angles(path, angle_sep): path for path in filepath_set } self.angles_set = frozenset(self.__angles_vs_filepath_dict.keys()) # 角度条件の重複がある場合、何が重複しているか調べる if len(filepath_set) != len(self.angles_set): angles_list = [self._filename_to_angles(path) for path in filepath_set] angle_collection = Counter(angles_list) for angles, counter in angle_collection.items(): if counter > 1: print( f"[BTF-Helper] '{self.zip_filepath}' has" + f"{counter} files with condition {angles}.", file=stderr, ) raise RuntimeError(f"'{self.zip_filepath}' has duplicated conditions.") if file_ext == ".jpg" or file_ext == ".jpeg": self.angles_to_image = self._angles_to_image_simplejpeg else: self.angles_to_image = self._angles_to_image_cv2 def _filename_to_angles( self, filename: str, sep: str ) -> Tuple[Decimal, Decimal, Decimal, Decimal]: """ファイル名(orパス)から角度(`Decimal`)のタプル(`tl`, `pl`, `tv`, `pv`)を取得する""" angles = filename.split("/")[-1][:-4].split(sep) try: tl = Decimal(angles[0][2:]).quantize(self.DECIMAL_PRECISION) pl = Decimal(angles[1][2:]).quantize(self.DECIMAL_PRECISION) tv = Decimal(angles[2][2:]).quantize(self.DECIMAL_PRECISION) pv = Decimal(angles[3][2:]).quantize(self.DECIMAL_PRECISION) except ValueError as e: raise ValueError("invalid angle:", angles) from e return (tl, pl, tv, pv) def _angles_to_image_cv2( self, tl: float, pl: float, tv: float, pv: float ) -> np.ndarray: """`tl`, `pl`, `tv`, `pv`の角度条件の画像をndarray形式で返す `filename`が含まれるファイルが存在しない場合は`ValueError`を投げる。 """ key = ( Decimal(tl).quantize(self.DECIMAL_PRECISION), Decimal(pl).quantize(self.DECIMAL_PRECISION), Decimal(tv).quantize(self.DECIMAL_PRECISION), Decimal(pv).quantize(self.DECIMAL_PRECISION), ) filepath = self.__angles_vs_filepath_dict.get(key) if not filepath: raise ValueError( f"Condition {key} does not exist in '{self.zip_filepath}'." ) with self.__z.open(filepath) as f: return cv2.imdecode( np.frombuffer(f.read(), np.uint8), cv2.IMREAD_ANYDEPTH + cv2.IMREAD_ANYCOLOR, ) def _angles_to_image_simplejpeg( self, tl: float, pl: float, tv: float, pv: float ) -> np.ndarray: """`tl`, `pl`, `tv`, `pv`の角度条件の画像をndarray形式で返す `filename`が含まれるファイルが存在しない場合は`ValueError`を投げる。 """ key = ( Decimal(tl).quantize(self.DECIMAL_PRECISION), Decimal(pl).quantize(self.DECIMAL_PRECISION), Decimal(tv).quantize(self.DECIMAL_PRECISION), Decimal(pv).quantize(self.DECIMAL_PRECISION), ) filepath = self.__angles_vs_filepath_dict.get(key) if not filepath: raise ValueError( f"Condition {key} does not exist in '{self.zip_filepath}'." ) with self.__z.open(filepath) as f: return decode_jpeg(f.read(), colorspace="BGR")
{"/btf_helper/__init__.py": ["/btf_helper/btfnpz.py", "/btf_helper/btfzip.py"]}
12,236
ToddLichty/BowlingKata
refs/heads/master
/bowling.py
class BowlScorer(): def __init__(self): self._rolls = [0 for i in range(21)] self._current_roll = 0 def roll(self, pins): self._rolls[self._current_roll] = pins self._current_roll += 1 def get_score(self): score = 0 rollIndex = 0 for frameIndex in range(10): if self.is_spare(rollIndex): score += self.spare_score(rollIndex) rollIndex += 2 elif self.is_strike(rollIndex): score += self.strike_score(rollIndex) rollIndex += 1 else: score += self.frame_score(rollIndex) rollIndex += 2 return score def is_strike(self, rollIndex): return self._rolls[rollIndex] == 10 def is_spare(self, rollIndex): return self._rolls[rollIndex] + self._rolls[rollIndex + 1] == 10 def strike_score(self, rollIndex): return 10 + self._rolls[rollIndex + 1] + self._rolls[rollIndex + 2] def spare_score(self, rollIndex): return 10 + self._rolls[rollIndex + 2] def frame_score(self, rollIndex): return self._rolls[rollIndex] + self._rolls[rollIndex + 1]
{"/test_bowling.py": ["/bowling.py"]}
12,237
ToddLichty/BowlingKata
refs/heads/master
/test_bowling.py
import unittest from bowling import BowlScorer class BowlingScorerTests(unittest.TestCase): def setUp(self): self.scorer = BowlScorer() def test_all_gutter_balls(self): self.rollMany(0, 20) self.assertEqual(0, self.scorer.get_score()) def test_knocked_over_single_pin(self): self.scorer.roll(1) self.assertEqual(1, self.scorer.get_score()) def test_entire_game_no_spares_or_strikes(self): self.rollMany(3, 20) self.assertEqual(60, self.scorer.get_score()) def test_one_spare(self): self.scorer.roll(5) self.scorer.roll(5) self.scorer.roll(3) self.rollMany(0, 17) self.assertEqual(16, self.scorer.get_score()) def test_one_strike(self): self.scorer.roll(10) self.scorer.roll(4) self.scorer.roll(3) self.rollMany(0, 17) self.assertEqual(24, self.scorer.get_score()) def test_perfect_game(self): self.rollMany(10, 20) self.assertEqual(300, self.scorer.get_score()) def rollMany(self, pins, number_of_rolls): for i in range(number_of_rolls): self.scorer.roll(pins)
{"/test_bowling.py": ["/bowling.py"]}
12,243
barrettellie/coursework
refs/heads/master
/mainwindow.py
#create the main window from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtSql import * import sys class MainWindow(QMainWindow): """simple example using QtSql""" #doc string #constructor def __init__(self): #calls the super class constructor super().__init__() self.stackedLayout = QStackedLayout() self.create_initial_layout() self.stackedLayout.addWidget(self.initial_layout_widget) self.central_widget = QWidget() self.central_widget.setLayout(self.stackedLayout) self.setCentralWidget(self.central_widget) #connection to the database self.db = QSqlDatabase.addDatabase("QSQLITE") self.db.setDatabaseName("coffee_shop.db") self.db.open() self.table_view = QTableView() def create_initial_layout(self): self.welcome_message = QLabel("Bed and Breakfast Payroll System") self.layout = QVBoxLayout() self.layout.addWidget(self.welcome_message) self.initial_layout_widget = QWidget() self.initial_layout_widget.setLayout(self.layout) if __name__ == "__main__": application = QApplication(sys.argv) window = MainWindow() window.show() window.raise_() application.exec_()
{"/display_menu.py": ["/full_time_employee.py", "/calculate_wages.py"], "/calculate_wages.py": ["/full_time_employee.py"]}
12,244
barrettellie/coursework
refs/heads/master
/createtables.py
#create tables and enititys import sqlite3 def create_table(db_name, table_name,sql): with sqlite3.connect(db_name) as db: cursor = db.cursor() cursor.execute("select name from sqlite_master where name = ?",(table_name,)) result = cursor.fetchall() if len(result) == 0: #turn on foriegn keys cursor.execute("PRAGMA foreign_keys = ON") cursor.execute(sql) db.commit()#theChoice else: pass if __name__ == "__main__": db_name = "bed_and_breakfast.db" table_name = "Employee" sql = ("""create table Employee (EmployeeID integer, PositionID integer, Title text, FirstName text, LastName text, DateOfBirth text, Telephone integer, Email text, HouseName Number text, StreetName text, Town text, County text, PostCode text, NINumber text, DateStarted text, DateLeft text, TaxCode text, SortCode integer, AccountNumber integer, primary key(EmployeeID), foreign key(PositionID) references Position(PositionID))""") create_table(db_name, table_name, sql) table_name = "Position" sql = ("""create table Position (PositionID integer, TypeID integer, RateofPay integer, primary key(PositionID), foreign key(TypeID) references Type(TypeID))""") create_table(db_name, table_name, sql) table_name = "Type" sql = ("""create table Type (TypeID integer, Description text, primary key(TypeID))""") create_table(db_name, table_name, sql) table_name = "Payment" sql = ("""create table Payment (PaymentID integer, DeliveryMethodID integer, PayFrequency text, BankName text, primary key(PaymentID), foreign key(DeliveryMethodID) references DeliverMethod(DeliveryMethodID))""") create_table(db_name, table_name, sql) table_name = "DeliveryMethod" sql = ("""create table DeliveryMethod (DeliveryMethodID integer, PayMethod text, DeliveryMethod text, primary key(DeliveryMethodID))""") create_table(db_name, table_name, sql) table_name = "Manager" sql = ("""create table Manager (ManagerID integer, Title text, FirstName text, LastName text, DateOfBirth text, Telephone integer, Email text, HouseName Number text, StreetName text, Town text, County text, PostCode text, primary key(ManagerID))""") create_table(db_name, table_name, sql) table_name = "Timesheet" sql = ("""create table Timesheet (TimesheetID integer, EmployeeID integer, PaymentID integer, DateWorked text, TimeStarted text, TimeEnded text, NumberOfHours integer, OvertimeHours integer, OvertimePay integer, TotalPay integer, primary key(TimesheetID), foreign key(EmployeeID) references Employee(EmployeeID), foreign key(PaymentID) references Payment(PaymentID))""") create_table(db_name, table_name, sql)
{"/display_menu.py": ["/full_time_employee.py", "/calculate_wages.py"], "/calculate_wages.py": ["/full_time_employee.py"]}
12,245
barrettellie/coursework
refs/heads/master
/full_time_employee.py
#full time employee def full_time_employee(): hours = int(input("Please enter the nuber of hours you have worked: ")) rate_of_pay = float(input("Please enter your hourly rate of pay: ")) overtime = int(input("Please enter the number of over time hours worked: ")) overtime_pay_rate = float(input("Please enter your overtime pay rate: ")) return hours, rate_of_pay, overtime, overtime_pay_rate def total_pay(hours, rate_of_pay, overtime, overtime_pay_rate): standard_pay = hours * rate_of_pay overtime_pay = overtime * overtime_pay_rate total_pay = overtime_pay + standard_pay return total_pay def full_time_main(): hours, rate_of_pay, overtime, overtime_pay_rate = full_time_employee() totalPay = total_pay(hours, rate_of_pay, overtime, overtime_pay_rate) print("Total pay = £{0}".format(totalPay)) if __name__ == "__main__": full_time_main()
{"/display_menu.py": ["/full_time_employee.py", "/calculate_wages.py"], "/calculate_wages.py": ["/full_time_employee.py"]}
12,246
barrettellie/coursework
refs/heads/master
/display_menu.py
from part_time_employee import * from full_time_employee import * from calculate_wages import * def display_menu(): print() print("1. Employee Login") print("2. Manager Login") print() print("Please select an option from the above menu") def select_option(): choice = "" valid_option = False while not valid_option: try: choice = int(input("Option Selected: ")) if choice in (1,2): valid_option = True else: print("Please enter a valid option") except ValueError: print("Please enter a valid option") return choice def login(): display_menu() choice = select_option() if choice == 1: pass if choice == 2: pass return login def loginPage(): print() print("1. Calculate Wages") print("2. Ammend Personal Information") print() print("Please select an option from the above menu") def loginPageChoice(): loginPage() choice = select_option() if choice == 1: employeeTypeChoice() if choice == 2: ammend_info() return loginPageChoice if __name__ == "__main__": login() loginPageChoice()
{"/display_menu.py": ["/full_time_employee.py", "/calculate_wages.py"], "/calculate_wages.py": ["/full_time_employee.py"]}
12,247
barrettellie/coursework
refs/heads/master
/calculate_wages.py
from full_time_employee import * from part_time_employee import * def calculate_wages(): print() print("1. Full Time Employee") print("2. Part Time Employee") print() print("Please select your employee status from the above menu") def select_option(): choice = "" valid_option = False while not valid_option: try: choice = int(input("Option Selected: ")) if choice in (1,2): valid_option = True else: print("Please enter a valid option") except ValueError: print("Please enter a valid option") return choice def employeeTypeChoice(): calculate_wages() choice = select_option() if choice == 1: full_time_main() if choice == 2: part_time_main() return employeeTypeChoice if __name__ == "__main__": employeeTypeChoice()
{"/display_menu.py": ["/full_time_employee.py", "/calculate_wages.py"], "/calculate_wages.py": ["/full_time_employee.py"]}
12,248
barrettellie/coursework
refs/heads/master
/employeelogin.py
class EmployeeLogin(): """Employee Login""" def __init__(self): super().__init__() def login(self, username, password): username = "barrettellie" password = "hello" username = input("Please enter your username: ") if username == True: password = input("Please enter your password: ") if password == True: print("Welcome. You have successfully logged in!") else: print("The password you entered was incorrect. Please try again.") else: print("The username you entered was incorrect. Please try again.") if __name__ == "__main__": ALogin = EmployeeLogin() ALogin.login("username", "password")
{"/display_menu.py": ["/full_time_employee.py", "/calculate_wages.py"], "/calculate_wages.py": ["/full_time_employee.py"]}
12,249
sosboy888/covidTrackerEDVERB
refs/heads/master
/Main.py
import requestData from tkinter import * from tkinter import messagebox from tkinter.ttk import * window=Tk() window.minsize(300,300) window.title("Coronavirus Tracker") logo=PhotoImage(file="icon.png") window.iconphoto(False, logo) imageLabel=Label(window, image=logo) imageLabel.grid() textLabel=Label(window, text="Enter the name of the country you want to know the number of cases for") textLabel.grid() countryName=StringVar() countryEntry=Entry(window, width=30, textvariable=countryName) countryEntry.grid() def getCases(): response=requestData.request(countryName.get()) messagebox.showinfo(response[0]["country"]+" Cases","Confirmed Cases:"+str(response[0]["confirmed"])+"\nRecovered Cases:"+str(response[0]["recovered"])) def getIndiaCases(): response=requestData.request("india") messagebox.showinfo(response[0]["country"]+" Cases","Confirmed Cases:"+str(response[0]["confirmed"])+"\nRecovered Cases:"+str(response[0]["recovered"])) goButton=Button(window, text="GO", command=getCases) goButton.grid() indiaButton=Button(window, text="Display number of cases in India",command=getIndiaCases) indiaButton.grid()
{"/Main.py": ["/requestData.py"]}
12,250
sosboy888/covidTrackerEDVERB
refs/heads/master
/requestData.py
import requests def request(countryName): url = "https://covid-19-data.p.rapidapi.com/country" querystring = {"format":"json","name":countryName} headers = { 'x-rapidapi-host': "covid-19-data.p.rapidapi.com", 'x-rapidapi-key': "YOUR API KEY" } response = requests.request("GET", url, headers=headers, params=querystring) return response.json()
{"/Main.py": ["/requestData.py"]}
12,251
tominsam/feedify
refs/heads/main
/instagram/migrations/0001_initial.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import datetime class Migration(migrations.Migration): dependencies = [ ] operations = [ migrations.CreateModel( name='AccessToken', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('key', models.CharField(unique=True, max_length=100)), ('created', models.DateTimeField(default=datetime.datetime.utcnow)), ('fetched', models.DateTimeField(null=True)), ('updated', models.DateTimeField()), ('username', models.CharField(max_length=100)), ('userid', models.CharField(unique=True, max_length=20)), ('feed_secret', models.CharField(unique=True, max_length=13)), ], options={ }, bases=(models.Model,), ), ]
{"/instagram/feeds.py": ["/instagram/models.py", "/flickr/feeds.py"], "/flickr/feeds.py": ["/flickr/models.py"], "/instagram/admin.py": ["/instagram/models.py"], "/urls.py": ["/flickr/feeds.py", "/instagram/feeds.py"], "/flickr/admin.py": ["/flickr/models.py"]}
12,252
tominsam/feedify
refs/heads/main
/flickr/models.py
from django.db import models from django.conf import settings from django.core.cache import cache import urlparse import urllib import datetime import oauth2 import uuid import json import time import logging EXTRAS = "date_upload,date_taken,owner_name,icon_server,original_format,description,geo,tags,machine_tags,o_dims,media,path_alias,url_t,url_s,url_m,url_z,url_l,url_o" class FlickrException(Exception): def __init__(self, code, message): self.code = code super(FlickrException, self).__init__(message) def __unicode__(self): return u"%s: %s"%(self.code, self.message) class RequestToken(models.Model): key = models.CharField(max_length=100, null=False, blank=False, unique=True) secret = models.CharField(max_length=100, null=False, blank=False) created = models.DateTimeField(default=datetime.datetime.utcnow) def __str__(self): data = {"oauth_token": self.key, "oauth_token_secret": self.secret} return urllib.urlencode(data) @classmethod def from_string(cls, string): data = dict(urlparse.parse_qsl(string)) token, created = cls.objects.get_or_create(key=data["oauth_token"], defaults=dict(secret = data["oauth_token_secret"])) if not created: token.secret = data["oauth_token_secret"] token.save() return token def token(self): return oauth2.Token(self.key, self.secret) class AccessToken(models.Model): key = models.CharField(max_length=100, null=False, blank=False, unique=True) secret = models.CharField(max_length=100, null=False, blank=False) created = models.DateTimeField(default=datetime.datetime.utcnow, null=False, blank=False) fetched = models.DateTimeField(null=True) updated = models.DateTimeField(blank=False, null=False) username = models.CharField(max_length=100, null=False, blank=False) nsid = models.CharField(max_length=20, null=False, blank=False, unique=True) fullname = models.CharField(max_length=100, null=False, blank=False) feed_secret = models.CharField(max_length=13, null=False, blank=False, unique=True) def __str__(self): data = {"oauth_token": self.key, "oauth_token_secret": self.secret} return urllib.urlencode(data) @classmethod def from_string(cls, string): data = dict(urlparse.parse_qsl(string)) properties = dict( key = data["oauth_token"], secret = data["oauth_token_secret"], username=data["username"], nsid=data["user_nsid"], fullname = data.get("fullname", data["username"]), updated = datetime.datetime.utcnow(), ) # remove old IDs for this user. cls.objects.filter(nsid=properties["nsid"]).exclude(key=properties["key"]).delete() token, created = cls.objects.get_or_create(key=properties["key"], defaults=properties) if not created: for k, v in properties.items(): setattr(token, k, v) token.save() return token def token(self): return oauth2.Token(self.key, self.secret) def save(self, *args, **kwargs): if not self.feed_secret: self.feed_secret = str(uuid.uuid4())[:13] return super(AccessToken, self).save(*args, **kwargs) def call(self, method, name, **kwargs): consumer = oauth2.Consumer(key=settings.FLICKR_API_KEY, secret=settings.FLICKR_API_SECRET) client = oauth2.Client(consumer, self.token()) args = dict( method = name, format = "json", nojsoncallback = "1", ) args.update(kwargs) params = urllib.urlencode(args) start = time.time() if method == "get": resp, content = client.request("%s?%s"%(settings.FLICKR_API_URL, params), "GET") else: resp, content = client.request(settings.FLICKR_API_URL, "POST", body=params) self.last_time = time.time() - start if resp['status'] != '200': raise FlickrException(0, "flickr API error : %s %s"%(resp["status"], content)) if args["format"] == "json": data = json.loads(content) if data["stat"] != "ok": raise FlickrException(data["code"], data["message"]) return data return content def recent_photos(self, no_instagram=False, just_friends=False, include_self=False): self.last_time = None cache_key = 'flickr_items_%s_%s_%s_%s'%(self.id, no_instagram, just_friends, include_self) photos = cache.get(cache_key) if not photos: try: response = self.call("get", "flickr.photos.getContactsPhotos", count = 50, extras = EXTRAS, just_friends = (just_friends and "1" or "0"), include_self = (include_self and "1" or "0"), ) photos = response["photos"]["photo"] except FlickrException, e: logging.error(e) # don't cache failure return [] def filter_instagram(p): mt = p["machine_tags"].split() return not "uploaded:by=instagram" in mt if no_instagram: photos = filter(filter_instagram, photos) def filter_aaron(p): mt = p["machine_tags"].split() return not "uploaded:by=parallelflickr" in mt photos = filter(filter_aaron, photos) cache.set(cache_key, photos, 120) for p in photos: p["description"] = p["description"]["_content"] p["link"] = "https://flickr.com/photos/%s/%s"%(p["pathalias"] or p["owner"], p['id']) p["upload_date"] = datetime.datetime.utcfromtimestamp(float(p["dateupload"])) p["tags"] = p["tags"].split() return photos def touch(self): self.fetched = datetime.datetime.utcnow() self.save()
{"/instagram/feeds.py": ["/instagram/models.py", "/flickr/feeds.py"], "/flickr/feeds.py": ["/flickr/models.py"], "/instagram/admin.py": ["/instagram/models.py"], "/urls.py": ["/flickr/feeds.py", "/instagram/feeds.py"], "/flickr/admin.py": ["/flickr/models.py"]}
12,253
tominsam/feedify
refs/heads/main
/flickr/views.py
from flickr.models import RequestToken, AccessToken, FlickrException from django.http import HttpResponseRedirect from django.contrib import messages from django.shortcuts import render from django.conf import settings import oauth2 import urllib import logging # decorator, for some reason def flickr_auth(fn): def wrapper(request, *args, **kwargs): request.access_token = None if request.session.get("fa"): try: request.token = AccessToken.objects.get(id=request.session['fa']) except AccessToken.DoesNotExist: logging.info("bad access token %s"%request.session['fa']) del request.session['fa'] return fn(request, *args, **kwargs) return wrapper @flickr_auth def index(request): if not hasattr(request, "token"): return render(request, "flickr/anon.html", dict(title="flickr")) no_instagram = request.REQUEST.get("no_instagram") just_friends = request.REQUEST.get("just_friends") include_self = request.REQUEST.get("include_self") try: photos = request.token.recent_photos( no_instagram=no_instagram, just_friends=just_friends, include_self=include_self, ) except FlickrException, e: if e.code == 98: # token error request.token.delete() return HttpResponseRedirect("/flickr/auth/?logout") return render(request, "flickr/index.html", dict( title = "flickr", token = request.token, photos = photos, time = request.token.last_time, )) def auth(request): consumer = oauth2.Consumer(key=settings.FLICKR_API_KEY, secret=settings.FLICKR_API_SECRET) if request.GET.get("logout") is not None: del request.session["fa"] return HttpResponseRedirect("/flickr/") # bounce step 1 if not request.GET.get("oauth_token"): client = oauth2.Client(consumer) # callback url support! SO AWESOME. params = urllib.urlencode(dict(oauth_callback = settings.SITE_URL+"/flickr/auth/",)) resp, content = client.request("%s?%s"%(settings.FLICKR_REQUEST_TOKEN_URL, params), "GET") if resp['status'] != '200': messages.add_message(request, messages.INFO, "Error talking to flickr: (%s) %s"%(resp['status'], content[:100])) return HttpResponseRedirect("/flickr/") request_token = RequestToken.from_string(content) # keep session small request.session['fr'] = request_token.id return HttpResponseRedirect("%s?perms=read&oauth_token=%s"%(settings.FLICKR_AUTHORIZE_URL, request_token.key)) else: # step 2 try: rt = RequestToken.objects.get(key = request.GET.get("oauth_token")) except RequestToken.DoesNotExist: messages.add_message(request, messages.INFO, "Bad token when talking to flickr. Try re-doing auth.") return HttpResponseRedirect("/flickr/") if rt.id != request.session.get('fr', None): logging.warn("tokens %r and %r do not match"%(rt.id, request.session.get('fr', "(None)"))) messages.add_message(request, messages.INFO, "Bad token when talking to flickr. Try re-doing auth.") return HttpResponseRedirect("/flickr/") token = rt.token() token.set_verifier(request.GET.get("oauth_verifier")) client = oauth2.Client(consumer, token) resp, content = client.request(settings.FLICKR_ACCESS_TOKEN_URL, "POST") if resp['status'] != '200': messages.add_message(request, messages.INFO, "Error talking to flickr: (%s) %s"%(resp['status'], content[:100])) return HttpResponseRedirect("/flickr/") # this creates/updates a token object about this user. It's the user record, for all intents and purposes. access_token = AccessToken.from_string(content) # keep session small request.session['fa'] = access_token.id if 'fr' in request.session: del request.session['fr'] return HttpResponseRedirect("/flickr/")
{"/instagram/feeds.py": ["/instagram/models.py", "/flickr/feeds.py"], "/flickr/feeds.py": ["/flickr/models.py"], "/instagram/admin.py": ["/instagram/models.py"], "/urls.py": ["/flickr/feeds.py", "/instagram/feeds.py"], "/flickr/admin.py": ["/flickr/models.py"]}
12,254
tominsam/feedify
refs/heads/main
/instagram/feeds.py
from instagram.models import AccessToken from flickr.feeds import GeoFeed from django.contrib.syndication.views import Feed from django.shortcuts import get_object_or_404 class InstagramPhotoFeed(Feed): feed_type = GeoFeed description_template = 'instagram/_photo.html' def get_object(self, request, token_secret): token = get_object_or_404(AccessToken, feed_secret = token_secret) token.filter_liked = request.REQUEST.get("liked", False) token.filter_mine = request.REQUEST.get("mine", False) return token def link(self, obj): return "http://feedify.movieos.org/instagram/" def title(self, obj): return u"instagram feed for %s"%obj.username def items(self, obj): obj.touch() if obj.filter_liked: return obj.get_photos("users/self/media/liked") elif obj.filter_mine: return obj.get_photos("users/self/media/recent") else: return obj.get_photos("users/self/feed") def item_title(self, item): try: caption = (item["caption"] or {})["text"] except KeyError: caption = "{no caption}" return u"%s - %s"%(item["user"]["full_name"], caption) def item_author_name(self, item): return item["user"]["full_name"] def item_link(self, item): return item["link"] def item_pubdate(self, item): return item["created_time"] def item_extra_kwargs(self, item): extra = {} if "location" in item and item["location"] and "latitude" in item["location"] and "longitude" in item["location"]: extra["latitude"] = item["location"]["latitude"] extra["longiutude"] = item["location"]["longitude"] # https://groups.google.com/forum/?fromgroups=#!topic/instagram-api-developers/ncB18unjqyg if isinstance(item["images"]["thumbnail"], dict): extra["media:thumbnail"] = dict( url = item["images"]["thumbnail"]["url"], width = str(item["images"]["thumbnail"]["width"]), height = str(item["images"]["thumbnail"]["height"]), ) extra["media:content"] = dict( url = item["images"]["standard_resolution"]["url"], width = str(item["images"]["standard_resolution"]["width"]), height = str(item["images"]["standard_resolution"]["height"]), ) else: extra["media:thumbnail"] = dict( url = item["images"]["thumbnail"], ) extra["media:content"] = dict( url = item["images"]["standard_resolution"], ) return extra
{"/instagram/feeds.py": ["/instagram/models.py", "/flickr/feeds.py"], "/flickr/feeds.py": ["/flickr/models.py"], "/instagram/admin.py": ["/instagram/models.py"], "/urls.py": ["/flickr/feeds.py", "/instagram/feeds.py"], "/flickr/admin.py": ["/flickr/models.py"]}
12,255
tominsam/feedify
refs/heads/main
/flickr/feeds.py
from flickr.models import AccessToken from django.contrib.syndication.views import Feed from django.utils.feedgenerator import Atom1Feed from django.shortcuts import get_object_or_404 class GeoFeed(Atom1Feed): def root_attributes(self): attrs = super(GeoFeed, self).root_attributes() attrs['xmlns:georss'] = 'http://www.georss.org/georss' attrs['xmlns:media'] = 'http://search.yahoo.com/mrss/' return attrs def add_item_elements(self, handler, item): super(GeoFeed, self).add_item_elements(handler, item) if "latitude" in item and "longitude" in item: handler.addQuickElement('georss:point', '%(latitude)s %(longitude)s'%item) if "media:thumbnail" in item: handler.addQuickElement("media:thumbnail", attrs = item["media:thumbnail"]) if "media:content" in item: handler.addQuickElement("media:content", attrs = item["media:content"]) handler.addQuickElement("media:title", item["title"]) class FlickrPhotoFeed(Feed): feed_type = GeoFeed description_template = 'flickr/_photo.html' def get_object(self, request, token_secret): self.no_instagram = request.REQUEST.get("no_instagram") self.just_friends = request.REQUEST.get("just_friends") self.include_self = request.REQUEST.get("include_self") return get_object_or_404(AccessToken, feed_secret = token_secret) def link(self, obj): return "http://feedify.movieos.org/flickr/" def title(self, obj): return u"flickr photos for contacts of %s"%obj.fullname def items(self, obj): obj.touch() return obj.recent_photos( no_instagram=self.no_instagram, just_friends=self.just_friends, include_self=self.include_self, ) def item_title(self, item): return u"%s - %s"%(item["ownername"], item["title"]) def item_author_name(self, item): return item["ownername"] def item_link(self, item): return item["link"] def item_pubdate(self, item): return item["upload_date"] def item_extra_kwargs(self, item): extra = {} if "latitude" in item and "longitude" in item and item["latitude"] and item["longitude"]: extra["latitude"] = item["latitude"] extra["longiutude"] = item["longitude"] #extra["thumbnail"] = item["url_t"] return extra
{"/instagram/feeds.py": ["/instagram/models.py", "/flickr/feeds.py"], "/flickr/feeds.py": ["/flickr/models.py"], "/instagram/admin.py": ["/instagram/models.py"], "/urls.py": ["/flickr/feeds.py", "/instagram/feeds.py"], "/flickr/admin.py": ["/flickr/models.py"]}
12,256
tominsam/feedify
refs/heads/main
/instagram/admin.py
from instagram.models import * from django.contrib import admin admin.site.register(AccessToken, list_display = ("key", "userid", "username", "created", "fetched"), date_hierarchy = "created", )
{"/instagram/feeds.py": ["/instagram/models.py", "/flickr/feeds.py"], "/flickr/feeds.py": ["/flickr/models.py"], "/instagram/admin.py": ["/instagram/models.py"], "/urls.py": ["/flickr/feeds.py", "/instagram/feeds.py"], "/flickr/admin.py": ["/flickr/models.py"]}
12,257
tominsam/feedify
refs/heads/main
/settings.py
# Django settings for feedify project. import os ROOT = os.path.dirname(__file__) ADMINS = ( ("Tom Insam", "tom@movieos.org"), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(os.path.dirname(__file__), 'default.db'), } } APPEND_SLASH = True TIME_ZONE = 'UTC' LANGUAGE_CODE = 'en-us' SITE_ID = 1 USE_I18N = False USE_L10N = False USE_ETAGS = True MEDIA_ROOT = '' MEDIA_URL = '' SITE_URL="http://localhost:8002" ALLOWED_HOSTS=["*"] STATIC_URL='/static/' STATICFILES_DIRS = ( os.path.join(os.path.dirname(__file__), "static"), ) SECRET_KEY = 'dev-secret-key' SESSION_COOKIE_NAME = "feedify_session" TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.static", "django.contrib.messages.context_processors.messages", "core.context_processors.all_settings", ) MIDDLEWARE_CLASSES = [ 'django.middleware.common.CommonMiddleware', 'session.middleware.SessionMiddleware', # 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'core.exception_handling.ExceptionMiddleware', ] # if not PRODUCTION: # MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware') # INTERNAL_IPS = ('127.0.0.1',) # DEBUG_TOOLBAR_CONFIG = { # "INTERCEPT_REDIRECTS": False, # } ROOT_URLCONF = 'urls' TEMPLATE_DIRS = ( os.path.join(ROOT, "templates"), ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.admin', 'django.contrib.staticfiles', # deps #"debug_toolbar", # my apps "core", "flickr", "instagram", ) LOGGING = { 'version': 1, 'formatters': { 'verbose': { 'format': '%(levelname)s|%(asctime)s|%(process)d|%(module)s|%(message)s' }, }, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'verbose' }, # 'file': { # 'level': 'DEBUG', # 'class': 'logging.FileHandler', # 'formatter': 'verbose', # 'filename': '/var/log/feedify/django.log', # }, 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' }, }, 'loggers': { 'django': { 'level': 'INFO', # SQL loggiung on debug 'handlers': ['console', "mail_admins"], }, '': { 'level': 'INFO', # SQL logging on debug 'handlers': ['console', "mail_admins"], }, } } CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } } FLICKR_REQUEST_TOKEN_URL="https://www.flickr.com/services/oauth/request_token" FLICKR_ACCESS_TOKEN_URL="https://www.flickr.com/services/oauth/access_token" FLICKR_AUTHORIZE_URL="https://www.flickr.com/services/oauth/authorize" INSTAGRAM_AUTHORIZE_URL="https://api.instagram.com/oauth/authorize/" INSTAGRAM_ACCESS_TOKEN_URL="https://api.instagram.com/oauth/access_token" INSTAGRAM_API_URL="https://api.instagram.com/v1/" FLICKR_API_URL="https://api.flickr.com/services/rest/" PRODUCTION = os.environ.get("PRODUCTION", False) if PRODUCTION: DEBUG=False EMAIL_BACKEND="sendmail.EmailBackend" SERVER_EMAIL="tom@movieos.org" DEFAULT_FROM_EMAIL="tom@movieos.org" STATIC_URL='http://feedify.movieos.org/static/' # ugh, hard-coding things sucks. Import production settings # from a python file in my home directory, rather than checking # them in. import imp prod = imp.load_source("production_settings", "/home/tomi/deploy/seatbelt/feedify_production.py") for k in filter(lambda a: a[0] != "_", dir(prod)): locals()[k] = getattr(prod, k) else: DEBUG=True # these are dev keys FLICKR_API_KEY="2d56dbb2d5cf87796478b53e4949dc66" FLICKR_API_SECRET="c27d752ea2bdba80" # these are dev keys INSTAGRAM_API_KEY="2ee26d19721040c98b4f93da87d7b485" INSTAGRAM_API_SECRET="4acc3891a73147dfb77262b0daf3cc01" TEMPLATE_DEBUG = DEBUG
{"/instagram/feeds.py": ["/instagram/models.py", "/flickr/feeds.py"], "/flickr/feeds.py": ["/flickr/models.py"], "/instagram/admin.py": ["/instagram/models.py"], "/urls.py": ["/flickr/feeds.py", "/instagram/feeds.py"], "/flickr/admin.py": ["/flickr/models.py"]}