From 498a067d7c01d8a7145a2bed073e124ad7778e7a Mon Sep 17 00:00:00 2001 From: golangisfun123 Date: Thu, 2 May 2024 10:48:20 -0500 Subject: [PATCH] [goreleaser] --- contrib/screener-api/client/client.go | 4 +- contrib/screener-api/docs/docs.go | 60 +++++++++++++++++++++++ contrib/screener-api/docs/swagger.json | 60 +++++++++++++++++++++++ contrib/screener-api/docs/swagger.yaml | 41 ++++++++++++++++ contrib/screener-api/screener/screener.go | 11 +++++ 5 files changed, 173 insertions(+), 3 deletions(-) diff --git a/contrib/screener-api/client/client.go b/contrib/screener-api/client/client.go index 0d36399a39..48e438175f 100644 --- a/contrib/screener-api/client/client.go +++ b/contrib/screener-api/client/client.go @@ -49,6 +49,7 @@ type blockedResponse struct { Blocked bool `json:"risk"` } +// ScreenAddress checks if an address is blocked by the screener. func (c clientImpl) ScreenAddress(ctx context.Context, ruleset, address string) (bool, error) { var blockedRes blockedResponse resp, err := c.rClient.R(). @@ -85,9 +86,6 @@ type blacklistResponse struct { func (c clientImpl) BlacklistAddress(ctx context.Context, appsecret string, appid string, body BlackListBody) (string, error) { var blacklistRes blacklistResponse - // TODO: remove, just for testing purposes - // future, take it from some .env or something - nonce := strings.ReplaceAll(uuid.New().String(), "-", "")[:32] timestamp := fmt.Sprintf("%d", time.Now().Unix()) queryString := "" diff --git a/contrib/screener-api/docs/docs.go b/contrib/screener-api/docs/docs.go index 2a6c89d4dc..ec00e7b428 100644 --- a/contrib/screener-api/docs/docs.go +++ b/contrib/screener-api/docs/docs.go @@ -73,6 +73,66 @@ const docTemplate = `{ ], "responses": {} } + }, + "/screen/{ruleset}/{address}": { + "get": { + "description": "Assess the risk associated with a given address using specified rulesets.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "address" + ], + "summary": "Screen address for risk", + "parameters": [ + { + "type": "string", + "description": "Ruleset to use for screening the address", + "name": "ruleset", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "Address to be screened", + "name": "address", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Returns the risk assessment result", + "schema": { + "type": "object", + "additionalProperties": { + "type": "boolean" + } + } + }, + "400": { + "description": "Returns error if the required parameters are missing or invalid", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Returns error if there are problems processing the indicators", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } } }, "definitions": { diff --git a/contrib/screener-api/docs/swagger.json b/contrib/screener-api/docs/swagger.json index 19c1b9f62e..ef9bf8b0e5 100644 --- a/contrib/screener-api/docs/swagger.json +++ b/contrib/screener-api/docs/swagger.json @@ -62,6 +62,66 @@ ], "responses": {} } + }, + "/screen/{ruleset}/{address}": { + "get": { + "description": "Assess the risk associated with a given address using specified rulesets.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "address" + ], + "summary": "Screen address for risk", + "parameters": [ + { + "type": "string", + "description": "Ruleset to use for screening the address", + "name": "ruleset", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "Address to be screened", + "name": "address", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Returns the risk assessment result", + "schema": { + "type": "object", + "additionalProperties": { + "type": "boolean" + } + } + }, + "400": { + "description": "Returns error if the required parameters are missing or invalid", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Returns error if there are problems processing the indicators", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } } }, "definitions": { diff --git a/contrib/screener-api/docs/swagger.yaml b/contrib/screener-api/docs/swagger.yaml index 5b1f5325b8..aa75918ffc 100644 --- a/contrib/screener-api/docs/swagger.yaml +++ b/contrib/screener-api/docs/swagger.yaml @@ -64,4 +64,45 @@ paths: - application/json responses: {} summary: blacklist an address + /screen/{ruleset}/{address}: + get: + consumes: + - application/json + description: Assess the risk associated with a given address using specified + rulesets. + parameters: + - description: Ruleset to use for screening the address + in: query + name: ruleset + required: true + type: string + - description: Address to be screened + in: query + name: address + required: true + type: string + produces: + - application/json + responses: + "200": + description: Returns the risk assessment result + schema: + additionalProperties: + type: boolean + type: object + "400": + description: Returns error if the required parameters are missing or invalid + schema: + additionalProperties: + type: string + type: object + "500": + description: Returns error if there are problems processing the indicators + schema: + additionalProperties: + type: string + type: object + summary: Screen address for risk + tags: + - address swagger: "2.0" diff --git a/contrib/screener-api/screener/screener.go b/contrib/screener-api/screener/screener.go index 025726464d..50fde4ae68 100644 --- a/contrib/screener-api/screener/screener.go +++ b/contrib/screener-api/screener/screener.go @@ -252,6 +252,17 @@ func (s *screenerImpl) Start(ctx context.Context) error { } // screenAddress returns whether an address is risky or not given a ruleset. +// @Summary Screen address for risk +// @Description Assess the risk associated with a given address using specified rulesets. +// @Tags address +// @Accept json +// @Produce json +// @Param ruleset query string true "Ruleset to use for screening the address" +// @Param address query string true "Address to be screened" +// @Success 200 {object} map[string]bool "Returns the risk assessment result" +// @Failure 400 {object} map[string]string "Returns error if the required parameters are missing or invalid" +// @Failure 500 {object} map[string]string "Returns error if there are problems processing the indicators" +// @Router /screen/{ruleset}/{address} [get] func (s *screenerImpl) screenAddress(c *gin.Context) { var err error