Skip to content

Commit

Permalink
add pulsar topics and message structs + fix BuildNonPersistentTopic (#4)
Browse files Browse the repository at this point in the history
* add pulsar topics and message structs

Signed-off-by: YiscahLevySilas1 <yiscahls@armosec.io>

* move files

Signed-off-by: YiscahLevySilas1 <yiscahls@armosec.io>

* more consts

Signed-off-by: YiscahLevySilas1 <yiscahls@armosec.io>

* Update pulsar/common/attackchains/topics.go

Co-authored-by: kooomix <eranm@armosec.io>
Signed-off-by: YiscahLevySilas1 <80635572+YiscahLevySilas1@users.noreply.github.com>

* Update pulsar/connector/types.go

Co-authored-by: kooomix <eranm@armosec.io>
Signed-off-by: YiscahLevySilas1 <80635572+YiscahLevySilas1@users.noreply.github.com>

* delete duplication

Signed-off-by: YiscahLevySilas1 <yiscahls@armosec.io>

* add AttackChainDelete

Signed-off-by: YiscahLevySilas1 <yiscahls@armosec.io>

---------

Signed-off-by: YiscahLevySilas1 <yiscahls@armosec.io>
Signed-off-by: YiscahLevySilas1 <80635572+YiscahLevySilas1@users.noreply.github.com>
Co-authored-by: kooomix <eranm@armosec.io>
  • Loading branch information
YiscahLevySilas1 and kooomix committed Sep 4, 2023
1 parent 4f24edf commit dc797df
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
35 changes: 35 additions & 0 deletions pulsar/common/attackchains/messages.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package attackchains

// structs for Pulsar messages

type AttackChainEngineIngesterMessage struct {
ImageScanID string `json:"imageScanID"`
ReportGUID string `json:"reportGUID"`
CustomerGUID string `json:"customerGUID"`
ClusterName string `json:"clusterName"`
}

type AttackChainFirstSeen struct {
AttackChainID string `json:"attackChainID,omitempty" bson:"attackChainID,omitempty"` // name/cluster/resourceID
CustomerGUID string `json:"customerGUID,omitempty" bson:"customerGUID,omitempty"`
ViewedMainScreen string `json:"viewedMainScreen,omitempty" bson:"viewedMainScreen,omitempty"`
}

type AttackChainScanStatus struct {
ClusterName string `json:"clusterName,omitempty" bson:"clusterName,omitempty"`
CustomerGUID string `json:"customerGUID,omitempty" bson:"customerGUID,omitempty"`
ProcessingStatus string `json:"processingStatus,omitempty" bson:"processingStatus,omitempty"` // "processing"/ "done"
}

type AttackChainDelete struct {
ClusterName string `json:"clusterName,omitempty" bson:"clusterName,omitempty"`
CustomerGUID string `json:"customerGUID,omitempty" bson:"customerGUID,omitempty"`
}

func (acps *AttackChainScanStatus) GetCustomerGUID() string {
return acps.CustomerGUID
}

func (acfs *AttackChainFirstSeen) GetCustomerGUID() string {
return acfs.CustomerGUID
}
22 changes: 22 additions & 0 deletions pulsar/common/attackchains/topics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package attackchains

const (
// topic names
AttackChainStateScanStateTopic = "attack-chain-scan-state-v1"
AttackChainStateViewedTopic = "attack-chain-viewed-v1"
KubescapeScanReportFinishedTopic = "kubescape-scan-report-finished-v1"
)

// --------- Ingesters structs and consts -------------

// supported topics and properties:
// [topic]/[propName]/[propValue]

// attack-chain-scan-state-v1/action/update
// attack-chain-viewed-v1/action/update

const (
MsgPropAction = "action"
MsgPropActionValueUpdate = "update"
NsgPropActionValueDelete = "delete"
)
2 changes: 1 addition & 1 deletion pulsar/connector/topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ func BuildPersistentTopic(tenant, namespace string, topicName TopicName) string
}

func BuildNonPersistentTopic(tenant, namespace string, topicName TopicName) string {
return BuildTopic(TopicTypePersistent, tenant, namespace, topicName)
return BuildTopic(TopicTypeNonPersistent, tenant, namespace, topicName)
}
1 change: 0 additions & 1 deletion pulsar/connector/types.go
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
package connector

0 comments on commit dc797df

Please sign in to comment.