1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli
John Howard 20833b06a0 Windows: (WCOW) Generate OCI spec that remote runtime can escape
Signed-off-by: John Howard <jhoward@microsoft.com>

Also fixes https://github.com/moby/moby/issues/22874

This commit is a pre-requisite to moving moby/moby on Windows to using
Containerd for its runtime.

The reason for this is that the interface between moby and containerd
for the runtime is an OCI spec which must be unambigious.

It is the responsibility of the runtime (runhcs in the case of
containerd on Windows) to ensure that arguments are escaped prior
to calling into HCS and onwards to the Win32 CreateProcess call.

Previously, the builder was always escaping arguments which has
led to several bugs in moby. Because the local runtime in
libcontainerd had context of whether or not arguments were escaped,
it was possible to hack around in daemon/oci_windows.go with
knowledge of the context of the call (from builder or not).

With a remote runtime, this is not possible as there's rightly
no context of the caller passed across in the OCI spec. Put another
way, as I put above, the OCI spec must be unambigious.

The other previous limitation (which leads to various subtle bugs)
is that moby is coded entirely from a Linux-centric point of view.

Unfortunately, Windows != Linux. Windows CreateProcess uses a
command line, not an array of arguments. And it has very specific
rules about how to escape a command line. Some interesting reading
links about this are:

https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
https://stackoverflow.com/questions/31838469/how-do-i-convert-argv-to-lpcommandline-parameter-of-createprocess
https://docs.microsoft.com/en-us/cpp/cpp/parsing-cpp-command-line-arguments?view=vs-2017

For this reason, the OCI spec has recently been updated to cater
for more natural syntax by including a CommandLine option in
Process.

What does this commit do?

Primary objective is to ensure that the built OCI spec is unambigious.

It changes the builder so that `ArgsEscaped` as commited in a
layer is only controlled by the use of CMD or ENTRYPOINT.

Subsequently, when calling in to create a container from the builder,
if follows a different path to both `docker run` and `docker create`
using the added `ContainerCreateIgnoreImagesArgsEscaped`. This allows
a RUN from the builder to control how to escape in the OCI spec.

