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 no. 175: Log Injection #347

Merged
merged 7 commits into from
Sep 30, 2024

Conversation

yacosta738
Copy link
Collaborator

Fixes https://github.com/dallay/lyra/security/code-scanning/175

To fix the log injection issue, we need to sanitize the user input before logging it. Specifically, we should remove or replace any characters that could be used to manipulate log entries, such as newline characters. This can be achieved by using the replace method to remove or replace such characters.

  1. Identify the lines where user input is logged: lines 33, 53, 65, and 77 in KeycloakRepository.kt.
  2. Sanitize the user input by replacing newline characters with an empty string or a safe character.
  3. Ensure that the sanitization is applied consistently across all logging statements that involve user input.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Yuniel Acosta Pérez <[email protected]>
Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.

Project coverage is 91.52%. Comparing base (0dfb2a9) to head (b751030).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...ructure/persistence/keycloak/KeycloakRepository.kt 55.55% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #347      +/-   ##
==========================================
- Coverage   91.58%   91.52%   -0.07%     
==========================================
  Files         360      360              
  Lines        4339     4342       +3     
  Branches      374      374              
==========================================
  Hits         3974     3974              
- Misses        234      237       +3     
  Partials      131      131              

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

@yacosta738 yacosta738 changed the title Fix code scanning alert no. 175: Log Injection fix: code scanning alert no. 175: Log Injection Sep 30, 2024
@yacosta738 yacosta738 marked this pull request as ready for review September 30, 2024 17:25
@yacosta738 yacosta738 merged commit 05a2c01 into main Sep 30, 2024
12 of 14 checks passed
@yacosta738 yacosta738 deleted the autofix/alert-175-b4a9a5a7ba branch September 30, 2024 17:26
yacosta738 pushed a commit that referenced this pull request Sep 30, 2024
## [1.14.1](v1.14.0...v1.14.1) (2024-09-30)

### Bug Fixes

* code scanning alert no. 173: Log Injection [#351](#351) ([f527add](f527add))
* code scanning alert no. 174: Log Injection [#352](#352) ([b4a1013](b4a1013))
* code scanning alert no. 175: Log Injection ([#347](#347)) ([05a2c01](05a2c01))
* code scanning alert no. 317: Log Injection ([4537476](4537476))
yacosta738 pushed a commit that referenced this pull request Sep 30, 2024
## [1.14.1](v1.14.0...v1.14.1) (2024-09-30)

### Bug Fixes

* code scanning alert no. 173: Log Injection [#351](#351) ([f527add](f527add))
* code scanning alert no. 174: Log Injection [#352](#352) ([b4a1013](b4a1013))
* code scanning alert no. 175: Log Injection ([#347](#347)) ([05a2c01](05a2c01))
* code scanning alert no. 317: Log Injection ([4537476](4537476))
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.

1 participant