Skip to content

Commit

Permalink
Add toprim/tostr calls to _whoisGuid() to allow heavy Dict objects to…
Browse files Browse the repository at this point in the history
… be hashed. (#2046)
  • Loading branch information
vEpiphyte committed Jan 8, 2021
1 parent 14e8c51 commit 1a1f5fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion synapse/lib/stormwhois.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ async def _whoisGuid(self, props, form):
Raises:
StormRuntimeError: If form is not supported in this method
'''

form = await s_stormtypes.tostr(form)
props = await s_stormtypes.toprim(props)
if form == 'iprec':
guid_props = ('net4', 'net6', 'asof', 'id')
elif form == 'ipcontact':
Expand Down
6 changes: 6 additions & 0 deletions synapse/tests/test_lib_stormwhois.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ async def test_storm_whois_guid(self):
guid_exp = s_common.guid(sorted((props['net4'], str(props['asof']), props['id'])))
self.len(1, await core.nodes(f'inet:whois:iprec={guid_exp}'))

stormcmd = '''$props=$lib.dict(net4="10.0.0.0/28", asof=(2554869000000), id='NET-10-0-0-0-1', status=validated)
return ($lib.inet.whois.guid($props, 'iprec'))
'''
guid = await core.callStorm(stormcmd)
self.eq(guid_exp, guid)

# contact
pscontact = s_common.guid()
props = {
Expand Down

0 comments on commit 1a1f5fe

Please sign in to comment.