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

Filter failed "terraform init" output for sensitive information #156

Merged
merged 1 commit into from
Feb 7, 2023

Conversation

ulucinar
Copy link
Collaborator

@ulucinar ulucinar commented Feb 6, 2023

Description of your changes

Fixes #154

This PR proposes a change for redacting sensitive information in terraform init output when debug-level logging or when updating the status.conditions of an MR.

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Tested against crossplane-contrib/provider-upjet-github#6. Following status.condition is now reported with redacted sensitive information:

status:
  atProvider: {}
  conditions:
  - lastTransitionTime: "2023-02-06T21:30:40Z"
    message: "connect failed: cannot get a terraform workspace for resource: cannot
      init workspace: \e[31m\e[0mThere are some problems with the configuration, described
      below.\n\nThe Terraform configuration must be valid before initialization so
      that\nTerraform can determine which modules and providers need to be installed.\e[0m\e[0m\n\e[31m\e[31m╷\e[0m\e[0m\n\e[31m│\e[0m
      \e[0m\e[1m\e[31mError: \e[0m\e[0m\e[1mInvalid resource name\e[0m\n\e[31m│\e[0m
      \e[0m\n\e[31m│\e[0m \e[0m\e[0m  on main.tf.json line 1, in resource.github_repository_file:\n\e[31m│\e[0m
      \e[0m   1: {\"provider\":{\"github\":{\"base_url\":\"REDACTED\",\"owner\":\"REDACTED\",\"REDACTED\":\"REDACTED\"}},\"resource\":{\"github_repository_file\":{\e[4m\"sample-file.txt\"\e[0m:{\"content\":\"HO.\",\"file\":\"test-file\",\"lifecycle\":{\"prevent_destroy\":true},\"name\":\"sample-file.txt\"}}},\"terraform\":{\"required_providers\":{\"github\":{\"source\":\"integrations/github\",\"version\":\"5.15.0\"}}}}\e[0m\n\e[31m│\e[0m
      \e[0m\n\e[31m│\e[0m \e[0mA name must start with a letter or underscore and may
      contain only letters,\n\e[31m│\e[0m \e[0mdigits, underscores, and dashes.\n\e[31m╵\e[0m\e[0m\n\e[0m\e[0m\n:
      exit status 1"
    reason: ReconcileError
    status: "False"
    type: Synced

Copy link
Member

@sergenyalcin sergenyalcin left a comment

Choose a reason for hiding this comment

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

Thanks @ulucinar LGTM!

pkg/terraform/workspace.go Show resolved Hide resolved
pkg/terraform/workspace.go Show resolved Hide resolved
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
@ulucinar ulucinar merged commit b1ed924 into crossplane:main Feb 7, 2023
@ulucinar ulucinar deleted the fix-154 branch February 7, 2023 10:54
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.

Secrets leakage when describing failing resource
2 participants