diff --git a/agent/container/pkg/application/githubmodule.go b/agent/container/pkg/application/githubmodule.go index b2b766b4..bebae4ea 100644 --- a/agent/container/pkg/application/githubmodule.go +++ b/agent/container/pkg/application/githubmodule.go @@ -123,7 +123,7 @@ func (c *GithubApiClient) FetchVersions(packageName string) ([]Version, error) { var versions []Version err = json.Unmarshal(body, &versions) if err != nil { - return nil, fmt.Errorf("error occured while unmarshalling the version %w", err) + return nil, fmt.Errorf("error occurred while unmarshalling the version %w", err) } return versions, nil diff --git a/client/pkg/clickhouse/db_client.go b/client/pkg/clickhouse/db_client.go index 431e1c96..9e265b95 100644 --- a/client/pkg/clickhouse/db_client.go +++ b/client/pkg/clickhouse/db_client.go @@ -583,7 +583,7 @@ func (c *DBClient) InsertKubvizEvent(metrics model.Metrics) { } defer stmt.Close() - eventJson, _ := json.Marshal(metrics.Event) + eventJSON, _ := json.Marshal(metrics.Event) formattedFirstTimestamp := metrics.Event.FirstTimestamp.Time.UTC().Format("2006-01-02 15:04:05") formattedLastTimestamp := metrics.Event.LastTimestamp.Time.UTC().Format("2006-01-02 15:04:05") @@ -598,7 +598,7 @@ func (c *DBClient) InsertKubvizEvent(metrics model.Metrics) { metrics.Event.Message, metrics.Event.Reason, metrics.Event.Source.Host, - string(eventJson), + string(eventJSON), metrics.ImageName, formattedFirstTimestamp, formattedLastTimestamp, @@ -1018,8 +1018,8 @@ func (c *DBClient) RetrieveKubvizEvent() ([]model.DbEvent, error) { log.Printf("Error: %s", err) return nil, err } - eventJson, _ := json.Marshal(dbEvent) - log.Printf("DB Event: %s", string(eventJson)) + eventJSON, _ := json.Marshal(dbEvent) + log.Printf("DB Event: %s", string(eventJSON)) events = append(events, dbEvent) } diff --git a/client/pkg/clickhouse/statements.go b/client/pkg/clickhouse/statements.go index a37c87d5..3761eb33 100644 --- a/client/pkg/clickhouse/statements.go +++ b/client/pkg/clickhouse/statements.go @@ -2,219 +2,219 @@ package clickhouse type DBStatement string -const kubvizTable DBStatement = ` - CREATE TABLE IF NOT EXISTS events ( - ClusterName String, - Id String, - EventTime DateTime('UTC'), - OpType String, - Name String, - Namespace String, - Kind String, - Message String, - Reason String, - Host String, - Event String, - FirstTime String, - LastTime String - ) engine=File(TabSeparated) -` -const rakeesTable DBStatement = ` -CREATE TABLE IF NOT EXISTS rakkess ( - ClusterName String, - Name String, - Create String, - Delete String, - List String, - Update String, - EventTime DateTime('UTC') -) engine=File(TabSeparated) -` +// const kubvizTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS events ( +// ClusterName String, +// Id String, +// EventTime DateTime('UTC'), +// OpType String, +// Name String, +// Namespace String, +// Kind String, +// Message String, +// Reason String, +// Host String, +// Event String, +// FirstTime String, +// LastTime String +// ) engine=File(TabSeparated) +// ` +// const rakeesTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS rakkess ( +// ClusterName String, +// Name String, +// Create String, +// Delete String, +// List String, +// Update String, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const kubePugDepricatedTable DBStatement = ` -CREATE TABLE IF NOT EXISTS DeprecatedAPIs ( - ClusterName String, - ObjectName String, - Description String, - Kind String, - Deprecated UInt8, - Scope String, - EventTime DateTime('UTC') -) engine=File(TabSeparated) -` +// const kubePugDepricatedTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS DeprecatedAPIs ( +// ClusterName String, +// ObjectName String, +// Description String, +// Kind String, +// Deprecated UInt8, +// Scope String, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const kubepugDeletedTable DBStatement = ` -CREATE TABLE IF NOT EXISTS DeletedAPIs ( - ClusterName String, - ObjectName String, - Group String, - Kind String, - Version String, - Name String, - Deleted UInt8, - Scope String, - EventTime DateTime('UTC') -) engine=File(TabSeparated) -` +// const kubepugDeletedTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS DeletedAPIs ( +// ClusterName String, +// ObjectName String, +// Group String, +// Kind String, +// Version String, +// Name String, +// Deleted UInt8, +// Scope String, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const jfrogContainerPushEventTable DBStatement = ` -CREATE TABLE IF NOT EXISTS jfrogcontainerpush ( - Domain String, - EventType String, - RegistryURL String, - RepositoryName String, - SHAID String, - Size Int32, - ImageName String, - Tag String, - Event String, - EventTime DateTime('UTC') -) engine=File(TabSeparated) -` +// const jfrogContainerPushEventTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS jfrogcontainerpush ( +// Domain String, +// EventType String, +// RegistryURL String, +// RepositoryName String, +// SHAID String, +// Size Int32, +// ImageName String, +// Tag String, +// Event String, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const ketallTable DBStatement = ` - CREATE TABLE IF NOT EXISTS getall_resources ( - ClusterName String, - Namespace String, - Kind String, - Resource String, - Age String, - EventTime DateTime('UTC') - ) engine=File(TabSeparated) - ` +// const ketallTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS getall_resources ( +// ClusterName String, +// Namespace String, +// Kind String, +// Resource String, +// Age String, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const outdateTable DBStatement = ` -CREATE TABLE IF NOT EXISTS outdated_images ( - ClusterName String, - Namespace String, - Pod String, - CurrentImage String, - CurrentTag String, - LatestVersion String, - VersionsBehind Int64, - EventTime DateTime('UTC') -) engine=File(TabSeparated) -` +// const outdateTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS outdated_images ( +// ClusterName String, +// Namespace String, +// Pod String, +// CurrentImage String, +// CurrentTag String, +// LatestVersion String, +// VersionsBehind Int64, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const kubescoreTable DBStatement = ` -CREATE TABLE IF NOT EXISTS kubescore ( - id UUID, - namespace String, - cluster_name String, - recommendations String, - EventTime DateTime('UTC') -) engine=File(TabSeparated) -` +// const kubescoreTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS kubescore ( +// id UUID, +// namespace String, +// cluster_name String, +// recommendations String, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const trivyTableVul DBStatement = ` - CREATE TABLE IF NOT EXISTS trivy_vul ( - id UUID, - cluster_name String, - namespace String, - kind String, - name String, - vul_id String, - vul_vendor_ids String, - vul_pkg_id String, - vul_pkg_name String, - vul_pkg_path String, - vul_installed_version String, - vul_fixed_version String, - vul_title String, - vul_severity String, - vul_published_date DateTime('UTC'), - vul_last_modified_date DateTime('UTC') - ) engine=File(TabSeparated) - ` +// const trivyTableVul DBStatement = ` +// CREATE TABLE IF NOT EXISTS trivy_vul ( +// id UUID, +// cluster_name String, +// namespace String, +// kind String, +// name String, +// vul_id String, +// vul_vendor_ids String, +// vul_pkg_id String, +// vul_pkg_name String, +// vul_pkg_path String, +// vul_installed_version String, +// vul_fixed_version String, +// vul_title String, +// vul_severity String, +// vul_published_date DateTime('UTC'), +// vul_last_modified_date DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const trivyTableMisconfig DBStatement = ` - CREATE TABLE IF NOT EXISTS trivy_misconfig ( - id UUID, - cluster_name String, - namespace String, - kind String, - name String, - misconfig_id String, - misconfig_avdid String, - misconfig_type String, - misconfig_title String, - misconfig_desc String, - misconfig_msg String, - misconfig_query String, - misconfig_resolution String, - misconfig_severity String, - misconfig_status String, - EventTime DateTime('UTC') - ) engine=File(TabSeparated) - ` +// const trivyTableMisconfig DBStatement = ` +// CREATE TABLE IF NOT EXISTS trivy_misconfig ( +// id UUID, +// cluster_name String, +// namespace String, +// kind String, +// name String, +// misconfig_id String, +// misconfig_avdid String, +// misconfig_type String, +// misconfig_title String, +// misconfig_desc String, +// misconfig_msg String, +// misconfig_query String, +// misconfig_resolution String, +// misconfig_severity String, +// misconfig_status String, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const trivyTableImage DBStatement = ` - CREATE TABLE IF NOT EXISTS trivyimage ( - id UUID, - cluster_name String, - artifact_name String, - vul_id String, - vul_pkg_id String, - vul_pkg_name String, - vul_installed_version String, - vul_fixed_version String, - vul_title String, - vul_severity String, - vul_published_date DateTime('UTC'), - vul_last_modified_date DateTime('UTC') - ) engine=File(TabSeparated) - ` -const dockerHubBuildTable DBStatement = ` - CREATE TABLE IF NOT EXISTS dockerhubbuild ( - PushedBy String, - ImageTag String, - RepositoryName String, - DateCreated String, - Owner String, - Event String, - EventTime DateTime('UTC') - ) engine=File(TabSeparated) - ` +// const trivyTableImage DBStatement = ` +// CREATE TABLE IF NOT EXISTS trivyimage ( +// id UUID, +// cluster_name String, +// artifact_name String, +// vul_id String, +// vul_pkg_id String, +// vul_pkg_name String, +// vul_installed_version String, +// vul_fixed_version String, +// vul_title String, +// vul_severity String, +// vul_published_date DateTime('UTC'), +// vul_last_modified_date DateTime('UTC') +// ) engine=File(TabSeparated) +// ` +// const dockerHubBuildTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS dockerhubbuild ( +// PushedBy String, +// ImageTag String, +// RepositoryName String, +// DateCreated String, +// Owner String, +// Event String, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const azureContainerPushEventTable DBStatement = ` - CREATE TABLE IF NOT EXISTS azurecontainerpush ( - RegistryURL String, - RepositoryName String, - Tag String, - ImageName String, - Event String, - Size Int32, - SHAID String, - EventTime DateTime('UTC') - ) engine=File(TabSeparated) - ` +// const azureContainerPushEventTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS azurecontainerpush ( +// RegistryURL String, +// RepositoryName String, +// Tag String, +// ImageName String, +// Event String, +// Size Int32, +// SHAID String, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const quayContainerPushEventTable DBStatement = ` - CREATE TABLE IF NOT EXISTS quaycontainerpush ( - name String, - repository String, - nameSpace String, - dockerURL String, - homePage String, - tag String, - Event String, - EventTime DateTime('UTC') - ) engine=File(TabSeparated) - ` +// const quayContainerPushEventTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS quaycontainerpush ( +// name String, +// repository String, +// nameSpace String, +// dockerURL String, +// homePage String, +// tag String, +// Event String, +// EventTime DateTime('UTC') +// ) engine=File(TabSeparated) +// ` -const trivySbomTable DBStatement = ` - CREATE TABLE IF NOT EXISTS trivysbom ( - id UUID, - cluster_name String, - image_name String, - package_name String, - package_url String, - bom_ref String, - serial_number String, - version INTEGER, - bom_format String - ) engine=File(TabSeparated) - ` +// const trivySbomTable DBStatement = ` +// CREATE TABLE IF NOT EXISTS trivysbom ( +// id UUID, +// cluster_name String, +// image_name String, +// package_name String, +// package_url String, +// bom_ref String, +// serial_number String, +// version INTEGER, +// bom_format String +// ) engine=File(TabSeparated) +// ` const InsertDockerHubBuild DBStatement = "INSERT INTO dockerhubbuild (PushedBy, ImageTag, RepositoryName, DateCreated, Owner, Event, EventTime) VALUES (?, ?, ?, ?, ?, ?, ?)" const InsertRakees DBStatement = "INSERT INTO rakkess (ClusterName, Name, Create, Delete, List, Update, EventTime) VALUES (?, ?, ?, ?, ?, ?, ?)" diff --git a/client/pkg/clients/bridge_client.go b/client/pkg/clients/bridge_client.go index 89ef50a9..3f6e8021 100644 --- a/client/pkg/clients/bridge_client.go +++ b/client/pkg/clients/bridge_client.go @@ -82,7 +82,7 @@ func (n *NATSContext) SubscribeGitBridgeNats(conn clickhouse.DBInterface) { var pl azuremodel.GitPushEvent err := json.Unmarshal([]byte(msg.Data), &pl) if err != nil { - log.Println("error occured while unmarshal the payload Error:", err.Error()) + log.Println("error occurred while unmarshal the payload Error:", err.Error()) return } var gca model.GitCommonAttribute diff --git a/cmd/cli/config/utils.go b/cmd/cli/config/utils.go index a4e6e49b..92602b57 100644 --- a/cmd/cli/config/utils.go +++ b/cmd/cli/config/utils.go @@ -100,7 +100,7 @@ func (cfg *Config) Migrate() error { conn, err := cfg.openClickHouseConn() if err != nil { - return fmt.Errorf("unable to create a clickhouse conection %w", err) + return fmt.Errorf("unable to create a clickhouse connection %w", err) } driver, err := ch.WithInstance(conn, &ch.Config{})