Skip to content

Conversation

@rebornplusplus
Copy link

Use strings.TrimPrefix() for relative paths instead of strings.TrimLeft(), since TrimLeft takes in a cutset instead of a prefix sub-string.

In this particular case, if the --root (output) directory is /tmp/foo and we are determining the relative path for /tmp/foo/tmp-foo, the relative path would result in /-foo since /tmp/foo/tmp would be matched by the /tmp/foo/ cutset.

This results in a flawed map of knownPaths inside slicer.go, which is only checked by the mutation script functions such as content.list().

This commit fixes said bug.

Use ``strings.TrimPrefix()`` for relative paths instead of
``strings.TrimLeft()``, since ``TrimLeft`` takes in a cutset instead of
a prefix sub-string.

In this particular case, if the ``--root`` (output) directory is
``/tmp/foo`` and we are determining the relative path for
``/tmp/foo/tmp-foo``, the relative path would result in ``/-foo`` since
``/tmp/foo/tmp`` would be matched by the ``/tmp/foo/`` cutset.

This results in a flawed map of ``knownPaths`` inside slicer.go, which
is only checked by the mutation script functions such as
``content.list()``.

This commit fixes said bug.
@rebornplusplus rebornplusplus added Simple Nice for a quick look on a minute or two Priority Look at me first labels Jul 3, 2024
@rebornplusplus rebornplusplus requested a review from letFunny July 3, 2024 08:55
Copy link
Collaborator

@letFunny letFunny left a comment

Choose a reason for hiding this comment

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

Thank you Rafid for doing your due diligence and for submitting the bugfix so quickly!

@rebornplusplus rebornplusplus requested a review from letFunny July 3, 2024 09:32
Copy link
Collaborator

@letFunny letFunny left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

Copy link
Collaborator

@cjdcordeiro cjdcordeiro left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @rebornplusplus .

@cjdcordeiro cjdcordeiro requested a review from niemeyer July 3, 2024 11:00
Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

Good catch, thanks Rafid.

@niemeyer niemeyer merged commit 504ad63 into canonical:main Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority Look at me first Simple Nice for a quick look on a minute or two

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants