Skip to content

Commit

Permalink
Merge pull request #535 from chef/ashiqueps/remove-netaddr
Browse files Browse the repository at this point in the history
[CVE] Removed the netaddr gem
  • Loading branch information
ashiqueps committed Nov 2, 2023
2 parents c564845 + 80bbc49 commit a7941c5
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 57 deletions.
41 changes: 0 additions & 41 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ expeditor:
timeout_in_minutes: 30

steps:

- label: run-lint-and-specs-ruby-2.7
command:
- .expeditor/run_linux_tests.sh rake
expeditor:
executor:
docker:
image: ruby:2.7-buster

- label: run-lint-and-specs-ruby-3.0
command:
- .expeditor/run_linux_tests.sh rake
expeditor:
executor:
docker:
image: ruby:3.0-buster

- label: run-lint-and-specs-ruby-3.1
command:
- .expeditor/run_linux_tests.sh rake
Expand All @@ -32,30 +15,6 @@ steps:
docker:
image: ruby:3.1-buster

- label: run-specs-windows-ruby-2.7
command:
- bundle config --local path vendor/bundle
- bundle config set --local without docs debug
- bundle install --jobs=7 --retry=3
- bundle exec rake
expeditor:
executor:
docker:
host_os: windows
image: rubydistros/windows-2019:2.7

- label: run-specs-windows-ruby-3.0
command:
- bundle config --local path vendor/bundle
- bundle config set --local without docs debug
- bundle install --jobs=7 --retry=3
- bundle exec rake
expeditor:
executor:
docker:
host_os: windows
image: rubydistros/windows-2019:3.0

- label: run-specs-windows-ruby-3.1
command:
- bundle config --local path vendor/bundle
Expand Down
3 changes: 1 addition & 2 deletions knife-vsphere.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ Gem::Specification.new do |s|
s.description = "VMware vSphere support for Chef Infra's Knife command"
s.email = "[email protected]"
s.files = Dir["lib/**/*"] + %w{LICENSE}
s.required_ruby_version = ">= 2.7"
s.required_ruby_version = ">= 3.1"
s.homepage = "https://github.com/chef/knife-vsphere"
s.license = "Apache-2.0"
s.add_dependency "netaddr", "~> 1.5"
s.add_dependency "rbvmomi2", ">= 3.5.0", "< 4.0"
s.add_dependency "filesize", ">= 0.1.1", "< 0.3.0"
s.add_dependency "chef-vault", ">= 2.6"
Expand Down
1 change: 0 additions & 1 deletion lib/chef/knife/vsphere_hosts_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Chef::Knife::VsphereHostsList < Chef::Knife::BaseVsphereCommand

deps do
Chef::Knife::BaseVsphereCommand.load_deps
require "netaddr" unless defined?(NetAddr)
end

common_options
Expand Down
1 change: 0 additions & 1 deletion lib/chef/knife/vsphere_pool_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Chef::Knife::VspherePoolQuery < Chef::Knife::BaseVsphereCommand

deps do
Chef::Knife::BaseVsphereCommand.load_deps
require "netaddr" unless defined?(NetAddr)
end

common_options
Expand Down
1 change: 0 additions & 1 deletion lib/chef/knife/vsphere_pool_show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Chef::Knife::VspherePoolShow < Chef::Knife::BaseVsphereCommand

deps do
Chef::Knife::BaseVsphereCommand.load_deps
require "netaddr" unless defined?(NetAddr)
end

common_options
Expand Down
15 changes: 8 additions & 7 deletions lib/chef/knife/vsphere_vm_clone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
deps do
Chef::Knife::BaseVsphereCommand.load_deps
require "ipaddr" unless defined?(IPAddr)
require "netaddr" unless defined?(NetAddr)
require "securerandom" unless defined?(SecureRandom)
require "chef/json_compat"

Expand Down Expand Up @@ -742,18 +741,20 @@ def generate_adapter_map(ip = nil, gw = nil, mac = nil)
if ip.nil? || ip.casecmp("dhcp") == 0
settings.ip = RbVmomi::VIM::CustomizationDhcpIpGenerator.new
else
cidr_ip = NetAddr::CIDR.create(ip)
settings.ip = RbVmomi::VIM::CustomizationFixedIp(ipAddress: cidr_ip.ip)
settings.subnetMask = cidr_ip.netmask_ext
ip_addr = IPAddr.new(ip)
ip_string, _length = ip.split("/")
settings.ip = RbVmomi::VIM::CustomizationFixedIp(ipAddress: ip_string)
settings.subnetMask = ip_addr.netmask

# TODO: want to confirm gw/ip are in same subnet?
# Only set gateway on first IP.
if config[:customization_ips].split(",").first == ip
if gw.nil?
settings.gateway = [cidr_ip.network(Objectify: true).next_ip]
next_ip = IPAddr.new(ip_addr.to_i + 1, Socket::AF_INET).to_s
settings.gateway = [next_ip]
else
gw_cidr = NetAddr::CIDR.create(gw)
settings.gateway = [gw_cidr.ip]
gw_string, _length = gw.split("/")
settings.gateway = [gw_string]
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions lib/chef/knife/vsphere_vm_network_add.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ class Chef::Knife::VsphereVmNetworkAdd < Chef::Knife::BaseVsphereCommand
description: "Adapter MAC address eg. AA:BB:CC:DD:EE:FF",
required: false

deps do
require "netaddr" unless defined?(NetAddr)
end

common_options

def run
Expand Down

0 comments on commit a7941c5

Please sign in to comment.