From 37b626273fad2d6ce5c8c43f62d99eaebdd0f65d Mon Sep 17 00:00:00 2001 From: Wilian Gabriel <63816070+wiliansilvazup@users.noreply.github.com> Date: Tue, 1 Jun 2021 14:36:26 -0300 Subject: [PATCH 1/3] Horusec-Swift (#44) * Adding update analysis queue and exchange (#41) * Adding update analysis queue and exchange * Removing unnecessary typing form exchanges * Removing update exchange and queues * add language Swift (#43) Co-authored-by: nathanmartinszup <63246935+nathanmartinszup@users.noreply.github.com> Co-authored-by: matheusalcantarazup <84723211+matheusalcantarazup@users.noreply.github.com> --- pkg/enums/languages/language.go | 4 ++++ pkg/enums/languages/language_test.go | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/enums/languages/language.go b/pkg/enums/languages/language.go index bb7b692..96cbf97 100644 --- a/pkg/enums/languages/language.go +++ b/pkg/enums/languages/language.go @@ -38,6 +38,7 @@ const ( Elixir Language = "Elixir" Shell Language = "Shell" Nginx Language = "Nginx" + Swift Language = "Swift" Unknown Language = "Unknown" ) @@ -73,6 +74,7 @@ func Values() []Language { Elixir, Shell, Nginx, + Swift, Unknown, } } @@ -99,6 +101,7 @@ func mapEnableLanguages() map[string]Language { Elixir.ToString(): Elixir, Shell.ToString(): Shell, Nginx.ToString(): Nginx, + Swift.ToString(): Swift, Unknown.ToString(): Unknown, } } @@ -131,5 +134,6 @@ func (l Language) MapLanguagesEnableInCLI() map[Language]string { Yaml: "yaml", Dart: "dart", Nginx: "nginx", + Swift: "swift", } } diff --git a/pkg/enums/languages/language_test.go b/pkg/enums/languages/language_test.go index 8f3c49a..4cec8dc 100644 --- a/pkg/enums/languages/language_test.go +++ b/pkg/enums/languages/language_test.go @@ -41,13 +41,14 @@ func TestParseStringToLanguage(t *testing.T) { assert.Equal(t, Elixir, ParseStringToLanguage("Elixir")) assert.Equal(t, Shell, ParseStringToLanguage("Shell")) assert.Equal(t, Nginx, ParseStringToLanguage("Nginx")) + assert.Equal(t, Swift, ParseStringToLanguage("Swift")) assert.Equal(t, Unknown, ParseStringToLanguage("")) }) } func TestValues(t *testing.T) { - t.Run("should return 20 valid values", func(t *testing.T) { - assert.Len(t, Values(), 20) + t.Run("should return 21 valid values", func(t *testing.T) { + assert.Len(t, Values(), 21) }) } @@ -74,6 +75,7 @@ func TestMapEnableLanguages(t *testing.T) { assert.Equal(t, Elixir, mapLanguages["Elixir"]) assert.Equal(t, Shell, mapLanguages["Shell"]) assert.Equal(t, Nginx, mapLanguages["Nginx"]) + assert.Equal(t, Swift, mapLanguages["Swift"]) assert.Equal(t, Unknown, mapLanguages["Unknown"]) }) } @@ -99,6 +101,7 @@ func TestToString(t *testing.T) { assert.Equal(t, "Elixir", Elixir.ToString()) assert.Equal(t, "Shell", Shell.ToString()) assert.Equal(t, "Nginx", Nginx.ToString()) + assert.Equal(t, "Swift", Swift.ToString()) assert.Equal(t, "Unknown", Unknown.ToString()) }) } @@ -121,5 +124,6 @@ func TestGetCustomImagesKeyByLanguage(t *testing.T) { assert.Equal(t, "elixir", Elixir.GetCustomImagesKeyByLanguage()) assert.Equal(t, "shell", Shell.GetCustomImagesKeyByLanguage()) assert.Equal(t, "nginx", Nginx.GetCustomImagesKeyByLanguage()) + assert.Equal(t, "swift", Swift.GetCustomImagesKeyByLanguage()) }) } From 015583e15db07aac460d5cc451a5cb545110c4f5 Mon Sep 17 00:00:00 2001 From: nathanmartinszup <63246935+nathanmartinszup@users.noreply.github.com> Date: Mon, 14 Jun 2021 08:35:23 -0300 Subject: [PATCH 2/3] Develop (#47) * Adding update analysis queue and exchange (#41) * Adding update analysis queue and exchange * Removing unnecessary typing form exchanges * Removing update exchange and queues * add language Swift (#43) * Adding owasp dependency check tool (#46) Co-authored-by: matheusalcantarazup <84723211+matheusalcantarazup@users.noreply.github.com> Co-authored-by: wilian --- pkg/enums/tools/tools.go | 36 ++++++++++++++++++----------------- pkg/enums/tools/tools_test.go | 6 ++++-- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/pkg/enums/tools/tools.go b/pkg/enums/tools/tools.go index bb5a566..3ae7a4f 100644 --- a/pkg/enums/tools/tools.go +++ b/pkg/enums/tools/tools.go @@ -19,23 +19,24 @@ import "github.com/iancoleman/strcase" type Tool string const ( - HorusecEngine Tool = "HorusecEngine" - GoSec Tool = "GoSec" - SecurityCodeScan Tool = "SecurityCodeScan" - Brakeman Tool = "Brakeman" - Safety Tool = "Safety" - Bandit Tool = "Bandit" - NpmAudit Tool = "NpmAudit" - YarnAudit Tool = "YarnAudit" - GitLeaks Tool = "GitLeaks" - TfSec Tool = "TfSec" - Semgrep Tool = "Semgrep" - Flawfinder Tool = "Flawfinder" - PhpCS Tool = "PhpCS" - MixAudit Tool = "MixAudit" - Sobelow Tool = "Sobelow" - ShellCheck Tool = "ShellCheck" - BundlerAudit Tool = "BundlerAudit" + HorusecEngine Tool = "HorusecEngine" + GoSec Tool = "GoSec" + SecurityCodeScan Tool = "SecurityCodeScan" + Brakeman Tool = "Brakeman" + Safety Tool = "Safety" + Bandit Tool = "Bandit" + NpmAudit Tool = "NpmAudit" + YarnAudit Tool = "YarnAudit" + GitLeaks Tool = "GitLeaks" + TfSec Tool = "TfSec" + Semgrep Tool = "Semgrep" + Flawfinder Tool = "Flawfinder" + PhpCS Tool = "PhpCS" + MixAudit Tool = "MixAudit" + Sobelow Tool = "Sobelow" + ShellCheck Tool = "ShellCheck" + BundlerAudit Tool = "BundlerAudit" + OwaspDependencyCheck Tool = "OwaspDependencyCheck" ) func (t Tool) ToString() string { @@ -66,5 +67,6 @@ func Values() []Tool { Sobelow, ShellCheck, BundlerAudit, + OwaspDependencyCheck, } } diff --git a/pkg/enums/tools/tools_test.go b/pkg/enums/tools/tools_test.go index f62635e..01b421c 100644 --- a/pkg/enums/tools/tools_test.go +++ b/pkg/enums/tools/tools_test.go @@ -39,6 +39,7 @@ func TestToString(t *testing.T) { assert.Equal(t, "Sobelow", Sobelow.ToString()) assert.Equal(t, "ShellCheck", ShellCheck.ToString()) assert.Equal(t, "BundlerAudit", BundlerAudit.ToString()) + assert.Equal(t, "OwaspDependencyCheck", OwaspDependencyCheck.ToString()) }) } @@ -61,11 +62,12 @@ func TestToLowerCase(t *testing.T) { assert.Equal(t, "sobelow", Sobelow.ToLowerCamel()) assert.Equal(t, "shellCheck", ShellCheck.ToLowerCamel()) assert.Equal(t, "bundlerAudit", BundlerAudit.ToLowerCamel()) + assert.Equal(t, "owaspDependencyCheck", OwaspDependencyCheck.ToLowerCamel()) }) } func TestValues(t *testing.T) { - t.Run("should return 17 valid values", func(t *testing.T) { - assert.Len(t, Values(), 17) + t.Run("should return 18 valid values", func(t *testing.T) { + assert.Len(t, Values(), 18) }) } From 09e050a76a77020d60bd9a86bd980dfc2de7be51 Mon Sep 17 00:00:00 2001 From: Wilian Gabriel <63816070+wiliansilvazup@users.noreply.github.com> Date: Thu, 17 Jun 2021 08:08:37 -0300 Subject: [PATCH 3/3] Remove migrations folder (#45) --- .../20210419185606_initial_migration.down.sql | 8 - .../20210419185606_initial_migration.up.sql | 142 ------------------ ...100413_create_table_if_not_exists.down.sql | 13 -- ...08100413_create_table_if_not_exists.up.sql | 83 ---------- ...20200818092502_create_table_cache.down.sql | 5 - .../20200818092502_create_table_cache.up.sql | 12 -- ...00820125410_create_table_analysis.down.sql | 9 -- ...0200820125410_create_table_analysis.up.sql | 59 -------- .../20200925114542_vuln_hash.down.sql | 6 - .../platform/20200925114542_vuln_hash.up.sql | 7 - ...929095207_token_repositoryid_null.down.sql | 1 - ...00929095207_token_repositoryid_null.up.sql | 1 - ...25_remove-type-vulnerable-version.down.sql | 3 - ...4025_remove-type-vulnerable-version.up.sql | 3 - .../20201001094426_unique_names.down.sql | 5 - .../20201001094426_unique_names.up.sql | 5 - ..._create-nn-analysis-vulnerability.down.sql | 13 -- ...20_create-nn-analysis-vulnerability.up.sql | 16 -- ...01021174800_ldap_permission_group.down.sql | 14 -- ...0201021174800_ldap_permission_group.up.sql | 14 -- ...23190326_create-super-admin-field.down.sql | 5 - ...1023190326_create-super-admin-field.up.sql | 5 - .../platform/20201111195526_webhook.down.sql | 5 - .../platform/20201111195526_webhook.up.sql | 20 --- ...0129093830_ldap-groups-array-type.down.sql | 12 -- ...210129093830_ldap-groups-array-type.up.sql | 28 ---- ...301125133_update-token-no-expires.down.sql | 5 - ...10301125133_update-token-no-expires.up.sql | 5 - .../20210406121213_workspace_rename.down.sql | 33 ---- .../20210406121213_workspace_rename.up.sql | 33 ---- 30 files changed, 570 deletions(-) delete mode 100644 pkg/services/database/migrations/analytic/20210419185606_initial_migration.down.sql delete mode 100644 pkg/services/database/migrations/analytic/20210419185606_initial_migration.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200818092502_create_table_cache.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200818092502_create_table_cache.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200820125410_create_table_analysis.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200820125410_create_table_analysis.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200925114542_vuln_hash.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200925114542_vuln_hash.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.up.sql delete mode 100644 pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.down.sql delete mode 100644 pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.up.sql delete mode 100644 pkg/services/database/migrations/platform/20201001094426_unique_names.down.sql delete mode 100644 pkg/services/database/migrations/platform/20201001094426_unique_names.up.sql delete mode 100644 pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.down.sql delete mode 100644 pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.up.sql delete mode 100644 pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.down.sql delete mode 100644 pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.up.sql delete mode 100644 pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.down.sql delete mode 100644 pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.up.sql delete mode 100644 pkg/services/database/migrations/platform/20201111195526_webhook.down.sql delete mode 100644 pkg/services/database/migrations/platform/20201111195526_webhook.up.sql delete mode 100644 pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.down.sql delete mode 100644 pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.up.sql delete mode 100644 pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.down.sql delete mode 100644 pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.up.sql delete mode 100644 pkg/services/database/migrations/platform/20210406121213_workspace_rename.down.sql delete mode 100644 pkg/services/database/migrations/platform/20210406121213_workspace_rename.up.sql diff --git a/pkg/services/database/migrations/analytic/20210419185606_initial_migration.down.sql b/pkg/services/database/migrations/analytic/20210419185606_initial_migration.down.sql deleted file mode 100644 index 5cc04d2..0000000 --- a/pkg/services/database/migrations/analytic/20210419185606_initial_migration.down.sql +++ /dev/null @@ -1,8 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS vulnerabilities_by_author CASCADE; -DROP TABLE IF EXISTS vulnerabilities_by_language CASCADE; -DROP TABLE IF EXISTS vulnerabilities_by_repository CASCADE; -DROP TABLE IF EXISTS vulnerabilities_by_time CASCADE; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/analytic/20210419185606_initial_migration.up.sql b/pkg/services/database/migrations/analytic/20210419185606_initial_migration.up.sql deleted file mode 100644 index 8742cb0..0000000 --- a/pkg/services/database/migrations/analytic/20210419185606_initial_migration.up.sql +++ /dev/null @@ -1,142 +0,0 @@ -BEGIN; - -CREATE TABLE IF NOT EXISTS "vulnerabilities_by_author" -( - "vulnerability_id" UUID NOT NULL, - "created_at" TIMESTAMP NOT NULL, - "author" VARCHAR(500) NOT NULL, - "active" BOOLEAN NOT NULL, - "workspace_id" UUID NOT NULL, - "repository_id" UUID NOT NULL, - "critical_vulnerability" INT NOT NULL, - "critical_false_positive" INT NOT NULL, - "critical_risk_accepted" INT NOT NULL, - "critical_corrected" INT NOT NULL, - "high_vulnerability" INT NOT NULL, - "high_false_positive" INT NOT NULL, - "high_risk_accepted" INT NOT NULL, - "high_corrected" INT NOT NULL, - "medium_vulnerability" INT NOT NULL, - "medium_false_positive" INT NOT NULL, - "medium_risk_accepted" INT NOT NULL, - "medium_corrected" INT NOT NULL, - "low_vulnerability" INT NOT NULL, - "low_false_positive" INT NOT NULL, - "low_risk_accepted" INT NOT NULL, - "low_corrected" INT NOT NULL, - "info_vulnerability" INT NOT NULL, - "info_false_positive" INT NOT NULL, - "info_risk_accepted" INT NOT NULL, - "info_corrected" INT NOT NULL, - "unknown_vulnerability" INT NOT NULL, - "unknown_false_positive" INT NOT NULL, - "unknown_risk_accepted" INT NOT NULL, - "unknown_corrected" INT NOT NULL, - PRIMARY KEY (vulnerability_id) -); - -CREATE TABLE IF NOT EXISTS "vulnerabilities_by_language" -( - "vulnerability_id" UUID NOT NULL, - "created_at" TIMESTAMP NOT NULL, - "language" VARCHAR(255) NOT NULL, - "active" BOOLEAN NOT NULL, - "workspace_id" UUID NOT NULL, - "repository_id" UUID NOT NULL, - "critical_vulnerability" INT NOT NULL, - "critical_false_positive" INT NOT NULL, - "critical_risk_accepted" INT NOT NULL, - "critical_corrected" INT NOT NULL, - "high_vulnerability" INT NOT NULL, - "high_false_positive" INT NOT NULL, - "high_risk_accepted" INT NOT NULL, - "high_corrected" INT NOT NULL, - "medium_vulnerability" INT NOT NULL, - "medium_false_positive" INT NOT NULL, - "medium_risk_accepted" INT NOT NULL, - "medium_corrected" INT NOT NULL, - "low_vulnerability" INT NOT NULL, - "low_false_positive" INT NOT NULL, - "low_risk_accepted" INT NOT NULL, - "low_corrected" INT NOT NULL, - "info_vulnerability" INT NOT NULL, - "info_false_positive" INT NOT NULL, - "info_risk_accepted" INT NOT NULL, - "info_corrected" INT NOT NULL, - "unknown_vulnerability" INT NOT NULL, - "unknown_false_positive" INT NOT NULL, - "unknown_risk_accepted" INT NOT NULL, - "unknown_corrected" INT NOT NULL, - PRIMARY KEY (vulnerability_id) -); - -CREATE TABLE IF NOT EXISTS "vulnerabilities_by_repository" -( - "vulnerability_id" UUID NOT NULL, - "created_at" TIMESTAMP NOT NULL, - "repository_name" VARCHAR(255) NOT NULL, - "active" BOOLEAN NOT NULL, - "workspace_id" UUID NOT NULL, - "repository_id" UUID NOT NULL, - "critical_vulnerability" INT NOT NULL, - "critical_false_positive" INT NOT NULL, - "critical_risk_accepted" INT NOT NULL, - "critical_corrected" INT NOT NULL, - "high_vulnerability" INT NOT NULL, - "high_false_positive" INT NOT NULL, - "high_risk_accepted" INT NOT NULL, - "high_corrected" INT NOT NULL, - "medium_vulnerability" INT NOT NULL, - "medium_false_positive" INT NOT NULL, - "medium_risk_accepted" INT NOT NULL, - "medium_corrected" INT NOT NULL, - "low_vulnerability" INT NOT NULL, - "low_false_positive" INT NOT NULL, - "low_risk_accepted" INT NOT NULL, - "low_corrected" INT NOT NULL, - "info_vulnerability" INT NOT NULL, - "info_false_positive" INT NOT NULL, - "info_risk_accepted" INT NOT NULL, - "info_corrected" INT NOT NULL, - "unknown_vulnerability" INT NOT NULL, - "unknown_false_positive" INT NOT NULL, - "unknown_risk_accepted" INT NOT NULL, - "unknown_corrected" INT NOT NULL, - PRIMARY KEY (vulnerability_id) -); - -CREATE TABLE IF NOT EXISTS "vulnerabilities_by_time" -( - "vulnerability_id" UUID NOT NULL, - "created_at" TIMESTAMP NOT NULL, - "active" BOOLEAN NOT NULL, - "workspace_id" UUID NOT NULL, - "repository_id" UUID NOT NULL, - "critical_vulnerability" INT NOT NULL, - "critical_false_positive" INT NOT NULL, - "critical_risk_accepted" INT NOT NULL, - "critical_corrected" INT NOT NULL, - "high_vulnerability" INT NOT NULL, - "high_false_positive" INT NOT NULL, - "high_risk_accepted" INT NOT NULL, - "high_corrected" INT NOT NULL, - "medium_vulnerability" INT NOT NULL, - "medium_false_positive" INT NOT NULL, - "medium_risk_accepted" INT NOT NULL, - "medium_corrected" INT NOT NULL, - "low_vulnerability" INT NOT NULL, - "low_false_positive" INT NOT NULL, - "low_risk_accepted" INT NOT NULL, - "low_corrected" INT NOT NULL, - "info_vulnerability" INT NOT NULL, - "info_false_positive" INT NOT NULL, - "info_risk_accepted" INT NOT NULL, - "info_corrected" INT NOT NULL, - "unknown_vulnerability" INT NOT NULL, - "unknown_false_positive" INT NOT NULL, - "unknown_risk_accepted" INT NOT NULL, - "unknown_corrected" INT NOT NULL, - PRIMARY KEY (vulnerability_id) -); - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.down.sql b/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.down.sql deleted file mode 100644 index b6f3cd1..0000000 --- a/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.down.sql +++ /dev/null @@ -1,13 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS accounts CASCADE; - -DROP TABLE IF EXISTS companies CASCADE; - -DROP TABLE IF EXISTS account_company CASCADE; - -DROP TABLE IF EXISTS repositories CASCADE; - -DROP TABLE IF EXISTS account_repository CASCADE; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.up.sql b/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.up.sql deleted file mode 100644 index f20fcc0..0000000 --- a/pkg/services/database/migrations/platform/20200508100413_create_table_if_not_exists.up.sql +++ /dev/null @@ -1,83 +0,0 @@ -BEGIN; - -CREATE TABLE IF NOT EXISTS "accounts" -( - "account_id" UUID NOT NULL, - "password" VARCHAR(255) NOT NULL, - "email" VARCHAR(255) UNIQUE NOT NULL, - "username" VARCHAR(255) NOT NULL, - "is_confirmed" BOOLEAN NOT NULL, - "created_at" DATE NOT NULL, - "updated_at" DATE, - PRIMARY KEY (account_id) -); - -CREATE TABLE IF NOT EXISTS "companies" -( - "company_id" UUID NOT NULL, - "name" VARCHAR(255) NOT NULL, - "description" VARCHAR(255), - "created_at" DATE NOT NULL, - "updated_at" DATE, - PRIMARY KEY (company_id) -); - -CREATE TABLE IF NOT EXISTS "account_company" -( - "company_id" UUID NOT NULL, - "account_id" UUID NOT NULL, - "role" VARCHAR(255) NOT NULL, - "created_at" DATE NOT NULL, - "updated_at" DATE, - FOREIGN KEY (company_id) REFERENCES companies (company_id) ON DELETE CASCADE, - FOREIGN KEY (account_id) REFERENCES accounts (account_id) ON DELETE CASCADE, - UNIQUE (company_id, account_id) - -); - -CREATE TABLE IF NOT EXISTS "repositories" -( - "repository_id" UUID NOT NULL, - "company_id" UUID NOT NULL, - "description" VARCHAR(255), - "name" VARCHAR(255) NOT NULL, - "created_at" DATE NOT NULL, - "updated_at" DATE, - PRIMARY KEY (repository_id), - FOREIGN KEY (company_id) REFERENCES companies (company_id) ON DELETE CASCADE -); - -CREATE TABLE IF NOT EXISTS "account_repository" -( - "repository_id" UUID NOT NULL, - "account_id" UUID NOT NULL, - "company_id" UUID NOT NULL, - "role" VARCHAR(255) NOT NULL, - "created_at" DATE NOT NULL, - "updated_at" DATE, - FOREIGN KEY (repository_id) REFERENCES repositories (repository_id) ON DELETE CASCADE, - FOREIGN KEY (account_id) REFERENCES accounts (account_id) ON DELETE CASCADE, - UNIQUE (repository_id, account_id) -); - -INSERT INTO accounts( - account_id, - password, - email, - username, - is_confirmed, - created_at, - updated_at) -VALUES ( - '4e0bfe1b-043d-4922-8198-07d84ab49bd0', - '$2a$10$hWoL3d6iUUl3wFBXouGDB.p/uE/K3t1k5vVFdN981IpoZJY8wftPm', /* Devpass0* */ - 'dev@example.com', - 'dev', - true, - '2020-07-29', - '2020-07-29' -); - -COMMIT; - - diff --git a/pkg/services/database/migrations/platform/20200818092502_create_table_cache.down.sql b/pkg/services/database/migrations/platform/20200818092502_create_table_cache.down.sql deleted file mode 100644 index 08ae1ce..0000000 --- a/pkg/services/database/migrations/platform/20200818092502_create_table_cache.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS cache CASCADE; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200818092502_create_table_cache.up.sql b/pkg/services/database/migrations/platform/20200818092502_create_table_cache.up.sql deleted file mode 100644 index 53ed88c..0000000 --- a/pkg/services/database/migrations/platform/20200818092502_create_table_cache.up.sql +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN; - -CREATE TABLE IF NOT EXISTS "cache" -( - "key" TEXT NOT NULL, - "value" TEXT NOT NULL, - "expires_at" TIMESTAMP NOT NULL DEFAULT NOW(), - "created_at" TIMESTAMP NOT NULL DEFAULT NOW(), - PRIMARY KEY (key) -); - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.down.sql b/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.down.sql deleted file mode 100644 index 9ab19f8..0000000 --- a/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.down.sql +++ /dev/null @@ -1,9 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS tokens CASCADE; - -DROP TABLE IF EXISTS vulnerabilities CASCADE; - -DROP TABLE IF EXISTS analysis CASCADE; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.up.sql b/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.up.sql deleted file mode 100644 index a28c80f..0000000 --- a/pkg/services/database/migrations/platform/20200820125410_create_table_analysis.up.sql +++ /dev/null @@ -1,59 +0,0 @@ -BEGIN; - -CREATE TABLE IF NOT EXISTS "analysis" -( - analysis_id UUID NOT NULL, - repository_id UUID NOT NULL, - repository_name VARCHAR(255) NOT NULL, - company_id UUID NOT NULL, - company_name VARCHAR(255) NOT NULL, - status VARCHAR(255) NOT NULL, - errors TEXT NOT NULL, - created_at DATE NOT NULL, - finished_at DATE NOT NULL, - PRIMARY KEY (analysis_id), - FOREIGN KEY (repository_id) REFERENCES "repositories" (repository_id) ON DELETE CASCADE, - FOREIGN KEY (company_id) REFERENCES "companies" (company_id) ON DELETE CASCADE -); - -CREATE TABLE IF NOT EXISTS "vulnerabilities" -( - vulnerability_id UUID NOT NULL, - analysis_id UUID NOT NULL, - line VARCHAR(255), - "column" VARCHAR(255), - confidence VARCHAR(255), - file VARCHAR, - code VARCHAR, - details VARCHAR, - type VARCHAR(255), - vulnerable_below VARCHAR(255), - version VARCHAR(255), - security_tool VARCHAR(255) NOT NULL, - language VARCHAR(255) NOT NULL, - severity VARCHAR(255), - commit_author VARCHAR(255), - commit_email VARCHAR(255), - commit_hash VARCHAR(255), - commit_message VARCHAR, - commit_date VARCHAR(255), - PRIMARY KEY (vulnerability_id), - FOREIGN KEY (analysis_id) REFERENCES "analysis" (analysis_id) ON DELETE CASCADE -); - -CREATE TABLE IF NOT EXISTS "tokens" -( - token_id UUID NOT NULL, - description VARCHAR(255) NOT NULL, - repository_id UUID NOT NULL, - company_id UUID NOT NULL, - suffix_value VARCHAR(255) NOT NULL, - value VARCHAR(255) NOT NULL, - created_at DATE NOT NULL, - expires_at DATE NOT NULL, - PRIMARY KEY (token_id), - FOREIGN KEY (repository_id) REFERENCES "repositories" (repository_id) ON DELETE CASCADE, - FOREIGN KEY (company_id) REFERENCES "companies" (company_id) ON DELETE CASCADE -); - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20200925114542_vuln_hash.down.sql b/pkg/services/database/migrations/platform/20200925114542_vuln_hash.down.sql deleted file mode 100644 index 64657bd..0000000 --- a/pkg/services/database/migrations/platform/20200925114542_vuln_hash.down.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -ALTER TABLE "vulnerabilities" -DROP COLUMN "vuln_hash"; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20200925114542_vuln_hash.up.sql b/pkg/services/database/migrations/platform/20200925114542_vuln_hash.up.sql deleted file mode 100644 index a59f9c9..0000000 --- a/pkg/services/database/migrations/platform/20200925114542_vuln_hash.up.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -ALTER TABLE "vulnerabilities" -ADD - "vuln_hash" VARCHAR(40); - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.down.sql b/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.down.sql deleted file mode 100644 index 4e890d5..0000000 --- a/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE tokens ALTER COLUMN repository_id SET NOT NULL; diff --git a/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.up.sql b/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.up.sql deleted file mode 100644 index dadccf4..0000000 --- a/pkg/services/database/migrations/platform/20200929095207_token_repositoryid_null.up.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE tokens ALTER COLUMN repository_id DROP NOT NULL; diff --git a/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.down.sql b/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.down.sql deleted file mode 100644 index bbc9da5..0000000 --- a/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.down.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE vulnerabilities ADD type VARCHAR(255); -ALTER TABLE vulnerabilities ADD vulnerable_below VARCHAR(255); -ALTER TABLE vulnerabilities ADD version VARCHAR(255); diff --git a/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.up.sql b/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.up.sql deleted file mode 100644 index 59b8dbb..0000000 --- a/pkg/services/database/migrations/platform/20200930164025_remove-type-vulnerable-version.up.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE vulnerabilities DROP COLUMN "type"; -ALTER TABLE vulnerabilities DROP COLUMN vulnerable_below; -ALTER TABLE vulnerabilities DROP COLUMN "version"; diff --git a/pkg/services/database/migrations/platform/20201001094426_unique_names.down.sql b/pkg/services/database/migrations/platform/20201001094426_unique_names.down.sql deleted file mode 100644 index 28d4ef4..0000000 --- a/pkg/services/database/migrations/platform/20201001094426_unique_names.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE accounts DROP CONSTRAINT uk_accounts_username; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201001094426_unique_names.up.sql b/pkg/services/database/migrations/platform/20201001094426_unique_names.up.sql deleted file mode 100644 index dbcb20e..0000000 --- a/pkg/services/database/migrations/platform/20201001094426_unique_names.up.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE accounts ADD CONSTRAINT uk_accounts_username UNIQUE (username); - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.down.sql b/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.down.sql deleted file mode 100644 index bb0b3f4..0000000 --- a/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.down.sql +++ /dev/null @@ -1,13 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS analysis_vulnerabilities CASCADE; - -ALTER TABLE vulnerabilities DROP COLUMN "type"; - -ALTER TABLE vulnerabilities ADD analysis_id UUID NOT NULL; - -ALTER TABLE vulnerabilities ADD FOREIGN KEY (analysis_id) REFERENCES analysis (analysis_id) ON DELETE CASCADE; - -ALTER TABLE vulnerabilities ALTER COLUMN vuln_hash TYPE varchar(40) USING vuln_hash::varchar; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.up.sql b/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.up.sql deleted file mode 100644 index d51eca0..0000000 --- a/pkg/services/database/migrations/platform/20201002082520_create-nn-analysis-vulnerability.up.sql +++ /dev/null @@ -1,16 +0,0 @@ -ALTER TABLE vulnerabilities DROP CONSTRAINT vulnerabilities_analysis_id_fkey; - -ALTER TABLE vulnerabilities DROP COLUMN analysis_id; - -ALTER TABLE vulnerabilities ADD COLUMN "type" varchar(255) NOT NULL; - -ALTER TABLE vulnerabilities ALTER COLUMN vuln_hash TYPE varchar(255) USING vuln_hash::varchar; - -CREATE TABLE analysis_vulnerabilities ( - vulnerability_id uuid NOT NULL, - analysis_id uuid NOT NULL, - created_at DATE NOT NULL, - FOREIGN KEY (vulnerability_id) REFERENCES vulnerabilities (vulnerability_id) ON DELETE CASCADE, - FOREIGN KEY (analysis_id) REFERENCES analysis (analysis_id) ON DELETE CASCADE, - PRIMARY KEY (analysis_id, vulnerability_id) -); diff --git a/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.down.sql b/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.down.sql deleted file mode 100644 index 2274eaa..0000000 --- a/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.down.sql +++ /dev/null @@ -1,14 +0,0 @@ -BEGIN; - -ALTER TABLE companies - DROP COLUMN IF EXISTS authz_member, - DROP COLUMN IF EXISTS authz_admin; - -ALTER TABLE repositories - DROP COLUMN IF EXISTS authz_member, - DROP COLUMN IF EXISTS authz_admin, - DROP COLUMN IF EXISTS authz_supervisor; - -ALTER TABLE "accounts" ALTER COLUMN "password" SET NOT NULL; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.up.sql b/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.up.sql deleted file mode 100644 index 66b2d2b..0000000 --- a/pkg/services/database/migrations/platform/20201021174800_ldap_permission_group.up.sql +++ /dev/null @@ -1,14 +0,0 @@ -BEGIN; - -ALTER TABLE "companies" - ADD COLUMN "authz_member" VARCHAR(255), - ADD COLUMN "authz_admin" VARCHAR(255); - -ALTER TABLE "repositories" - ADD COLUMN "authz_member" VARCHAR(255), - ADD COLUMN "authz_admin" VARCHAR(255), - ADD COLUMN "authz_supervisor" VARCHAR(255); - -ALTER TABLE "accounts" ALTER COLUMN "password" DROP NOT NULL; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.down.sql b/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.down.sql deleted file mode 100644 index e70296b..0000000 --- a/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE accounts DROP COLUMN "is_application_admin"; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.up.sql b/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.up.sql deleted file mode 100644 index af96b64..0000000 --- a/pkg/services/database/migrations/platform/20201023190326_create-super-admin-field.up.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE accounts ADD COLUMN "is_application_admin" boolean NOT NULL DEFAULT false; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20201111195526_webhook.down.sql b/pkg/services/database/migrations/platform/20201111195526_webhook.down.sql deleted file mode 100644 index d3041f9..0000000 --- a/pkg/services/database/migrations/platform/20201111195526_webhook.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -DROP TABLE IF EXISTS webhooks CASCADE; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20201111195526_webhook.up.sql b/pkg/services/database/migrations/platform/20201111195526_webhook.up.sql deleted file mode 100644 index b31ea46..0000000 --- a/pkg/services/database/migrations/platform/20201111195526_webhook.up.sql +++ /dev/null @@ -1,20 +0,0 @@ -BEGIN; - -CREATE TABLE IF NOT EXISTS "webhooks" -( - "webhook_id" UUID NOT NULL, - "repository_id" UUID NOT NULL, - "company_id" UUID NOT NULL, - "description" VARCHAR(255), - "method" VARCHAR(255) NOT NULL, - "url" VARCHAR(500) NOT NULL, - "headers" JSONB, - "created_at" DATE NOT NULL, - "updated_at" DATE, - PRIMARY KEY (webhook_id), - FOREIGN KEY (repository_id) REFERENCES repositories (repository_id) ON DELETE CASCADE, - FOREIGN KEY (company_id) REFERENCES companies (company_id) ON DELETE CASCADE, - UNIQUE (repository_id) -); - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.down.sql b/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.down.sql deleted file mode 100644 index 23aa1b6..0000000 --- a/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.down.sql +++ /dev/null @@ -1,12 +0,0 @@ -BEGIN; - -ALTER TABLE IF EXISTS workspaces - DROP COLUMN IF EXISTS authz_member, - DROP COLUMN IF EXISTS authz_admin; - -ALTER TABLE IF EXISTS repositories - DROP COLUMN IF EXISTS authz_member, - DROP COLUMN IF EXISTS authz_admin, - DROP COLUMN IF EXISTS authz_supervisor; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.up.sql b/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.up.sql deleted file mode 100644 index c44b622..0000000 --- a/pkg/services/database/migrations/platform/20210129093830_ldap-groups-array-type.up.sql +++ /dev/null @@ -1,28 +0,0 @@ -BEGIN; - -alter table companies - alter authz_member drop default, - alter authz_member type text[] using array[authz_member], - alter authz_member set default '{}'; - -alter table companies - alter authz_admin drop default, - alter authz_admin type text[] using array[authz_admin], - alter authz_admin set default '{}'; - -alter table repositories - alter authz_member drop default, - alter authz_member type text[] using array[authz_member], - alter authz_member set default '{}'; - -alter table repositories - alter authz_supervisor drop default, - alter authz_supervisor type text[] using array[authz_supervisor], - alter authz_supervisor set default '{}'; - -alter table repositories - alter authz_admin drop default, - alter authz_admin type text[] using array[authz_admin], - alter authz_admin set default '{}'; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.down.sql b/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.down.sql deleted file mode 100644 index cb82b9b..0000000 --- a/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE "tokens" DROP COLUMN "is_expirable"; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.up.sql b/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.up.sql deleted file mode 100644 index 15023e5..0000000 --- a/pkg/services/database/migrations/platform/20210301125133_update-token-no-expires.up.sql +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN; - -ALTER TABLE "tokens" ADD "is_expirable" BOOLEAN default true; - -COMMIT; \ No newline at end of file diff --git a/pkg/services/database/migrations/platform/20210406121213_workspace_rename.down.sql b/pkg/services/database/migrations/platform/20210406121213_workspace_rename.down.sql deleted file mode 100644 index 76640cf..0000000 --- a/pkg/services/database/migrations/platform/20210406121213_workspace_rename.down.sql +++ /dev/null @@ -1,33 +0,0 @@ -BEGIN; - -ALTER TABLE workspaces - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE workspaces - RENAME TO companies; - -ALTER TABLE account_workspace - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE account_workspace - RENAME TO account_company; - -ALTER TABLE analysis - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE analysis - RENAME COLUMN workspace_name TO company_name; - -ALTER TABLE webhooks - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE tokens - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE repositories - RENAME COLUMN workspace_id TO company_id; - -ALTER TABLE account_repository - RENAME COLUMN workspace_id TO company_id; - -COMMIT; diff --git a/pkg/services/database/migrations/platform/20210406121213_workspace_rename.up.sql b/pkg/services/database/migrations/platform/20210406121213_workspace_rename.up.sql deleted file mode 100644 index a886a36..0000000 --- a/pkg/services/database/migrations/platform/20210406121213_workspace_rename.up.sql +++ /dev/null @@ -1,33 +0,0 @@ -BEGIN; - -ALTER TABLE companies - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE companies - RENAME TO workspaces; - -ALTER TABLE account_company - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE account_company - RENAME TO account_workspace; - -ALTER TABLE analysis - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE analysis - RENAME COLUMN company_name TO workspace_name; - -ALTER TABLE webhooks - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE tokens - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE repositories - RENAME COLUMN company_id TO workspace_id; - -ALTER TABLE account_repository - RENAME COLUMN company_id TO workspace_id; - -COMMIT;