Skip to content

Conversation

@Debarshi11
Copy link
Contributor

@Debarshi11 Debarshi11 commented Nov 13, 2025

Description

Related issues

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I have created feat/bugfix branch out of develop branch
  • Code passes linting/formatting checks
  • Changes to resources have been tested in our dev environments
  • I have made corresponding changes to the documentation

Testing

Reviewer instructions

Summary by CodeRabbit

  • Chores
    • Updated user password values to be marked as sensitive in Terraform, preventing exposure in outputs and logs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

Both files have been updated to wrap the user_password local value with the sensitive() function, ensuring passwords are treated as sensitive data by Terraform. The underlying lookup logic and default behavior remain unchanged.

Changes

Cohort / File(s) Change Summary
Password Sensitivity Wrapping
modules/mongo_user/default/0.2/locals.tf, modules/mongo_user/default/0.3/locals.tf
user_password local value now wrapped with sensitive() function to treat password as sensitive data in Terraform outputs and logs, without altering lookup logic or default behavior

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is essentially empty template boilerplate with no actual content filled in—all sections lack concrete details about changes, motivation, testing, or related issues. Fill in the description template with actual details: summarize the changes, specify the related issue/task, indicate the change type, document testing performed, and provide any reviewer guidance.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'made the user_password section sensitive' accurately describes the main change across both modified files, which wrap the user_password local value with sensitive() to treat passwords as sensitive data.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch password_sensitive

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e675a15 and 6334db6.

📒 Files selected for processing (2)
  • modules/mongo_user/default/0.2/locals.tf (1 hunks)
  • modules/mongo_user/default/0.3/locals.tf (1 hunks)
🔇 Additional comments (1)
modules/mongo_user/default/0.3/locals.tf (1)

11-11: Consistent security improvement across versions.

The sensitive() wrapper is applied consistently in version 0.3, mirroring the change in 0.2. This ensures uniform security handling of passwords across module versions.


user_name = lookup(local.user, "username", module.unique_name.name)
user_password = lookup(local.user, "password", module.user_password.result)
user_password = sensitive(lookup(local.user, "password", module.user_password.result))
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Security improvement: password is now marked as sensitive.

The sensitive() wrapper correctly prevents the password from appearing in Terraform logs and plan outputs, which is a security best practice.

Verify that downstream code (resources, outputs, or other modules referencing local.user_password) properly handles the sensitive value wrapper. Please confirm:

  • Are there any resources or outputs that use local.user_password that might break with the sensitive annotation?
  • Does the module that provides module.user_password.result also return a sensitive value?

🏁 Script executed:

#!/bin/bash
# Description: Verify downstream usage of user_password in the mongo_user module

# Search for references to user_password in the module directory
echo "=== Searching for user_password references ==="
rg -n "user_password" modules/mongo_user/default/0.2/ --type tf

echo ""
echo "=== Checking for outputs that might expose the sensitive value ==="
rg -n "output.*user_password\|user_password.*output" modules/mongo_user/default/0.2/ --type tf

Length of output: 557



---

🏁 Script executed:

```shell
#!/bin/bash
# Display full context of outputs.tf to understand output structure

echo "=== Full outputs.tf file ==="
cat modules/mongo_user/default/0.2/outputs.tf

echo ""
echo "=== Context around line 22 in main.tf ==="
sed -n '15,30p' modules/mongo_user/default/0.2/main.tf

Length of output: 699


Critical security issue: output "password" exposes the sensitive value.

The sensitive() wrapper on local.user_password does not propagate to outputs in Terraform. The output block at line 15 of outputs.tf must explicitly mark the password output as sensitive:

output "password" {
  value = local.user_password
  sensitive = true
}

Without this, the password will be exposed in terraform output commands and stored unmasked in state. The sensitive() wrapper on the local variable alone is insufficient for protecting output values.

The kubernetes_secret resource usage (main.tf line 22) is safe and properly stores the password as sensitive data.

🤖 Prompt for AI Agents
In modules/mongo_user/default/0.2/locals.tf around line 14 and outputs.tf at
line 15, the local.user_password is wrapped with sensitive() but the outputs.tf
password output is not marked sensitive; update the outputs.tf password output
block to set sensitive = true so Terraform will mask the value in outputs and
state views, i.e., explicitly add the sensitive = true attribute to the password
output and keep the current value reference to local.user_password.

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.

2 participants