Skip to content

l0.DependencyControl.FeedTrust

FeedTrust = require "l0.DependencyControl.FeedTrust"
local FeedTrust = require("l0.DependencyControl.FeedTrust")

FeedTrust

Owns DependencyControl's feed-trust model: the official trust lists (loaded from DepCtrl's own feed), the merged trusted/blocked sets (official plus the user's config), the trust queries the resolver asks per candidate, and the user-config mutations. Built and exposed by Updater as updater.feedTrust.

Constructor

feedTrust = FeedTrust config, logger, feedLoader
local feedTrust = FeedTrust(config, logger, feedLoader)
param type description
config ConfigView The updater's config view; its c holds extraFeeds/trustedFeeds/blockedFeeds.
logger? Logger Logger for the trust/block confirmations.
feedLoader FeedLoader Loads DependencyControl's own feed for the official trust lists.

Instance methods

getOfficialTrustedFeeds

feedTrust\getOfficialTrustedFeeds!
feedTrust:getOfficialTrustedFeeds()

Returns the feed URLs DependencyControl officially trusts (its own feed URL plus the feeds it advertises).

Returns:

  • trustedFeeds table<string,boolean>

getOfficialBlockedFeeds

feedTrust\getOfficialBlockedFeeds!
feedTrust:getOfficialBlockedFeeds()

Returns DependencyControl's official block list as raw {url, matchMode?, reason?} entries, exactly as declared in its own feed.

Returns:

getTrustedFeeds

feedTrust\getTrustedFeeds!
feedTrust:getTrustedFeeds()

Returns the merged trusted feed-URL set: the official feeds plus the user's own trusted feeds (extraFeeds and trustedFeeds). Cached; invalidated when the user's lists change.

Returns:

  • trustedFeeds table<string,boolean>

getBlockedFeeds

feedTrust\getBlockedFeeds!
feedTrust:getBlockedFeeds()

Returns a merged, normalized list of the "officially" blocked feeds (as per DependencyControls own feed), followed by the user's blocked feeds. Block overrides trust.

Returns:

  • blockedFeeds BlockedFeedEntry[] — The merged list of normalized block entries, each tagged isOfficial when it comes from the official feed.

isTrusted

feedTrust\isTrusted url
feedTrust:isTrusted(url)

Reports whether a feed URL is in the merged trusted set (exact match).

param type description
url? string The feed URL to check.

Returns:

  • trusted boolean — True when the feed URL is trusted, false otherwise.

isUserTrusted

feedTrust\isUserTrusted url
feedTrust:isUserTrusted(url)

Reports whether a feed URL is trusted through one of the user's own lists (extraFeeds or trustedFeeds), as opposed to DependencyControl's official set. A block does not factor into this.

param type description
url? string The feed URL to check.

Returns:

  • userTrusted boolean — True when the feed URL is in one of the user's trust lists.

isOfficiallyTrusted

feedTrust\isOfficiallyTrusted url
feedTrust:isOfficiallyTrusted(url)

Reports whether a feed URL is in DependencyControl's official trusted set (its own feed plus the feeds it advertises), as opposed to the user's own lists. A block does not factor into this.

param type description
url? string The feed URL to check.

Returns:

  • officiallyTrusted boolean — True when the feed URL is officially trusted.

isBlocked

feedTrust\isBlocked url
feedTrust:isBlocked(url)

Reports whether a feed URL is matched by any block entry (official or user).

param type description
url? string The feed URL to check.

Returns:

  • blocked boolean — True when the feed URL is blocked, false otherwise.

getBlockingEntry

feedTrust\getBlockingEntry url
feedTrust:getBlockingEntry(url)

Returns the block entry that matches a feed URL or nil if none does. Useful to get the reason for a block.

param type description
url? string The feed URL to check.

Returns:

getTrustStatus

feedTrust\getTrustStatus url
feedTrust:getTrustStatus(url)

Classifies a feed URL's trust: a block overrides any trust, and official vs user trust are reported independently (a feed in both is TrustedBoth).

param type description
url? string The feed URL to classify.

Returns:

getFetchDecision

feedTrust\getFetchDecision url
feedTrust:getFetchDecision(url)

Classifies whether a feed may be fetched, from its block/trust status and the fetchUntrustedFeeds policy: a blocked feed is always denied, a trusted feed always allowed, and an untrusted feed follows the policy (always → allow, never → deny, prompt → prompt); an unrecognized policy fails closed (deny). It neither prompts nor mutates trust state.

param type description
url? string The feed URL to classify.

Returns:

shouldFetch

feedTrust\shouldFetch url
feedTrust:shouldFetch(url)

Resolves whether a feed may be fetched now, asking through the prompter (see setPrompter) when the policy is prompt. A prompt answer is remembered for the session so the same feed isn't asked twice; with no prompter available (e.g. headless), a prompt policy denies — the safe default.

param type description
url? string The feed URL to check.

Returns:

  • fetch boolean — True when the feed may be fetched.

setPrompter

feedTrust\setPrompter prompter
feedTrust:setPrompter(prompter)

Sets the callback consulted for an untrusted feed under the prompt policy. It receives the feed URL and this FeedTrust (so it may trust/block the feed) and returns whether to fetch it now.

param type description
prompter? fun(url: string, feedTrust: FeedTrust): boolean The prompter, or nil to remove it.

trust

feedTrust\trust feedUrl
feedTrust:trust(feedUrl)

Adds a feed URL to the user's trustedFeeds list in the DependencyControl config file (ignoring an exact duplicate).

param type description
feedUrl string The exact (case-sensitive) feed URL to trust.

Returns:

  • added boolean — True when the feed was added to the user's trustedFeeds, false when it was already present.

untrust

feedTrust\untrust feedUrl
feedTrust:untrust(feedUrl)

Removes a feed URL from the user's trustedFeeds list in the DependencyControl config file. Feeds trusted through the official list or extraFeeds are unaffected; block the feed to override those.

param type description
feedUrl string The exact (case-sensitive) feed URL to untrust.

Returns:

  • removed boolean — True, when the feed was removed from the user's trustedFeeds, false when it wasn't present.

block

feedTrust\block feedUrl, opts
feedTrust:block(feedUrl, opts)

Adds a new entry to the user's blockedFeeds in the DependencyControl config file, unless a block with the same url and match mode is already present.

param type description
feedUrl string The feed URL or URL prefix to block.
opts? { matchMode?: BlockedFeedMatchMode, reason?: string } The match mode (default prefix) and an optional reason.

Returns:

  • added boolean — False when an equivalent block (same url and match mode) was already present.

unblock

feedTrust\unblock feedUrl
feedTrust:unblock(feedUrl)

Removes every entry from the user's blockedFeeds list in the DependencyControl config file, whose url matches feedUrl. Does not affect the official block list.

param type description
feedUrl string The blocked url/prefix to remove.

Returns:

  • removed boolean — True when a user block was removed, false when no user block matched.

addExtraFeed

feedTrust\addExtraFeed feedUrl
feedTrust:addExtraFeed(feedUrl)

Adds a feed URL to the user's extraFeeds config (ignoring an exact duplicate) and persists it. Extra feeds are trusted and act as discovery roots.

param type description
feedUrl string The exact (case-sensitive) feed URL to add.

Returns:

  • added boolean — False when the feed was already in the user's extraFeeds.

removeExtraFeed

feedTrust\removeExtraFeed feedUrl
feedTrust:removeExtraFeed(feedUrl)

Removes a feed URL from the user's extraFeeds config and persists it.

param type description
feedUrl string The exact (case-sensitive) feed URL to remove.

Returns:

  • removed boolean — False when the feed was not in the user's extraFeeds.

Class methods

urlMatchesPrefix

FeedTrust\urlMatchesPrefix url, prefixes
FeedTrust:urlMatchesPrefix(url, prefixes)

Reports whether a URL is matched by any of the given prefixes. Case-insensitive to resist evasion attempts.

param type description
url? string The feed URL to check.
prefixes? string[] The list of prefixes to match against.

Returns:

  • matches boolean — True when the feed URL matches any of the prefixes, false otherwise.

matchesBlockEntry

FeedTrust\matchesBlockEntry url, entry
FeedTrust:matchesBlockEntry(url, entry)

Reports whether a URL is matched by a single block entry, per its match mode. All matches are case-insensitive to combat evasion attempts.

param type description
url? string The feed URL to check.
entry BlockedFeedEntry A normalized block entry.

Returns:

  • matches boolean — True when the feed URL is blocked, false otherwise.

Fields

field type description
userTrustedFeeds table<string,boolean> The user's own trusted feeds — the union of extraFeeds and trustedFeeds. Cached, invalidated on mutation. Read-only.
defaultFetchUntrustedFeeds FetchUntrustedFeeds

Enums

BlockedFeedMatchMode

member value description
Prefix "prefix" matches any feed URL starting with this value (case-insensitive)
Exact "exact" matches only this exact feed URL (case-insensitive)

FeedTrustStatus

member value description
TrustedOfficial "trusted-official" trusted only through DependencyControl's official set
TrustedUser "trusted-user" trusted only through one of the user's own lists (extraFeeds or trustedFeeds)
TrustedBoth "trusted-both" trusted through both the official set and one of the user's own lists
Untrusted "untrusted" neither trusted nor blocked (the default)
Blocked "blocked" matched by the block list, which overrides trust

FeedFetchDecision

member value description
Allow "allow" fetch without asking (trusted, or untrusted under fetchUntrustedFeeds = always)
Deny "deny" never fetch (blocked, or untrusted under fetchUntrustedFeeds = never)
Prompt "prompt" ask the user before fetching (untrusted under fetchUntrustedFeeds = prompt)

Types

BlockedFeedEntry

A normalized feed block entry: the URL/prefix to match, how to match it, and why.

field type description
url string The feed URL or URL prefix to match.
matchMode BlockedFeedMatchMode How url is matched against a candidate feed URL.
reason? string Human-readable explanation of why the feed is blocked.
isOfficial? boolean True for an entry from the official block list (read-only); false for a user block.