Expand description
External rule sources: git repositories cloned into a local cache, plus
extra local directories. Each configured [[rules.sources]] is resolved to
a directory of rule YAML and the provenance stamped on the rules loaded
from it.
External sources are untrusted input, so every git call is hardened:
- A URL or ref starting with
-is rejected before git runs (git would parse it as an option such as--upload-pack=...), and the fetch passes--before its positional arguments. GIT_ALLOW_PROTOCOLrestricts git tohttpsandssh(nofile://,ext::or other transports).SLOPGUARD_GIT_ALLOW_PROTOCOLoverrides the list; it exists for tests and CI that serve rules fromfile://remotes.- A ref that is not a full 40-character commit sha is floating: the rules
it loads can change under the user, so the CLI warns about it
(
unpinned_source_warnings). A pinned sha already checked out in the cache is reused without touching the network. - Refreshing an existing cache when online must succeed: a failed fetch fails the resolution instead of silently scanning with stale rules.
Git auth is delegated to the machine’s own git (ssh-agent, credential
helper, ~/.gitconfig). SLOPGUARD_GIT_TOKEN overrides that for https URLs
of a single trusted host (SLOPGUARD_GIT_TOKEN_HOST, else [git] token_host in the user config): the token is injected into the transient
git fetch <url> argument only, never into the persisted remote, so no
token is written to disk. Without a configured host, no token is injected.
Structs§
- GitToken
- An https token together with the single host it may be sent to.
- Resolved
Source - A source resolved to a directory on disk plus the provenance of its rules.
- Source
Options - How git sources are cached, fetched and authenticated.
Enums§
- Rule
Origin - Where a rule came from, tracked so
slopguard listcan show provenance. - Source
Error
Constants§
- DEFAULT_
ALLOWED_ PROTOCOLS - Protocols git may use to fetch a source unless overridden.
Functions§
- default_
allowed_ protocols - The protocols git may use for sources:
$SLOPGUARD_GIT_ALLOW_PROTOCOLwhen set, otherwiseDEFAULT_ALLOWED_PROTOCOLS. - default_
cache_ root - Default cache location for git sources:
$SLOPGUARD_SOURCES_CACHEwhen set, otherwise<user cache>/slopguard/sources. - git_
token_ from_ env - Read the git token from
SLOPGUARD_GIT_TOKEN, bound to the host named bySLOPGUARD_GIT_TOKEN_HOST, elseconfig_host([git] token_host). - is_
pinned_ sha - Whether
git_refis a full 40-character hex commit sha, i.e. a pinned ref whose content cannot change. - resolve_
sources - Resolve every configured source to a directory and its provenance.
- unpinned_
source_ warnings - One warning per git source whose ref is missing or is not a pinned commit sha. The URL is printed without its userinfo, so no credential leaks.