Metadata-Version: 2.5
Name: trustsight
Version: 0.31.0
Summary: Security analysis and intelligence platform for the AUR ecosystem
Project-URL: Homepage, https://github.com/emiliano-go/trustsight
Project-URL: Documentation, https://docs.trustsight.org/
Project-URL: Repository, https://github.com/emiliano-go/trustsight
Project-URL: Issues, https://github.com/emiliano-go/trustsight/issues
Project-URL: Changelog, https://docs.trustsight.org/changelog/
Author-email: Emiliano Gandini Outeda <e@emiliano-go.com>
License-Expression: MIT
License-File: LICENSE
Keywords: arch-linux,aur,pkgbuild,security,vetting
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Security
Classifier: Topic :: System :: Archiving :: Packaging
Requires-Python: >=3.11
Requires-Dist: cryptography>=42.0
Requires-Dist: pydantic>=2.0
Requires-Dist: pygit2>=1.20.1
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.0
Requires-Dist: tldextract>=5.0
Requires-Dist: typer>=0.12
Provides-Extra: credentials
Requires-Dist: keyring>=24.0; extra == 'credentials'
Provides-Extra: dev
Requires-Dist: hypothesis; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-xdist>=3.8.0; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: tree-sitter-bash>=0.23; extra == 'dev'
Requires-Dist: tree-sitter>=0.23; extra == 'dev'
Provides-Extra: docs
Requires-Dist: seoslug==2.3.0; extra == 'docs'
Requires-Dist: zensical==0.0.51; extra == 'docs'
Description-Content-Type: text/markdown

<h3 align="center">TrustSight</h3>

<p align="center">
  <em>An immune system for the AUR.</em>
</p>

<p align="center">
  <a href="https://docs.trustsight.org/">
    <img src="https://img.shields.io/badge/Docs-docs.trustsight.org-2C7BE5?style=for-the-badge&logo=readthedocs&logoColor=white" alt="Documentation">
  </a>
  <a href="https://www.python.org/downloads/">
    <img src="https://img.shields.io/badge/Python-3.11%2B-3776AB?logo=python&logoColor=white&style=for-the-badge" alt="Python">
  </a>
  <a href="LICENSE">
    <img src="https://img.shields.io/badge/License-MIT-10AC84?style=for-the-badge" alt="License">
  </a>
  <a href="https://deepwiki.com/emiliano-go/trustsight">
    <img src="https://img.shields.io/badge/Ask-DeepWiki-007ec6?style=for-the-badge" alt="Ask DeepWiki">
  </a>
  <a href="https://github.com/emiliano-go/trustsight/actions/workflows/release-tests.yml">
    <img src="https://img.shields.io/github/actions/workflow/status/emiliano-go/trustsight/release-tests.yml?style=for-the-badge&logo=github&label=Release%20tests" alt="Release tests">
  </a>
  <a href="https://pypi.org/project/trustsight/">
    <img src="https://img.shields.io/pypi/v/trustsight?logo=pypi&logoColor=white&style=for-the-badge&cacheSeconds=60" alt="PyPI">
  </a>
  <a href="https://watcher.trustsight.org/">
    <img src="https://img.shields.io/badge/watcher-watcher.trustsight.org-8250DF?style=for-the-badge&logo=linux&logoColor=white" alt="Live watcher">
  </a>
  <a href="https://ntfy.sh/trustsight-aur-1d8a3fd2">
    <img src="https://img.shields.io/badge/alert_feed-ntfy.sh-00897B?style=for-the-badge&logo=rss&logoColor=white" alt="Alert feed">
  </a>
  <a href="https://harness.trustsight.org/">
    <img src="https://img.shields.io/badge/harness-harness.trustsight.org-C2410C?style=for-the-badge&logo=target&logoColor=white" alt="Adversarial harness">
  </a>
</p>

<p align="center">
  <strong><a href="https://docs.trustsight.org/">Full documentation</a></strong>
  &nbsp;|&nbsp;
  <strong><a href="https://github.com/emiliano-go/trustsight">Source Code</a></strong>
</p>

---

TrustSight is immune-inspired security intelligence for the Arch User Repository. It audits PKGBUILD updates, remembers what the ecosystem has seen, recognizes changes that matter, and correlates campaigns across packages. It combines static analysis, supply-chain intelligence, behavioral heuristics, dependency graph analysis, threat intelligence, and historical correlation to turn package changes into deterministic, evidence-linked reports: what changed, who is behind it, and what the analysis could not see.

