Open Bug 1402010 Opened 7 years ago Updated 2 years ago

Don't parse test manifests in files metadata reading mode

Categories

(Firefox Build System :: General, enhancement)

enhancement

Tracking

(firefox57 wontfix)

Tracking Status
firefox57 --- wontfix

People

(Reporter: gps, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(6 files, 8 obsolete files)

59 bytes, text/x-review-board-request
chmanchester
: review+
Details
59 bytes, text/x-review-board-request
chmanchester
: review+
Details
59 bytes, text/x-review-board-request
Details
59 bytes, text/x-review-board-request
chmanchester
: review+
Details
59 bytes, text/x-review-board-request
Details
59 bytes, text/x-review-board-request
ted
: review+
Details
We should not read test manifests in files metadata moz.build reading mode.
Comment on attachment 8910887 [details]
Bug 1402010 - Normalize paths according to finder's base;

https://reviewboard.mozilla.org/r/182362/#review187674

I don't have a ton of context on bug 1397406, but this looks ok.

::: python/mozbuild/mozbuild/frontend/mach_commands.py:173
(Diff revision 1)
>          for p in paths:
>              a = mozpath.abspath(p)
>              if not mozpath.basedir(a, [self.topsrcdir]):
>                  raise InvalidPathException('path is outside topsrcdir: %s' % p)
>  
> -            relpaths.append(mozpath.relpath(a, self.topsrcdir))
> +            query_paths.append(mozpath.relpath(a, reader.finder.base))

Should the `basedir` check above also refer to `reader.finder.base` instead of `self.topsrcdir` now?
Attachment #8910887 - Flags: review?(cmanchester) → review+
Comment on attachment 8910888 [details]
Bug 1402010 - Don't use mutable default argument value;

https://reviewboard.mozilla.org/r/182364/#review187676
Attachment #8910888 - Flags: review?(cmanchester) → review+
Comment on attachment 8910887 [details]
Bug 1402010 - Normalize paths according to finder's base;

https://reviewboard.mozilla.org/r/182362/#review187674

> Should the `basedir` check above also refer to `reader.finder.base` instead of `self.topsrcdir` now?

No. The paths being validated must reside under topsrcdir, so topsrcdir is correct.

It is only the paths that are fed into the reader/finder that need to be relative to the finder's base.
Comment on attachment 8910890 [details]
Bug 1402010 - Support not reading test manifests in moz.build files;

https://reviewboard.mozilla.org/r/182368/#review187684
Attachment #8910890 - Flags: review?(cmanchester) → review+
Comment on attachment 8910889 [details]
Bug 1402010 - Define evaluation flags on moz.build contexts;

https://reviewboard.mozilla.org/r/182366/#review187682

If we just set this as an attribute on the config (we could even clear out `ENABLE_TESTS` in the EmptyConfig we use for our files-info reader where applicable) I think we could avoid passing these flags around everywhere.

::: python/mozbuild/mozbuild/frontend/reader.py:1355
(Diff revision 1)
>          3. Iterate over Files sub-contexts.
>          4. If the file pattern matches the file we're seeking info on,
>             apply attribute updates.
>          5. Return the most recent value of attributes.
>          """
> -        paths, _ = self.read_relevant_mozbuilds(paths)
> +        eval_flags = {'files-info'}

I don't see this flag being read/checked here or elsewhere in the series.
Attachment #8910889 - Flags: review?(cmanchester)
Depends on: 1402142
Depends on: 1402233
Comment on attachment 8910890 [details]
Bug 1402010 - Support not reading test manifests in moz.build files;

https://reviewboard.mozilla.org/r/182368/#review215142

::: python/mozbuild/mozbuild/testing.py:531
(Diff revision 2)
>                                         rootdir=context.config.topsrcdir,
>                                         finder=context._finder,
>                                         handle_defaults=False)
>  
>  def read_reftest_manifest(context, manifest_path):
> -    import reftest
> +    if 'no-test-manifests' in context.eval_flags:

`s/po/no/`
Comment on attachment 8910890 [details]
Bug 1402010 - Support not reading test manifests in moz.build files;

https://reviewboard.mozilla.org/r/182368/#review215142

> `s/po/no/`

I'm going to blame dust on my screen.
Comment on attachment 8943880 [details]
Bug 1402010 - Only evaluate Files() context managers in files reading mode

This can't land yet. I'm just looking for your feedback on whether you like the approach.

Essentially, Files() metadata is nice. But it is incompatible with out-of-tree readers that need to securely extract file metadata from untrusted commits because it is impossible to keep the moz.build reading code up-to-date. We need to do *something* to support the moz.build web service (bug 1354791) and other consumers. This is the best strategy I can think of that doesn't involve "extract the metadata definition to something not moz.build."

The reason this came up today is because Connor is working on some things to define code commit policies in-repo. That can either piggyback on top of Files(), we can adapt Files() metadata so it can work more reliably, or we invent a one-off for Connor's use case. I was hoping to not create a one-off. So I think our choices are "make moz.build reader more robust" (this PoC) or "move files metadata out of moz.build."
Attachment #8943880 - Flags: review?(ted)
Connor: herein I attempt to make moz.build evaluation safe and less error prone. Read the patch if you want to see some face melting advanced Python :)
Attachment #8947269 - Attachment is obsolete: true
Attachment #8947270 - Attachment is obsolete: true
Attachment #8947271 - Attachment is obsolete: true
Attachment #8947274 - Attachment is obsolete: true
Attachment #8947277 - Attachment is obsolete: true
Attachment #8947280 - Attachment is obsolete: true
Attachment #8947284 - Attachment is obsolete: true
Comment on attachment 8943880 [details]
Bug 1402010 - Only evaluate Files() context managers in files reading mode

https://reviewboard.mozilla.org/r/214238/#review228692

I don't have any real concerns with this approach. We should probably think longer-term about whether keeping this data in moz.build files is the right thing to do.

::: commit-message-e4eb0:56
(Diff revision 1)
> +* `with Files(), Files()` may not work properly. It definitely needs
> +  tests.
> +* If a `with Files()` references a symbol defined outside the context
> +  manager, evaluation fails due to the symbol being stripped. We
> +  could use static analysis and avoid this pattern (at the cost of
> +  convenience in moz.build files).

I think at a bare minimum we ought to have some sort of lint or test for these few things you've called out before landing this. I don't think any of these are unreasonable--Files metadata shouldn't be incredibly complicated, and I'd be surprised if we actually had a good reason to violate any of these.

::: commit-message-e4eb0:70
(Diff revision 1)
> +in this approach. If not, then the only viable alternative I see
> +for the futures of Files() metadata if we want trusted execution
> +is to extract Files() to separate files that can be statically
> +evaluated without executing Python. This *is* probably the best
> +path forward. But it fragments data between moz.build and
> +*something else*.

Given the fact that this data is already in moz.build files I think these changes are useful.

However, given glob's moz.vendor proposal, I wonder if it wouldn't make sense longer-term to just move the Files metadata into that same format? (I certainly wish we had some half-measure available where we could have the nice Pythonic syntax of moz.build files but without Turing completeness!)
Attachment #8943880 - Flags: review?(ted) → review+
Product: Core → Firefox Build System
Attachment #8947287 - Attachment is obsolete: true

The bug assignee didn't login in Bugzilla in the last 7 months, so the assignee is being reset.

Assignee: gps → nobody
Status: ASSIGNED → NEW
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: