oliver-kriska/claude-elixir-phoenix / targets/amp/skills/phx-deps-audit
phx-deps-audit
FlaggedAudit Hex deps for supply-chain security risk — bidi chars, compile-time exec, maintainer changes, typosquats, CVEs. Use after mix deps.update, when checking if a package upgrade is safe, or reviewing mix.lock PR diffs.
scripts/fetch_tarball.sh
View on GitHub#!/usr/bin/env bash
# scripts/fetch_tarball.sh — fetch real Hex tarballs into the local cache.
# Used by /phx:deps-vet (single-vet) and by calibration runs against the
# benign corpus; the offline smoke fixtures never call it.
#
# Usage:
# bash scripts/fetch_tarball.sh phoenix 1.7.21
# bash scripts/fetch_tarball.sh --batch batch.txt # "<pkg> <version>" per line
# bash scripts/fetch_tarball.sh --prune # drop tarballs >30 days old
#
# Cache layout:
# ${AUDIT_TMPDIR}/corpus/<pkg>/<version>/
# ├── <pkg>-<version>.tar # raw Hex tarball
# └── contents/ # extracted source
#
# Soft dependency: requires a Mix project context for `mix hex.package fetch`.
# If invoked outside a Mix project, falls back to direct repo.hex.pm download.
set -u
CACHE_ROOT="${HEX_AUDIT_CACHE:-${HOME}/.cache/phx-deps-audit/corpus}"
mkdir -p "${CACHE_ROOT}"
fail() { echo "fetch: $*" >&2; exit 1; }
info() { echo "fetch: $*" >&2; }
fetch_one() {
local pkg="$1" ver="$2"
local dest="${CACHE_ROOT}/${pkg}/${ver}"
if [ -d "${dest}/contents" ]; then
info "cached: ${pkg} ${ver}"
return 0
fi
mkdir -p "${dest}/contents"
if command -v mix >/dev/null 2>&1 && [ -f mix.exs ]; then
# In a Mix project — use the canonical tool.
mix hex.package fetch "${pkg}" "${ver}" --output "${dest}/${pkg}-${ver}.tar" \
--unpack >/dev/null 2>&1 || fail "mix hex.package fetch failed for ${pkg} ${ver}"
# mix --unpack writes to a folder named ${pkg}-${ver}/; move into contents/
if [ -d "${dest}/${pkg}-${ver}" ]; then
mv "${dest}/${pkg}-${ver}"/* "${dest}/contents/" 2>/dev/null || true
rmdir "${dest}/${pkg}-${ver}" 2>/dev/null || true
fi
else
# Fallback: download tarball directly via curl. No checksum verification
# at this level — production audits validate via hex_metadata.config.
local url="https://repo.hex.pm/tarballs/${pkg}-${ver}.tar"
info "no mix project; falling back to direct download ${url}"
curl -fsSL "${url}" -o "${dest}/${pkg}-${ver}.tar" \
|| fail "curl failed for ${pkg} ${ver}"
(cd "${dest}/contents" && tar -xf "../${pkg}-${ver}.tar") \
|| fail "tar extraction failed for ${pkg} ${ver}"
# Hex inner archive is contents.tar.gz inside the outer tar
if [ -f "${dest}/contents/contents.tar.gz" ]; then
tar -xzf "${dest}/contents/contents.tar.gz" -C "${dest}/contents/" \
|| fail "inner contents.tar.gz extraction failed"
fi
fi
info "fetched: ${pkg} ${ver}"
}
prune() {
# Drop tarballs older than 30 days (cache TTL).
find "${CACHE_ROOT}" -type d -mtime +30 -exec rm -rf {} + 2>/dev/null || true
info "pruned entries older than 30 days"
}
main() {
case "${1:-}" in
--prune) prune ;;
--batch)
[ -f "$2" ] || fail "batch file not found: $2"
while IFS=' ' read -r pkg ver; do
[ -z "${pkg}" ] && continue
[[ "${pkg}" =~ ^# ]] && continue
fetch_one "${pkg}" "${ver}"
done < "$2"
;;
'')
fail "usage: fetch_tarball.sh <pkg> <version> | --batch <file> | --prune"
;;
*)
[ -n "${2:-}" ] || fail "version required"
fetch_one "$1" "$2"
;;
esac
}
main "$@"
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |