Skip to content

fix: reject target paths and section names with a trailing newline - #116

Merged
somethingwithproof merged 1 commit into
mainfrom
fix/target-path-trailing-newline
Nov 20, 2026
Merged

somethingwithproof merged 1 commit into
mainfrom
fix/target-path-trailing-newline

Conversation

@somethingwithproof

Copy link
Copy Markdown
Owner

Fixes #114

The only item in the checklist: the SEGMENT and LOCATION patterns in TargetPath, and the sections filter in smokeping_import.php, ended in $ without the D modifier, so a trailing newline passed. An imported path ending in a newline was stored as a target that can never match a SmokePing section.

Added the D modifier to all three patterns. Unit cases added for "gw1\n", "Europe/gw1\n", "Europe\n/gw1" and a location "sydney\n"; four of them fail without the change.

Verification (php:8.4-cli, locked Pest harness): pest --configuration=phpunit.xml, 554 passed, 1 skipped. php -l on PHP 8.0 for smokeping_import.php clean.

Risk: low; inputs that were wrongly accepted are now refused.

Without the D modifier, $ matches before a final newline, so TargetPath::fromString("Europe/gw1\n") succeeded and stored a target no SmokePing section can match.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e643cfba-6c0e-44c7-9dcf-344ea1cdcf78
Commits

Reviewing files that changed from the base of the PR and between f01d5e6 and 102e2bb.

Files selected for processing: 3

  • lib/TargetPath.php
  • smokeping_import.php
  • tests/Unit/ValueObjectTest.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@gitar-bot

gitar-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@sonarqubecloud

Copy link
Copy Markdown

@somethingwithproof
somethingwithproof merged commit 3a860a8 into main Nov 20, 2026
43 checks passed
@somethingwithproof
somethingwithproof deleted the fix/target-path-trailing-newline branch November 20, 2026 06:27
somethingwithproof added a commit that referenced this pull request Nov 20, 2026
)

Follow-up to #116

Intent: #116 added the `D` modifier to three patterns;
`SummaryScript::parse` and other whole-string checks still ended in `$`
and accepted a trailing newline (`12~berlin\n`).

Changed: `D` on the series argument, the CLI numeric options,
`ConfigSchema::coerce`, `LossColors` version parsing,
`SmokepingInventory::intOrNull`, the YAML hex escape and
`YamlScalar::classify`. `Row`'s numeric check is untouched: it trims
whitespace by design.

Tests: unit cases with a trailing newline for the series, versions, int
coercion and YAML classification; six fail without the change.

Verification: Pest (locked harness, php:8.4-cli) 584 passed, 1 skipped.

Risk: low; only inputs ending in a newline change, and they are now
refused.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved validation of numeric values, versions, YAML escapes, and
summary inputs. Trailing newlines or extra characters are no longer
accepted as valid matches, and affected values are handled as strings or
rejected as appropriate.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
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.

Minor review findings

1 participant