-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated Visualizer to use GraphViz #144
Changes from all commits
3328cb9
aa530bd
e3d5656
b6b45d0
11158cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"testing.openTesting": "neverOpen", | ||
"jest.outputConfig": { | ||
"revealOn": "run", | ||
"revealWithFocus": "none", | ||
"clearOnRun": "none" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should definitely go into a shared module eventually. Other projects should be re-using this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed. I'll just move it now so it's done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
export interface CALMInstantiation { | ||
nodes: CALMNode[], | ||
relationships: CALMRelationship[] | ||
} | ||
|
||
export type NodeType = 'actor' | 'system' | 'service' | 'database' | 'internal-network' | 'ldap' | 'dataclient'; | ||
|
||
export interface CALMNode { | ||
name: string, | ||
class?: string, | ||
'unique-id': string, | ||
'node-type': NodeType, | ||
description: string, | ||
'data-classification'?: string, | ||
'run-as'?: string, | ||
instance?: string | ||
} | ||
|
||
export type CALMRelationship = CALMInteractsRelationship | CALMConnectsRelationship | CALMDeployedInRelationship | CALMComposedOfRelationship; | ||
|
||
export interface CALMInteractsRelationship { | ||
'relationship-type': { | ||
willosborne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'interacts': { | ||
actor: string, | ||
nodes: string[] | ||
} | ||
}, | ||
uniqueId: string, | ||
} | ||
|
||
export interface CALMConnectsRelationship { | ||
'relationship-type': { | ||
'connects': { | ||
source: { node: string, interface?: string }, | ||
destination: { node: string, interface?: string } | ||
} | ||
}, | ||
uniqueId: string, | ||
protocol?: string, | ||
authentication?: string, | ||
} | ||
|
||
export interface CALMDeployedInRelationship { | ||
'relationship-type': { | ||
'deployed-in': { | ||
container: string, | ||
nodes: string[] | ||
} | ||
}, | ||
uniqueId: string, | ||
} | ||
|
||
export interface CALMComposedOfRelationship { | ||
'relationship-type': { | ||
'composed-of': { | ||
container: string, | ||
nodes: string[] | ||
}, | ||
} | ||
uniqueId: string, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { CALMInstantiation } from './Types'; | ||
import calmToDot from './calmToDot'; | ||
|
||
jest.mock('../helper.js', () => { | ||
return { | ||
initLogger: () => { | ||
return { | ||
info: jest.fn(), | ||
debug: jest.fn(), | ||
error: jest.fn() | ||
}; | ||
} | ||
}; | ||
}); | ||
|
||
describe('calmToDot', () => { | ||
let calm: CALMInstantiation; | ||
|
||
beforeEach(() => { | ||
calm = { | ||
nodes: [ | ||
{ | ||
'unique-id': 'node-1', | ||
'name': 'Node 1', | ||
'node-type': 'service', | ||
'description': 'This is node 1' | ||
}, | ||
{ | ||
'unique-id': 'node-2', | ||
'name': 'Node 2', | ||
'node-type': 'service', | ||
'description': 'This is node 2' | ||
} | ||
], | ||
relationships: [ | ||
{ | ||
'uniqueId': 'relationship-1', | ||
'protocol': 'HTTPS', | ||
'relationship-type': { | ||
'connects': { | ||
source: { | ||
node: 'node-1' | ||
}, | ||
destination: { | ||
node: 'node-2' | ||
} | ||
} | ||
} | ||
} | ||
] | ||
}; | ||
}); | ||
|
||
it('creates a basic node', () => { | ||
const actualDot = calmToDot(calm); | ||
expect(actualDot).toContain('"node-1" ['); | ||
expect(actualDot).toContain('label = "Service: Node 1"'); | ||
expect(actualDot).toContain('shape = "box"'); | ||
}); | ||
|
||
it('creates a basic relationship', () => { | ||
const actualDot = calmToDot(calm); | ||
expect(actualDot).toContain('"node-1" -> "node-2" ['); | ||
expect(actualDot).toContain('label = "connects HTTPS "'); | ||
}); | ||
|
||
it('creates an empty graph when given empty calm', () => { | ||
calm = { nodes: [], relationships: []}; | ||
const actualDot = calmToDot(calm); | ||
expect(actualDot).toEqual('digraph { nodesep = 0.5; }'); | ||
}); | ||
|
||
it('creates a subgraph relationship', () => { | ||
calm = { | ||
...calm, | ||
relationships: [ | ||
{ | ||
'uniqueId': 'subtest', | ||
'relationship-type': { | ||
'deployed-in': { | ||
container: 'node-1', | ||
nodes: ['node-2'] | ||
} | ||
} | ||
} | ||
] | ||
}; | ||
const actualDot = calmToDot(calm); | ||
expect(actualDot).toContain('subgraph "clusternode-1" {'); | ||
expect(actualDot).toContain('label = "node-1"'); | ||
expect(actualDot).toContain('"node-2" ['); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we removing Mermaid now that it's no longer needed? That should remove the dependency on Playwright/puppeteer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, I'll do a follow up PR to remove all the old visualizer code once this is all merged in and done