norad_cli 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4016c7a4f61f8e8d54b9daf79ef1748e3c115d6f
4
- data.tar.gz: b3c5f09f37994be524483685590551a7aebef891
3
+ metadata.gz: 3e3063cd4907e612894a79f1355b7fd550ecc25c
4
+ data.tar.gz: 960742bba7ea52a70b425d9c46af4aa35ed5cad7
5
5
  SHA512:
6
- metadata.gz: 13375c60fb7f24b76e66ed00566beff0374b637bc3ab2f72eea211a3d1849f8356d39af51896f1e847960771baf780504af678e4630817f9d01b22f59acccd6f
7
- data.tar.gz: 93ab9c1e2f66f400bb6e61e7bb69bdaa47ddeb379b4dd6cca407d7e05c4f7d57f994e085322802f25b03301008fdd955eaadc62d4498526b0924a3db37b1a106
6
+ metadata.gz: 176111f240083608fcfa4e9906bf054d0d6de427c73d215752388aebc56eecc9284ec5025def2d7389abdb3d5180dcfad7b8eb0a7e04695d55f8592695ceeacc
7
+ data.tar.gz: d8f0a0bc199330a03a43c39c0503a3939e90dede9b30747f8163b9d2128ba2d937f28c60964acd767b2a9740b52ba1eb7b22b2e21545ba7f6c4de4bcbb3eba77
@@ -67,6 +67,9 @@ class Sectest < Thor
67
67
  # Correct set default registry and version
68
68
  load_manifest(ARGV[2])
69
69
 
70
+ # Used to prevent JSON::ParserError when parsing the output stream
71
+ Docker.options[:chunk_size] = 1
72
+
70
73
  desc 'scaffold TESTNAME', 'Create a new security test with standard files + testing'
71
74
  option :test_type, aliases: '-t', default: 'whole_host', desc: 'The security test type, Options: [authenticated|web_application|brute_force|ssl_crypto|ssh_crypto|whole_host]'
72
75
  option :registry, aliases: '-r', default: @@sectest_manifest['registry'], desc: 'The Docker registry to store docker images'
@@ -153,7 +156,7 @@ class Sectest < Thor
153
156
  imgs_to_build.keys.reverse_each do |img_dir|
154
157
  say("Building image #{img_dir}...", :green)
155
158
  Docker::Image.build_from_dir(img_dir, t: imgs_to_build[img_dir]) do |v|
156
- $stdout.puts v if options[:debug]
159
+ parse_json v if options[:debug]
157
160
  end
158
161
  end
159
162
  end
@@ -179,7 +182,7 @@ class Sectest < Thor
179
182
  docker_file = img_dir.split('/')[-1]
180
183
  nocache = docker_file['no-cache'] ? true : false
181
184
  Docker::Image.build_from_dir(img_dir.gsub(docker_file, ''), dockerfile: docker_file, t: imgs_to_build[img_dir], nocache: nocache) do |v|
182
- $stdout.puts v if options[:debug]
185
+ parse_json v if options[:debug]
183
186
  end
184
187
  end
185
188
 
@@ -371,4 +374,15 @@ class Sectest < Thor
371
374
  exit(codes.detect(-> { 0 }, &:nonzero?))
372
375
  end
373
376
  end
377
+
378
+ private
379
+
380
+ def parse_json(stream)
381
+ stream.split(/\r\n/).each do |string|
382
+ parsed = JSON.parse(string)
383
+ $stdout.print(parsed['stream']) if parsed.is_a?(Hash)
384
+ end
385
+ rescue JSON::ParserError
386
+ $stdout.print stream
387
+ end
374
388
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Style/FormatStringToken
3
4
  require 'safe_yaml'
4
5
  SafeYAML::OPTIONS[:default_mode] = :safe
5
6
 
@@ -79,7 +80,7 @@ describe Manifest do
79
80
  expect(manifest.values['prog_args']).to_not eq(nil)
80
81
  expect(manifest.values['prog_args'].scan('%{target}').length).to eq(1)
81
82
  category = manifest.values['category']
82
- assert false unless category == 'blackbox' || category == 'whitebox'
83
+ assert false unless %w[whitebox blackbox].include? category
83
84
  if category == 'blackbox'
84
85
  expect(manifest.values['prog_args'].scan('%{ssh_user}').length).to eq(0)
85
86
  expect(manifest.values['prog_args'].scan('%{ssh_key}').length).to eq(0)
@@ -116,3 +117,4 @@ describe Manifest do
116
117
  puts
117
118
  end
118
119
  end
120
+ # rubocop:enable Style/FormatStringToken
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NoradCli
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norad_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hitchcock
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-05-12 00:00:00.000000000 Z
13
+ date: 2017-07-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: git