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

Log the master IPS when there is a login in error #439

Merged
merged 1 commit into from
Jan 25, 2022
Merged

Conversation

mFelgate
Copy link
Contributor

@mFelgate mFelgate commented Jan 13, 2022

Desired Outcome

Log the requests IP address when there is a login error

Implemented Changes

Add a function to find and print he ip address taken from the host name.

  • What's changed? Why were these changes made?
  • How should the reviewer approach this PR, especially if manual tests are required?
  • Are there relevant screenshots you can add to the PR description?

Connected Issue/Story

CyberArk internal issue link: ONYX-14476

Definition of Done

Improved error message in authenticator client when request goes to an unhealthy master (502 error code doesn't reveal what IP address the name resolved to). Log the node's IP address when the connection fails.

Changelog

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a
    CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code
    changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR
  • A follow-up issue to update official docs has been filed here: insert issue ID
  • This PR does not require updating any documentation

Behavior

  • This PR changes product behavior and has been reviewed by a PO, or
  • These changes are part of a larger initiative that will be reviewed later, or
  • No behavior was changed with this PR

Security

  • Security architect has reviewed the changes in this PR,
  • These changes are part of a larger initiative with a separate security review, or
  • There are no security aspects to these changes

@mFelgate mFelgate requested review from a team as code owners January 13, 2022 21:00
ips, lookUpError := net.LookupIP(host)
if lookUpError != nil {
fmt.Fprintf(os.Stderr, "Could not get IPs: %v\n", lookUpError)
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Dont we want to return error if error happens and dont exit here like other places in this file?

fmt.Fprintf(os.Stderr, "Could not get IPs: %v\n", lookUpError)
os.Exit(1)
}
ipsList := " IP Addresses: "
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a join function of any other allegant string function that can do what you doing here

}
ipsList := " IP Addresses: "
for _, ip := range ips {
ipsList += ip.String()
Copy link
Contributor

Choose a reason for hiding this comment

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

If you remain in this way maybe this two lines can be combined to one with string formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i dont think there is a way since the ip address are []byte and have to be first converted to a readable string. i could drop the optional ipv6 and just only submit one ip address, this would get rid of the need of a for loop and also allow me to do a formatted string.

@mFelgate mFelgate force-pushed the Add-IPS-log branch 2 times, most recently from 56dd870 to 4cfb2bd Compare January 18, 2022 16:36
Copy link
Contributor

@diverdane diverdane left a comment

Choose a reason for hiding this comment

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

LGTM!!!

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

Successfully merging this pull request may close these issues.

3 participants