Beyond a single package, TrustSight tracks maintainer histories, package adoptions and orphan status, ownership transitions, release patterns, and dependency relationships. It uses those signals to identify unusual behavior, suspicious takeovers, stale package revivals, and coordinated activity across packages.

The unit of protection is the AUR ecosystem, not one machine. A bad update still lands on your machine, but the pattern that identifies it may only be visible across thousands of packages, maintainers, and update waves. TrustSight watches that surface at a scale one person cannot.

It is not an antivirus and not a gate. It is the sensing and memory layer of a system completed by people.

---

## Why an immune system?

An immune system does not only destroy pathogens. It watches, remembers, signals, and coordinates a response. TrustSight brings those functions to the AUR: a signed seed of prior ecosystem knowledge, local history, diverse recognition rules, campaign correlation, bounded alerting, and a report that names its own blind spots.

TrustSight is not the whole system. You triage and report. Maintainers and Arch volunteers act on reports. The watcher and public feed carry shared memory. The loop between those parts is the AUR immune system.

TrustSight detects, remembers, and correlates what one person cannot. You decide what matters.

[Read the full argument →](https://docs.trustsight.org/explanation/why-an-immune-system/)

---

## Setup

> **TrustSight is available on the AUR, maintained by this project.** The `trustsight` AUR package is built from `packaging/aur/PKGBUILD` in this repository. It gets no special trust for being the author's: it is an AUR package like any other, so inspect its PKGBUILD before installing. Source remains the recommended install, below.

```bash
# 1. Import the release signing key once (makepkg verifies the tarball's
#    detached signature; without the key it reports "unknown public key")
gpg --keyserver hkps://keys.openpgp.org \
  --recv-keys F759D6D49B0A395AB922414A5CC3B4C50D37E793

# 2. Install the latest release tag (the PKGBUILD pins one version)
git clone --depth 1 --branch "$(git ls-remote --tags --refs --sort=-v:refname \
  https://github.com/emiliano-go/trustsight.git 'v*' | head -1 | cut -d/ -f3)" \
  https://github.com/emiliano-go/trustsight.git
cd trustsight/packaging/aur
makepkg -si
# Or build the checkout in place, with no second download:
#   cd trustsight/packaging/dev && makepkg -si   # trustsight-dev, not a release

# 3. Scan your outdated AUR packages
trustsight review

# 4. Scan a package before install
trustsight inspect PACKAGE_NAME --allow-uninstalled --full-recipe
```

Requires **Python 3.11+** and **Arch Linux** (the tool discovers packages via `pacman -Qm`, `pacman -Sl` for local repos, or `--repo`/`--all-repos` flags).


---

## Security model

TrustSight is **evidence-producing**, not proof-of-safety. Read the [full security model](https://docs.trustsight.org/security-design/security-model/) for the threat model, invariants, and enforcement gates. It audits and does not install. The tool never runs the PKGBUILD, never executes extracted commands, and never modifies your system. Every finding is traceable to a specific diff line, URL, or novelty record. The output is a structured evidence report, not a gate. See [what TrustSight cannot see](https://docs.trustsight.org/explanation/limitations-and-uncertainty/).

> **Why static analysis?** TrustSight is a SAST tool by design: it never executes PKGBUILDs or fetches URLs declared by them, and runs before `makepkg`. Its only network egress is the AUR metadata snapshot and the signed baseline channel - never a source the package declares. For how to customize the detection surface, see [Why Static Analysis](https://docs.trustsight.org/explanation/static-analysis-and-resolution/).

---

## What it detects

| Attack / Risk | How TrustSight catches it |
|---|---|
| **Piped shell scripts** (`curl \| bash`, `base64 \| sh`) | Scans every new or changed line for command-subprocess pipelines (R001 / R002 / R003; 100% on the labelled fixtures) |
| **Obfuscated commands** (encoded strings, environment subversion like `LD_PRELOAD`) | Resolves variables and decodes known obfuscation patterns; flags build-environment tampering (H025, H036; decode-and-execute: X001/R003) |
| **Checksum disabled or removed** | Compares old vs new `sha256sums` / `md5sums` arrays (H001, H002, C004) |
| **Source URL typosquatting** (`githab.com` instead of `github.com`) | Character-level edit distance against known forge domains (confusable-domain pipeline) |
| **Package-name typosquatting** (e.g. `libuvc` resembling `libuv`) | Edit-distance comparison against more popular packages in the seed database (H029) |
| **URL swapped without a version bump** | Tracks source URL changes that are not accompanied by a new version (C003) |
| **Novel / never-before-seen URLs or maintainers** | Compares against the release-channel seed (195,023 known source URLs, 43,815 hashed maintainer identities and 224,423 dependency names, verified against the pinned key on import); flags first-seen domains and maintainers (novelty tier) |
| **Known-bad indicators** | Matches package URLs and strings against signed, federated IOC baselines from the release channel; reported in the IOC tier, outside the heuristic score |
| **Unicode bidi override attacks** (invisible characters that change how text displays) | Detects directionality overrides and homoglyph codepoints in PKGBUILD content (R013) |
| **Reviewer-directed instruction templates** in package metadata | Flags common reviewer-manipulation templates as a high-severity tripwire (R012); a match requires review, not an inference about author intent |
| **GPG verification removed** | Detects when `validpgpkeys` was populated and is now empty (H024) |
| **Untrusted maintainer takeover** | A maintainer change to someone never seen before (H026) |
| **Stale package revived** | A package with no updates for over a year suddenly gets one (H022) |
| **Accelerated release cadence** | 3+ commits in the last 24 hours (H028, informational) |
| **Sabotage payloads** (fork bombs, `rm -rf /`, disk wiping, permission sabotage, service disruption, coin miners, log wiping) | Command-position matching that distinguishes the build sandbox from the system: `rm -rf "$srcdir/x"` is housekeeping, `rm -rf /` is not (S001-S011) |
| **Orphan hijacking** (a package adopted from orphan, then its recipe rewritten with no upstream change) | The AUR maintainer field against the last recorded state, plus a recipe-only-change signature and the composition of both with an unpinned build fetch (H086-H088) |
| **Build steps that fetch unpinned code** (`npm install`, `pip install`, `cargo fetch` in a build function) | Not scored - reported as the `unpinned_build_deps` coverage gap, because what the build will run is not in the analysed text and no checksum covers it |
| **Risky files in the built package** (setuid, file capabilities, undeclared units, eBPF) | The optional **L9 build lane** inspects an externally built package manifest (`trustsight verify-build --manifest MANIFEST`) and reports artifact rules A001 through A008. It is off by default, never blended into the static score, and reports `l9_unavailable` when no manifest is supplied. |
| **Risk in AUR dependencies** | Dependencies are analysed as packages in their own right, to a configurable [depth](#dependency-depth) |

## What it cannot detect

| Limitation | Why |
|---|---|
| **Malicious upstream release tarballs** | TrustSight audits the PKGBUILD, not the binaries it downloads. A clean build file can point to a compromised tarball. |
| **Deliberately unremarkable attacks** | If no commands are added, no URLs change, and no checksums are disabled, there is no diff signal. The update is invisible to this kind of analysis. |
| **Dependencies beyond the configured depth** | AUR dependencies *are* analysed - see [Dependency depth](#dependency-depth) - but only to the configured number of levels. Past that, and past the hard ceilings on an exhaustive walk, the closure is unread and the result says so with a `deps_not_scanned` coverage gap. |
| **Runtime attacks** | The tool never executes the PKGBUILD, never runs extracted commands, and never modifies your system. |
| **Zero-day structural attacks** | Rules are pattern-based and calibrated against a known corpus. A novel attack that leaves no matching pattern will not fire. |

The default review output shows findings and a verdict, not score or risk columns. Add `--score` or `--risk` when you want the numeric band in the terminal. The default review profile flags scores above 20; on the locked benign corpus that is about **1 in 15** review workload items. `quiet` and `strict` profiles change the queue without changing scores or bands. A clean score means no known risk signals fired, not that the package is safe. This is a point-in-time corpus measurement, not a universal false-positive rate. See [what TrustSight cannot see](https://docs.trustsight.org/explanation/limitations-and-uncertainty/) for details.

---

## How it works

A run is deterministic: the same diff, effective configuration, and stored observation history always produce the same evidence record. The pipeline is:

1. **Diff** the old and new PKGBUILD, then read the post-patch end state
2. **Resolve** variable references in `source`, `sha256sums`, `pkgver`, `pkgrel`, and `package()`; anything not statically resolvable becomes a coverage gap
3. **Apply rules** for structural changes, suspicious commands, typosquatting, evasion and hidden text, install-script and persistence behaviour, and the `U`-series upstream manifests
4. **Classify URLs** into trust buckets (trusted forge, official, raw hosting, unknown, homograph)
5. **Check novelty** against the local database of known URLs and maintainers, and follow the AUR dependency closure to its configured depth
6. **Read declared verification**; checksums, PGP keys, signature sources, and commit/tag pins are reported at weight 0
7. **Report** the findings, the change summary, and any coverage gaps

Verdicts are template-based, describing each triggered finding in plain English. All output is deterministic and generated locally.

### The evidence layers

Every rule carries an **evidence layer**, `L1`-`L8`, naming the *kind* of evidence a finding is - not a stage an attacker passed through. A finding at `L4` does not mean `L1`-`L3` were cleared, and a layer with no finding is not a safety certificate.

| Layer | The question its evidence answers | Rule families |
|---|---|---|
| `L1` Structural coherence | Does the change hang together as an honest edit? | `C`, `P` |
| `L2` Readability | Was anything hidden from the reader? | `W`, and the refusal rules `X026`/`X027` |
| `L3` Payload signature | Does it do a known-bad thing? | `R`, `S`, `U` |
| `L4` Evasion shape | Was it *written* to defeat reading? | `X`, `E` |
| `L5` Behavioral suspicion | Does the package's story make sense? | `H` |
| `L6` Ecosystem memory | Has the ecosystem seen this before? | `D`, `T` |
| `L7` Known indicators | Is it on the list? | `I` |
| `L8` Campaign correlation | Do other packages tell the same story? | `G` |

The report keeps detection and coverage separate: `L3 fired` says the payload-signature check matched, `L1 passed` says the structural check was read in full and stayed silent (not that the update is safe), and `L8 not_applicable` says the check could not run on a single package. `M` reasons about other findings and fires *at* their layer, so it owns no layer of its own. The optional `L9` build lane (`A001` through `A008`) inspects the built package and is not one of the eight. See [How TrustSight groups security evidence](https://docs.trustsight.org/security-design/assurance-layers/).

Signals come from 283 documented rules across eleven rule families: 37 detection rules (R-series, TOML-configurable), 109 heuristic rules (H-series), 35 code-structure rules (C001-C035), 5 dependency-graph rules (D001-D005), 11 sabotage rules (S001-S011), 34 crossfire anti-evasion rules (X001-X034), 6 meta rules (M001-M006), 3 entropy rules (E001-E003), 12 temporal rules (T001-T012), 16 correlation rules (G001-G011, G012-G016), and 15 manifest rules (U001-U015). Two further families are reported but never weighted: declared practice (P001-P009) and unverifiable (W001-W015), the latter naming what an analysis could not read. The optional artifact lanes add sixteen artifact rules (A001-A016), reported outside the heuristic: A001 through A008 are the L9 build lane; A009/A010/A014/A015/A016 are the opt-in upstream-source lane; A011-A013 inspect shipped hooks, udev rules and install scripts. Calibration uses a locked, point-in-time 8,393-diff benign corpus of real AUR updates and 213 self-authored, labelled malicious fixtures; it is regression evidence, not an independent recall claim. See [Benchmarks and Methodology](https://docs.trustsight.org/explanation/detection-and-evidence/) and the [blinded-evaluation intake](https://docs.trustsight.org/contributing/blinded-evaluation/) for scope.

---

## License

MIT

---

## Documentation hub

| Section | Description |
|---|---|
| [Overview](https://docs.trustsight.org/start-here/quickstart/) | Install TrustSight, run a first review, understand the report |
| [Workflows](https://docs.trustsight.org/workflows/) | Auditing before update, yay and paru, CI, triage, configuration |
| [Security & Design](https://docs.trustsight.org/security-design/security-model/) | The security model, boundaries, evidence model and threat model |
| [Rules](https://docs.trustsight.org/rules/) | Categories, series, mechanics and every rule definition |
| [Reference](https://docs.trustsight.org/reference/) | CLI, Python API, configuration, report schema and exit codes |
| [Contributing](https://docs.trustsight.org/contributing/) | Development, rule authoring, evaluation, releases and docs policy |
| [Vulnerability Reporting](https://docs.trustsight.org/security-design/vulnerability-reporting/) | How to report a vulnerability |
| [License](https://docs.trustsight.org/license/) | MIT full text |

## Agent discovery

The docs origin publishes an API catalog, an AI/ARD catalog, an agent-skills
index, a read-only MCP server card and `/auth.md`. MkDocs does not copy
dot-directories, so the source files live under `docs/assets/well-known/` and
`docs/assets/agent/`, and `docs/_redirects` serves them at the well-known
paths. `docs/_headers` adds the `Link`, `Vary: Accept`, CORS and content-type
headers.
