From acf89e5193a13316c443e94fbc8f78e9f909cff8 Mon Sep 17 00:00:00 2001 From: mborne Date: Fri, 7 Apr 2023 17:25:18 +0200 Subject: [PATCH 1/2] add --unsafe-ssl option, keep it safe by default (refs #2) --- src/MBO/SatisGitlab/Command/GitlabToConfigCommand.php | 11 ++++++----- tests/Command/expected-with-filter.json | 9 +-------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/MBO/SatisGitlab/Command/GitlabToConfigCommand.php b/src/MBO/SatisGitlab/Command/GitlabToConfigCommand.php index 36dcbbe..4cd0914 100644 --- a/src/MBO/SatisGitlab/Command/GitlabToConfigCommand.php +++ b/src/MBO/SatisGitlab/Command/GitlabToConfigCommand.php @@ -55,6 +55,7 @@ protected function configure() { */ ->addArgument('gitlab-url', InputArgument::REQUIRED) ->addArgument('gitlab-token') + ->addOption('unsafe-ssl', null, InputOption::VALUE_NONE, 'allows to ignore SSL problems') /* * Project listing options (hosted git api level) @@ -102,11 +103,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $clientOptions = new ClientOptions(); $clientOptions->setUrl($input->getArgument('gitlab-url')); $clientOptions->setToken($input->getArgument('gitlab-token')); - /* - * TODO add option - * see https://github.com/mborne/satis-gitlab/issues/2 - */ - $clientOptions->setUnsafeSsl(true); + + if ( $input->getOption('unsafe-ssl') ){ + $clientOptions->setUnsafeSsl(true); + } + $client = ClientFactory::createClient( $clientOptions, $logger diff --git a/tests/Command/expected-with-filter.json b/tests/Command/expected-with-filter.json index 797c36a..88878d6 100644 --- a/tests/Command/expected-with-filter.json +++ b/tests/Command/expected-with-filter.json @@ -8,14 +8,7 @@ }, { "type": "vcs", - "url": "https:\/\/gitlab.com\/mborne\/sample-composer.git", - "options": { - "ssl": { - "verify_peer": false, - "verify_peer_name": false, - "allow_self_signed": true - } - } + "url": "https:\/\/gitlab.com\/mborne\/sample-composer.git" } ], "require": { From a81aa511a4b97f7d90f7b5a35507ebfa08b11265 Mon Sep 17 00:00:00 2001 From: mborne Date: Fri, 7 Apr 2023 17:26:00 +0200 Subject: [PATCH 2/2] add a note about unsafe ssl option (refs #2) --- docs/options.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docs/options.md diff --git a/docs/options.md b/docs/options.md new file mode 100644 index 0000000..cee43cc --- /dev/null +++ b/docs/options.md @@ -0,0 +1,19 @@ +# Notes about some options + +## unsafe-ssl + +Using `--unsafe-ssl` produce the following output for repositories : + +```json +{ + "options": { + "ssl": { + "allow_self_signed": true, + "verify_peer": false, + "verify_peer_name": false + } + }, + "type": "vcs", + "url": "https://gitlab.com/mborne/sample-composer.git" +} +```