Skip to content
SAF Advanced InSpec Profile Developer CourseSAF Advanced InSpec Profile Developer Course
MITRE InSpec Advanced Profile Developer Course
Course
Resources
Installation
  • Course

    • 1. Course Overview
      • 2. Review the Fundamentals
        • 3. Practice the Fundamentals
          • 4. Tools for Automation
            • 5. Automate Security Testing
              • 6. Explore InSpec Resources
                • 7. Local vs Built-in Resources
                  • 7.1. Local Resource
                    • 7.2. Built-in InSpec Resource
                    • 8. Create a Custom Resource - The Git Example
                      • 9. Create a Custom Resource - The Docker Example
                        • 10. Writing Plural Resources
                          • 11. Dissecting Resources
                            • 12. Exercise - Develop your own resources
                              • 13. Add Your Resource to InSpec
                                • 14. Custom Resource Examples from InSpec

                                7. Local vs Built-in Resources

                                June 7, 2022Less than 1 minute

                                On This Page
                                • 7.1. Local Resource
                                • 7.2. Built-in InSpec Resource

                                # 7.1. Local Resource

                                Local resources exist only in the profile they are developed in. As was shown in the previous example, a local resource would be placed in the libraries directory

                                $ tree examples/profile
                                examples/profile
                                ...
                                ├── libraries
                                │   └── custom_resource.rb
                                

                                From there you would develop your custom resource custom_resource.rb and be able to utilize the resource within that profile.

                                # 7.2. Built-in InSpec Resource

                                Sometimes when working on resources you may find a gap in InSpec where a resource doesn't exist where it should. In a situation such as that you may want to develop a resource for upstream InSpec in Github. When developing a resource for InSpec you touch a few more files than just the custom_resource.rb as mentioned before.

                                First you would have to fork a copy of the InSpec Github Repoopen in new window to make the necessary changes to the repository.

                                The following directories are the ones you would want to change:

                                For the actual resource you can place it in lib/inspec/resources/.

                                You have to add your new resource to the helper file in lib/inspec/resources.rb

                                Then you have to write out your integration tests for the resource in this directory test/integration/default/controls/

                                Next you are required to write the unit tests for your new resource here test/unit/resources/

                                Finally, you will have to write up the documentation that will be put up on InSpec's official doc page here docs/resources/

                                Edit this pageopen in new window
                                Last update: 6/9/2022, 4:39:14 PM
                                Contributors: Emily Rodriguez
                                Prev
                                6. Explore InSpec Resources
                                Next
                                8. Create a Custom Resource - The Git Example
                                Apache-2.0 | Copyright © 2022 - The MITRE Corporation
                                Copyright © 2022 Aaron Lippold