Skip to content

Commit

Permalink
adding owned to hvt calc option
Browse files Browse the repository at this point in the history
  • Loading branch information
skelsec committed Feb 21, 2021
1 parent b9f5366 commit 2f16d42
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 2 deletions.
6 changes: 6 additions & 0 deletions buildnode.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.open /home/devel/Desktop/AD2.db
.mode csv
.output workdir/graphcache/1/networkx.csv
.separator " "
SELECT src,dst FROM adedges, adedgelookup WHERE adedges.graph_id = 1 AND adedgelookup.id = adedges.src AND adedgelookup.oid IS NOT NULL;
.exit
36 changes: 36 additions & 0 deletions jackdaw/nest/api/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,42 @@ def query_path_fromowned(graphid, exclude = None, format = 'vis'):

return res.to_dict(format = format)

def query_path_fromowned_tohighvalue(graphid, exclude = None, format = 'vis'):
exclude_edgetypes = __exclude_parse(exclude)
if graphid not in current_app.config['JACKDAW_GRAPH_DICT']:
load(graphid)

source_sids = {}

for domain_id in current_app.config['JACKDAW_GRAPH_DICT'][graphid].adids:
for res in current_app.db.session.query(EdgeLookup.oid)\
.filter_by(ad_id = domain_id)\
.filter(EdgeLookup.oid == ADObjProps.oid)\
.filter(ADObjProps.graph_id == graphid)\
.filter(ADObjProps.prop == 'OWNED')\
.all():

source_sids[res[0]] = 0

target_sids = {}

for domain_id in current_app.config['JACKDAW_GRAPH_DICT'][graphid].adids:
for res in current_app.db.session.query(EdgeLookup.oid)\
.filter_by(ad_id = domain_id)\
.filter(EdgeLookup.oid == ADObjProps.oid)\
.filter(ADObjProps.graph_id == graphid)\
.filter(ADObjProps.prop == 'HVT')\
.all():

target_sids[res[0]] = 0

res = GraphData()
for src_sid in source_sids:
for dst_sid in target_sids:
res += current_app.config['JACKDAW_GRAPH_DICT'][graphid].shortest_paths(src_sid=src_sid, dst_sid=dst_sid, exclude = exclude_edgetypes)

return res.to_dict(format = format)


def list_nodes(graphid, with_data = False):
if graphid not in current_app.config['JACKDAW_GRAPH_DICT']:
Expand Down
33 changes: 33 additions & 0 deletions jackdaw/nest/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,39 @@ paths:
type: string
description: TODO

/graph/{graphid}/query/path/fromownedtohighvalue/:
get:
operationId: jackdaw.nest.api.graph.query_path_fromowned_tohighvalue
tags:
- Graph
summary: Paths from owned users to highvalue targets
description: Paths from owned users to highvalue targets
parameters:
- name: graphid
in: path
description: ID of the graph view
type: integer
required: True
- name: format
in: query
description: return format. either vis or d3
type: string
required: False
- name: exclude
in: query
description: edge type to be excluded in the path calc
required: False
type: string
responses:
200:
description: TODO
schema:
type: object
properties:
graph:
type: string
description: TODO

/graph/{graphid}/query/path/tohighvalue/:
get:
operationId: jackdaw.nest.api.graph.query_path_tohighvalue
Expand Down
12 changes: 12 additions & 0 deletions jackdaw/nest/site/nui/client/Pages/GraphPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ class GraphPageComponent extends ApiClient {
case "highvalue":
url = `/graph/${this.state.graph}/query/path/tohighvalue${excludeParameter}`;
break;
case "fromownedtohighvalue":
url = `/graph/${this.state.graph}/query/path/fromownedtohighvalue${excludeParameter}`;
break;
default:
return;
}
Expand Down Expand Up @@ -818,6 +821,15 @@ class GraphPageComponent extends ApiClient {
>
Draw user paths to High Value targets
</Button>
</Box>
<Box className="margin-top">
<Button
color="primary"
variant="contained"
onClick={() => this.fetchGraph('fromownedtohighvalue')}
>
Draw paths from owned users to high value targets
</Button>
</Box>
</VBox>
</VBox>
Expand Down
4 changes: 2 additions & 2 deletions jackdaw/nest/site/nui/dist/bundle.js

Large diffs are not rendered by default.

0 comments on commit 2f16d42

Please sign in to comment.