|
26 | 26 |
|
27 | 27 | import edu.umd.cs.findbugs.annotations.CheckForNull; |
28 | 28 | import edu.umd.cs.findbugs.annotations.NonNull; |
| 29 | +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
29 | 30 | import hudson.AbortException; |
30 | 31 | import hudson.Extension; |
31 | 32 | import hudson.ExtensionList; |
|
51 | 52 | import java.util.logging.Level; |
52 | 53 | import java.util.logging.Logger; |
53 | 54 | import jenkins.model.Jenkins; |
| 55 | +import jenkins.util.SystemProperties; |
54 | 56 | import org.apache.commons.discovery.ResourceClassIterator; |
55 | 57 | import org.apache.commons.discovery.ResourceNameIterator; |
56 | 58 | import org.apache.commons.discovery.resource.ClassLoaders; |
|
62 | 64 | import org.kohsuke.accmod.restrictions.NoExternalUse; |
63 | 65 | import org.kohsuke.args4j.CmdLineException; |
64 | 66 | import org.kohsuke.args4j.CmdLineParser; |
| 67 | +import org.kohsuke.args4j.ParserProperties; |
65 | 68 | import org.kohsuke.args4j.spi.OptionHandler; |
66 | 69 | import org.springframework.security.access.AccessDeniedException; |
67 | 70 | import org.springframework.security.authentication.BadCredentialsException; |
|
107 | 110 | */ |
108 | 111 | @LegacyInstancesAreScopedToHudson |
109 | 112 | public abstract class CLICommand implements ExtensionPoint, Cloneable { |
| 113 | + |
| 114 | + /** |
| 115 | + * Boolean values to either allow or disallow parsing of @-prefixes. |
| 116 | + * If a command line value starts with @, it is interpreted as being a file, loaded, |
| 117 | + * and interpreted as if the file content would have been passed to the command line |
| 118 | + */ |
| 119 | + @SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "Accessible via System Groovy Scripts") |
| 120 | + @Restricted(NoExternalUse.class) |
| 121 | + public static boolean ALLOW_AT_SYNTAX = SystemProperties.getBoolean(CLICommand.class.getName() + ".allowAtSyntax"); |
| 122 | + |
110 | 123 | /** |
111 | 124 | * Connected to stdout and stderr of the CLI agent that initiated the session. |
112 | 125 | * IOW, if you write to these streams, the person who launched the CLI command |
@@ -307,7 +320,8 @@ private void logAndPrintError(Throwable e, String errorMessage, String logMessag |
307 | 320 | * @since 1.538 |
308 | 321 | */ |
309 | 322 | protected CmdLineParser getCmdLineParser() { |
310 | | - return new CmdLineParser(this); |
| 323 | + ParserProperties properties = ParserProperties.defaults().withAtSyntax(ALLOW_AT_SYNTAX); |
| 324 | + return new CmdLineParser(this, properties); |
311 | 325 | } |
312 | 326 |
|
313 | 327 | /** |
|
0 commit comments