sourceledger downloads files from servers you don’t control, and you may publish what it builds. This page lists what it checks for you, and what you still have to do.
sourceledger trusts the manifest as much as your code: it downloads every URL in it. It
also follows file:// URLs, which the tests use. Review a change to sources.toml as you
would a code change.
Write each url as https:// where the publisher serves it. sourceledger accepts http://
for a source without headers, but then anyone on the network path can change the bytes.
A sha256 pin, described below, catches that for a fixed file.
These checks apply to every fetch:
headers from the manifest.
An API key meant for one host never goes to another, and never goes out over http after
a redirect from https.A source that needs a key names an environment variable in headers:
headers = { Authorization = "env:EIA_TOKEN" }
headers is a manifest error, so a key never lands in git.headers must have an https url, so the key never crosses the network
in clear text.archive = true sends no headers. Don’t use
archive on a source that needs a login: the archive could not fetch it anyway.In CI, put the key in a repository secret and pass it to the job as an environment variable.
For a file that should never change, such as a dated release, set sha256 in the
manifest:
sha256 = "38fe14e8b0ed..." # all 64 characters, as sha256sum prints them
fetch then refuses bytes with another hash, and build and validate refuse a raw file
that no longer matches. Without a pin, a change upstream is recorded as a new version and
shown by revisions, but not refused.
max_bytes caps each download, 200 MiB unless set. A gzipped file or an Excel
workbook is also refused when it unpacks past the cap, so a small file cannot expand
without limit.fetch refuses a symlink at data/raw/.lock or data/fetches.jsonl.Every implemented source must say whether its terms let you republish the raw file:
redistribute = true or false. validate fails without it. sourceledger never
publishes anything itself. It records redistribute in datapackage.json, and shows it in
the status and attribution reports. The README tells you to keep data/raw/ and
data/processed/ out of git, so a push never republishes them.
Before you publish a dataset, check the sources marked redistribute = false. Leave their
raw files out of the release. Your outputs still hold their values, so check the terms
for those too.
sourceledger verify DIR checks each file a published datapackage.json lists against
the size and SHA-256 it gives. It needs no network, no manifest and no log. It refuses a
path that leads out of the folder, including through a symlink.
Each release on PyPI comes with signed provenance that ties it to the workflow that built it. The README’s Verify a release section shows how to check it.
sourceledger has no runtime dependencies, so installing it pulls in no other code. The
optional xlsx extra adds openpyxl. CONTRIBUTING.md
explains how the development tools are locked and audited.
Report a vulnerability privately, as SECURITY.md describes.