Skip to content

Commit

Permalink
feat: read WITH_EU_SCREENING_LIST as option to skip EU CSL list
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Oct 7, 2024
1 parent 47de185 commit 04b0db5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ PONG
| `OFAC_DOWNLOAD_TEMPLATE` | HTTP address for downloading raw OFAC files. | `https://www.treasury.gov/ofac/downloads/%s` |
| `DPL_DOWNLOAD_TEMPLATE` | HTTP address for downloading the DPL. | `https://www.bis.doc.gov/dpl/%s` |
| `EU_CSL_DOWNLOAD_URL` | Use an alternate URL for downloading EU Consolidated Screening List | Subresource of `webgate.ec.europa.eu` |
| `WITH_EU_SCREENING_LIST` | Download and parse the EU Consolidated Screening List | Default: `true` |
| `UK_CSL_DOWNLOAD_URL` | Use an alternate URL for downloading UK Consolidated Screening List | Subresource of `www.gov.uk` |
| `UK_SANCTIONS_LIST_URL` | Use an alternate URL for downloading UK Sanctions List | Subresource of `www.gov.uk` |
| `WITH_UK_SANCTIONS_LIST` | Download and parse the UK Sanctions List on startup. | Default: `false` |
Expand Down
19 changes: 12 additions & 7 deletions cmd/server/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main

import (
"bytes"
"cmp"
"encoding/json"
"errors"
"fmt"
Expand All @@ -14,6 +15,7 @@ import (
"time"

"github.com/moov-io/base/log"
"github.com/moov-io/base/strx"
"github.com/moov-io/watchman/pkg/csl"
"github.com/moov-io/watchman/pkg/dpl"
"github.com/moov-io/watchman/pkg/ofac"
Expand Down Expand Up @@ -284,12 +286,15 @@ func (s *searcher) refreshData(initialDir string) (*DownloadStats, error) {
}
dps := precomputeDPs(deniedPersons, s.pipe)

euConsolidatedList, err := euCSLRecords(s.logger, initialDir)
if err != nil {
lastDataRefreshFailure.WithLabelValues("EUCSL").Set(float64(time.Now().Unix()))
stats.Errors = append(stats.Errors, fmt.Errorf("EUCSL: %v", err))
var euConsolidatedList []*csl.EUCSLRecord
withEUScreeningList := cmp.Or(os.Getenv("WITH_EU_SCREENING_LIST"), "true")
if strx.Yes(withEUScreeningList) {
euConsolidatedList, err = euCSLRecords(s.logger, initialDir)
if err != nil {
lastDataRefreshFailure.WithLabelValues("EUCSL").Set(float64(time.Now().Unix()))
stats.Errors = append(stats.Errors, fmt.Errorf("EUCSL: %v", err))
}
}

euCSLs := precomputeCSLEntities[csl.EUCSLRecord](euConsolidatedList, s.pipe)

ukConsolidatedList, err := ukCSLRecords(s.logger, initialDir)
Expand All @@ -301,8 +306,8 @@ func (s *searcher) refreshData(initialDir string) (*DownloadStats, error) {
ukCSLs := precomputeCSLEntities[csl.UKCSLRecord](ukConsolidatedList, s.pipe)

var ukSLs []*Result[csl.UKSanctionsListRecord]
withSanctionsList := os.Getenv("WITH_UK_SANCTIONS_LIST")
if strings.ToLower(withSanctionsList) == "true" {
withUKSanctionsList := os.Getenv("WITH_UK_SANCTIONS_LIST")
if strings.ToLower(withUKSanctionsList) == "true" {
ukSanctionsList, err := ukSanctionsListRecords(s.logger, initialDir)
if err != nil {
lastDataRefreshFailure.WithLabelValues("UKSanctionsList").Set(float64(time.Now().Unix()))
Expand Down

0 comments on commit 04b0db5

Please sign in to comment.