Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions synapse/datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,11 +1244,12 @@ def addForm(self, formname, forminfo, propdefs, checks=True):
if prop.ifaces:
continue

if (newdef := ptypes.get(prop.name)) is not None:
if newdef != prop.typedef:
mesg = f'Form {formname} overrides inherited prop {prop.name} with a different typedef.'
raise s_exc.BadPropDef(mesg=mesg, typedef=newdef, form=formname, prop=prop.name)
continue
# FIXME - We must allow more specific declarations...
# if (newdef := ptypes.get(prop.name)) is not None:
# if newdef != prop.typedef:
# mesg = f'Form {formname} overrides inherited prop {prop.name} with a different typedef.'
# raise s_exc.BadPropDef(mesg=mesg, typedef=newdef, form=formname, prop=prop.name)
# continue

pprops.append((prop.name, prop.typedef, prop.info))

Expand Down
148 changes: 77 additions & 71 deletions synapse/models/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,70 +92,88 @@ async def _normPyStr(self, valu, view=None):
modeldefs = (
{

'interfaces': (
('inet:dns:record', {
'doc': 'An interface for DNS records.'}),
),

'types': (

('inet:dns:name', (None, {'ctor': 'synapse.models.dns.DnsName'}), {
'ex': 'vertex.link',
'doc': 'A DNS query name string. Likely an FQDN but not always.'}),

('inet:dns:a', ('comp', {'fields': (('fqdn', 'inet:fqdn'), ('ip', 'inet:ipv4'))}), {
'template': {'title': 'DNS A record'},
'interfaces': (
('meta:observable', {'template': {'title': 'DNS A record'}}),
('meta:observable', {}),
('inet:dns:record', {}),
),
'ex': '(vertex.link,1.2.3.4)',
'doc': 'The result of a DNS A record lookup.'}),

('inet:dns:aaaa', ('comp', {'fields': (('fqdn', 'inet:fqdn'), ('ip', 'inet:ipv6'))}), {
'template': {'title': 'DNS AAAA record'},
'interfaces': (
('meta:observable', {'template': {'title': 'DNS AAAA record'}}),
('meta:observable', {}),
('inet:dns:record', {}),
),
'ex': '(vertex.link,2607:f8b0:4004:809::200e)',
'doc': 'The result of a DNS AAAA record lookup.'}),

('inet:dns:rev', ('comp', {'fields': (('ip', 'inet:ip'), ('fqdn', 'inet:fqdn'))}), {
'template': {'title': 'Reverse DNS record'},
'interfaces': (
('meta:observable', {'template': {'title': 'Reverse DNS record'}}),
('meta:observable', {}),
('inet:dns:record', {}),
),
'ex': '(1.2.3.4,vertex.link)',
'doc': 'The transformed result of a DNS PTR record lookup.'}),

('inet:dns:ns', ('comp', {'fields': (('zone', 'inet:fqdn'), ('ns', 'inet:fqdn'))}), {
'template': {'title': 'DNS NS record'},
'interfaces': (
('meta:observable', {'template': {'title': 'DNS NS record'}}),
('meta:observable', {}),
('inet:dns:record', {}),
),
'ex': '(vertex.link,ns.dnshost.com)',
'doc': 'The result of a DNS NS record lookup.'}),

('inet:dns:cname', ('comp', {'fields': (('fqdn', 'inet:fqdn'), ('cname', 'inet:fqdn'))}), {
'template': {'title': 'DNS CNAME record'},
'interfaces': (
('meta:observable', {'template': {'title': 'DNS CNAME record'}}),
('meta:observable', {}),
('inet:dns:record', {}),
),
'ex': '(foo.vertex.link,vertex.link)',
'doc': 'The result of a DNS CNAME record lookup.'}),

('inet:dns:mx', ('comp', {'fields': (('fqdn', 'inet:fqdn'), ('mx', 'inet:fqdn'))}), {
'template': {'title': 'DNS MX record'},
'interfaces': (
('meta:observable', {'template': {'title': 'DNS MX record'}}),
('meta:observable', {}),
('inet:dns:record', {}),
),
'ex': '(vertex.link,mail.vertex.link)',
'doc': 'The result of a DNS MX record lookup.'}),

('inet:dns:soa', ('guid', {}), {
'template': {'title': 'DNS SOA record'},
'interfaces': (
('meta:observable', {'template': {'title': 'DNS SOA record'}}),
('meta:observable', {}),
('inet:dns:record', {}),
),
'doc': 'The result of a DNS SOA record lookup.'}),

('inet:dns:txt', ('comp', {'fields': (('fqdn', 'inet:fqdn'), ('txt', 'str'))}), {
'template': {'title': 'DNS TXT record'},
'interfaces': (
('meta:observable', {'template': {'title': 'DNS TXT record'}}),
('meta:observable', {}),
('inet:dns:record', {}),
),
'ex': '(hehe.vertex.link,"fancy TXT record")',
'doc': 'The result of a DNS TXT record lookup.'}),

('inet:dns:type', ('int', {}), {
'doc': 'A DNS query/answer type integer.'}),

('inet:dns:query',
('comp', {'fields': (('client', 'inet:client'), ('name', 'inet:dns:name'), ('type', 'int'))}), {
'interfaces': (
Expand All @@ -168,11 +186,57 @@ async def _normPyStr(self, valu, view=None):
'interfaces': (
('inet:proto:request', {}),
),
'doc': 'A single instance of a DNS resolver request and optional reply info.'}),
'props': (

('query:name', ('inet:dns:name', {}), {
'doc': 'The DNS query name string in the request.'}),

('query:type', ('int', {}), {
'doc': 'The type of record requested in the query.'}),

('response', ('inet:dns:response', {}), {
'doc': 'The response sent by the DNS server.'}),
),
'doc': 'A DNS protocol request.'}),

('inet:dns:response', ('guid', {}), {
'interfaces': (
('inet:proto:response', {}),
),
'props': (

('code', ('dns:reply:code', {}), {
'doc': 'The DNS server reply code.'}),

('answers', ('inet:dns:answers', {}), {
'doc': 'The DNS answers included in the response.'}),
),
'doc': 'A DNS protocol response.'}),

('inet:dns:answer', ('guid', {}), {
'props': (

('ttl', ('int', {}), {
'doc': 'The time to live value of the DNS record in the response.'}),

('record', ('inet:dns:record', {}), {
'doc': 'The DNS record contained in the answer.'}),
),
'doc': 'A single answer from within a DNS reply.'}),

('inet:dns:mx:answer', ('inet:dns:answer', {}), {
'props': (
('record', ('inet:dns:mx', {}), {
'doc': 'The MX record in the answer.'}),

('priority', ('int', {}), {
'doc': 'The DNS MX record priority.'}),
),
'doc': 'A single MX answer from within a DNS reply.'}),

('inet:dns:answers', ('array', {'type': 'inet:dns:answer'}), {
'doc': 'An array of DNS answers.'}),

('inet:dns:wild:a', ('comp', {'fields': (('fqdn', 'inet:fqdn'), ('ip', 'inet:ip'))}), {
'interfaces': (
('meta:observable', {'template': {'title': 'DNS wildcard A record'}}),
Expand Down Expand Up @@ -257,6 +321,7 @@ async def _normPyStr(self, valu, view=None):
)),

('inet:dns:query', {}, (

('client', ('inet:client', {}), {
'computed': True,
'doc': 'The client that performed the DNS query.'}),
Expand All @@ -265,70 +330,11 @@ async def _normPyStr(self, valu, view=None):
'computed': True,
'doc': 'The DNS query name string.'}),

('name:ip', ('inet:ip', {}), {
'computed': True,
'doc': 'The IP address in the DNS query name string.',
'prevnames': ('name:ipv4', 'name:ipv6')}),

('name:fqdn', ('inet:fqdn', {}), {
'computed': True,
'doc': 'The FQDN in the DNS query name string.'}),

('type', ('int', {}), {
'computed': True,
'doc': 'The type of record that was queried.'}),
)),

('inet:dns:request', {}, (

('query', ('inet:dns:query', {}), {
'doc': 'The DNS query contained in the request.'}),

('query:name', ('inet:dns:name', {}), {
'doc': 'The DNS query name string in the request.'}),

('query:name:ip', ('inet:ip', {}), {
'doc': 'The IP address in the DNS query name string.',
'prevnames': ('query:name:ipv4', 'query:name:ipv6')}),

('query:name:fqdn', ('inet:fqdn', {}), {
'doc': 'The FQDN in the DNS query name string.'}),

('query:type', ('int', {}), {
'doc': 'The type of record requested in the query.'}),

('reply:code', ('dns:reply:code', {}), {
'doc': 'The DNS server response code.'}),
)),

('inet:dns:answer', {}, (

('ttl', ('int', {}), {
'doc': 'The time to live value of the DNS record in the response.'}),

('request', ('inet:dns:request', {}), {
'doc': 'The DNS request that was answered.'}),

('record', (
('inet:dns:a', {}),
('inet:dns:aaaa', {}),
('inet:dns:cname', {}),
('inet:dns:mx', {}),
('inet:dns:ns', {}),
('inet:dns:rev', {}),
('inet:dns:soa', {}),
('inet:dns:txt', {}),
), {
'doc': 'The DNS record returned by the lookup.',
'prevnames': ('a', 'aaaa', 'cname', 'mx', 'ns', 'rev', 'soa', 'txt')}),

('mx:priority', ('int', {}), {
'doc': 'The DNS MX record priority.'}),

('time', ('time', {}), {
'doc': 'The time that the DNS response was transmitted.'}),
)),

('inet:dns:wild:a', {}, (
('fqdn', ('inet:fqdn', {}), {'computed': True,
'doc': 'The domain containing a wild card record.'}),
Expand Down
56 changes: 40 additions & 16 deletions synapse/models/inet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,11 +1441,33 @@ async def _normPyStr(self, valu, view=None):
'doc': 'An HTTP session.'}),

('inet:http:request', ('guid', {}), {
'template': {'title': 'HTTP request'},
'interfaces': (
('inet:proto:request', {}),
),
'doc': 'A single HTTP request.'}),

('inet:http:response', ('guid', {}), {
'template': {'title': 'HTTP response'},
'interfaces': (
('inet:proto:response', {}),
),
'props': (

('code', ('int', {}), {
'doc': 'The HTTP response code received.'}),

('reason', ('str', {}), {
'doc': 'The HTTP response reason phrase received.'}),

('headers', ('array', {'type': 'inet:http:response:header', 'uniq': False, 'sorted': False}), {
'doc': 'An array of HTTP headers from the response.'}),

('body', ('file:bytes', {}), {
'doc': 'The HTTP response body received.'}),
),
'doc': 'A HTTP response returned by a server.'}),

('inet:hyperlink', ('guid', {}), {
'doc': 'A URL link embedded in a message.'}),

Expand Down Expand Up @@ -1918,7 +1940,21 @@ async def _normPyStr(self, valu, view=None):
('flow', ('inet:flow', {}), {
'doc': 'The network flow which contained the {title}.'}),
),
'doc': 'Properties common to network protocol requests and responses.'}),
'doc': 'Properties common to network protocol requests.'}),

