feat: Add proxy_install_only config to restrict proxy to download commands

Introduces proxy_install_only (default: false) which, when enabled,
skips the proxy for package manager commands that do not download
packages (e.g. npm ls, pip list), avoiding unnecessary MITM overhead.

- Add ProxyInstallOnly to Config and config template
- Add IsKnownDownloadCommand / MayDownloadPackages to ParsedCommand
- Add DownloadCommands to npm and pypi PM configs covering update,
  ci, audit, dlx, exec, x, download, run and equivalents per PM
- Extract shared runner.Execute used by both proxy flow and guard
- Proxy flow short-circuits to runner.Execute for non-download commands
  when proxy_install_only=true
This commit is contained in:
Sahilb315
2026-04-13 20:15:50 +05:30
parent 887984612c
commit da098a51a8
11 changed files with 387 additions and 69 deletions
+13
View File
@@ -38,13 +38,26 @@ type ParsedCommand struct {
// ManifestFiles contains the list of manifest files to install from
// (e.g., ["requirements.txt"] for pip install -r requirements.txt)
ManifestFiles []string
// IsKnownDownloadCommand is true for commands that may download packages but are not
// fully parsed (e.g., npm update, npm ci, poetry update). Used by the proxy to decide
// whether to intercept when proxy_install_only is enabled.
IsKnownDownloadCommand bool
}
// IsInstallationCommand returns true if command installs packages (explicit targets or from manifest).
// This is used by guard mode where we need to know which packages are being installed.
func (pc *ParsedCommand) IsInstallationCommand() bool {
return pc.HasInstallTarget() || pc.HasManifestInstall()
}
// MayDownloadPackages returns true if the command may download packages from a registry.
// This is broader than IsInstallationCommand and includes commands like npm update or npm ci
// that download packages but are not fully parsed. Used by the proxy to decide interception scope.
func (pc *ParsedCommand) MayDownloadPackages() bool {
return pc.IsInstallationCommand() || pc.IsKnownDownloadCommand
}
func (pc *ParsedCommand) HasInstallTarget() bool {
return len(pc.InstallTargets) > 0
}