search

package
v0.27.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CslRecords added in v0.27.2

func CslRecords(logger log.Logger, initialDir string) (*csl.CSL, error)

func DplRecords added in v0.27.2

func DplRecords(logger log.Logger, initialDir string) ([]*dpl.DPL, error)

func EuCSLRecords added in v0.27.2

func EuCSLRecords(logger log.Logger, initialDir string) ([]*csl.EUCSLRecord, error)

func OfacRecords added in v0.27.2

func OfacRecords(logger log.Logger, initialDir string) (*ofac.Results, error)
func Search(logger log.Logger, searcher *Searcher) http.HandlerFunc

func UkCSLRecords added in v0.27.2

func UkCSLRecords(logger log.Logger, initialDir string) ([]*csl.UKCSLRecord, error)

func UkSanctionsListRecords added in v0.27.2

func UkSanctionsListRecords(logger log.Logger, initialDir string) ([]*csl.UKSanctionsListRecord, error)

Types

type Address

type Address struct {
	Address *ofac.Address
	// contains filtered or unexported fields
}

Address is ofac.Address wrapped with precomputed search metadata

func PrecomputeAddresses added in v0.27.2

func PrecomputeAddresses(adds []*ofac.Address) []*Address

func TopAddressesFn

func TopAddressesFn(limit int, minMatch float64, addresses []*Address, compare func(*Address) *item) []Address

TopAddressesFn performs a ranked search over an arbitrary set of Address fields.

compare takes an Address (from s.Addresses) and is expected to extract some property to be compared against a captured parameter (in a closure calling compare) to return an *item for final sorting. See searchByAddress in search_handlers.go for an example

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

MarshalJSON is a custom method for marshaling a SDN Address search result

type Alt

type Alt struct {
	AlternateIdentity *ofac.AlternateIdentity
	// contains filtered or unexported fields
}

Alt is an ofac.AlternateIdentity wrapped with precomputed search metadata

func PrecomputeAlts added in v0.27.2

func PrecomputeAlts(alts []*ofac.AlternateIdentity, pipe *Pipeliner) []*Alt

func (Alt) MarshalJSON

func (a Alt) MarshalJSON() ([]byte, error)

MarshalJSON is a custom method for marshaling a SDN Alternate Identity search result

type DP

type DP struct {
	DeniedPerson *dpl.DPL
	// contains filtered or unexported fields
}

DP is a BIS Denied Person wrapped with precomputed search metadata

func PrecomputeDPs added in v0.27.2

func PrecomputeDPs(persons []*dpl.DPL, pipe *Pipeliner) []*DP

func (DP) MarshalJSON

func (d DP) MarshalJSON() ([]byte, error)

MarshalJSON is a custom method for marshaling a BIS Denied Person (DP)

type DownloadStats

type DownloadStats struct {
	// US Office of Foreign Assets Control (OFAC)
	SDNs      int `json:"SDNs"`
	Alts      int `json:"altNames"`
	Addresses int `json:"addresses"`

	// US Bureau of Industry and Security (BIS)
	DeniedPersons int `json:"deniedPersons"`

	// Consolidated Screening List (CSL)
	BISEntities                      int `json:"bisEntities"`
	MilitaryEndUsers                 int `json:"militaryEndUsers"`
	SectoralSanctions                int `json:"sectoralSanctions"`
	Unverified                       int `json:"unverifiedCSL"`
	NonProliferationSanctions        int `json:"nonProliferationSanctions"`
	ForeignSanctionsEvaders          int `json:"foreignSanctionsEvaders"`
	PalestinianLegislativeCouncil    int `json:"palestinianLegislativeCouncil"`
	CAPTA                            int `json:"CAPTA"`
	ITARDebarred                     int `json:"ITARDebarred"`
	ChineseMilitaryIndustrialComplex int `json:"chineseMilitaryIndustrialComplex"`
	NonSDNMenuBasedSanctions         int `json:"nonSDNMenuBasedSanctions"`

	// EU Consolidated Sanctions List
	EUCSL int `json:"europeanSanctionsList"`

	// UK Consolidated Sanctions List
	UKCSL int `json:"ukConsolidatedSanctionsList"`

	// UK Sanctions List
	UKSanctionsList int `json:"ukSanctionsList"`

	Errors      []error   `json:"-"`
	RefreshedAt time.Time `json:"timestamp"`
}

DownloadStats holds counts for each type of list data parsed from files and a timestamp of when the download happened.

func (*DownloadStats) Error

func (ss *DownloadStats) Error() string

func (*DownloadStats) MarshalJSON

func (ss *DownloadStats) MarshalJSON() ([]byte, error)

type Name

type Name struct {
	// Original is the initial value and MUST not be changed by any pipeline step.
	Original string

	// Processed is the mutable value that each pipeline step can optionally
	// replace and is read as the input to each step.
	Processed string
	// contains filtered or unexported fields
}

Name represents an individual or entity name to be processed for search.

type Pipeliner

type Pipeliner struct {
	// contains filtered or unexported fields
}

func NewPipeliner

func NewPipeliner(logger log.Logger) *Pipeliner

func (*Pipeliner) Do

func (p *Pipeliner) Do(name *Name) error

type Result

type Result[T any] struct {
	Data T
	// contains filtered or unexported fields
}

func PrecomputeCSLEntities added in v0.27.2

func PrecomputeCSLEntities[T any](items []*T, pipe *Pipeliner) []*Result[T]

func (Result[T]) MarshalJSON

func (e Result[T]) MarshalJSON() ([]byte, error)

type SDN

type SDN struct {
	*ofac.SDN
	// contains filtered or unexported fields
}

SDN is ofac.SDN wrapped with precomputed search metadata

func PrecomputeSDNs added in v0.27.2

func PrecomputeSDNs(sdns []*ofac.SDN, addrs []*ofac.Address, pipe *Pipeliner) []*SDN

func (SDN) MarshalJSON

func (s SDN) MarshalJSON() ([]byte, error)

MarshalJSON is a custom method for marshaling a SDN search result

type SearchResponse

type SearchResponse struct {
	// OFAC
	SDNs      []*SDN    `json:"SDNs"`
	AltNames  []Alt     `json:"altNames"`
	Addresses []Address `json:"addresses"`

	// BIS
	DeniedPersons []DP `json:"deniedPersons"`

	// Consolidated Screening List
	BISEntities                            []*Result[csl.EL]     `json:"bisEntities"`
	MilitaryEndUsers                       []*Result[csl.MEU]    `json:"militaryEndUsers"`
	SectoralSanctions                      []*Result[csl.SSI]    `json:"sectoralSanctions"`
	Unverified                             []*Result[csl.UVL]    `json:"unverifiedCSL"`
	NonproliferationSanctions              []*Result[csl.ISN]    `json:"nonproliferationSanctions"`
	ForeignSanctionsEvaders                []*Result[csl.FSE]    `json:"foreignSanctionsEvaders"`
	PalestinianLegislativeCouncil          []*Result[csl.PLC]    `json:"palestinianLegislativeCouncil"`
	CaptaList                              []*Result[csl.CAP]    `json:"captaList"`
	ITARDebarred                           []*Result[csl.DTC]    `json:"itarDebarred"`
	NonSDNChineseMilitaryIndustrialComplex []*Result[csl.CMIC]   `json:"nonSDNChineseMilitaryIndustrialComplex"`
	NonSDNMenuBasedSanctionsList           []*Result[csl.NS_MBS] `json:"nonSDNMenuBasedSanctionsList"`

	// EU - Consolidated Sanctions List
	EUCSL []*Result[csl.EUCSLRecord] `json:"euConsolidatedSanctionsList"`

	// UK - Consolidated Sanctions List
	UKCSL []*Result[csl.UKCSLRecord] `json:"ukConsolidatedSanctionsList"`

	// UK Sanctions List
	UKSanctionsList []*Result[csl.UKSanctionsListRecord] `json:"ukSanctionsList"`

	// Metadata
	RefreshedAt time.Time `json:"refreshedAt"`
}

type Searcher

type Searcher struct {
	// OFAC
	SDNs      []*SDN
	Addresses []*Address
	Alts      []*Alt

	// BIS
	DPs []*DP

	// US Consolidated Screening List
	BISEntities      []*Result[csl.EL]
	MilitaryEndUsers []*Result[csl.MEU]
	SSIs             []*Result[csl.SSI]
	UVLs             []*Result[csl.UVL]
	ISNs             []*Result[csl.ISN]
	FSEs             []*Result[csl.FSE]
	PLCs             []*Result[csl.PLC]
	CAPs             []*Result[csl.CAP]
	DTCs             []*Result[csl.DTC]
	CMICs            []*Result[csl.CMIC]
	NS_MBSs          []*Result[csl.NS_MBS]

	// EU Consolidated List of Sactions
	EUCSL []*Result[csl.EUCSLRecord]

	// UK Consolidated List of Sactions - OFSI
	UKCSL []*Result[csl.UKCSLRecord]

	// UK Sanctions List
	UKSanctionsList []*Result[csl.UKSanctionsListRecord]

	sync.RWMutex   // protects all above fields
	*syncutil.Gate // limits concurrent processing
	// contains filtered or unexported fields
}

Searcher holds precomputed data for each object available to search against. This data comes from various US and EU Federal agencies

func NewSearcher

func NewSearcher(logger log.Logger, pipeline *Pipeliner, workers int) *Searcher

exposed for testing

func (*Searcher) FilterCountries

func (s *Searcher) FilterCountries(name string) []*Address

FilterCountries returns Addresses that match a given country name.

If name is blank all Addresses are returned.

This filtering ignore case differences, but does require the name matches to the underlying data.

func (*Searcher) FindAddresses

func (s *Searcher) FindAddresses(limit int, id string) []*ofac.Address

func (*Searcher) FindAlts

func (s *Searcher) FindAlts(limit int, id string) []*ofac.AlternateIdentity

func (*Searcher) FindSDN

func (s *Searcher) FindSDN(entityID string) *ofac.SDN

func (*Searcher) FindSDNsByRemarksID

func (s *Searcher) FindSDNsByRemarksID(limit int, id string) []*SDN

FindSDNsByRemarksID looks for SDN's whose remarks property contains an ID matching what is provided to this function. It's typically used with values assigned by a local government. (National ID, Drivers License, etc)

func (*Searcher) TopAddresses

func (s *Searcher) TopAddresses(limit int, minMatch float64, reqAddress string) []Address

func (*Searcher) TopAltNames

func (s *Searcher) TopAltNames(limit int, minMatch float64, alt string) []Alt

func (*Searcher) TopBISEntities

func (s *Searcher) TopBISEntities(limit int, minMatch float64, name string) []*Result[csl.EL]

TopBISEntities searches BIS Entity List records by name and alias

func (*Searcher) TopCAPs

func (s *Searcher) TopCAPs(limit int, minMatch float64, name string) []*Result[csl.CAP]

TopCAPs searches the CAPTA list by Name and Alias

func (*Searcher) TopCMICs

func (s *Searcher) TopCMICs(limit int, minMatch float64, name string) []*Result[csl.CMIC]

TopCMICs searches the Non-SDN Chinese Military Industrial Complex list by Name and Alias

func (*Searcher) TopDPs

func (s *Searcher) TopDPs(limit int, minMatch float64, name string) []DP

func (*Searcher) TopDTCs

func (s *Searcher) TopDTCs(limit int, minMatch float64, name string) []*Result[csl.DTC]

TopDTCs searches the ITAR Debarred list by Name and Alias

func (*Searcher) TopEUCSL

func (s *Searcher) TopEUCSL(limit int, minMatch float64, name string) []*Result[csl.EUCSLRecord]

TopEUCSL searches the EU Sanctions list by Name and Alias

func (*Searcher) TopFSEs

func (s *Searcher) TopFSEs(limit int, minMatch float64, name string) []*Result[csl.FSE]

TopFSEs searches Foreign Sanctions Evaders records by Name and Alias

func (*Searcher) TopISNs

func (s *Searcher) TopISNs(limit int, minMatch float64, name string) []*Result[csl.ISN]

TopISNs searches Nonproliferation Sanctions records by Name and Alias

func (*Searcher) TopMEUs

func (s *Searcher) TopMEUs(limit int, minMatch float64, name string) []*Result[csl.MEU]

TopMEUs searches Military End User records by name and alias

func (*Searcher) TopNS_MBS

func (s *Searcher) TopNS_MBS(limit int, minMatch float64, name string) []*Result[csl.NS_MBS]

TopNS_MBS searches the Non-SDN Menu Based Sanctions list by Name and Alias

func (*Searcher) TopPLCs

func (s *Searcher) TopPLCs(limit int, minMatch float64, name string) []*Result[csl.PLC]

TopPLCs searches Palestinian Legislative Council records by Name and Alias

func (*Searcher) TopSDNs

func (s *Searcher) TopSDNs(limit int, minMatch float64, name string, keepSDN func(*SDN) bool) []*SDN

func (*Searcher) TopSSIs

func (s *Searcher) TopSSIs(limit int, minMatch float64, name string) []*Result[csl.SSI]

TopSSIs searches Sectoral Sanctions records by Name and Alias

func (*Searcher) TopUKCSL

func (s *Searcher) TopUKCSL(limit int, minMatch float64, name string) []*Result[csl.UKCSLRecord]

TopUKCSL searches the UK Sanctions list by Name and Alias

func (*Searcher) TopUKSanctionsList

func (s *Searcher) TopUKSanctionsList(limit int, minMatch float64, name string) []*Result[csl.UKSanctionsListRecord]

TopUKSanctionsList searches the UK Sanctions list by Name and Alias

func (*Searcher) TopUVLs

func (s *Searcher) TopUVLs(limit int, minMatch float64, name string) []*Result[csl.UVL]

TopUVLs search Unverified Lists records by Name and Alias

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL