Browse Source

rename overlay_refs to parent_refs... fix up hash string

description..
main
John-Mark Gurney 5 years ago
parent
commit
54b6ec745f
2 changed files with 12 additions and 7 deletions
  1. +1
    -1
      README.md
  2. +11
    -6
      ui/cli.py

+ 1
- 1
README.md View File

@@ -75,7 +75,7 @@ object_marking_refs Imported from [STIX v2.0 Part 1]: Section 3.1
granular_markings Imported from [STIX v2.0 Part 1]: Section 3.1
hashes A list of hash strings.
lang RFC XXXX language of the properties.
parent_ref UUIDv4 of the parent MetaData Object. Any properties on this object override the parent. (allow deletion via None/null?) Any missing properties are passed through to the parent for resolution.
parent_refs List of UUIDv4s of MetaData Object that overlay. Any properties on this object override the parent. (allow deletion via None/null?) Any missing properties are passed through to the parent for resolution. The first/earliest object that has a property is used in that objects later in the list are "hidden" by the earlier objects.
mime-type The mime-type. If the set of bytes is polymorphic, there should be one for each "type".
uri List of URI's where the file may be located.
child_files A dictionary where the keys are the file names and the values are hash strings. (One issue w/ using hashes is that you can't tie YOUR idea of the metadata, but it also allows a person to have metadata about a file that is private and not be forced to share it, nor create a dummy object.)


+ 11
- 6
ui/cli.py View File

@@ -70,7 +70,7 @@ class MDBase(object):
}

_common_properties = [ 'type', 'created_by_ref' ] # XXX - add lang?
_common_optional = set(('overlay_refs', 'sig'))
_common_optional = set(('parent_refs', 'sig'))
_common_names = set(_common_properties + _generated_properties.keys())

def __init__(self, obj={}, **kwargs):
@@ -183,7 +183,7 @@ class Identity(MDBase):
_common_properties = [ x for x in MDBase._common_properties if x !=
'created_by_ref' ]
_common_optional = set([ x for x in MDBase._common_optional if x !=
'overlay_refs' ] + [ 'name', 'pubkey' ])
'parent_refs' ] + [ 'name', 'pubkey' ])
_common_names = set(_common_properties + MDBase._generated_properties.keys())

def _trytodict(o):
@@ -363,12 +363,17 @@ class ObjectStore(object):

@staticmethod
def makehash(hashstr, strict=True):
'''Take a hash string, and return a valid hash string from it.
'''Take a hash or hash string, and return a valid hash
string from it.

This makes sure that it is of the correct type and length.

If strict is False, the function will detect the length and
return a valid hash if one can be found.'''
return a valid hash string if one can be found.

By default, the string must be prepended by the type,
followed by a colon, followed by the value in hex in all
lower case characters.'''

try:
hash, value = hashstr.split(':')
@@ -759,7 +764,7 @@ class _TestCases(unittest.TestCase):
'modified': datetime.datetime(2019, 6, 10, 18, 3, 10),
'created_by_ref': self.created_by_ref,
'hashes': [ dhash ],
'overlay_refs': [ bid ],
'parent_refs': [ bid ],
'lang': 'en',
})

@@ -768,7 +773,7 @@ class _TestCases(unittest.TestCase):
odict = dict(oobj.items())

# that is has the overlays property
self.assertEqual(odict['overlay_refs'], [ bid ])
self.assertEqual(odict['parent_refs'], [ bid ])

# that it doesn't have a common property
self.assertNotIn('type', odict)


Loading…
Cancel
Save