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

[ws-daemon] Fix quota size regex's false positives #10744

Merged
merged 1 commit into from
Jun 19, 2022
Merged

[ws-daemon] Fix quota size regex's false positives #10744

merged 1 commit into from
Jun 19, 2022

Conversation

CuriousCorrelation
Copy link
Contributor

Description

I found this while browsing the repo

// This test should fail but doesn't because match somehow matches the regexp
// {"-42m", 0, quota.ErrInvalidSize},

-42m works because the regex correctly matched on the 42m part, see https://regexr.com/6o0va

so does this

{"-42m", 42 * quota.Megabyte, nil},
{"ab-42mcd", 42 * quota.Megabyte, nil},

Quick fix is to constrain starting and ending characters, i.e.

^(\d+)(k|m|g|t)?$

How to test

This test now succeeds

func TestParseSize(t *testing.T) {

Release Notes

Fixed quota size regex allowing false positives

@Furisto
Copy link
Member

Furisto commented Jun 19, 2022

/werft run

👍 started the job as gitpod-build-fix-quota-regex-fork.0
(with .werft/ from main)

@roboquat roboquat merged commit ba74f4d into gitpod-io:main Jun 19, 2022
@Furisto
Copy link
Member

Furisto commented Jun 19, 2022

Thank you @CuriousCorrelation

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.

None yet

3 participants