('inet:proto:response', {

'template': {'title': 'response'},
'interfaces': (
('base:event', {}),
('inet:proto:link', {}),
),
'props': (

('flow', ('inet:flow', {}), {
'doc': 'The network flow which contained the {title}.'}),
),
'doc': 'Properties common to network protocol responses.'}),

('inet:service:base', {
'doc': 'Properties common to most forms within a service platform.',
Expand Down Expand Up @@ -2334,23 +2370,11 @@ async def _normPyStr(self, valu, view=None):
('cookies', ('array', {'type': 'inet:http:cookie'}), {
'doc': 'An array of HTTP cookie values parsed from the "Cookies:" header in the request.'}),

('response:time', ('time', {}), {
'doc': 'The time a response to the request was received.'}),

('response:code', ('int', {}), {
'doc': 'The HTTP response code received.'}),

('response:reason', ('str', {}), {
'doc': 'The HTTP response reason phrase received.'}),

('response:headers', ('array', {'type': 'inet:http:response:header', 'uniq': False, 'sorted': False}), {
'doc': 'An array of HTTP headers from the response.'}),

('response:body', ('file:bytes', {}), {
'doc': 'The HTTP response body received.'}),

('session', ('inet:http:session', {}), {
'doc': 'The HTTP session this request was part of.'}),

('response', ('inet:http:response', {}), {
'doc': 'The HTTP response sent by the server.'}),
)),

('inet:http:session', {}, (
Expand Down
Loading
Loading