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

Write log on Conjur config permission issues #2715

Merged
merged 3 commits into from
Feb 9, 2023

Conversation

micahlee
Copy link
Contributor

@micahlee micahlee commented Feb 7, 2023

Desired Outcome

The desired outcome of this PR is make it visible to the end user when the Conjur configuration file (conjur.yml) cannot be loaded due to permission on either the file itself or its containing directory.

Implemented Changes

The primary change in this PR is to write log messages for the known failure modes with the config file permissions:

  • When the directory doesn't exist
  • When the directory permissions are incorrect (need search/execute permissions for the Conjur server user)
  • When the file doesn't exist
  • When the file permissions are incorrect (need read permissions for the Conjur server user)

Given that the config file is optional, we only log the directory/file missing message at the DEBUG level. That way these are visible when troubleshooting Conjur, but are not otherwise logging noise.

When the file/directory exist but have incorrect permissions, we log these at the WARN level, given we expect the intention is to use the config file and it may not be obvious that it can't be read by Conjur.

This PR also includes a tooling commit to make it easier to identify the next Conjur standard log code, as well as a refactor commit to prepare for injecting the logger into the Conjur config loader.

Connected Issue/Story

CyberArk internal issue ID: CNJR-390

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: CNJR-365
  • 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 onyx-31936-config-directory-permission branch from a151d46 to b8617e3 Compare February 7, 2023 13:23
lib/conjur/conjur_config.rb Outdated Show resolved Hide resolved
lib/conjur/conjur_config.rb Outdated Show resolved Hide resolved
lib/conjur/conjur_config.rb Outdated Show resolved Hide resolved
lib/conjur/conjur_config.rb Outdated Show resolved Hide resolved
@micahlee micahlee force-pushed the onyx-31936-config-directory-permission branch 2 times, most recently from 78dd867 to 3b8a01d Compare February 7, 2023 15:15
@micahlee micahlee changed the title WIP: Write log on Conjur config permission issues Write log on Conjur config permission issues Feb 7, 2023
@micahlee micahlee force-pushed the onyx-31936-config-directory-permission branch 9 times, most recently from 503bae2 to 76ced6e Compare February 8, 2023 21:37
@micahlee micahlee changed the base branch from master to update-trivyignore February 8, 2023 21:39
lib/conjur/conjur_config.rb Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
Base automatically changed from update-trivyignore to master February 8, 2023 22:07
Previously, this only considered codes in the `errors.rb`
file. This means we do have duplicate numeric codes
between logs and errors in the existing definitions
that we'll also need to clean-up and de-dup.
@micahlee micahlee force-pushed the onyx-31936-config-directory-permission branch from 76ced6e to f6dc2a5 Compare February 8, 2023 22:08
@micahlee micahlee marked this pull request as ready for review February 8, 2023 22:10
@micahlee micahlee requested a review from a team as a code owner February 8, 2023 22:10
imheresamir
imheresamir previously approved these changes Feb 9, 2023
Copy link
Contributor

@imheresamir imheresamir left a comment

Choose a reason for hiding this comment

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

Reviewed by commit, LGTM

This is important to inject the Rails logger
into it as a dependency in the next commit.
@micahlee micahlee force-pushed the onyx-31936-config-directory-permission branch from f6dc2a5 to a1a41b4 Compare February 9, 2023 18:11
@codeclimate
Copy link

codeclimate bot commented Feb 9, 2023

Code Climate has analyzed commit a1a41b4 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Style 1

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

This pull request will bring the total coverage in the repository to 89.9%.

View more on Code Climate.

@micahlee micahlee merged commit 9663993 into master Feb 9, 2023
@micahlee micahlee deleted the onyx-31936-config-directory-permission branch February 9, 2023 19:01
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.

2 participants