mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
First step to get inspec names changeable
for community distributions Signed-off-by: Artem Sidorenko <artem.sidorenko@t-systems.com>
This commit is contained in:
parent
5de39cb325
commit
96353a708a
4 changed files with 28 additions and 15 deletions
|
@ -16,6 +16,7 @@ require 'inspec/runner_mock'
|
|||
require 'inspec/env_printer'
|
||||
require 'inspec/schema'
|
||||
require 'inspec/config'
|
||||
require 'inspec/dist'
|
||||
|
||||
class Inspec::InspecCLI < Inspec::BaseCLI
|
||||
class_option :log_level, aliases: :l, type: :string,
|
||||
|
@ -206,55 +207,55 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
|
||||
Automate:
|
||||
```
|
||||
inspec compliance login
|
||||
inspec exec compliance://username/linux-baseline
|
||||
#{Inspec::Dist::EXEC_NAME} compliance login
|
||||
#{Inspec::Dist::EXEC_NAME} exec compliance://username/linux-baseline
|
||||
```
|
||||
|
||||
Supermarket:
|
||||
```
|
||||
inspec exec supermarket://username/linux-baseline
|
||||
#{Inspec::Dist::EXEC_NAME} exec supermarket://username/linux-baseline
|
||||
```
|
||||
|
||||
Local profile (executes all tests in `controls/`):
|
||||
```
|
||||
inspec exec /path/to/profile
|
||||
#{Inspec::Dist::EXEC_NAME} exec /path/to/profile
|
||||
```
|
||||
|
||||
Local single test (doesn't allow inputs or custom resources)
|
||||
```
|
||||
inspec exec /path/to/a_test.rb
|
||||
#{Inspec::Dist::EXEC_NAME} exec /path/to/a_test.rb
|
||||
```
|
||||
|
||||
Git via SSH
|
||||
```
|
||||
inspec exec git@github.com:dev-sec/linux-baseline.git
|
||||
#{Inspec::Dist::EXEC_NAME} exec git@github.com:dev-sec/linux-baseline.git
|
||||
```
|
||||
|
||||
Git via HTTPS (.git suffix is required):
|
||||
```
|
||||
inspec exec https://github.com/dev-sec/linux-baseline.git
|
||||
#{Inspec::Dist::EXEC_NAME} exec https://github.com/dev-sec/linux-baseline.git
|
||||
```
|
||||
|
||||
Private Git via HTTPS (.git suffix is required):
|
||||
```
|
||||
inspec exec https://API_TOKEN@github.com/dev-sec/linux-baseline.git
|
||||
#{Inspec::Dist::EXEC_NAME} exec https://API_TOKEN@github.com/dev-sec/linux-baseline.git
|
||||
```
|
||||
|
||||
Private Git via HTTPS and cached credentials (.git suffix is required):
|
||||
```
|
||||
git config credential.helper cache
|
||||
git ls-remote https://github.com/dev-sec/linux-baseline.git
|
||||
inspec exec https://github.com/dev-sec/linux-baseline.git
|
||||
#{Inspec::Dist::EXEC_NAME} exec https://github.com/dev-sec/linux-baseline.git
|
||||
```
|
||||
|
||||
Web hosted fileshare (also supports .zip):
|
||||
```
|
||||
inspec exec https://webserver/linux-baseline.tar.gz
|
||||
#{Inspec::Dist::EXEC_NAME} exec https://webserver/linux-baseline.tar.gz
|
||||
```
|
||||
|
||||
Web hosted fileshare with basic authentication (supports .zip):
|
||||
```
|
||||
inspec exec https://username:password@webserver/linux-baseline.tar.gz
|
||||
#{Inspec::Dist::EXEC_NAME} exec https://username:password@webserver/linux-baseline.tar.gz
|
||||
```
|
||||
EOT
|
||||
exec_options
|
||||
|
@ -359,7 +360,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|||
# display outdated version
|
||||
latest = LatestInSpecVersion.new.latest
|
||||
if Gem::Version.new(Inspec::VERSION) < Gem::Version.new(latest)
|
||||
puts "\nYour version of InSpec is out of date! The latest version is #{latest}."
|
||||
puts "\nYour version of #{Inspec::Dist::PRODUCT_NAME} is out of date! The latest version is #{latest}."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
11
lib/inspec/dist.rb
Normal file
11
lib/inspec/dist.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Inspec
|
||||
module Dist
|
||||
# When referencing a product directly, like InSpec
|
||||
PRODUCT_NAME = 'Chef InSpec'
|
||||
|
||||
# The inspec executable
|
||||
EXEC_NAME = 'inspec'
|
||||
end
|
||||
end
|
|
@ -12,6 +12,7 @@ require 'inspec/metadata'
|
|||
require 'inspec/secrets'
|
||||
require 'inspec/config'
|
||||
require 'inspec/dependencies/cache'
|
||||
require 'inspec/dist'
|
||||
# spec requirements
|
||||
|
||||
module Inspec
|
||||
|
@ -216,9 +217,9 @@ module Inspec
|
|||
|
||||
def supports_profile?(profile)
|
||||
if !profile.supports_runtime?
|
||||
raise 'This profile requires InSpec version '\
|
||||
raise "This profile requires #{Inspec::Dist::PRODUCT_NAME} version "\
|
||||
"#{profile.metadata.inspec_requirement}. You are running "\
|
||||
"InSpec v#{Inspec::VERSION}.\n"
|
||||
"#{Inspec::Dist::PRODUCT_NAME} v#{Inspec::VERSION}.\n"
|
||||
end
|
||||
|
||||
true
|
||||
|
|
|
@ -238,7 +238,7 @@ Test Summary: 0 successful, 0 failures, 0 skipped
|
|||
|
||||
it 'does not support this profile' do
|
||||
out.exit_status.must_equal 1
|
||||
out.stderr.must_equal "This profile requires InSpec version >= 99.0.0. You are running InSpec v#{Inspec::VERSION}.\n"
|
||||
out.stderr.must_equal "This profile requires Chef InSpec version >= 99.0.0. You are running Chef InSpec v#{Inspec::VERSION}.\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue