Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for bridge in bridges:
bridge_node = Node(get_device_id(bridge),
label=get_device_label(bridge, 'Bridge'),
shape='box')
tenant_cluster.add_node(bridge_node)
for p in dao.get_ports_by_bridge_id(bridge['id']):
seen_port_ids.add(p['id'])
bridge_port_node = Node(shorten_uuid(p['id']),
label=get_port_label(p))
tenant_cluster.add_node(bridge_port_node)
tenant_cluster.add_edge(
Edge(bridge_node, shorten_uuid(p['id'])))
if p['type'] == 'InteriorBridge':
if p['peerId']:
if p['peerId'] in seen_port_ids:
continue
peer_port = dao.get_port_by_id(p['peerId'])
peer_device_id = peer_port['deviceId']
edge = Edge(bridge_port_node,
shorten_uuid(peer_port['id']))
if peer_port['type'].endswith('Bridge'):
other_tenant_id = dao.get_bridge_by_id(
peer_device_id)['tenantId']
continue
attr_list = {}
for attr in G.edge_attributes((edge_from, edge_to)):
attr_list[str(attr[0])] = str(attr[1])
if str(G.edge_label((edge_from, edge_to))):
attr_list['label'] = str(G.edge_label((edge_from, edge_to)))
elif weighted:
attr_list['label'] = str(G.edge_weight((edge_from, edge_to)))
if weighted:
attr_list['weight'] = str(G.edge_weight((edge_from, edge_to)))
newEdge = pydot.Edge(str(edge_from), str(edge_to), **attr_list)
dotG.add_edge(newEdge)
seen_edges.add(str(edge_from) + "-" + str(edge_to))
return dotG.to_string()
to_node = pydot.Node(link["remote_hostname"], label=to_label, style="filled", fillcolor="#323232", color="#646464", fontcolor="white", fontname="helvetica", href="https://obs.example.net/device/device={device_id}/".format(device_id=link["remote_device_id"]))
graph.add_node(to_node)
usage_perc = max(link["local_in_octets_perc"],link["local_out_octets_perc"])
if usage_perc <= 100:
color = "%s" % colors_scale[usage_perc]
else:
color = "purple"
if link["local_port_speed"] == 10000:
size = 8
elif link["local_port_speed"] == 1000:
size = 3
else:
size = 1
edge = pydot.Edge(from_node, to_node, color=color, fontcolor="white", fontsize=10, fontname="helvetica", penwidth=size, label="{from_if} -> {to_if}; Rx: {rx}, Tx: {tx}".format(from_if=link["local_port"], to_if=link["remote_port"], rx=sizeof_fmt(link["local_in_octets_rate"]), tx=sizeof_fmt(link["local_out_octets_rate"])), href="https://obs.example.net/device/device={device_id}/tab=port/port={port_id}/".format(device_id=link["local_device_id"], port_id=link["local_port_id"]))
graph.add_edge(edge)
scanned_ports.append([link["local_hostname"],link["local_port"]])
scanned_ports.append([link["remote_hostname"],link["remote_port"]])
scanned_devices.append(link["local_hostname"])
global debug_mode
if debug_mode:
debug_id = debug_id + 1
print("Wrote debug_%05d.png" % (debug_id))
graph.write_png("debug_%05d.png" % (debug_id))
new_graph = discover_links(graph, link["remote_hostname"])
if new_graph is not None:
graph = new_graph
else:
print("GRAPH IS NULL %s" % this_device)
sys.stdout.write("<")
sys.stdout.flush()
for domain in domains:
self.buildNode(domain[0],domain[1])
edgeList = set([])
for association in self.theAssociations:
headName = association.headDomain()
tailName = association.tailDomain()
connectionDomain = association.connectionDomain()
if (connectionDomain == ''):
edge = pydot.Edge(headName,tailName,label=association.phenomena(),dir='none',fontsize='5.0')
self.theGraph.add_edge(edge)
edgeList.add((headName,tailName))
else:
objtUrl = 'connection#' + headName + connectionDomain + tailName
self.theGraph.add_node(pydot.Node(objtUrl,label='',shape='point',fontsize='1',URL=objtUrl))
edge1 = pydot.Edge(headName,objtUrl,label=association.phenomena(),dir='none',fontsize='5.0')
edgeList.add((headName,objtUrl))
self.theGraph.add_edge(edge1)
edge2 = pydot.Edge(objtUrl,connectionDomain,label='',dir='none',fontsize='5.0')
edgeList.add((objtUrl,connectionDomain))
self.theGraph.add_edge(edge2)
edge3 = pydot.Edge(objtUrl,tailName,label='',dir='none',fontsize='5.0')
edgeList.add((objtUrl,tailName))
self.theGraph.add_edge(edge3)
return self.layout()
except ARM.DatabaseProxyException, errTxt:
raise ARM.ARMException(errTxt)
def _draw_graph_edge(parent, child):
"""Generates a Graphviz edge between `parent` and `child` modules."""
import pydot
return pydot.Edge( parent, child, dir='back')
'label': edge_label})
for top_blob in layer.top:
pydot_nodes[top_blob + '_blob'] = pydot.Node('%s' % (top_blob))
if label_edges:
edge_label = get_edge_label(layer)
else:
edge_label = '""'
pydot_edges.append({'src': node_name,
'dst': top_blob + '_blob',
'label': edge_label})
# Now, add the nodes and edges to the graph.
for node in pydot_nodes.values():
pydot_graph.add_node(node)
for edge in pydot_edges:
pydot_graph.add_edge(
pydot.Edge(pydot_nodes[edge['src']],
pydot_nodes[edge['dst']],
label=edge['label']))
return pydot_graph
def _dot_edge(self, node):
return pydot.Edge(str(node.parent), str(node), label=self._dot_edge_label(node), **self._dot_edge_kwargs(node))
# traverse through our dict so we can find some chunks?
for key,value in chunk_dict.iteritems():
# if we have got the correct entry
if key == ndx_nodes.index(node):
# if we have chunks in the particular lookaside list..
if len(value) != 0:
for v in value:
lalgraph.add_node(v)
if value.index(v) == 0:
if re.match(exploitable_conditions[0], v.get_name().strip('"')):
lalgraph.add_edge(pydot.Edge(ndx_nodes[key], v, label="exploitable condition?"))
elif re.match(exploitable_conditions[1], v.get_name().strip('"')):
lalgraph.add_edge(pydot.Edge(ndx_nodes[key], v, label="exploitable condition?"))
else:
lalgraph.add_edge(pydot.Edge(ndx_nodes[key], v))
try:
if re.match(exploitable_conditions[0], v.get_name().strip('"')):
lalgraph.add_edge(pydot.Edge(v, value[value.index(v)+1], label="exploitable condition?"))
elif re.match(exploitable_conditions[1], v.get_name().strip('"')):
lalgraph.add_edge(pydot.Edge(v, value[value.index(v)+1], label="exploitable condition?"))
else:
lalgraph.add_edge(pydot.Edge(v, value[value.index(v)+1]))
except:
pass
lalgraph.write_png(filename+".png")
tok_attrs = [a for a in toks if isinstance(a, P_AttrList)]
attrs = {}
for a in tok_attrs:
attrs.update(a.attrs)
e = []
n_prev = toks[0]
if isinstance(toks[2][0], pydot.Graph):
n_next_list = [[n.get_name(),] for n in toks[2][0].get_node_list()]
for n_next in [n for n in n_next_list]:
n_prev_port, n_next_port = do_node_ports(n_prev, n_next)
e.append(pydot.Edge(n_prev[0]+n_prev_port, n_next[0]+n_next_port, **attrs))
else:
for n_next in [n for n in tuple(toks)[2::2]]:
n_prev_port, n_next_port = do_node_ports(n_prev, n_next)
e.append(pydot.Edge(n_prev[0]+n_prev_port, n_next[0]+n_next_port, **attrs))
n_prev = n_next
return e
graph.add_node(pydot.Node(str(table.name),
shape="plaintext",
label=_render_table_html(table, metadata, show_indexes, show_datatypes, show_column_keys),
fontname=font, fontsize="7.0"
))
for table in tables:
for fk in table.foreign_keys:
if fk.column.table not in tables:
continue
edge = [table.name, fk.column.table.name]
is_inheritance = fk.parent.primary_key and fk.column.primary_key
if is_inheritance:
edge = edge[::-1]
graph_edge = pydot.Edge(
dir='both',
headlabel="+ %s"%fk.column.name, taillabel='+ %s'%fk.parent.name,
arrowhead=is_inheritance and 'none' or 'odot' ,
arrowtail=(fk.parent.primary_key or fk.parent.unique) and 'empty' or 'crow' ,
fontname=font,
#samehead=fk.column.name, sametail=fk.parent.name,
*edge, **relation_kwargs
)
graph.add_edge(graph_edge)
# not sure what this part is for, doesn't work with pydot 1.0.2
# graph_edge.parent_graph = graph.parent_graph
# if table.name not in [e.get_source() for e in graph.get_edge_list()]:
# graph.edge_src_list.append(table.name)
# if fk.column.table.name not in graph.edge_dst_list:
# graph.edge_dst_list.append(fk.column.table.name)