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
Filter active controls in profile by tags #5596
Conversation
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
✔️ Deploy Preview for chef-inspec canceled. 🔨 Explore the source changes: aeed833 🔍 Inspect the deploy log: https://app.netlify.com/sites/chef-inspec/deploys/60fe62f1e83d5000076fb902 |
Can tags be put in alphabetical order with the other items. |
docs-chef-io/content/inspec/cli.md
Outdated
@@ -272,6 +272,8 @@ This subcommand has additional options: | |||
Read configuration from JSON file (`-` reads from stdin). | |||
* ``--controls=one two three`` | |||
A list of control names to run, or a list of /regexes/ to match against control names. Ignore all other tests. | |||
* ``--tags=one two three`` | |||
A list of tags names that are part of controls to filter and run controls, or a list of /regexes/ to match against tags names of controls. Ignore all other tests. And when tag on the control is a hashmap, it only uses values of hashmap for filtering controls. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A list of tags names that are part of controls to filter and run controls, or a list of /regexes/ to match against tags names of controls. Ignore all other tests. And when tag on the control is a hashmap, it only uses values of hashmap for filtering controls. | |
A list of tags or a list of regular expressions that match tags. `exec` will run controls referenced by the listed or matching tags. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IanMadd I feel we should also include in doc that if tags are of type hash then it matches the value of an hash not a key to bring more clarity. I mentioned this sentence for that purpose "And when tag on the control is a hash map, it only uses values of hashmap for filtering controls." Can we put this in more clear way in doc ? What are your suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like this:
A list of tags, a list of regular expressions that match tags, or a hash map where each value is a tag.
exec
will run controls referenced by the listed or matching tags.
docs-chef-io/content/inspec/cli.md
Outdated
@@ -379,6 +381,8 @@ This subcommand has additional options: | |||
|
|||
* ``--controls=one two three`` | |||
A list of controls to include. Ignore all other tests. | |||
* ``--tags=one two three`` | |||
A list of tags to filter controls and include only those. Ignore all other tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A list of tags to filter controls and include only those. Ignore all other tests. | |
A list of tags that reference certain controls. Other controls are ignored. |
@IanMadd I am a little confused can you elaborate this? What do you mean by putting it in alphabetical order? |
On the cli page all the flags are in alphabetical order except the --tags that you're adding. |
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
SonarCloud Quality Gate failed. 0 Bugs No Coverage information |
Signed-off-by: Nikita Mathur nikita.mathur@chef.io
Filtering active controls in profile by tags.
Description
Similar to the feature of filtering controls using
--controls
, a new option--tags
was required which could be used for passing the tags names of controls and filtering them.Solution
--tags
option is introduced.--tags
to match with control tags using method tag_exist_in_control_tags?Needs Suggestion (Code Refactoring)
The method introduced to get controls tags is using block of control which is in string format. Tags are fetched from this string using regex and string manipulation.
Though it works successfully on all the cases of ways and formats a tag can be used, as used in this testing control. A better solution could be easier to understand.
Related Issue
Closes #5447
Types of changes
Checklist: