Skip to content

Conversation

@GingerGraham
Copy link
Owner

Copilot AI review requested due to automatic review settings February 6, 2026 13:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses issue #52 by tightening log-message sanitization so newline handling and ANSI escape stripping are controlled independently, and by refining the fallback ANSI escape stripping pattern.

Changes:

  • Update _sanitize_log_message so enabling LOG_UNSAFE_ALLOW_NEWLINES no longer short-circuits other sanitization steps.
  • Adjust _strip_ansi_codes fallback stripping regex and add explanatory comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>
@GingerGraham
Copy link
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 6, 2026

@GingerGraham I've opened a new pull request, #55, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 5 commits February 6, 2026 14:27
…SI regex

Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>
…omment

Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>
Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>
Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>
fix(sanitization): close security gaps in ANSI escape sequence stripping
GingerGraham added a commit that referenced this pull request Feb 9, 2026
- addresses comments left on #54
- adds regression tests for ansi attack handling
- improves ansi sanitisation logic
…d-fixes-02

Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>
@GingerGraham GingerGraham merged commit 38673cd into fix/bug-fixes-feb-2026-phase-01 Feb 9, 2026
2 checks passed
@GingerGraham GingerGraham deleted the bug/52-recommended-fixes-02 branch February 9, 2026 18:02
GingerGraham added a commit that referenced this pull request Feb 9, 2026
BREAKING CHANGE: changes behaviour for messages passed to the logger and so revving to v2.x

* feat: enhance logging sanitization

- Introduced a comprehensive security review document for the bash-logger library, detailing vulnerabilities and recommendations.
- Implemented input sanitization to prevent log injection via newline, carriage return, and tab characters.
- Added a configuration option to allow unsafe logging of newlines, with appropriate warnings and documentation.
- Enhanced tests to cover new functionality related to unsafe logging and input sanitization.
- Updated troubleshooting documentation to reflect changes in newline handling and logging behavior.
- Included security research findings from 2026-02-04 for evidence
- fixes #35

* feat: implement ANSI code injection protection and update documentation

- fixes #36

* feat: add TOCTOU race condition protection during log file creation and enhance related tests

* feat: add script name sanitization to prevent shell metacharacter injection

- fixes #39

* feat: add configurable log line length limits to prevent DoS attacks

- fixes #41

* Update logging.sh

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>

* fix(logging): improved TOCTOU risk mitigation and error messaging

- addresses suggestions from #49
- fixes part of #52
- also updated Makefile to provide for parallel processing of linting

* fix(log_sanitise): improved sanitization logic

- address #52

* Update logging.sh

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>

* Initial plan

* fix(sanitization): handle ST-terminated OSC, DEC modes, and improve CSI regex

Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>

* fix(sanitization): handle embedded escapes in OSC sequences and fix comment

Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>

* fix(sanitization): prevent greedy matching across multiple OSC sequences

Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>

* docs(sanitization): improve comment clarity for OSC pattern matching

Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>

* fix: addressing PR comments

- addresses comments left on #54
- adds regression tests for ansi attack handling
- improves ansi sanitisation logic

* Update docs/sensitive-data.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>

* Update demo-scripts/demo_unsafe_newlines.sh

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>

* Update demo-scripts/demo_ansi_protection.sh

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>

* Update logging.sh

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>

* Update tests/test_ansi_injection.sh

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>

* chore: refactor demo and test scripts for clarity and consistency

* Update docs/configuration.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>

* docs: adding unsafe_allow_ansi_codes

* docs: updating security policy supported versions

---------

Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
GingerGraham pushed a commit that referenced this pull request Feb 9, 2026
## [2.0.0](1.3.0...2.0.0) (2026-02-09)

### ⚠ BREAKING CHANGES

* changes behaviour for messages passed to the logger and so revving to v2.x

* feat: enhance logging sanitization

- Introduced a comprehensive security review document for the bash-logger library, detailing vulnerabilities and recommendations.
- Implemented input sanitization to prevent log injection via newline, carriage return, and tab characters.
- Added a configuration option to allow unsafe logging of newlines, with appropriate warnings and documentation.
- Enhanced tests to cover new functionality related to unsafe logging and input sanitization.
- Updated troubleshooting documentation to reflect changes in newline handling and logging behavior.
- Included security research findings from 2026-02-04 for evidence

### Features

* adding defensive programming and bug fixes ([#56](#56)) ([62b717a](62b717a)), closes [#35](#35) [#36](#36) [#39](#39) [#41](#41) [#49](#49) [#52](#52) [#52](#52) [#54](#54)
* **ref:** primary git message ([a0a7a09](a0a7a09))

### Documentation

* adding download tracking ([001f03b](001f03b))
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