HomePhabricator

Allow certain flags to be required to appear before non-flag arguments

Description

Allow certain flags to be required to appear before non-flag arguments

Summary:
Ref T13098. Historically, we've seen some issues (particularly with Mercurial) where naming a branch something like --execute-remote-website=evil.com would evaluate even with "--" in the argument list (see T13012).

We're broadly better about this, but still need to parse arguments in multiple phases, and callers/users aren't always careful about using -- to terminate argument lists.

To reduce the danger of flags like --config, --load-library, etc., allow argument parsing to require that they appear before workflow arguments, so arc --config xyz diff is valid, but arc diff --config xyz is not. This reduces the chance that some user script somewhere which does arc diff %s instead of arc diff -- %s will ever be able to do anything truly dangerous.

Test Plan: See upcoming changes to Arcanist. (This does nothing on its own.)

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13098

Differential Revision: https://secure.phabricator.com/D19675

Details

Provenance
epriestleyAuthored on Sep 14 2018, 6:20 PM
epriestleyPushed on Sep 15 2018, 3:00 PM
Reviewer
amckinley
Differential Revision
D19675: Allow certain flags to be required to appear before non-flag arguments
Parents
rPHUa28f6e5d64f3: Port the Java fragment lexer to PHP
Branches
Unknown
Tags
Unknown
Tasks
T13098: Plans: Arcanist toolsets and extensions
Build Status
Buildable 20838
Build 28343: Run Core Tests