Closed Bug 1326547 Opened 8 years ago Closed 8 years ago

Require that by-* regular expression matches match the whole string

Categories

(Firefox Build System :: Task Configuration, task)

task
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla53

People

(Reporter: dustin, Assigned: dustin)

Details

Attachments

(2 files)

This will avoid unintentionally allowing substring matches. For example, by-foo-platform: macosx64: ... should not match foo-platform `macosx64-and-stuff`, but by-foo-platform: macosx64.*: ... should.
Comment on attachment 8823460 [details] Bug 1326547: require that regexps in by-* match entire string; https://reviewboard.mozilla.org/r/101986/#review102358 ::: taskcluster/taskgraph/transforms/base.py:148 (Diff revision 1) > if key in alternatives: > container[subfield] = alternatives[key] > return item > > # regular expression match > - matches = [(k, v) for k, v in alternatives.iteritems() if re.match(k, key)] > + matches = [(k, v) for k, v in alternatives.iteritems() if re.match(k + '$', key)] you likely want "^{}$".format(k) because you could have "64.*" which ends up matching linux64 and macosx64
Comment on attachment 8823460 [details] Bug 1326547: require that regexps in by-* match entire string; https://reviewboard.mozilla.org/r/101986/#review102358 > you likely want "^{}$".format(k) because you could have "64.*" which ends up matching linux64 and macosx64 `re.match` anchors to the beginning of the string already. In fact, in py3.4 there's `re.matchfull` which anchors at both ends -- but until then appending $ is enough.
Comment on attachment 8823459 [details] Bug 1326547: replace get_keyed_by with resolve_keyed_by; https://reviewboard.mozilla.org/r/101984/#review103012 ::: taskcluster/taskgraph/transforms/base.py:100 (Diff revision 1) > > -def get_keyed_by(item, field, item_name, subfield=None): > +def resolve_keyed_by(item, field, item_name): > """ > + > For values which can either accept a literal value, or be keyed by some > - other attribute of the item, perform that lookup. For example, this supports > + other attribute of the item, perform that lookup and replacement in-place. and do the replacement in-place. Or some other way to emphasise the fact that this mutates the passed in value somehow would be great. ::: taskcluster/taskgraph/transforms/base.py:120 (Diff revision 1) > + job: > + chunks: 12 > + > The `item_name` parameter is used to generate useful error messages. > The `subfield` parameter, if specified, allows access to a second level > of the item dictionary: item[field][subfield]. For example, this supports subfield is now gone, this prose is dangling obsolete info.
Attachment #8823459 - Flags: review?(bugspam.Callek) → review+
Comment on attachment 8823460 [details] Bug 1326547: require that regexps in by-* match entire string; https://reviewboard.mozilla.org/r/101986/#review103016
Attachment #8823460 - Flags: review?(bugspam.Callek) → review+
Pushed by dmitchell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/34196ed0d140 replace get_keyed_by with resolve_keyed_by; r=Callek https://hg.mozilla.org/integration/autoland/rev/f43da8b320ae require that regexps in by-* match entire string; r=Callek
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Product: TaskCluster → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: