Skip to content

Add trust command for package trust verification#44

Merged
thebenignhacker merged 1 commit intomainfrom
feat/trust-command
Mar 14, 2026
Merged

Add trust command for package trust verification#44
thebenignhacker merged 1 commit intomainfrom
feat/trust-command

Conversation

@thebenignhacker
Copy link
Copy Markdown
Contributor

Summary

  • Add hackmyagent trust <package> for single package trust lookup
  • Add hackmyagent trust --audit <file> to scan package.json/requirements.txt dependencies
  • Add hackmyagent trust --batch pkg1 pkg2 for multi-package queries
  • Queries OpenA2A Registry trust API (same endpoints as ai-trust CLI)
  • Build passes, 908 existing tests pass

Test plan

  • npm run build clean
  • All 908 existing tests pass
  • Smoke tested all 3 modes against live registry

Adds `hackmyagent trust` command that queries the OpenA2A Registry
to check trust scores, vulnerability status, and dependency risk
for MCP servers, A2A agents, and AI tools before installation.

Three modes:
- `trust <package>` -- single package lookup
- `trust --audit <file>` -- audit package.json or requirements.txt
- `trust --batch pkg1 pkg2` -- batch lookup for multiple packages

Uses the same Registry API endpoints as ai-trust (added as dependency),
with output formatting consistent with HMA's existing color system.
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

Security Review: PR #44 - Add trust command for package trust verification

VERDICT: APPROVE

SUMMARY:

This PR adds a trust command for querying the OpenA2A Registry API to check trust scores for AI packages. The implementation includes three modes: single package lookup, batch lookup, and dependency file auditing. After thorough verification of all potential security concerns, I found no exploitable vulnerabilities. All user inputs are properly validated, external API calls are safe, file operations are protected, and the code follows secure patterns throughout.

FINDINGS:

None. All initially identified concerns were mitigated upon verification:

Verified Safe Patterns:

  1. URL Construction (lines 4649, 4669) - VERIFIED SAFE

    • registryUrl is sanitized via .replace(/\/+$/, '') at line 4908 before use
    • User-controlled name parameter is passed through URLSearchParams constructor which automatically URL-encodes values
    • No string concatenation or template injection possible
  2. Arbitrary File Read (line 4830) - VERIFIED SAFE

    • parseDepsFile() receives filePath from Commander option --audit <file>
    • Commander treats option values as raw strings (no shell expansion)
    • User explicitly provides the path they want to read (intended functionality)
    • No path traversal validation needed - user chooses which file to audit
    • Only supports package.json/requirements.txt (line 4869 throws on others)
  3. JSON Parsing (lines 4660, 4679, 4836) - VERIFIED SAFE

    • Line 4660: Parses response from Registry API (external but HTTPS, not arbitrary user input)
    • Line 4679: Same as above (batch endpoint)
    • Line 4836: Parses user's own package.json file (user chose to audit their own file)
    • Standard JSON.parse() errors are caught by outer try/catch (line 4915)
  4. ReDoS in Requirements Parsing (line 4857) - VERIFIED SAFE

    • Regex: /^([a-zA-Z0-9_-]+(?:\[[a-zA-Z0-9_,-]+\])?)/
    • Pattern is linear-time: single character class with optional bracketed section
    • No nested quantifiers or catastrophic backtracking paths
    • Bounded by line splits (one match per line)
  5. Integer Parsing (line 4909) - VERIFIED SAFE

    • parseInt(opts.minTrust, 10) with base-10 specified
    • Validated: isNaN(minTrust) || minTrust < 0 || minTrust > 4 (lines 4910-4913)
    • Safe range enforcement before use
  6. SSRF via Registry URL (lines 4649, 4669) - VERIFIED ACCEPTABLE

    • Default: https://api.oa2a.org (hardcoded constant line 4612)
    • User can override via --registry-url flag
    • Design Intent: Users should be able to point to alternate/dev registries
    • This is a CLI tool where users control their own environment
    • No automatic execution of untrusted URLs

All security boundaries are correctly enforced. The code properly handles user input, validates ranges, and safely interacts with external APIs.


Reviewed 3 files changed (15246 bytes)

@thebenignhacker thebenignhacker merged commit 51ced27 into main Mar 14, 2026
1 check passed
@thebenignhacker thebenignhacker deleted the feat/trust-command branch March 14, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant