From 3ef4092d39a179d6e42c729b8093d783e3745ada Mon Sep 17 00:00:00 2001 From: James Stocks Date: Tue, 2 Jul 2019 16:49:38 +0100 Subject: [PATCH] Permit plugin to be in path with git ref Fixes #3904 Signed-off-by: James Stocks --- .../lib/inspec-plugin-manager-cli/cli_command.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb b/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb index e717659fb..0f20996a1 100644 --- a/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +++ b/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb @@ -229,6 +229,7 @@ module InspecPlugins given = given.expand_path # Resolve any relative paths name_regex = /^(inspec|train)-/ versioned_regex = /^(inspec|train)-[a-z0-9\-\_]+-\d+\.\d+\.\d+$/ + sha_ref_regex = /^(inspec|train)-[a-z0-9\-\_]+-[0-9a-f]{5,40}$/ # What are the last four things like? parts = [ @@ -257,14 +258,14 @@ module InspecPlugins # In that case, we'll have a version on the plugin name in part 0 # /home/you/.gems/2.4.0/gems/inspec-something-3.45.1/lib/inspec-something.rb # parts index: ^0^ ^1^ ^2^ ^3^ - if parts[0] =~ versioned_regex && parts[1] == "lib" && parts[0].start_with?(parts[2]) && parts[3] == ".rb" + if (parts[0] =~ versioned_regex || parts[0] =~ sha_ref_regex) && parts[1] == "lib" && parts[0].start_with?(parts[2]) && parts[3] == ".rb" return given.to_s end # Case 4: Like case 3, but missing the .rb # /home/you/.gems/2.4.0/gems/inspec-something-3.45.1/lib/inspec-something # parts index: ^0^ ^1^ ^2^ ^3^ (empty) - if parts[0] =~ versioned_regex && parts[1] == "lib" && parts[0].start_with?(parts[2]) && parts[3].empty? + if (parts[0] =~ versioned_regex || parts[0] =~ sha_ref_regex) && parts[1] == "lib" && parts[0].start_with?(parts[2]) && parts[3].empty? return given.to_s + ".rb" end