aws_security_viz 0.1.2.pre.alpha.pre.59 → 0.1.2.pre.alpha.pre.60

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTU2ODBmNTYyYTNkYTUwZWVlNGM4ODQwNWUxOGI4ZWU0ZDlhMTIwMQ==
4
+ MTI5ZTMzMzI0MWM5NDNhMmQ0YjY3YzMzM2RlYjY0MjEyZjVlYTU2NA==
5
5
  data.tar.gz: !binary |-
6
- YTMzYTFhODNlZjAyMWEwMjRiNjUzN2JjZDc1M2I0ZGNhODAwMDRjMg==
6
+ OGRmNjU2ZTc0M2U3ZmQ5NmM4OTJlN2M0NDMwZWRmOTc0OWQyZjVmMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDNjMTcxMGU3ZDlhYjlmYzc4ZTExZTQ0MWI5NDlkMTNjYWFjYmY0ZDZhYmM3
10
- YTIzMzIwNzQ0N2U5NjM3Njk3YmM5OGIzMjUwZjRmZjRlM2I4OWNlNzBlOGQy
11
- M2YwZTYxZmE4NTkwNTQ4Y2VmZDQyNjBhYWVhZjY5ZDAzNDM4YWM=
9
+ NGJlNTRmYjhhOTkwYjI0NmZlMDg2NzBhYjM1MzU3OWVlOWZiMDU0N2UwNmUz
10
+ Y2Q2Y2IyOWZkZTU2ZWFlYzg5NmI2NzgyYTljMTM0ZmI4MTk3YTFjMzg0MDlm
11
+ OTNmODA5Y2QyNDM0YmJkZTQ2NDMxZTAzMzE3N2Q5ZTE5NGUwYmM=
12
12
  data.tar.gz: !binary |-
13
- YzIxOGFiZmMzNDYyMTNhZGZjYmMyNzBhZmZhOTYwYzE1ZDllOTU1NDM4NzVk
14
- NzU3Njg1Y2RiMDcxNzlkNWU1MWRiYTdhNDE0NjQxYmZjNDYzMWM1N2U4MmU4
15
- NDUzOTM0ZGEzMzM4OWFhYTBiYjAyNGJiZDk3ZTgzZTc0YThmYzc=
13
+ Yzc3MTM4Mzg2M2FmNzQ0NWVmNjIyNzBjZWNmNjllNTQ5MmUxZWE4N2JhYWYy
14
+ Y2EzMGY4ZmI4OWQ3MmU0NmQ2ZWFkYjJhYzgzNjAyNTJlNDlkZmE0OThlMjI2
15
+ MDNmYmY3Y2E2ZTRjMGFlNmNhMzBmODdkN2MzZjI5ZDViZTJjMDA=
@@ -19,8 +19,12 @@ class VisualizeAws
19
19
 
20
20
  def unleash(output_file)
21
21
  g = build
22
- renderer = output_file.end_with?('json') ? Renderer::Json.new(output_file, @config) : Renderer::GraphViz.new(output_file, @config)
23
- g.output(renderer)
22
+ if output_file.end_with?('json')
23
+ g.output(Renderer::Json.new(output_file, @config))
24
+ FileUtils.copy(File.expand_path('../export/html/view.html', __FILE__), 'view.html')
25
+ else
26
+ g.output(Renderer::GraphViz.new(output_file, @config))
27
+ end
24
28
  end
25
29
 
26
30
  def build
@@ -6,9 +6,19 @@
6
6
  height: 100%;
7
7
  margin: auto;
8
8
  }
9
+
10
+ #error {
11
+ color: #31708f;
12
+ background-color: #d9edf7;
13
+ padding: 15px;
14
+ margin-bottom: 20px;
15
+ border: 1px solid transparent;
16
+ border-radius: 4px;
17
+ }
9
18
  </style>
10
19
  </head>
11
20
  <body>
21
+ <div id="error" style="display:none"></div>
12
22
  <div id="container"></div>
13
23
  <script src="https://rawgit.com/Linkurious/linkurious.js/develop/dist/sigma.min.js"></script>
14
24
  <script src="https://rawgit.com/Linkurious/linkurious.js/develop/dist/plugins/sigma.parsers.json.min.js"></script>
@@ -52,80 +62,101 @@
52
62
  edgeLabelSize: 'proportional'
53
63
  }
54
64
  };
