Skip to content

Commit

Permalink
[goreleaser]
Browse files Browse the repository at this point in the history
  • Loading branch information
golangisfun123 committed May 2, 2024
1 parent 8c215e4 commit 498a067
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 3 deletions.
4 changes: 1 addition & 3 deletions contrib/screener-api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down Expand Up @@ -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 := ""
Expand Down
60 changes: 60 additions & 0 deletions contrib/screener-api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
60 changes: 60 additions & 0 deletions contrib/screener-api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
41 changes: 41 additions & 0 deletions contrib/screener-api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 11 additions & 0 deletions contrib/screener-api/screener/screener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Check failure on line 265 in contrib/screener-api/screener/screener.go

View workflow job for this annotation

GitHub Actions / Lint (contrib/screener-api)

Comment should end in a period (godot)
func (s *screenerImpl) screenAddress(c *gin.Context) {
var err error

Expand Down

0 comments on commit 498a067

Please sign in to comment.