InSpec: "Cannot load <profile> since it is not listed as a dependency" 当依赖被定义时

InSpec: "Cannot load <profile> since it is not listed as a dependency" when dependency is defined

在 InSpec 1.9.0 中,我定义了以下具有依赖性的配置文件,包括依赖配置文件中的所有控件。

但是,在执行时我收到错误指示配置文件“未列为依赖项

我错过了什么?


我没有看到语法错误。这几乎是来自 InSpec Profiles 页面的复制粘贴示例。

以下依赖项定义(git 而不是 url)也导致了与上面相同的错误消息:

depends:
  - name: ssh-baseline
    git: https://github.com/dev-sec/ssh-baseline.git

我刚刚根据您的post为它创建了一个配置文件,它可以正常工作。我使用了 inspec 1.9.0。只是为了确定,你可以试试 inspec exec ./my-profile -t ssh://user@host.domain?

inspec.lock 文件是在第一次执行配置文件时创建的,其中包含对依赖项的引用。如果您逐步构建您的配置文件,您最终可能会得到一个不包含依赖项的 inspec.yml 文件(从第一个 运行 开始):

---
lockfile_version: 1
depends: []

如果要反映对 inspec.yml 的更改或 运行 配置文件目录中的以下内容,则需要删除该文件:

inspec vendor --overwrite

参见Vendoring dependencies(它没有提到--overwrite,但如果不存在它会立即抛出错误):

When you execute a local profile, the inspec.yml file will be read in order to source any profile dependencies. It will then cache the dependencies locally and generate an inspec.lock file. If you add or update dependencies in inspec.yml, please refresh the lock file by either:

  • running inspec vendor inside the profile directory; or
  • deleting inspec.lock before running inspec exec