It changes the builder so that when shell form is used for RUN,
CMD or ENTRYPOINT, it builds (for WCOW) a more natural command line
using the original as put by the user in the dockerfile, not
the parsed version as a set of args which loses fidelity.
This command line is put into args[0] and `ArgsEscaped` is set
to true for CMD or ENTRYPOINT. A RUN statement does not commit
`ArgsEscaped` to the commited layer regardless or whether shell
or exec form were used.
2019-03-12 18:41:55 -07:00
..
checker Add canonical import comment 2018-02-05 16:51:57 -05:00
cli Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
daemon Test: Replace NewClient() with NewClientT() 2018-12-22 15:53:02 +01:00
environment Various code-cleanup 2018-05-23 17:50:54 +02:00
fixtures Clean some integration-cli/fixtures package/files 2018-04-16 10:48:58 +02:00
requirement Add canonical import comment 2018-02-05 16:51:57 -05:00
testdata Clean some integration-cli/fixtures package/files 2018-04-16 10:48:58 +02:00
benchmark_test.go
check_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
daemon_swarm_hack_test.go Make internal/test/daemon.Daemon swarm aware 2018-04-11 12:10:17 +02:00
docker_api_attach_test.go integration-cli: remove deprecated daemonHost() utility 2019-01-21 12:07:36 +01:00
docker_api_build_test.go integration-cli/build: don't panic 2018-12-20 18:51:57 -08:00
docker_api_build_windows_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_api_containers_test.go Remove use of deprecated client.NewClient() 2019-01-28 17:08:54 +01:00
docker_api_containers_windows_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_api_exec_resize_test.go integration-cli: remove deprecated daemonHost() utility 2019-01-21 12:07:36 +01:00
docker_api_exec_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
docker_api_images_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
docker_api_inspect_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
docker_api_logs_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
docker_api_network_test.go migrate TestAPINetworkCreateDelete from integration-cli/ to integration/ 2018-06-15 16:06:45 -04:00
docker_api_stats_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
docker_api_swarm_node_test.go Slightly speed up TestAPISwarmNodeDrainPause 2019-01-13 21:08:20 +01:00
docker_api_swarm_service_test.go Merge pull request #38417 from thaJeztah/replace_newclient 2019-01-04 23:37:00 -08:00
docker_api_swarm_test.go Completely remove d.NewClient from testing tools 2019-02-07 16:07:02 -08:00
docker_api_test.go fix and skip some tests based on API version 2018-05-15 16:05:04 -07:00
docker_cli_attach_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_attach_unix_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_build_test.go Windows: (WCOW) Generate OCI spec that remote runtime can escape 2019-03-12 18:41:55 -07:00
docker_cli_build_unix_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_by_digest_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_commit_test.go Fix ineffassign linting 2018-07-11 22:18:45 +02:00
docker_cli_cp_from_container_test.go Migrate some copy tests to integration 2018-02-27 16:48:35 -05:00
docker_cli_cp_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_cp_to_container_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_cp_to_container_unix_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_cp_utils_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_create_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_daemon_plugins_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_daemon_test.go fix unless-stopped unexpected behavior 2019-02-01 15:03:17 -08:00
docker_cli_events_test.go Make TestEventsFilterLabels less flaky 2019-01-14 00:29:13 +01:00
docker_cli_events_unix_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_exec_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
docker_cli_exec_unix_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_external_volume_driver_unix_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_health_test.go Fix ineffassign linting 2018-07-11 22:18:45 +02:00
docker_cli_history_test.go
docker_cli_images_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_import_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_info_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_info_unix_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_inspect_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_links_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_login_test.go integration: use %s for check.Commentf() 2018-08-14 10:45:39 +03:00
docker_cli_logout_test.go integration: use %s for check.Commentf() 2018-08-14 10:45:39 +03:00
docker_cli_logs_bench_test.go
docker_cli_logs_test.go integration: use %s for check.Commentf() 2018-08-14 10:45:39 +03:00
docker_cli_netmode_test.go fix and skip some tests based on API version 2018-05-15 16:05:04 -07:00
docker_cli_network_unix_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_plugins_logdriver_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
docker_cli_plugins_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_port_test.go Fixes for dnephin review 2017-09-14 19:27:09 +02:00
docker_cli_proxy_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_prune_unix_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_ps_test.go Fix ineffassign linting 2018-07-11 22:18:45 +02:00
docker_cli_pull_local_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_pull_test.go Disallow using legacy (V1) registries 2017-12-09 02:24:43 -08:00
docker_cli_push_test.go integration: use %s for check.Commentf() 2018-08-14 10:45:39 +03:00
docker_cli_registry_user_agent_test.go Move and refactor integration-cli/registry to internal/test 2018-04-13 10:45:34 +02:00
docker_cli_restart_test.go Windows:Disable 2 restart test when Hyper-V 2019-02-22 11:15:51 -08:00
docker_cli_rmi_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_run_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
docker_cli_run_unix_test.go Merge pull request #38486 from thaJeztah/dont_use_deprecated_envclient 2019-01-05 11:23:19 +01:00
docker_cli_save_load_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_save_load_unix_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_search_test.go integration: use %s for check.Commentf() 2018-08-14 10:45:39 +03:00
docker_cli_service_create_test.go integration: use %s for check.Commentf() 2018-08-14 10:45:39 +03:00
docker_cli_service_health_test.go integration: use %s for check.Commentf() 2018-08-14 10:45:39 +03:00
docker_cli_service_logs_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_service_scale_test.go Fix ineffassign linting 2018-07-11 22:18:45 +02:00
docker_cli_sni_test.go Various code-cleanup 2018-05-23 17:50:54 +02:00
docker_cli_start_test.go TestStartReturnCorrectExitCode: show error 2018-09-11 12:43:30 -07:00
docker_cli_stats_test.go Fix tests creating zombie processes 2017-10-20 07:11:38 -07:00
docker_cli_swarm_test.go Completely remove d.NewClient from testing tools 2019-02-07 16:07:02 -08:00
docker_cli_swarm_unix_test.go integration: use %s for check.Commentf() 2018-08-14 10:45:39 +03:00
docker_cli_top_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00
docker_cli_update_unix_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
docker_cli_userns_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_cli_v2_only_test.go Move and refactor integration-cli/registry to internal/test 2018-04-13 10:45:34 +02:00
docker_cli_volume_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
docker_deprecated_api_v124_test.go fix and skip some tests based on API version 2018-05-15 16:05:04 -07:00
docker_deprecated_api_v124_unix_test.go Move integration-cli/request to internal/test/request… 2018-04-17 16:25:59 +02:00
docker_hub_pull_suite_test.go Remove SameHostDaemon, use testEnv.IsLocalDaemon instead 2018-12-24 13:25:53 +01:00
docker_utils_test.go integration-cli: remove deprecated daemonHost() utility 2019-01-21 12:07:36 +01:00
events_utils_test.go Update libcontainerd to use containerd 1.0 2017-10-20 07:11:37 -07:00
fixtures_linux_daemon_test.go Clean some integration-cli/fixtures package/files 2018-04-16 10:48:58 +02:00
requirements_test.go Remove use of deprecated client.NewEnvClient() 2019-01-03 22:49:00 +01:00
requirements_unix_test.go Skip kernel-memory tests on RHEL/CentOS daemons 2019-01-04 13:27:46 +01:00
test_vars_exec_test.go
test_vars_noexec_test.go
test_vars_noseccomp_test.go
test_vars_seccomp_test.go
test_vars_test.go Remove deprecated environment.DaemonPlatform() 2018-01-15 15:32:06 +01:00
test_vars_unix_test.go
test_vars_windows_test.go
utils_test.go Update tests to use gotest.tools 👼 2018-06-13 09:04:30 +02:00