Profile Dependencies
InSpec profiles can bring in the controls from another InSpec profile. These dependencies are maintained in the metadata and captured in the profile's lockfile.
Steps:
Let's consider we have two profiles viz.
base_profileandchild_profilewhich has different controls executed by them.If you do not have two profiles, create using
inspec init profile [profile_name]for learning purpose.We would like to execute
child_profilewhich in turns should execute the controls present in thebase_profile.Add dependency in the metadata of the
child_profilei.e.inspec.ymlas belowdepends: - name: base_profile path: ../base_profileEdit the control file of the
child_profileand add the following lines:include_controls 'base_profile'This will include the controls present in the
base_profileExecute the
child_profilewhich should execute the controls present in its own control file as well as thebase_profilecontrol file.inspec exec child_profile
Possible reasons of failure for the child_profile not being able to execute controls present in the base_profile
The
inspec.lockfile is not updated. To do this delete the file and execute the profile again. Other way to do this without deleting theinspec.lockfile is to use--no-create-lockfilewhile executing the profile. Example:inspec exec child_profile --no-create-lockfileThe path to the profile is not set correctly in the
inspec.ymlfile.
Other ways to add depedency of other profile are as follows:
via git:
via url:
via supermarket:
via compliance:
Last updated