mirror of
https://github.com/inspec/inspec
synced 2024-12-26 04:53:24 +00:00
1 line
No EOL
6.3 KiB
JSON
1 line
No EOL
6.3 KiB
JSON
[["InSpec Introduction","<p>Welcome to the interactive InSpec demo. You will learn how to use the command line and shell and get an introduction to all aspects of the language.</p>\n\n<p>To navigate this demo, type <code>next</code> to move forward and <code>prev</code> to move back.\nUse <code>clear</code> to clear the terminal screen.</p>\n"],["InSpec Help","<p>InSpec is called via</p>\n\n<p><code>\ninspec\n</code></p>\n\n<p>Try it out! You will see the help menu. You can also view it with:</p>\n\n<p><code>\ninspec help\n</code></p>\n"],["InSpec Help Subcommands","<p>This list of subcommands may be intimidating at first. It is easy to get help on any of these commands via <code>inspec help <COMMAND></code>. Let's try it out for a few:</p>\n\n<p><code>\ninspec help version\n</code></p>\n\n<p><code>\ninspec help detect\n</code></p>\n\n<p><code>\ninspec help exec\n</code></p>\n"],["InSpec Version","<p>The easiest subcommand is <code>inspec version</code>. It tells you which version of InSpec is running.</p>\n"],["InSpec Check","<p>The most frequent use of InSpec is to execute profiles. You can find the <code>examples/profile</code> in the InSpec repository. Before executing it for the first time, let's verify if it is valid profile</p>\n\n<p><code>\ninspec check examples/profile\n</code></p>\n\n<p>This command is not only used for syntax testing and linting, but can also provide information on valid profiles including its version and control overview.</p>\n"],["InSpec Exec","<p>Let's try testing some profiles! To run the profile and test the local machine, type:</p>\n\n<p><code>\ninspec exec examples/profile\n</code></p>\n\n<p>The result is shown in the report.</p>\n"],["InSpec Exec SSH","<p>InSpec can also test your remote machines! Let's assume there is node <code>host.node</code> registered with SSH configured for user <code>bob</code> with a keyfile in the current directory (<code>bob.rsa</code>). You can run the same profile against this node via:</p>\n\n<p><code>\ninspec exec examples/profile -t ssh://bob@host.node -i bob.rsa\n</code></p>\n"],["InSpec Exec SSH (More Options)","<p>The wonderful <code>-t</code> option (or <code>--target</code>) is a shorthand for specifying all fields separately:</p>\n\n<p><code>\ninspec exec examples/profile -b ssh --host host.node --user bob -i bob.rsa\n</code></p>\n\n<p>For more options try:</p>\n\n<p><code>\ninspec help exec\n</code></p>\n"],["InSpec Exec WinRm","<p>We can also scan Windows machines. Let's assume <code>windows.node</code> is configured with WinRM access for user <code>alice</code> with a password <code>pass</code>. The command will now read:</p>\n\n<p><code>\ninspec exec examples/profile -t winrm://alice:pass@windows.node\n</code></p>\n"],["InSpec Exec WinRm SSL","<p>The previous example is not quite realistic. Most Windows nodes with WinRM are configured to use SSL. Let's assume the user also has a self-signed certificate. It would now read</p>\n\n<p><code>\ninspec exec examples/profile -t winrm://alice:pass@windows.node --ssl --self-signed\n</code></p>\n"],["InSpec Exec Docker","<p>InSpec also supports scanning containers. Let's try it with Docker and pick a container</p>\n\n<p><code>\ninspec exec examples/profile -t docker://abcdef123\n</code></p>\n"],["InSpec Detect","<p>InSpec is able to verify local and remote nodes before running tests. This is a utility command to check connections and get information on the target</p>\n\n<p><code>\ninspec detect\n</code></p>\n\n<p><code>\ninspec detect -t ssh://bob@host.node -i bob.rsa\n</code></p>\n"],["InSpec Shell Introduction","<p>Let's explore the InSpec shell. It's an integrated utility to test and debug the InSpec language. Before we start it interactively, let's try the command execution mode. It runs code and resources and prints the result.</p>\n\n<p>First, we start with the OS detection:</p>\n\n<p><code>\ninspec shell -c 'os.params'\n</code></p>\n\n<p>Another example is to test an existing resource:</p>\n\n<p><code>\ninspec shell -c 'sshd_config.Protocol'\n</code></p>\n"],["InSpec Shell with Remotes","<p>These commands also work with remote targets</p>\n\n<p><code>\ninspec shell -c 'sshd_config.Protocol' -t ssh://bob@host.node -i bob.rsa\n</code></p>\n\n<p><code>\ninspec shell -c 'os.params' -t docker://abcdef123\n</code></p>\n"],["Interactive InSpec Shell","<p>It's time to see the interactive shell! Type</p>\n\n<p><code>\ninspec shell\n</code></p>\n\n<p>You can still use <code>next</code> and <code>prev</code> to move between demos. Look at how the shell prompt looks different between the system shell and the inspec shell.</p>\n"],["InSpec Shell Help","<p>The greeting of the InSpec shell suggests to run the help command:</p>\n\n<p><code>\nhelp\n</code></p>\n\n<p>You will not only see the help menu, but also a quick summary of the machine where this is running.</p>\n"],["InSpec Shell Help Resources","<p>To get a list of all available resources, you can type:</p>\n\n<p><code>\nhelp resources\n</code></p>\n"],["InSpec Shell Help Subcommands","<p>To explore any of these resources, you can try:</p>\n\n<p><code>\nhelp file\n</code></p>\n\n<p><code>\nhelp command\n</code></p>\n\n<p><code>\nhelp os\n</code></p>\n\n<p>These 3 resources are the core trinity of all executions. All other resources reference them in some way. They lead of system interactions.</p>\n"],["InSpec Shell Commands","<p>To use any of these resources, you can call it and its arguments. Try these examples:</p>\n\n<p><code>\ncommand('uname -a').stdout\n</code></p>\n\n<p><code>\nfile('/proc/cpuinfo').owner\n</code></p>\n\n<p><code>\nsshd_config.params\n</code></p>\n"],["InSpec Shell - Describe Block","<p><code>describe</code> blocks are used to create simple checks. We will create a test that verifies a file's access permissions.</p>\n\n<p><code>\ndescribe file('/root') do\n it { should exist }\n its('mode') { should cmp '0750'}\nend\n</code></p>\n"],["Inspec Shell - Full Control","<p>Tests can be combined in controls, which offer more context. They are mainly used for policy/compliance testing:</p>\n\n<p><code>\ncontrol "id" do\n title "Check permissions on /root!"\n impact 0.5\n describe file('/root') do\n its('mode') { should cmp '0750'}\n end\nend\n</code></p>\n"]] |