From 1289b999e3a3b77e7e4cfbb3440777c4253ae231 Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Fri, 14 Aug 2020 14:37:44 -0300 Subject: [PATCH 01/13] [refactor] add const for windows os --- functional/runner.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/functional/runner.go b/functional/runner.go index b0c7bc47c..b1e777568 100644 --- a/functional/runner.go +++ b/functional/runner.go @@ -30,7 +30,8 @@ import ( ) const ( - rit = "rit" + rit = "rit" + windows = "windows" // initCmd = "init" ) @@ -50,7 +51,7 @@ func (scenario *Scenario) RunSteps() (string, error) { fmt.Println("Running: " + scenario.Entry) os := runtime.GOOS - if os == "windows" && len(scenario.Steps) >= 2 { + if os == windows && len(scenario.Steps) >= 2 { ginkgo.Skip("Scenarios with multi steps for windows doesnt work") return "", nil } else { @@ -62,7 +63,7 @@ func (scenario *Scenario) RunSteps() (string, error) { func (scenario *Scenario) RunStdin() (string, error) { fmt.Println("Running STDIN: " + scenario.Entry) os := runtime.GOOS - if os == "windows" { + if os == windows { b2, err := scenario.runStdinForWindows() return b2.String(), err } else { @@ -74,7 +75,7 @@ func (scenario *Scenario) RunStdin() (string, error) { func RitSingleInit() { os := runtime.GOOS - if os == "windows" { + if os == windows { setUpRitSingleWin() } else { setUpRitSingleUnix() @@ -84,7 +85,7 @@ func RitSingleInit() { func RitClearConfigs() { os := runtime.GOOS - if os == "windows" { + if os == windows { setUpClearSetupWindows() } else { setUpClearSetupUnix() From c446070a87a3c718f82e1850faaa2fe597419d78 Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Fri, 14 Aug 2020 15:13:00 -0300 Subject: [PATCH 02/13] [fix] change duplicate test --- functional/core/core_feature.json | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/functional/core/core_feature.json b/functional/core/core_feature.json index 9fa43152f..e81ce45a7 100644 --- a/functional/core/core_feature.json +++ b/functional/core/core_feature.json @@ -111,11 +111,11 @@ "steps":[ { "key":"", - "value":"list repo", + "value":"list", "action":"main" } ], - "result":"commons" + "result":"This command consists of multiple subcommands to interact with ritchie." }, { "entry":"List repo", @@ -128,6 +128,17 @@ ], "result":"commons" }, + { + "entry":"List credential", + "steps":[ + { + "key":"", + "value":"list credential", + "action":"main" + } + ], + "result":"opa" + }, { "entry":"Delete repo", "steps":[ From 5824eb5afdaaaaa44909740b51bc13c34e762970 Mon Sep 17 00:00:00 2001 From: Nathan Tavares Nascimento Date: Fri, 14 Aug 2020 15:00:42 -0300 Subject: [PATCH 03/13] updating horus job in circleci config Signed-off-by: Nathan Tavares Nascimento --- .circleci/config.yml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 44d1bde26..4b7d47bd7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,6 @@ references: python: &PYTHON_IMAGE circleci/python:2.7-stretch ruby: &RUBY_IMAGE cimg/ruby:2.6.5 ci_machine: &CI_MACHINE_IMAGE ubuntu-1604:202004-01 - horus: &HORUS_IMAGE library/docker:dind ubuntu: &UBUNTU_IMAGE cimg/base:2020.01 centos: &CENTOS_IMAGE viniciusramosdefaria/centos-circleci:7.0 windows: &WINDOWS_IMAGE windows-server-2019 @@ -57,9 +56,8 @@ executors: working_directory: /workspace horus-executor: - docker: - - image: *HORUS_IMAGE - user: root + machine: + image: ubuntu-1604:202004-01 delivery-executor: docker: @@ -108,20 +106,13 @@ jobs: /go/bin/golangci-lint run --no-config --issues-exit-code=1 --deadline=10m -v horus: executor: horus-executor - environment: - <<: *ENVIRONMENT steps: - - setup_remote_docker + - checkout - run: name: Horus Security Analysis command: | - echo "Starting scan Horus..." - docker run --rm -e HORUS_CLIENT_REPO_URL=$HORUS_CLIENT_REPO_URL \ - -e HORUS_CLIENT_REPO_BRANCH=$HORUS_CLIENT_REPO_BRANCH \ - -e HORUS_CLIENT_API_ADDR=$HORUS_CLIENT_API_ADDR \ - -e HORUS_CLIENT_TOKEN=$HORUS_CLIENT_TOKEN \ - -e HORUS_CLIENT_API_USE_HTTPS=$HORUS_CLIENT_API_USE_HTTPS \ - -e HORUS_VULNERABILITY_CHECK=$HORUS_VULNERABILITY_CHECK horuszup/horus-client:latest + curl -fsSL https://horus-assets.s3.amazonaws.com/install.sh | bash + horus start -p ./ -i testdata unit_test: executor: ritchie-tests-executor From 26fd41a1dc97e04caf5fa474dce4627cb85bcd1b Mon Sep 17 00:00:00 2001 From: Nathan Tavares Nascimento Date: Fri, 14 Aug 2020 15:07:29 -0300 Subject: [PATCH 04/13] ignoring vendor path in horus pipeline job Signed-off-by: Nathan Tavares Nascimento --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4b7d47bd7..84c6dcb3b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,7 +112,7 @@ jobs: name: Horus Security Analysis command: | curl -fsSL https://horus-assets.s3.amazonaws.com/install.sh | bash - horus start -p ./ -i testdata + horus start -p ./ -i testdata,vendor unit_test: executor: ritchie-tests-executor From b3ac608fe02aca701304b2d017a2d25f21cf9f55 Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Mon, 17 Aug 2020 09:24:14 -0300 Subject: [PATCH 05/13] [test] add functional test for core list credential command --- functional/core/core_feature.json | 2 +- functional/core/core_integration_test.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/functional/core/core_feature.json b/functional/core/core_feature.json index e81ce45a7..065b089f7 100644 --- a/functional/core/core_feature.json +++ b/functional/core/core_feature.json @@ -137,7 +137,7 @@ "action":"main" } ], - "result":"opa" + "result":"CONTEXT" }, { "entry":"Delete repo", diff --git a/functional/core/core_integration_test.go b/functional/core/core_integration_test.go index 0d2236745..0f8705196 100644 --- a/functional/core/core_integration_test.go +++ b/functional/core/core_integration_test.go @@ -53,20 +53,21 @@ var _ = Describe("RitCore", func() { // Entry(scenariosCore[4].Entry, scenariosCore[4]), Entry(scenariosCore[5].Entry, scenariosCore[5]), - Entry(scenariosCore[6].Entry, scenariosCore[6]), - // Entry(scenariosCore[7].Entry, scenariosCore[7]), - + // Entry(scenariosCore[6].Entry, scenariosCore[6]), + Entry(scenariosCore[7].Entry, scenariosCore[7]), // Entry(scenariosCore[8].Entry, scenariosCore[8]), - Entry(scenariosCore[9].Entry, scenariosCore[9]), - // Entry(scenariosCore[10].Entry, scenariosCore[10]), - Entry(scenariosCore[11].Entry, scenariosCore[11]), + // Entry(scenariosCore[9].Entry, scenariosCore[9]), + Entry(scenariosCore[10].Entry, scenariosCore[10]), + // Entry(scenariosCore[11].Entry, scenariosCore[11]), + Entry(scenariosCore[12].Entry, scenariosCore[12]), Entry(scenariosCore[13].Entry, scenariosCore[13]), - Entry(scenariosCore[14].Entry, scenariosCore[14]), + Entry(scenariosCore[15].Entry, scenariosCore[15]), Entry(scenariosCore[16].Entry, scenariosCore[16]), Entry(scenariosCore[17].Entry, scenariosCore[17]), + Entry(scenariosCore[18].Entry, scenariosCore[18]), ) }) From 8f787e018e2fffc494dc503754f7388ebd8a8cb6 Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Mon, 17 Aug 2020 09:46:35 -0300 Subject: [PATCH 06/13] [refactor] add const for windows os --- functional/runner.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/functional/runner.go b/functional/runner.go index b1e777568..6773fe00e 100644 --- a/functional/runner.go +++ b/functional/runner.go @@ -31,7 +31,7 @@ import ( const ( rit = "rit" - windows = "windows" + windows = runtime.GOOS == "windows" // initCmd = "init" ) @@ -50,8 +50,7 @@ type Scenario struct { func (scenario *Scenario) RunSteps() (string, error) { fmt.Println("Running: " + scenario.Entry) - os := runtime.GOOS - if os == windows && len(scenario.Steps) >= 2 { + if windows && len(scenario.Steps) >= 2 { ginkgo.Skip("Scenarios with multi steps for windows doesnt work") return "", nil } else { @@ -62,8 +61,7 @@ func (scenario *Scenario) RunSteps() (string, error) { func (scenario *Scenario) RunStdin() (string, error) { fmt.Println("Running STDIN: " + scenario.Entry) - os := runtime.GOOS - if os == windows { + if windows { b2, err := scenario.runStdinForWindows() return b2.String(), err } else { @@ -74,8 +72,7 @@ func (scenario *Scenario) RunStdin() (string, error) { } func RitSingleInit() { - os := runtime.GOOS - if os == windows { + if windows { setUpRitSingleWin() } else { setUpRitSingleUnix() @@ -84,8 +81,7 @@ func RitSingleInit() { } func RitClearConfigs() { - os := runtime.GOOS - if os == windows { + if windows { setUpClearSetupWindows() } else { setUpClearSetupUnix() From 2878a6759b2d83d6559bc32247e089a27306aedf Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Mon, 17 Aug 2020 16:07:52 -0300 Subject: [PATCH 07/13] [fix] fix test of 'list credential' command that failed in ci --- functional/core/core_feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functional/core/core_feature.json b/functional/core/core_feature.json index 065b089f7..13bb33139 100644 --- a/functional/core/core_feature.json +++ b/functional/core/core_feature.json @@ -137,7 +137,7 @@ "action":"main" } ], - "result":"CONTEXT" + "result":"You dont have any credential, use" }, { "entry":"Delete repo", From 729e257c7b3d19c185057b8ae075f0acec3334ef Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Fri, 14 Aug 2020 14:37:44 -0300 Subject: [PATCH 08/13] [refactor] add const for windows os --- functional/runner.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/functional/runner.go b/functional/runner.go index b0c7bc47c..b1e777568 100644 --- a/functional/runner.go +++ b/functional/runner.go @@ -30,7 +30,8 @@ import ( ) const ( - rit = "rit" + rit = "rit" + windows = "windows" // initCmd = "init" ) @@ -50,7 +51,7 @@ func (scenario *Scenario) RunSteps() (string, error) { fmt.Println("Running: " + scenario.Entry) os := runtime.GOOS - if os == "windows" && len(scenario.Steps) >= 2 { + if os == windows && len(scenario.Steps) >= 2 { ginkgo.Skip("Scenarios with multi steps for windows doesnt work") return "", nil } else { @@ -62,7 +63,7 @@ func (scenario *Scenario) RunSteps() (string, error) { func (scenario *Scenario) RunStdin() (string, error) { fmt.Println("Running STDIN: " + scenario.Entry) os := runtime.GOOS - if os == "windows" { + if os == windows { b2, err := scenario.runStdinForWindows() return b2.String(), err } else { @@ -74,7 +75,7 @@ func (scenario *Scenario) RunStdin() (string, error) { func RitSingleInit() { os := runtime.GOOS - if os == "windows" { + if os == windows { setUpRitSingleWin() } else { setUpRitSingleUnix() @@ -84,7 +85,7 @@ func RitSingleInit() { func RitClearConfigs() { os := runtime.GOOS - if os == "windows" { + if os == windows { setUpClearSetupWindows() } else { setUpClearSetupUnix() From 513912bb9b3c1322166700058fda885899093883 Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Fri, 14 Aug 2020 15:13:00 -0300 Subject: [PATCH 09/13] [fix] change duplicate test --- functional/core/core_feature.json | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/functional/core/core_feature.json b/functional/core/core_feature.json index 9fa43152f..e81ce45a7 100644 --- a/functional/core/core_feature.json +++ b/functional/core/core_feature.json @@ -111,11 +111,11 @@ "steps":[ { "key":"", - "value":"list repo", + "value":"list", "action":"main" } ], - "result":"commons" + "result":"This command consists of multiple subcommands to interact with ritchie." }, { "entry":"List repo", @@ -128,6 +128,17 @@ ], "result":"commons" }, + { + "entry":"List credential", + "steps":[ + { + "key":"", + "value":"list credential", + "action":"main" + } + ], + "result":"opa" + }, { "entry":"Delete repo", "steps":[ From 596209a864d79692780883ed577318bfc5a94af3 Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Mon, 17 Aug 2020 09:24:14 -0300 Subject: [PATCH 10/13] [test] add functional test for core list credential command --- functional/core/core_feature.json | 2 +- functional/core/core_integration_test.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/functional/core/core_feature.json b/functional/core/core_feature.json index e81ce45a7..065b089f7 100644 --- a/functional/core/core_feature.json +++ b/functional/core/core_feature.json @@ -137,7 +137,7 @@ "action":"main" } ], - "result":"opa" + "result":"CONTEXT" }, { "entry":"Delete repo", diff --git a/functional/core/core_integration_test.go b/functional/core/core_integration_test.go index 0d2236745..0f8705196 100644 --- a/functional/core/core_integration_test.go +++ b/functional/core/core_integration_test.go @@ -53,20 +53,21 @@ var _ = Describe("RitCore", func() { // Entry(scenariosCore[4].Entry, scenariosCore[4]), Entry(scenariosCore[5].Entry, scenariosCore[5]), - Entry(scenariosCore[6].Entry, scenariosCore[6]), - // Entry(scenariosCore[7].Entry, scenariosCore[7]), - + // Entry(scenariosCore[6].Entry, scenariosCore[6]), + Entry(scenariosCore[7].Entry, scenariosCore[7]), // Entry(scenariosCore[8].Entry, scenariosCore[8]), - Entry(scenariosCore[9].Entry, scenariosCore[9]), - // Entry(scenariosCore[10].Entry, scenariosCore[10]), - Entry(scenariosCore[11].Entry, scenariosCore[11]), + // Entry(scenariosCore[9].Entry, scenariosCore[9]), + Entry(scenariosCore[10].Entry, scenariosCore[10]), + // Entry(scenariosCore[11].Entry, scenariosCore[11]), + Entry(scenariosCore[12].Entry, scenariosCore[12]), Entry(scenariosCore[13].Entry, scenariosCore[13]), - Entry(scenariosCore[14].Entry, scenariosCore[14]), + Entry(scenariosCore[15].Entry, scenariosCore[15]), Entry(scenariosCore[16].Entry, scenariosCore[16]), Entry(scenariosCore[17].Entry, scenariosCore[17]), + Entry(scenariosCore[18].Entry, scenariosCore[18]), ) }) From 2bd4e350a3af03bdb9958319bec132b12ee1b60c Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Mon, 17 Aug 2020 09:46:35 -0300 Subject: [PATCH 11/13] [refactor] add const for windows os --- functional/runner.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/functional/runner.go b/functional/runner.go index b1e777568..6773fe00e 100644 --- a/functional/runner.go +++ b/functional/runner.go @@ -31,7 +31,7 @@ import ( const ( rit = "rit" - windows = "windows" + windows = runtime.GOOS == "windows" // initCmd = "init" ) @@ -50,8 +50,7 @@ type Scenario struct { func (scenario *Scenario) RunSteps() (string, error) { fmt.Println("Running: " + scenario.Entry) - os := runtime.GOOS - if os == windows && len(scenario.Steps) >= 2 { + if windows && len(scenario.Steps) >= 2 { ginkgo.Skip("Scenarios with multi steps for windows doesnt work") return "", nil } else { @@ -62,8 +61,7 @@ func (scenario *Scenario) RunSteps() (string, error) { func (scenario *Scenario) RunStdin() (string, error) { fmt.Println("Running STDIN: " + scenario.Entry) - os := runtime.GOOS - if os == windows { + if windows { b2, err := scenario.runStdinForWindows() return b2.String(), err } else { @@ -74,8 +72,7 @@ func (scenario *Scenario) RunStdin() (string, error) { } func RitSingleInit() { - os := runtime.GOOS - if os == windows { + if windows { setUpRitSingleWin() } else { setUpRitSingleUnix() @@ -84,8 +81,7 @@ func RitSingleInit() { } func RitClearConfigs() { - os := runtime.GOOS - if os == windows { + if windows { setUpClearSetupWindows() } else { setUpClearSetupUnix() From f28270851983cc4ed533bb304c36d1e507ca7a30 Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Mon, 17 Aug 2020 16:07:52 -0300 Subject: [PATCH 12/13] [fix] fix test of 'list credential' command that failed in ci --- functional/core/core_feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functional/core/core_feature.json b/functional/core/core_feature.json index 065b089f7..13bb33139 100644 --- a/functional/core/core_feature.json +++ b/functional/core/core_feature.json @@ -137,7 +137,7 @@ "action":"main" } ], - "result":"CONTEXT" + "result":"You dont have any credential, use" }, { "entry":"Delete repo", From 52c0c4bc136131af6b62aa77bf1ffc180069c2b2 Mon Sep 17 00:00:00 2001 From: Lucas Dittrich Date: Mon, 17 Aug 2020 16:37:55 -0300 Subject: [PATCH 13/13] [env] rerun ci --- functional/core/core_feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functional/core/core_feature.json b/functional/core/core_feature.json index 13bb33139..4acbfd9fa 100644 --- a/functional/core/core_feature.json +++ b/functional/core/core_feature.json @@ -137,7 +137,7 @@ "action":"main" } ], - "result":"You dont have any credential, use" + "result":"You dont have any credential" }, { "entry":"Delete repo",