Skip to content

TRUNK-6550: Logging should not be vulnerable to injection attacks#6128

Open
jwnasambu wants to merge 3 commits into
openmrs:masterfrom
jwnasambu:TRUNK-6549
Open

TRUNK-6550: Logging should not be vulnerable to injection attacks#6128
jwnasambu wants to merge 3 commits into
openmrs:masterfrom
jwnasambu:TRUNK-6549

Conversation

@jwnasambu

@jwnasambu jwnasambu commented May 26, 2026

Copy link
Copy Markdown
Contributor

Description of what I changed

I updated logging statements to prevent log injection vulnerabilities by sanitizing untrusted input before writing it to logs. Specifically, carriage return (\r) and newline (\n) characters are replaced to prevent attackers from forging or manipulating log entries. This ensures log integrity and aligns with secure logging practices recommended by SonarQube and OWASP.

Issue I worked on

https://openmrs.atlassian.net/browse/TRUNK-6550

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

@jwnasambu jwnasambu marked this pull request as draft May 26, 2026 12:34
@codecov-commenter

codecov-commenter commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.63158% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.40%. Comparing base (a711ef6) to head (41f1729).

Files with missing lines Patch % Lines
...g/openmrs/logging/OpenmrsConfigurationFactory.java 40.00% 3 Missing ⚠️
api/src/main/java/org/openmrs/PersonAttribute.java 33.33% 2 Missing ⚠️
...rg/openmrs/api/impl/AdministrationServiceImpl.java 0.00% 2 Missing ⚠️
...n/java/org/openmrs/logging/OpenmrsLoggingUtil.java 66.66% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6128      +/-   ##
============================================
+ Coverage     59.38%   59.40%   +0.01%     
- Complexity     9337     9339       +2     
============================================
  Files           695      695              
  Lines         37448    37459      +11     
  Branches       5515     5515              
============================================
+ Hits          22238    22251      +13     
  Misses        13204    13204              
+ Partials       2006     2004       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jwnasambu jwnasambu force-pushed the TRUNK-6549 branch 2 times, most recently from c1b5d35 to 8b02b2b Compare May 27, 2026 11:20
@jwnasambu jwnasambu marked this pull request as ready for review May 27, 2026 11:46
@jwnasambu

jwnasambu commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

@dkayiwa, @chibongho kindly feel free to review my PR at your convenient time please!

@jwnasambu jwnasambu force-pushed the TRUNK-6549 branch 2 times, most recently from ad2501e to 0d70de4 Compare June 3, 2026 14:06
@jwnasambu

jwnasambu commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

@wikumChamith, @ibacher, @dkayiwa Kindly feel free to review my PR at your convenient time please!

@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2026

Copy link
Copy Markdown

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