55
- sigma.parsers.json('/aws.json', config, function (s) {
56
- s.graph.nodes().forEach(function (n) {
57
- n.x = Math.random();
58
- n.y = Math.random();
59
- n.size = 1;
60
- n.label = n.id;
61
- n.data = {edgeCount: s.graph.neighborCount(n.id)};
62
- });
63
- var myStyles = {
64
- nodes: {
65
- color: {
66
- by: 'data.edgeCount',
67
- scheme: 'colorbrewer.nodes',
68
- bins: 3
69
- },
70
- size: {
71
- by: 'data.edgeCount',
72
- bins: 7,
73
- min: 2,
74
- max: 10
75
- }
76
- }
77
- };
78
- var myPalette = {
79
- colorbrewer: {
80
- nodes: sigma.plugins.colorbrewer.Dark2
81
- }
82
- };
83
- var design = sigma.plugins.design(s, {styles: myStyles, palette: myPalette});
84
- design.apply();
85
-
86
- s.graph.nodes().forEach(function (n) {
87
- n.originalColor = n.color;
88
- });
89
- s.graph.edges().forEach(function (e) {
90
- e.size = 1;
91
- e.originalColor = e.color;
92
- e.type = "arrow";
93
- });
94
- var fa = sigma.layouts.startForceLink(s, {autoStop: true, adjustSizes: true, randomize: true});
95
-
96
- s.bind('clickNode', function (e) {
97
- var nodeId = e.data.node.id,
98
- toKeep = s.graph.neighbors(nodeId);
99
- toKeep[nodeId] = e.data.node;
65
+ var graphUrl = function () {
66
+ return window.location.hash.replace(/^#/, '/');
67
+ };
68
+ var errorElement = document.getElementById("error");
69
+ window.onhashchange = function () {
70
+ loadGraph(graphUrl());
71
+ };
100
72
 
73
+ function loadGraph(url) {
74
+ errorElement.style.display = "none";
75
+ var initializeGraph = function (s) {
101
76
  s.graph.nodes().forEach(function (n) {
102
- if (toKeep[n.id])
103
- n.color = n.originalColor;
104
- else
105
- n.color = '#eee';
77
+ n.x = Math.random();
78
+ n.y = Math.random();
79
+ n.size = 1;
80
+ n.label = n.id;
81
+ n.data = {edgeCount: s.graph.neighborCount(n.id)};
106
82
  });
83
+ var myStyles = {
84
+ nodes: {
85
+ color: {
86
+ by: 'data.edgeCount',
87
+ scheme: 'colorbrewer.nodes',
88
+ bins: 3
89
+ },
90
+ size: {
91
+ by: 'data.edgeCount',
92
+ bins: 7,
93
+ min: 2,
94
+ max: 10
95
+ }
96
+ }
97
+ };
98
+ var myPalette = {
99
+ colorbrewer: {
100
+ nodes: sigma.plugins.colorbrewer.Dark2
101
+ }
102
+ };
103
+ var design = sigma.plugins.design(s, {styles: myStyles, palette: myPalette});
104
+ design.apply();
107
105
 
106
+ s.graph.nodes().forEach(function (n) {
107
+ n.originalColor = n.color;
108
+ });
108
109
  s.graph.edges().forEach(function (e) {
109
- if (toKeep[e.source] && toKeep[e.target])
110
- e.color = e.originalColor;
111
- else
112
- e.color = '#eee';
110
+ e.size = 1;
111
+ e.originalColor = e.color;
112
+ e.type = "arrow";
113
113
  });
114
+ var fa = sigma.layouts.startForceLink(s, {autoStop: true, adjustSizes: true, randomize: true});
114
115
 
115
- s.refresh();
116
- });
117
- s.bind('clickStage', function (e) {
118
- s.graph.nodes().forEach(function (n) {
119
- n.color = n.originalColor;
116
+ s.bind('clickNode', function (e) {
117
+ var nodeId = e.data.node.id,
118
+ toKeep = s.graph.neighbors(nodeId);
119
+ toKeep[nodeId] = e.data.node;
120
+
121
+ s.graph.nodes().forEach(function (n) {
122
+ if (toKeep[n.id])
123
+ n.color = n.originalColor;
124
+ else
125
+ n.color = '#eee';
126
+ });
127
+
128
+ s.graph.edges().forEach(function (e) {
129
+ if (toKeep[e.source] && toKeep[e.target])
130
+ e.color = e.originalColor;
131
+ else
132
+ e.color = '#eee';
133
+ });
134
+
135
+ s.refresh();
120
136
  });
137
+ s.bind('clickStage', function (e) {
138
+ s.graph.nodes().forEach(function (n) {
139
+ n.color = n.originalColor;
140
+ });
121
141
 
122
- s.graph.edges().forEach(function (e) {
123
- e.color = e.originalColor;
142
+ s.graph.edges().forEach(function (e) {
143
+ e.color = e.originalColor;
144
+ });
145
+
146
+ s.refresh();
124
147
  });
148
+ };
149
+ sigma.parsers.json(url, config, initializeGraph);
150
+ }
125
151
 
126
- s.refresh();
127
- });
128
- });
152
+ var url = graphUrl();
153
+ if (url) {
154
+ loadGraph(graphUrl());
155
+ } else {
156
+ var link = '<a href="' + location.href + '#test.json">' + location.href + '#test.json</a>';
157
+ errorElement.innerHTML = "Please pass in a datasource via html fragment identifier. For e.g. " + link;
158
+ errorElement.style.display = "";
159
+ }
129
160
  </script>
130
161
  </body>
131
162
  </html>
@@ -25,6 +25,7 @@ describe VisualizeAws do
25
25
  let(:temp_file) { Tempfile.new(%w(aws .json)) }
26
26
 
27
27
  it 'should parse json input', :integration => true do
28
+ expect(FileUtils).to receive(:copy)
28
29
  VisualizeAws.new(config, opts).unleash(temp_file.path)
29
30
  expect(File.read(expected_file)).to eq(temp_file.read)
30
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_security_viz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.pre.alpha.pre.59
4
+ version: 0.1.2.pre.alpha.pre.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anay Nayak