algosec-sdk 1.2.0 → 1.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: d57a7f42feec59ab1260d8b662d201048b341515
4
- data.tar.gz: f116ced6c0739e3823ced4f4e10b82219131025b
3
+ metadata.gz: 56034524fe3048203cf77cd466bc6a5c3a4c8a2c
4
+ data.tar.gz: aa9cdba1f2bdd438a30671d2e2369b39481f60c4
5
5
  SHA512:
6
- metadata.gz: 982599fbbf3ac54e546469470dac5d86d6456dddfd1669032b10df17e290759f51c46afe5a7e01b964aaae5de343bb966cc35db939ceb625d31503f212ae4a55
7
- data.tar.gz: b8a0bd17374d44d8d642bc3b9a3bd7b13fd2d9f2d8e24d21e6cd39ccb0a2bfa11bd3ea61457c0ba1ae142b1e7c6a80e99feafda1f1e235fca7203ab40668044d
6
+ metadata.gz: 9c3424704a4cd59a987fdbec1bad9e8166bef1e55bc0610afeafbb6a63e58b5df73b464ca1ea6e6242173926fd5f3cac66c166118d67ccddddae201c9b858966
7
+ data.tar.gz: 518c7ce35db30dbc3f752dc0e63371eb61f7cd3e60b80642595e4cfed9ffc169488c92f5508468ff736f6dfe68a45524f6858899bb0771596e033a67a9c9d505
data/.bumpversion.cfg CHANGED
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 1.2.0
2
+ current_version = 1.2.1
3
3
  commit = True
4
4
  tag = True
5
5
 
@@ -366,20 +366,14 @@ module ALGOSEC_SDK
366
366
  # TODO: Add unitests that objects are being create only once (if the same object is twice in the incoming list)
367
367
  network_object_names = Set.new(network_object_names)
368
368
  ipv4_or_subnet_objects = network_object_names.map do |object_name|
369
- begin
370
- IPAddress.parse object_name
371
- search_result = search_network_object(object_name, NetworkObjectSearchType::EXACT)
372
- # If no object was found in search, we'll count this object for creation
373
- search_result.empty? ? object_name : nil
374
- rescue ArgumentError
375
- # The parsed object name was not IP Address or IP Subnet, ignore it
376
- nil
369
+ if get_network_object_type(object_name)
370
+ search_network_object(object_name, NetworkObjectSearchType::EXACT).empty? ? object_name : nil
377
371
  end
378
372
  end.compact
379
373
 
380
374
  # Create all the objects. If the error from the server tells us that the object already exists, ignore the error
381
375
  ipv4_or_subnet_objects.map do |ipv4_or_subnet|
382
- create_network_object(NetworkObjectType::HOST, ipv4_or_subnet, ipv4_or_subnet)
376
+ create_network_object(get_network_object_type(ipv4_or_subnet), ipv4_or_subnet, ipv4_or_subnet)
383
377
  end.compact
384
378
  end
385
379
 
@@ -403,5 +397,19 @@ module ALGOSEC_SDK
403
397
  end
404
398
  end.compact
405
399
  end
400
+
401
+ private
402
+
403
+ def get_network_object_type(object_name)
404
+ # handle IP ranges
405
+ if object_name.split('-').size == 2
406
+ object_name.split('-').all? { |ip| !get_network_object_type(ip).nil? } ? NetworkObjectType::RANGE : nil
407
+ else
408
+ ip_parse = IPAddress.parse object_name
409
+ ip_parse.size == 1 ? NetworkObjectType::HOST : NetworkObjectType::RANGE
410
+ end
411
+ rescue ArgumentError
412
+ nil
413
+ end
406
414
  end
407
415
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Gem version defined here
4
4
  module ALGOSEC_SDK
5
- VERSION = '1.2.0'.freeze
5
+ VERSION = '1.2.1'.freeze
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algosec-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Almog Cohen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-05 00:00:00.000000000 Z
11
+ date: 2018-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient