Skip to content

Conversation

@micahlee
Copy link
Contributor

Desired Outcome

Please describe the desired outcome for this PR. Said another way, what was
the original request that resulted in these code changes? Feel free to copy
this information from the connected issue.

Implemented Changes

Describe how the desired outcome above has been achieved with this PR. In
particular, consider:

  • 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

Resolves #[relevant GitHub issue(s), e.g. 76]

CyberArk internal issue ID: [insert issue ID]

Definition of Done

At least 1 todo must be completed in the sections below for the PR to be
merged.

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

@micahlee micahlee force-pushed the reset-password-rake-task branch from ea8ef3b to 040c878 Compare May 18, 2023 14:15
require 'io/console'

namespace :role do
desc "Retrieve the API key for the given role"
Copy link
Contributor

Choose a reason for hiding this comment

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

The description and the task name address two different points (retrieve an API key, reset password). What do you think about combining these two outcomes in the description and task name?

Copy link
Contributor Author

@micahlee micahlee May 18, 2023

Choose a reason for hiding this comment

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

Ah, that's actually a copy/paste error from https://github.com/cyberark/conjur/blob/master/lib/tasks/role.rake I overlooked .

I will update this to:

desc "Reset the password and API key for the given role"

WDYT?

desc "Retrieve the API key for the given role"
task :"reset-password", [:role_id] => [:environment] do |t, args|

role = Role.first(role_id: args[:role_id])
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of Role, do we want to limit this to `User? If we are keeping this generic, should we skip password setting for hosts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's a good call. I'll update this. Thanks!


namespace :role do
desc "Retrieve the API key for the given role"
task :"reset-password", [:role_id] => [:environment] do |t, args|

Choose a reason for hiding this comment

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

Complex method namespace(role)::task#reset-password (61.8)

namespace :role do
desc "Retrieve the API key for the given role"
task :"reset-password", [:role_id] => [:environment] do |t, args|

Choose a reason for hiding this comment

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

Extra empty line detected at block body beginning.


namespace :role do
desc "Retrieve the API key for the given role"
task :"reset-password", [:role_id] => [:environment] do |t, args|

Choose a reason for hiding this comment

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

Unused block argument - t. If it's necessary, use _ or _t as an argument name to indicate that it won't be used.

role.credentials.rotate_api_key
role.credentials.save
end
rescue => err

Choose a reason for hiding this comment

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

Use e instead of err.

exit(1)
end

password = IO::console.getpass("Enter new password: ")

Choose a reason for hiding this comment

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

Do not use :: for method calls.

@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit 040c878 and detected 6 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Style 5

The test coverage on the diff in this pull request is 14.2% (50% is the threshold).

This pull request will bring the total coverage in the repository to 89.8% (-1.6% change).

View more on Code Climate.

@micahlee micahlee force-pushed the reset-password-rake-task branch from 040c878 to 744af77 Compare May 18, 2023 18:51
@micahlee micahlee force-pushed the reset-password-rake-task branch from 744af77 to 8e38d61 Compare May 18, 2023 19:24
@szh
Copy link
Contributor

szh commented Feb 7, 2025

It seems like this could be really useful. Any reason it isn't merged?

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