Skip to content

fix(package): reject trailing reference segments - #1792

Open
unbridled-41 wants to merge 1 commit into
OpenAtom-Linyaps:masterfrom
unbridled-41:fix/reference-parse-boundary
Open

fix(package): reject trailing reference segments#1792
unbridled-41 wants to merge 1 commit into
OpenAtom-Linyaps:masterfrom
unbridled-41:fix/reference-parse-boundary

Conversation

@unbridled-41

Copy link
Copy Markdown

Summary

Reject complete package reference strings that contain unexpected trailing path segments.

Previously, Reference::parse() accepted a valid reference prefix even when additional segments remained in the input. The extra input was silently discarded when the parsed reference was converted back to a string.

Root cause

The regular expression used by Reference::parse() was not anchored at the start and end of the input. As a result, QRegularExpression::match() could succeed without requiring the entire input to match the expected reference format.

For example:

main:com.example.App/1.0.0.0/x86_64/extra

was accepted as:

main:com.example.App/1.0.0.0/x86_64

Changes

  • Anchor the complete reference regular expression with ^ and $.
  • Add a regression test covering a valid reference followed by an unexpected path segment.

Reproduction

  1. Call Reference::parse() with main:com.example.App/1.0.0.0/x86_64/extra.
  2. Before this change, parsing succeeds and silently drops /extra.
  3. After this change, parsing returns an error.

Test plan

  • Run the focused reference test:

    /workspace/build-release/libs/linglong/tests/ll-tests/ll-tests --gtest_filter='Package.Reference'
  • Verify the regression input is rejected.

  • Verify existing valid reference inputs continue to pass.

  • Run git diff --check.

Compatibility

This only changes the handling of malformed complete references containing unexpected trailing input. Valid references are unaffected.

Require complete package references to match the entire input so extra path segments are not silently discarded. Add a regression case for a valid reference followed by an unexpected segment.

Signed-off-by: 做着百万梦的鱼 <yangzihao_41@outlook.com>
@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: unbridled-41

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Welcome @unbridled-41! It looks like this is your first PR to OpenAtom-Linyaps/linyaps 🎉

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Hi @unbridled-41. Thanks for your PR.

I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants