Skip to content

Conversation

@ishikaa-p
Copy link
Contributor

@ishikaa-p ishikaa-p commented Jul 3, 2025

Description

mask secrets

here, any leaked fact which might be a security concern is seen as a secret.
to find secrets which were leaked, went through all the logs manually with verbosity 4.

hiding all fields of a task for curl command as:
-> The uri module does not mark headers or Authorization as no_log fields internally.
-> Even if you mark your token secret as no_log: true in set_fact, it still leaks in -vvvv logs.
-> The VALUE_SPECIFIED_IN_NO_LOG_PARAMETER won’t be triggered unless the module itself marks that parameter as sensitive.

tomorrow if someone writes a new task, to ensure that we don't leak secrets, check below type of task:
-> if the task is a uri POST/PUT method
-> if the task is to set_fact, which sets any field which can be asecurity concern.

Fixes # (issue)

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

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Checklist:

  • Any variable/code changes have been validated to be backwards compatible (doesn't break upgrade)
  • I have added tests that prove my fix is effective or that my feature works
  • If required, I have ensured the changes can be discovered by cp-ansible discovery codebase
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@ishikaa-p ishikaa-p requested a review from a team as a code owner July 3, 2025 20:40
url_password: "{{kafka_broker_rest_health_check_password}}"
force_basic_auth: true
register: erp_result
no_log: "{{mask_secrets|bool}}"
Copy link
Member

Choose a reason for hiding this comment

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

probably not needed here and maybe needed in the above mds health check

}
]
status_code: 204
no_log: "{{mask_secrets|bool}}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This post request respond with mds toker, hence masking it.

Copy link
Member

Choose a reason for hiding this comment

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

lets also add it for all other occurances of register cluster

@rrbadiani
Copy link
Member

rrbadiani commented Jul 4, 2025

lets add ci checks for 3 things in all prs. We can check the git diff and do the following -

  • if we have uri module in diff with authorization header and no mask secrets - ci job should fail
  • if we have uri module in diff it should raise a warning.
  • if we have set fact in diff it should raise warning.

This will help us warn incase we might leak any secret accidentally. Although not full proof but it should cover us in significant percentage of cases.

@ishikaa-p
Copy link
Contributor Author

image

@ishikaa-p
Copy link
Contributor Author

image


if not all_files:
print("No YAML files found to check.")
return 0
Copy link
Member

Choose a reason for hiding this comment

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

we will always find yaml files. so if we dont then i think we should be returning error

# Parse YAML content
try:
parsed_content = yaml.safe_load(content)
except yaml.YAMLError:
Copy link
Member

Choose a reason for hiding this comment

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

should this give different output then the case where we have no errors ?

return False

# Check for direct authentication parameters
auth_params = ['Authorization']
Copy link
Member

Choose a reason for hiding this comment

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

i dont think uri module has any argument called authorization. so this will never return true

return False


def has_no_log_protection(task):
Copy link
Member

Choose a reason for hiding this comment

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

the name is a bit confusing. has_no_log_protection may mean it has no protection in logs or may mean it has no_log protecting logs 😅


def get_task_line_number(content, task_name, task_index):
"""Get approximate line number for a task in the file content."""
if not task_name:
Copy link
Member

Choose a reason for hiding this comment

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

i didnt understand the logic here

return task_index + 1

lines = content.split('\n')
for i, line in enumerate(lines):
Copy link
Member

Choose a reason for hiding this comment

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

this may fail in case we have 2 tasks of same name in same file. But shouldn't be a big deal. Name should be sufficient to find in such cases.

print(f"Comparing {current_branch} against base branch: {base_branch}")

# Build command list based on available base branch
if base_branch:
Copy link
Member

@rrbadiani rrbadiani Jul 11, 2025

Choose a reason for hiding this comment

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

what is the reason for doing this if base_branch and the list of commands in both if and else blocks ?

@ishikaa-p ishikaa-p changed the base branch from 7.2.x to 7.4.x October 30, 2025 05:49
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