Closed
Bug 1379244
Opened 7 years ago
Closed 7 years ago
don't allow arbitrary regex matching in channels
Categories
(Release Engineering Graveyard :: Applications: Balrog (backend), enhancement, P3)
Release Engineering Graveyard
Applications: Balrog (backend)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: bhearsum, Assigned: bhavishyagopesh, Mentored)
References
Details
(Whiteboard: [lang=python][ready][good first bug])
Today I realized that while it's not documented, we allow arbitrary regexes in the "channel" part of a Rule, see https://github.com/mozilla/balrog/blob/f8d9bd8c054ff26d70b76e633f53032c739ac789/auslib/db.py#L1503 and https://github.com/mozilla/balrog/blob/f8d9bd8c054ff26d70b76e633f53032c739ac789/auslib/db.py#L1486. This is way more power than is needed, and could lead to accidents (eg: if we set "*" as the channel, or r* or something silly like that).
I suspect this was a very quick and lazy way to allow for globbing. The only thing we truly want to support here is globbing at the end of the channel -- so we should rework this code to make that the only supported case.
Reporter | ||
Updated•7 years ago
|
Mentor: bhearsum
Assignee | ||
Comment 1•7 years ago
|
||
I'm looking into this, will update if there are any advances.
Assignee | ||
Comment 2•7 years ago
|
||
@bhearsum So do we just need to ensure that channel name contains more than a certain number of characters...I don't have much experience with balrog but may be something like this->
```
def _matchesRegex(self, foo, bar):
# Expand wildcards and use ^/$ to make sure we don't succeed on partial
# matches. Eg, 3.6* matches 3.6, 3.6.1, 3.6b3, etc.
if foo.endswith('*'):
#To stop small matches like 'r*'
if(re.match('^.{0,2}\*$', foo)):
return False
test = foo.replace('.', '\.').replace('*', '\*', foo.count('*')-1)
test = test[:-1]
test = test + '.*'
test = '^%s$' % test
if re.match(test, bar):
return True
return False
else:
test = foo.replace('.', '\.').replace('*', '\*')
test = '^%s$' % test
if re.match(test, bar):
return True
return False
```
Reporter | ||
Comment 3•7 years ago
|
||
(In reply to bhavishyagopesh from comment #2)
> @bhearsum So do we just need to ensure that channel name contains more than
> a certain number of characters...I don't have much experience with balrog
> but may be something like this->
>
> ```
>
> def _matchesRegex(self, foo, bar):
> # Expand wildcards and use ^/$ to make sure we don't succeed on
> partial
> # matches. Eg, 3.6* matches 3.6, 3.6.1, 3.6b3, etc.
> if foo.endswith('*'):
> #To stop small matches like 'r*'
> if(re.match('^.{0,2}\*$', foo)):
> return False
>
> test = foo.replace('.', '\.').replace('*', '\*',
> foo.count('*')-1)
> test = test[:-1]
> test = test + '.*'
> test = '^%s$' % test
> if re.match(test, bar):
> return True
> return False
> else:
> test = foo.replace('.', '\.').replace('*', '\*')
> test = '^%s$' % test
> if re.match(test, bar):
> return True
> return False
>
> ```
I think this is on the right track, I replied in detail in your pull request (https://github.com/mozilla/balrog/pull/367#pullrequestreview-55003575).
Comment 4•7 years ago
|
||
Commit pushed to master at https://github.com/mozilla/balrog
https://github.com/mozilla/balrog/commit/2bcdd4c115e89a61eb1d09b66aea3300ad803f30
bug 1379244: don't allow arbitrary regex matching in channels (#367). r=bhearsum
Reporter | ||
Comment 5•7 years ago
|
||
This is in production. Thank you for your contribution!
Assignee: nobody → bhavishyagopesh
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Updated•5 years ago
|
Product: Release Engineering → Release Engineering Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•