diff --git a/cli/commands/run/server/agent.proto b/cli/commands/run/server/agent.proto index 41c0e37..95b9af4 100644 --- a/cli/commands/run/server/agent.proto +++ b/cli/commands/run/server/agent.proto @@ -315,6 +315,7 @@ message AlertEvent { string entityType = 4; bool remove = 5; repeated string metadata = 6; + string uniqueKey = 7; } // Unique string to identify this class of finding, diff --git a/cli/commands/run/server/alert.proto b/cli/commands/run/server/alert.proto index ff80c85..16c0899 100644 --- a/cli/commands/run/server/alert.proto +++ b/cli/commands/run/server/alert.proto @@ -90,6 +90,7 @@ message Label { bool remove = 6; string label = 7; repeated string metadata = 8; + string uniqueKey = 9; } message Source { diff --git a/python-sdk/src/forta_agent/alerts_api.py b/python-sdk/src/forta_agent/alerts_api.py index 2846a59..6956b77 100644 --- a/python-sdk/src/forta_agent/alerts_api.py +++ b/python-sdk/src/forta_agent/alerts_api.py @@ -182,6 +182,7 @@ def get_query(self): entityType remove metadata + uniqueKey } addressBloomFilter { bitset diff --git a/python-sdk/src/forta_agent/label.py b/python-sdk/src/forta_agent/label.py index e6acbb0..37239b3 100644 --- a/python-sdk/src/forta_agent/label.py +++ b/python-sdk/src/forta_agent/label.py @@ -21,6 +21,7 @@ def __init__(self, dict): self.confidence = dict['confidence'] self.label = dict['label'] self.remove = dict.get('remove', False) + self.unique_key = dict.get('unique_key', dict.get('uniqueKey')) self.metadata = dict.get('metadata') if dict.get( 'metadata') is not None else {} # if metadata is array, convert to map @@ -34,6 +35,7 @@ def __init__(self, dict): def toDict(self): d = dict(self.__dict__, **{ 'entityType': self.entity_type, + 'uniqueKey': self.unique_key, }) return {k: v for k, v in d.items() if v is not None} diff --git a/python-sdk/src/forta_agent/labels_api.py b/python-sdk/src/forta_agent/labels_api.py index ad50359..aab463b 100644 --- a/python-sdk/src/forta_agent/labels_api.py +++ b/python-sdk/src/forta_agent/labels_api.py @@ -54,6 +54,7 @@ def get_query(self): label metadata remove + uniqueKey } source { alertHash diff --git a/sdk/alerts.api.ts b/sdk/alerts.api.ts index 910a424..d869669 100644 --- a/sdk/alerts.api.ts +++ b/sdk/alerts.api.ts @@ -233,6 +233,7 @@ const getQueryFromAlertOptions = (options: AlertQueryOptions) => { entityType remove metadata + uniqueKey } addressBloomFilter { bitset diff --git a/sdk/label.ts b/sdk/label.ts index 340b9af..256f2b5 100644 --- a/sdk/label.ts +++ b/sdk/label.ts @@ -37,6 +37,7 @@ type LabelInput = { source?: LabelSource; createdAt?: string; id?: string; + uniqueKey?: string; }; export class Label { @@ -49,7 +50,8 @@ export class Label { readonly metadata: { [key: string]: string }, readonly source?: LabelSource, readonly id?: string, - readonly createdAt?: string + readonly createdAt?: string, + readonly uniqueKey?: string ) {} static from(labelInput: LabelInput) { @@ -66,6 +68,7 @@ export class Label { source, id, createdAt, + uniqueKey }: LabelInput) { if (typeof entityType == "string") { entityType = ENTITY_TYPE_STRING_TO_ENUM[entityType]; @@ -91,7 +94,8 @@ export class Label { metadata, source, id, - createdAt + createdAt, + uniqueKey ); } } diff --git a/sdk/labels.api.ts b/sdk/labels.api.ts index fe15bf6..083ff59 100644 --- a/sdk/labels.api.ts +++ b/sdk/labels.api.ts @@ -131,6 +131,7 @@ export const getQueryFromLabelOptions = (options: LabelQueryOptions) => { label metadata remove + uniqueKey } source { alertHash