Skip to content

feat: support GitHub repositories in scan - #125

Merged
Mr-Lucky merged 3 commits into
mainfrom
feat/scan-github-repository
Sep 2, 2026
Merged

feat: support GitHub repositories in scan#125
Mr-Lucky merged 3 commits into
mainfrom
feat/scan-github-repository

Conversation

@Mr-Lucky

@Mr-Lucky Mr-Lucky commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Add HTTPS GitHub repository support to agentguard scan.

  • Support scanning repositories by URL before installation.
  • Add --ref selection for branches, tags, fully qualified refs, and full commit SHAs.
  • Use bounded, non-interactive Git acquisition with cleanup retries.
  • Preserve existing local-directory scan behavior.
  • Document GitHub repository scanning in the README and Codex guide.

Type

  • Bug fix
  • New feature / detection rule
  • Refactoring
  • Documentation

Testing

  • npm run build passes
  • npm test passes (604 tests)
  • Manually tested the change

Related Issues

Closes #

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

AgentGuard PR Review

  1. severity: high — src/scanner/source.ts / resolveScanSource fetch path
    The new GitHub scan path allows --ref to be any branch/tag/fully qualified ref and passes the resolved ref directly to git fetch ... origin <expectedRevision>. For refs that resolve to a moving branch/tag, the code then checks out the fetched commit by SHA, but it does not re-verify that the fetched commit still matches the advertised ref at checkout time. A repo update between ls-remote and fetch can produce a scan of a different revision than requested, making results non-reproducible and potentially bypassing “scan before install” assumptions.
    Fix: fetch and verify the exact advertised ref atomically where possible, or re-run ls-remote after fetch and abort unless the resolved SHA still matches the requested ref; for reproducibility, prefer requiring a full commit SHA in security-sensitive flows.

  2. severity: medium — src/scanner/source.ts / normalizeGithubRepositoryUrl and repo URL handling
    The scanner only accepts https://github.com/owner/repository and rejects other GitHub-hosted HTTPS forms (e.g. uppercase hostnames, .git with queryless alternate paths are okay, but www.github.com, enterprise GitHub, or URLs with encoded path variants are not). More importantly, the regex accepts any single path segment after the owner, so some malformed repository URLs can be normalized and sent to git before later failure, which can be used to trigger unnecessary network access and confusing error paths.
    Fix: validate the URL with new URL(), require exact github.com host, and perform stricter path segment checks before any git invocation; clearly reject unsupported GitHub Enterprise/alternate hosts up front.

@Mr-Lucky
Mr-Lucky merged commit a1dab9d into main Sep 2, 2026
4 checks passed
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.

2 participants