Documentation
¶
Overview ¶
Package dbcache validates a JA4+ fingerprint database and installs it in the cache file.
A downloaded database is untrusted input, and this package is the validation boundary of the library. No caller writes the cache file by another path.
The package holds one bound and one CSV column set for the whole repository. The library and the command-line program each read them here, so the two never state two values.
The CSV column set and the ja4db.com JSON field set are two keyspaces, and this package holds the CSV one alone. `ja4db/lookup.go` names `application`, `library`, `device` and `os` as JSON field names of the remote response. That literal is no second copy of this column set. The names read alike because ja4db.com publishes one record shape in two encodings.
`docs/specs/features/09-database-lookup.md` states FR-lookup-23 through FR-lookup-26.
Index ¶
Constants ¶
const MaxBytes = 16 << 20
MaxBytes bounds a database that replaces the cache file. FR-lookup-25 states 16 MB.
The mapping file that FoxIO publishes holds 4740 bytes, measured on 2026-08-14, so the bound leaves the file room to grow by a factor of about 3500.
Variables ¶
This section is empty.
Functions ¶
func FingerprintColumns ¶
func FingerprintColumns() []string
FingerprintColumns returns the name of each column that holds a fingerprint value. `parseMapping` in `lookup.go` indexes a record by each one of them.
The function returns a new slice at each call, because a package-level slice is state that a caller changes.
func IdentityColumns ¶
func IdentityColumns() []string
IdentityColumns returns the name of each column that identifies the application of a record. `parseMapping` in `lookup.go` joins the non-empty ones into the application name.
func Validate ¶
Validate reports whether the database is one the library loads.
It returns an error in each of these cases.
- The database is above MaxBytes.
- The CSV reader rejects the header row.
- The header holds no fingerprint column.
- The header holds no identity column.
- No record carries both a fingerprint value and an identity value.
The last case matters, because a database that yields no entry answers every lookup with nil. `rebuildTable` in `lookup.go` then keeps the previous table, and the caller reads a successful update that changed nothing.
A record that the CSV reader rejects is not a reason to reject the file, because `parseMapping` in `lookup.go` skips such a record.
func Write ¶
Write validates the database and replaces the cache file at the path.
It writes a temporary file in the directory of the path and renames it, so a reader reads the previous database or the new one and never a partial file. It removes the temporary file on each failure path.
A failure leaves the previous cache file unchanged.
The function syncs the temporary file and it syncs no directory, so a power loss between the rename and the next directory write can leave the previous name. The cache file holds a copy of a file the program downloads again, so the library declines that cost.
Types ¶
This section is empty.