-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC Platforms #1661
Comments
In section 2:
This could probably use some additional explanation as to what you're trying to convey. |
Section 2.3: I'd love to see us raise a specific exception if we can't detect the platform (maybe something like |
Sections 3 and 4: 💯 -- cannot wait for this level of control. Will provide a much better UX to both resource and profile creators as well as those that consume them. |
Thank you so much, @arlimus, for writing this up. This sounds great. |
I feel like this could also connect/link to the other discussion chain of knowing when you are inside a container, a vm or on a host - i.e. as part of the platform data that is returned - i.e. #1005. |
@adamleff Thank you for the feedback, all added into the current version! This RFC is now complete. I removed the custom transport target definition (e.g. |
@arlimus LGTM 👍 |
Starting to cover work items:
|
As part of #1661 Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
* Add cache connection to train * Update caching to be on BaseConnection * Refactor tests and cleanup logic * Move caching into base_connection and privatize connection calls * Update mock transport to use base caching. * Add author tag and caching comments. * Added exception for invalid cache type and small logic refactor. Signed-off-by: Jared Quick <jquick@chef.io>
Moving outstanding work here: |
v0.4-2017.04.24 Complete version for now; not covering custom transport targets in this RFC
work items are tracked below in #1661 (comment) and will be moved into a milestone
1. Summary
This RFC describes InSpec's platform definition. Platforms are the sum of all the things that InSpec can test. It is designed to support all types of platforms, from operating systems, network equipment, to APIs, databases, and cloud systems.
This is not a breaking change. This RFC contains a detailed explanation of goals and supported fields.
Platforms in InSpec are fundamentally separated in operating systems (OS) and application interfaces (APIs). [See section 2]
Platforms are used in platform definitions and resources to declare what these can support. [See sections 3 + 4]
2. Platform definition and list
Platforms describe the things that InSpec can test. There are specific platforms (e.g. Red Hat Linux 7.0) and more general definitions that act as a grouping mechanism (e.g. Linux OS). Platforms are overall grouped in operating systems and APIs. Operating systems are built on the
file
,command
, andos
resources. APIs provide common tests around requests on different layers (e.g. testing SSL and HTTP).Every platform is uniquely identified by the combination of
name
andrelease
. A specific platform may have a number of platformfamily
entries associated with it. (See section 2.2)A core goal of this RFC is the ability to scan e.g. HTTP endpoints, APIs, SSL, and more without being disconnected from the scan-target(1). At the moment the details are hidden in code while the profile is executed on a host.
(1) At the moment a user may write a profile that targets a remote host (
--target ssh://something
) but really opens a connection to test an API (like AWS/Azure/VMware). Disconnected points to the difference in scan-target and actually tested object.2.1 Naming conventions
InSpec's platform types are oriented towards Serverspec compatibility. This provides both simplicity in the OS world, as well as a few limitations and differences in convention to other tools. As for limitations: Shorthand specifiers like
redhat
would have a better replacement withrhel
, considering there is an OS group calledredhat
and other products in this space likeredhat-openstack
.A long-term transitional goal is to (1) introduce clear identifiers for new platforms, (2) add new identifiers to platforms that are loose and start to deprecate old identifiers, (3) remove old identifiers. This RFC will not deprecate or remove identifiers yet (steps 2+3) and only introduce new terms (step 1).
2.2 Platform definition
Platforms are mainly defined in Train. API platforms may be extended beyond that in InSpec.
Platform definitions are done via:
Examples:
Some platforms might change families on certain conditions:
2.3 Platform detection
Platform detection may result in very complex tests for the OS layer. For this reason, most detection is handled in Train's OS layer. API's may go beyond Train's detection and provide detection mechanisms during the defintion layer.
Detection is handled via:
This leaves room to define more control elements (e.g.
before
,after
, and possiblypriority
in the future). An example for a custom API resource:If the platform is not detected, the
Train::Exceptions::PlatformDetectionFailed
will be raised.2.4 Operating systems
The list of platform families with platform names is:
Additionally the following platform families are larger groups:
All operating system platforms are part of the
os
platform family. More operating systems may be added. The underlying abstraction is handled by Train, specificallytrain-os
. It abstractsfile
,command
, and theos
resources.Note: A linux platform family does not contain another linux platform family, but rather the generic linux platform (if we detected Linux but don't know which one).
2.5 APIs
InSpec's API platforms are quickly evolving. To accommodate different platforms, profiles have the ability to define their platform support in terms of names and family.
The following is a list of initial platforms:
Specific product families:
3. Platform in profiles
Profiles can specify a list of supported platforms. This is done via the
supports
field and includes:os-name
: for OS-specific platform namesos-family
: for OS-specific platform familiesplatform
: to target platform families or namesplatform-name
: for specific platform namesplatform-family
: for general platform familiesrelease
: for the platform versionThe
support
entries are combined viaOR
and each entry is made up of fields combined viaAND
. Example:4. Platforms in resources
Resources can specify a list of supported platforms. This is done via the
supports
field. It behaves just likesupports
ininspec.yml
(section above).Due to the Ruby language, a few names needed adjustments:
os_name
,os_family
,platform
,platform_name
,platform_family
Full example:
4.1 Resources in profiles
Resources may be used in profiles that don't support them. For example: The Windows resource
registry_key
may be ineffective in a profile that only supportsredhat
.To detect this and help users,
inspec check
provides warnings about using resources in a profile whose platform definition does not support them. For example:If the profile does not have a list of supported systems defined,
inspec check
will provide a warning and recommendation for a list of supported systems:5. The
platform
resourceTo accommodate these platforms and provide information the new
platform
resource is introduced. It is governed by the Train library for both OSs and APIs.The
os
resource will remain active but will only function for platforms that are part of theos
platform family.Resource specification:
The
os
resource mimics theplatform
resource.6. Targeting platforms
InSpec profiles and interactive commands are targeted towards platforms, i.e. a profile is run with the purpose to test a platform. The mechanism for describing the target does not uniquely identify platform. It does provide some indication on the platform.
SSH example: Running InSpec on a remote host via SSH may see a target specified as
ssh://hostname
. This target may lead to multiple specific platforms that are tested, e.g. RedHat, Ubuntu, or even Solaris. Train helps to identify the platform that is described by the InSpec target. SSH will always describe an OS target. However, it also serves as a target for profiles testing the SSH platform, i.e. the application itself.HTTP example: InSpec may be provided a remote HTTP/HTTPS endpoint as a target, via
http://hostname:port
. A multitude of platforms may be identified by this endpoint. It is part of the detection mechanism in Train and beyond to choose which resources and profiles apply.6.1 Custom transports
Specific APIs may be defined by a custom transport target. These help in providing useful shorthands for shared functionality. For example, a cloud platform 'XYZ' (to stay vendor neutral) may define its target as
xyz://accesskey:secret@region
. These can be defined alongside platform defintions.Custom transport targets will be defined in a separate RFC. Until then, please use existing Train transports for operating systems and APIs.
6.2 Train-API
The Train-API subsystem supports non-OS platforms targets. It provides the
tcp
,udp
, andunix
transports for low-level socket access, as well ashttp
andhttps
for high-level transport implementations.These are defined via the URI schema:
Some of these fields may not apply to certain transports. There may be resources that are based on the
tcp
transport but don't process apath
orquery
parameter (e.g. for low-level interface testing).The
tcp
,udp
, andunix
transports will all provide a low-level socket object with a basic communication interface (using an abstraction on top of the underlying Socket object). It is exposed to all InSpec resources viainspec.backend
including all configuration options.The
http
andhttps
transports offer a simpler interface for all RESTful endpoints, exposed as theinspec.backend
object to InSpec resources. Apart from the simplerequest
it is also possible to use HTTP verbs (get
,post
,put
,options
,delete
,head
,trace
).7. InSpec platform utility
InSpec provides all platforms with grouping criteria via:
Please note that this is a hidden command, as it is only required for dev integrations.
The schema provides all information on currently supported platforms and may go beyond this document.
Example output:
8. Annex / Q&A
Q: I see a
redhat
platform and aredhat
platform family. Won't that lead to conflicts?A: See InSpec's naming conventions, section 2.1. Confusion may arise from grouping platforms, e.g. the
linux
family includesredhat
. The convention is to include platform families whenever available and platforms by name if not.Q: Will the
os
resource be removed?A: This RFC does not remove or deprecate any part of the current InSpec runtime. We may deprecate this resource in the future and appreciate more feedback to guide this decision.
Q: Will
os-family
,os-name
, andos
fields ininspec.yml
be removed?A: This RFC does not remove or deprecate any part of the current InSpec runtime. We may deprecate these fields in the future and appreciate more feedback to guide this decision.
Q: What happens if I use 2 conflicting resources in the same profile? For example: AWS and Azure?
A: This is supported both in a profile as well as through profile inheritance. InSpec will warn if the profile doesn't configure a list of supported platforms (see section 4.1). If a resource is used that only runs on a platform that is not in the list of supported platforms, users will receive a warning as well (section 4.1). This use-case is especially relevant if you consider e.g. scanning a Database, which is made up of on-system configuration as well as run-time tests and may (in the future) combine two targets.
The text was updated successfully, but these errors were encountered: