Skip to content
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

wmi resource: properly escape quotes in WMI query #2342

Merged
merged 2 commits into from
Nov 29, 2017
Merged

wmi resource: properly escape quotes in WMI query #2342

merged 2 commits into from
Nov 29, 2017

Conversation

TheLonelyGhost
Copy link
Contributor

@TheLonelyGhost TheLonelyGhost commented Nov 27, 2017

Fixes #2260.

This modifies an existing test to include that scenario and fixes it as 2 separate commits.

@TheLonelyGhost TheLonelyGhost requested a review from a team as a code owner November 27, 2017 22:29
@TheLonelyGhost TheLonelyGhost changed the title [WIP] Escape quotes wmi Escape quotes in WMI query Nov 27, 2017
@adamleff adamleff changed the title Escape quotes in WMI query wmi resource: properly escape quotes in WMI query Nov 28, 2017
Copy link
Contributor

@adamleff adamleff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know more about Windows than I do, but this seems like a reasonable change. Thanks, @TheLonelyGhost!

@adamleff adamleff added the Type: Bug Feature not working as expected label Nov 28, 2017
@@ -14,7 +14,7 @@
# Use win32_service with filter, it returns a single service object
describe wmi({
class: 'win32_service',
filter: "name like '%winrm%'"
filter: 'name like "%winrm%"'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this breaking existing users that used the old syntax?

Copy link
Contributor Author

@TheLonelyGhost TheLonelyGhost Nov 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand what you mean. The original test checks if a nested string works with single-quotes (') whereas this test checks against nested double-quotes (").

This small change makes it so the same test covers 2 concepts instead of just one.

Since the wmi resource implementation executes powershell with nested "'s using a string composed with "'s, it makes sense to check that the string given here uses "'s and that it escapes them properly.

Additionally, this line of the test checks that the filter option actually works as expected.

What's the question here? What concern is there about a breaking change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it was late during my review. All good, thank you for catching this one!

Copy link
Contributor

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching this issue @TheLonelyGhost

@@ -14,7 +14,7 @@
# Use win32_service with filter, it returns a single service object
describe wmi({
class: 'win32_service',
filter: "name like '%winrm%'"
filter: 'name like "%winrm%"'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it was late during my review. All good, thank you for catching this one!

@chris-rock chris-rock merged commit beb326a into inspec:master Nov 29, 2017
@TheLonelyGhost TheLonelyGhost deleted the escape-quotes-wmi branch November 29, 2017 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WMI resource does not escape double-quotes
3 participants