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

Fix code scanning alert #78: Log Injection #53

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix code scanning alert #78: Log Injection
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Devasy23 and github-advanced-security[bot] authored Sep 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 004ca5d5cc7a2c35bdc63654095e3aad99892c84
3 changes: 2 additions & 1 deletion API/route.py
Original file line number Diff line number Diff line change
@@ -392,7 +392,8 @@

"""
logging.info('Deleting Employee')
logging.debug(f"Deleting for EmployeeCode: {EmployeeCode}")
sanitized_employee_code = re.sub(r'\D', '', str(EmployeeCode))
logging.debug(f"Deleting for EmployeeCode: {sanitized_employee_code}")
client2.find_one_and_delete(collection2, {'EmployeeCode': EmployeeCode})

return {'Message': 'Successfully Deleted'}

Choose a reason for hiding this comment

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

CODE REVIEW

Good job on sanitizing the EmployeeCode before logging! However, ensure that the original variable remains unchanged for further operations. Alternatively, consider logging the sanitized value conditionally based on the logging level to avoid unnecessary processing.

sanitized_employee_code = re.sub(r'\D', '', str(EmployeeCode))
if logging.getLogger().isEnabledFor(logging.DEBUG):
    logging.debug(f"Deleting for EmployeeCode: {sanitized_employee_code}")