-
Notifications
You must be signed in to change notification settings - Fork 66
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
windows-011 array order failure #63
Comments
A quick workaround may be to just override the default ordering in the inspec.yml file
|
You could also just used to be_in matcher witch don’t care about element
order.
On Tue, Nov 15, 2022 at 15:09 Spencer ***@***.***> wrote:
A quick workaround may be to just override the default ordering in the
inspec.yml file
name: .
title: InSpec Profile
maintainer: The Authors
copyright: The Authors
copyright_email: ***@***.***
license: Apache-2.0
summary: An InSpec Compliance Profile
version: 0.1.0
supports:
platform-family: windows
depends:
- name: windows-baseline
git: https://github.com/dev-sec/windows-baseline
tag: 2.1.9
inputs:
- name: se_network_logon_right
value: ['S-1-5-32-544', 'S-1-5-9']
—
Reply to this email directly, view it on GitHub
<#63 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALK42CEOGHYDET7MZCZVITWIPUWXANCNFSM6AAAAAASBJ2GFE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
--------
Aaron Lippold
***@***.***
260-255-4779
twitter/aim/yahoo,etc.
'aaronlippold'
|
We don’t recommend modifying the inspec.yml file to override defaults. If
you want to update an inputs value, you should do it either via the command
line CLI flag or providing an input file.
On Thu, Nov 17, 2022 at 21:14 Aaron Lippold ***@***.***>
wrote:
You could also just used to be_in matcher witch don’t care about element
order.
On Tue, Nov 15, 2022 at 15:09 Spencer ***@***.***> wrote:
> A quick workaround may be to just override the default ordering in the
> inspec.yml file
>
> name: .
> title: InSpec Profile
> maintainer: The Authors
> copyright: The Authors
> copyright_email: ***@***.***
> license: Apache-2.0
> summary: An InSpec Compliance Profile
> version: 0.1.0
> supports:
> platform-family: windows
> depends:
> - name: windows-baseline
> git: https://github.com/dev-sec/windows-baseline
> tag: 2.1.9
> inputs:
> - name: se_network_logon_right
> value: ['S-1-5-32-544', 'S-1-5-9']
>
> —
> Reply to this email directly, view it on GitHub
> <
#63 (comment)
>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AALK42CEOGHYDET7MZCZVITWIPUWXANCNFSM6AAAAAASBJ2GFE
>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>
--
--------
Aaron Lippold
***@***.***
260-255-4779
twitter/aim/yahoo,etc.
'aaronlippold'
—
Reply to this email directly, view it on GitHub
<#63 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALK42HDSLRPHXFX7KLG7PTWI3RBTANCNFSM6AAAAAASBJ2GFE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
--------
Aaron Lippold
***@***.***
260-255-4779
twitter/aim/yahoo,etc.
'aaronlippold'
|
Thanks @aaronlippold Does Here is a POC leveraging
foo=['42','9000']
bar=['9000','42']
foo.each do |f|
describe f do
it {should be_in bar}
end
end
|
The being matcher will compare a list to an array and make sure it is a proper subset. So if I had an array, which was ABC, I would expect that a would be in ABC or that a C or CA would be in ABC. It doesn't care about order. I built this specifically to solve the list of Cyphers problem. |
So you don't really need to do a loop |
As I understand the This should do the trick: describe security_policy do
its('SeNetworkLogonRight.sort') { should eq input('se_network_logon_right') }
end |
I've tested .sort with no luck. I setup an additional test for the
bar=['9000','42']
describe ini('foo.ini') do
its('foo.sort') {should eq bar}
end Which returned error INI foo.ini
× foo.sort
undefined method `sort' for "['42','9000']":String Looking at the Rspec documentation, I'm not finding a However there are examples of the
https://docs.chef.io/inspec/resources/azurerm_virtual_machines/#os_disks Looking at the code for
But I'm not seeing a .sort method 🤔 |
This is very stranke. I also did some tests on a temporary system. My I'm using a default Windows 10 with the current version of cinc-auditor
The security policy is set and is an array
So I took the reported values and reversed them
So the basic idea seems to work. I have no clue, why it does not work for your environment. |
@schurzi Thank you for testing that. Your test looks very concise and logical. It appears that My tests were done through a layer of abstraction so I trust your results over mine. Changing the order should fix it for me, but there is a possibility it will break the benchmark for other users if they have different ordering. Would sorting both sides of the comparator be safer? e.g. describe security_policy do
its('SeNetworkLogonRight.sort') { should eq input('se_network_logon_right').sort }
end |
very good point. Are you up to generate a PR for this and do some testing in your environment? |
Description
Window-011 check is failing due to an array ordering problem
It is looking for
expected: ["S-1-5-9", "S-1-5-32-544"]
but is findinggot: ["S-1-5-32-544", "S-1-5-9"]
Reproduction steps
This is with a stock windows 2016 build, using the stock inspec defaults
https://github.com/dev-sec/windows-baseline/blob/master/inspec.yml#L34-L38
Current Behavior
Expected Behavior
The array order should not change.
If the array order does change, it should not be considered a failure as long as the contents are equivalent.
OS / Environment
windows 2016
Inspec Version
5.18.14
Baseline Version
Additional information
No response
The text was updated successfully, but these errors were encountered: