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

Added isSecure field in the winrm settings. When isSecure is true, we allow HTTPs connection to end point powershell. If isSecure is false, we allow HTTP connection to end point powershell. #5

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

aspiremore
Copy link

No description provided.

Copy link

@rabadin rabadin left a comment

Choose a reason for hiding this comment

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

I see there isn't a ton of tests in this repo... but how about adding one for your change?

winrm.go Outdated
@@ -27,6 +27,7 @@ const (
NTLM
Kerberos
)
const WINRM_HTTP_PORT = 5985
Copy link

Choose a reason for hiding this comment

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

It's a detail but this is unused... so I'm wondering why you're adding it.

Copy link
Author

Choose a reason for hiding this comment

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

addressed

winrm.go Outdated
@@ -55,6 +56,8 @@ type winrmSettings struct {
operationTimeout string
// Timeout of each HTTP call made
timeout int
//Whether the call is http or https
Copy link

Choose a reason for hiding this comment

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

Nits:

  • Missing space before "Whether"
  • http -> HTTP / https -> HTTPS

Copy link
Author

Choose a reason for hiding this comment

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

addressed

@@ -185,7 +196,11 @@ func NewWinRMClient(details getEndpointDetails, options ...winrmSettingsOption)
for _, o := range options {
client.winrmSettings = o(client.winrmSettings)
}
client.url = fmt.Sprintf("https://%s:%d/wsman", client.ipAddress, client.port)
if client.isSecure {
Copy link

Choose a reason for hiding this comment

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

It's a detail but to avoid repeating the whole Sprintf line, how about:

if client.isSecure {
    protocol = "https"
} else {
    protocol = "http"
}

then use protocol

Copy link
Author

Choose a reason for hiding this comment

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

addressed

@@ -27,6 +27,10 @@ const (
NTLM
Kerberos
)
const (
HTTP_PROTOCOL = "http"
Copy link

@rabadin rabadin Jan 4, 2023

Choose a reason for hiding this comment

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

This is a detail but http/https is usually referred as the "scheme".

@@ -65,3 +65,21 @@ func TestCaptureAttribute(t *testing.T) {
t.Error("invalid attribute")
}
}

func BenchmarkHTTPRequest(b *testing.B) {
Copy link

Choose a reason for hiding this comment

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

Not sure how this is relevant...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants