amf

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package amf is the connector of the AMF blacklist: the CSV file the Autorité des marchés financiers publishes daily on data.gouv.fr under the Licence Ouverte 2.0 (docs/sources.md).

Each snapshot row is one site or address, looked up by its normalised host or address. Free-text names, which may name natural persons, are left out: no input kind matches them.

Index

Constants

View Source
const (
	// ColumnKind is "domain" or "email".
	ColumnKind = "kind"
	// ColumnKey is the normalised host or address the entry is looked up by.
	ColumnKey = "key"
	// ColumnPath is the path and query of a site entry that targets one
	// page, "" when it targets the whole site.
	ColumnPath = "path"
	// ColumnEntry is the entry as the AMF lists it.
	ColumnEntry = "entry"
	// ColumnCategories are the AMF categories, separated by "|".
	ColumnCategories = "categories"
	// ColumnListedOn is the listing date, AAAA-MM-JJ.
	ColumnListedOn = "listed_on"
)

Columns of a snapshot row, in order.

View Source
const DatasetURL = "https://www.data.gouv.fr/api/1/datasets/641d5dab1d84b530f7720b08/"

DatasetURL is the data.gouv.fr API page of the dataset, which names the current file: its URL is dated and changes with every export.

View Source
const Source domain.Source = "AMF"

Source is the name of the AMF blacklist, as shown to users.

Variables

View Source
var ErrFormat = errors.New("unexpected AMF file format")

ErrFormat means the file is not laid out as docs/sources.md records it.

View Source
var ErrResource = errors.New("no single AMF CSV resource")

ErrResource means the dataset metadata does not name exactly one CSV file.

Functions

func Hosts

func Hosts() []string

Hosts returns the hosts a Fetcher reaches, for the HTTP client allowlist: the data.gouv.fr API and the object store that serves the file.

func Parse

func Parse(r io.Reader) (domain.Snapshot, error)

Parse reads the published CSV file into a snapshot, one row per site or address. Free-text names are left out. A file that departs from the recorded format is rejected with ErrFormat rather than half read.

Types

type Fetcher

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

Fetcher downloads and parses the AMF blacklist. It implements app.SourceFetcher.

func NewFetcher

func NewFetcher(client Getter, datasetURL string) *Fetcher

NewFetcher returns a Fetcher that reads the dataset metadata at datasetURL, DatasetURL in production, through client.

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(ctx context.Context) (domain.Snapshot, error)

Fetch resolves the current file from the dataset metadata, downloads it and parses it.

func (*Fetcher) Spec

func (f *Fetcher) Spec() domain.SnapshotSpec

Spec declares the snapshot columns and the least number of rows.

type Getter

type Getter interface {
	Get(ctx context.Context, rawURL string) ([]byte, error)
}

Getter fetches a URL; *httpclient.Client is one.

Jump to

Keyboard shortcuts

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