Commit Graph
113 Commits
Author SHA1 Message Date
Abhisek DattaandGitHub 51c68c4cc4 Merge branch 'main' into feat/experimental-sandbox-support
Signed-off-by: Abhisek Datta <abhisek.datta@gmail.com>
2026-01-12 11:13:04 +05:30
Abhisek DattaandGitHub c0122898ca feat: Add support for setup-info command (#108)
* feat: Add support for setup-info command

* fix: Code review fixes

* fix: Add event log info
2026-01-11 19:25:13 +05:30
Sahil BansalandGitHub 11481c3f4c remove windows proxy limitation (#107)
* remove windows proxy limitation

* move setup cmd details to a single place
v0.3.2
2026-01-11 10:05:19 +05:30
f851a1ebba remove process control code to pause/resume process (#106)
Co-authored-by: Abhisek Datta <abhisek.datta@gmail.com>
2026-01-10 11:21:24 +00:00
f50d296935 add e2e and alias for npx, pnpx (#105)
* add e2e and alias for npx, pnpx

* Update .github/workflows/pmg-e2e.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>

---------

Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-10 16:47:43 +05:30
Sahil BansalandGitHub ca224f523c enable support for proxy mode for npm package managers (#104)
Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>
2026-01-10 00:24:45 +05:30
31f23fd065 Add support for package executors and support for PTY handling (#100)
* define contract for package executors

* introduce npx executor

* add npx and pnpx cmd support

* fix typo

* rm PackageExecutor and depend on PackageManager interface

* add support for PTY to handle parent-child process interaction

* refactor PTY handling in proxy flow

* enforce interactiveSession interface check

* close reader explicitly and clean npm version for pkg executors

* rm interaction from interceptors

* add docs and wait for outputRouter before exit

* add support for non interactive TTY for proxy mode

* add support for CI env var check for non interactive tty proxy mode

* update readme to include npx, pnpx support

* Update internal/flows/proxy_flow.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>

* update ptyx lib

* fix docs typo

---------

Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-09 22:03:42 +05:30
Abhisek DattaandGitHub a373b5b243 docs: Add doc for trusted packages and proxy mode (#102) v0.3.1 2026-01-09 13:56:48 +00:00
Abhisek Datta 65753ebc13 fix: Seatbelt translator handle glob 2026-01-09 19:00:19 +05:30
Abhisek Datta 9cb5345bd6 feat: Add support for config templates 2026-01-09 18:46:08 +05:30
Abhisek Datta e72c1d6324 test: Add policy test 2026-01-09 15:00:24 +05:30
Abhisek Datta 66b9279924 fix: Sandbox profile loader from file should use path for caching 2026-01-09 12:52:16 +05:30
Abhisek Datta 188f6f3d90 test: Add test for seatbelt sandbox driver 2026-01-09 12:35:15 +05:30
Abhisek Datta 3cc09db342 test: Remove unused var 2026-01-09 12:28:21 +05:30
1229246926 Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Abhisek Datta <abhisek.datta@gmail.com>
2026-01-09 12:26:52 +05:30
Abhisek Datta b38d177707 fix: Sandbox executor 2026-01-08 20:51:15 +05:30
Abhisek Datta ced873d98d fix: Handle the case when package manager policy is explicitly disabled 2026-01-08 20:43:09 +05:30
Abhisek Datta a550d26a3b chore: Go mod cleanup 2026-01-08 20:37:13 +05:30
Abhisek Datta cc1dc065f6 fix: Update config template 2026-01-08 20:32:22 +05:30
Abhisek Datta 774d21fc32 fix: Remove violation mode 2026-01-08 20:27:05 +05:30
Abhisek Datta cb081348fa fix: Misc cleanup fixes 2026-01-08 16:35:22 +05:30
Abhisek Datta eaeaff9cb8 chore: Cleanup sandbox 2026-01-08 16:32:49 +05:30
Abhisek Datta 45049b001d chore: Cleanup sandbox policy 2026-01-08 16:26:18 +05:30
Abhisek Datta 8ba18338d9 chore: Cleanup sandbox registry 2026-01-08 16:22:31 +05:30
Abhisek Datta eeeed76f07 fix: Misc cleanup fixes 2026-01-08 16:17:59 +05:30
Abhisek Datta bb3e001e87 test: Add variable interpolation test 2026-01-08 16:06:18 +05:30
Abhisek Datta f07d8e6a38 fix: Add support for sandbox cleanup 2026-01-08 14:30:33 +05:30
Abhisek Datta 9f77cca5e5 fix: Apply API 2026-01-08 14:20:47 +05:30
Abhisek Datta b92ba00cfa refactor: Sandbox for separation of boundaries 2026-01-08 14:11:10 +05:30
Abhisek Datta aa2a6cc214 fix: Misc fixes 2026-01-08 13:50:21 +05:30
Abhisek Datta 8492fcf93d refactor: Remove concept of PM_CACHE 2026-01-08 13:42:05 +05:30
Abhisek Datta ed59693f88 feat: Sandbox implementation with seatbelt 2026-01-08 13:40:22 +05:30
Sahil BansalandGitHub 6e830c4c3d update node to use v24 (#99) 2026-01-08 06:48:57 +05:30
Abhisek DattaandGitHub 1684e25cc9 fix: Use separate event for trusted package allowed (#98) 2026-01-08 01:03:31 +05:30
Abhisek DattaandGitHub 0603df8c25 docs: Update README (#97)
* docs: Update README

* docs: Update README
v0.3.0
2026-01-07 18:54:18 +00:00
Abhisek DattaandGitHub 1c319eba0e fix: Proxy flow should respect trusted packages (#96)
* fix: Handle trusted packages in proxy flow

* perf: Pre-parse trusted PURLs

* fix: Code review fixes

* fix: Remove unused config
2026-01-08 00:15:02 +05:30
Sahil BansalandGitHub 028e78aed8 rm npm progress bar flag (#95) 2026-01-07 17:17:00 +05:30
Sahil BansalandGitHub 4fb147b0fb add unit tests for validating config template (#94)
* add unit tests for validating config template

* add defensive check

* update asserts
2026-01-07 07:59:32 +00:00
779deeb23d feat: Add Support for Proxy Based Npm Interceptor (#87)
* feat: Add experimental proxy based npm interceptor

* refactor: Analysis cache

* ci: Add E2E for npm proxy

* fix: Handle dry-run in proxy flow

* fix: Handle special case for scope package name

* fix: Misc fixes

* fix: Code review fixes

* fix: Code review fixes

* refactor: Reusable code into base registry interceptor

* Pause npm process during user confirmation (#90)

* pause npm process when prompting user for confirmation

* disable progress bar

* fix logging and close chan on return

* update use of deprecated field

* refactor: Separation of concerns for handling process state

* fix: Safe permission for cert file

* fix: Handle nil check for interaction hook

* fix: Add test for base registry

* Fix goreleaser for windows build (#93)

* introduce platform specific process control

* rename common.go to common_flow.go

* feat: Add support for pause resume on windows

* fix: Code review fixes

* test: Add confirmation handler tests

---------

Co-authored-by: Sahil Bansal <bansalsahil315@gmail.com>
2026-01-07 13:22:08 +05:30
20c854e473 feat: Config Persistence & API (#83)
* introduce a persistent config

* add tests and refactor config creation

* update config handling and add support for removing config

* add support to skip suspicious pkgs marked as trusted

* add support for config dir Env & unexport functions

* small fixes

* add assert for dir

* fix tests

* fix shell source line & trusted pkgs parsing

* fix flag inconsistency

* update config to read on each invocation and create if does not exist

* fix flags value being overridden

* remove redundant func call

* modify trusted pkg check to be config bound

* modify RemoveConfig to rm files & not dir. add tests for paths.go

* add versions for package for e2e

* modify tests to reset config

* fix: Simplify config persistence

* fix: Misc comments

* fix: Misc fix

* fix: Do not overwrite config file if exists

* fix: Do not overwrite config file if exists

* fix: Config cobra command should override and not replace

* fix: Create dir before writing config template

* fix: Create dir before writing config template

* fix: Misc refactoring

* test: Add test for is trusted package version

* Update cmd/setup/setup.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Abhisek Datta <abhisek.datta@gmail.com>

* Update config/config.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Abhisek Datta <abhisek.datta@gmail.com>

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Abhisek Datta <abhisek.datta@gmail.com>

* fix: Remove unused constant in config

* fix: Resolve conflict with event logger

* docs: Add doc for eventlogger.Logger interface

* test: Add E2E for config file creation

* fix: Code review fixes

---------

Signed-off-by: Abhisek Datta <abhisek.datta@gmail.com>
Co-authored-by: Sahilb315 <bansalsahil315@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-01 12:33:52 +05:30
EapolSniperandGitHub 698bd3dd13 Add comprehensive event logging system (#82)
* Add comprehensive event logging system with OS-specific location and rotation

Features:
- Event logging for security-relevant events (malware detection, installations)
- OS-specific default log locations (~/.pmg/logs/ on macOS/Linux, %LOCALAPPDATA%\pmg\logs\ on Windows)
- Automatic 7-day log rotation with daily log files (YYYYMMDD-pmg.log format)
- Support for custom log files via --log flag
- Thread-safe JSON logging with zero external dependencies

Implementation:
- New internal/eventlog package with comprehensive logging functionality
- Integration with guard.go to log malware detections and blocks
- Integration with main.go for initialization and cleanup
- Log file naming: YYYYMMDD-pmg.log (e.g., 20251216-pmg.log)
- Fail-safe design - PMG continues if logging fails

Event Types:
- malware_blocked: Malicious package blocked from installation
- malware_confirmed: User proceeded with flagged package
- install_allowed: Clean package installation allowed
- install_started: Package manager command initiated
- error: Error events

Testing:
- Comprehensive test suite with 6 passing tests
- Verified with real malware detection (e.g., @postman/tunnel-agent)
- Works with all package managers (npm, pip, etc.)

Technical Details:
- Thread-safe with mutex protection
- JSON format for easy parsing
- Automatic cleanup of logs >7 days old
- Background cleanup goroutine
- Uses only Go standard library (encoding/json, os, path/filepath, sync, time)

* Add update command support and improve event logging robustness

Features:
- Add support for npm/pnpm/bun/yarn update/upgrade/ci commands
- These commands now scan packages for malware before updating
- Closes security gap where update commands bypassed PMG protection

Improvements:
- Make event logging more defensive (graceful failure when not initialized)
- Add nil check for packageManager in guard to prevent test failures
- Add comprehensive tests for update commands

Testing:
- All 33+ unit tests passing
- Integration tests verified with real malware detection
- Tested with npm update, npm ci, npm upgrade, pnpm update, yarn upgrade

Files changed:
- packagemanager/npm.go: Added update/upgrade/ci to InstallCommands
- packagemanager/npm_test.go: Added 4 new test cases for update commands
- guard/guard.go: Added nil check for packageManager
- internal/eventlog/eventlog.go: Made logging more defensive

* Address review feedback: use log.Warnf instead of silently failing

Replace silent error handling in cleanupOldLogs with log.Warnf
to avoid completely swallowing errors when reading log directory.

Fixes reviewer feedback from abhisek.

* Remove update/upgrade command support, keep logging improvements

- Remove update/upgrade/ci commands from InstallCommands for npm, pnpm, bun, yarn
- Remove special handling for update/upgrade/ci commands in ParseCommand
- Remove update command test cases and restore original test
- Preserve logging improvements (nil check in guard.go, defensive check in eventlog.go)

All tests passing.
2025-12-31 16:05:31 +05:30
Sahil BansalandGitHub 2bc500f817 replace token based auth with OIDC auth (#80) 2025-12-16 12:58:45 +00:00
Abhisek DattaandGitHub 21eb05373f feat: Add Support for Proxy with Interceptor (#77) 2025-12-10 08:34:28 +05:30
a8723cd680 refactor and introduce tests for npm & pypi (#79)
* refactor and introduce tests for npm & pypi

* refactor and introduce tests for npm & pypi

* add skip intermediate flags test case

* fix tests

---------

Co-authored-by: Abhisek Datta <abhisek.datta@gmail.com>
2025-12-08 17:30:29 +00:00
2be1e5f009 Update go version to 1.25 & Add steps for introducing new package manager (#78)
* upgrade go version to 1.25.1

* introduce doc for steps for creating a new pkg manager

* Update docs/package-manager.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>

* Update docs/package-manager.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>

* Update docs/package-manager.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>

---------

Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-08 09:36:32 +05:30
Abhisek DattaandGitHub 47fc5252ba fix: Add pip3 shell alias (#76) v0.2.1 2025-12-04 09:49:43 +05:30
Sahil BansalandGitHub 50d7b55445 Add Pip3 support (#75)
* add pip3 support

* add pip3 e2e

* chore: rename var
v0.2.0
2025-12-03 20:28:45 +05:30
Sahil BansalandGitHub c47cb30de0 Add pmg E2E Tests (#73)
* add pmg e2e tests

* pin sha version

* pin python sha version

* add pmg to path

* fix pnpm init

* fix pnpm init

* rm poerty verification

* fix poetry verification

* comment poetry verification

* fix poetry error

* add poetry verification back

* fix poetry error

* add yarn e2e

* fix yarn installation

---------

Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>
2025-12-01 12:13:24 +05:30
Sahil BansalandGitHub 34750d71d3 update report url (#74) 2025-11-11 21:19:53 +05:30
Shrvan SudhakaraandGitHub 03bd697ae0 Add support for yarn package manager (#72)
* Add support for yarn package manager

- Added yarn command handler in cmd/npm/yarn.go
- Added DefaultYarnPackageManagerConfig() in packagemanager/npm.go
- Added yarn dev flag support (--dev/-D) in ParseCommand()
- Added yarn analytics tracking in internal/analytics/event.go
- Registered yarn command in main.go
- Added yarn to alias setup in internal/alias/alias.go
- Added comprehensive test suite in packagemanager/yarn_test.go
- All tests passing (12 yarn tests + existing tests)

Resolves #30

Signed-off-by: shrvansudhakara <shrvansudhakara@gmail.com>

* docs: update README with yarn package manager support

Updated documentation to reflect yarn support addition:
- Changed yarn status from '🚧 Planned' to ' Active' in package managers table
- Added 'pmg yarn add <package>' command example
- Added 'yarn add <package-name>' to command list
- Added 'yarn install # Uses yarn.lock' to lockfile examples

This documentation update corresponds to the yarn implementation in the previous commit.

Related to #30

Signed-off-by: shrvansudhakara <shrvansudhakara@gmail.com>

* fix: address review feedback for yarn support

- Add support for bare 'yarn' command as manifest install
- Validate yarn install does not accept package names
- Add YarnExtractor for yarn.lock file support

Changes:
- packagemanager/npm.go: Added bare yarn command handling and validation
- packagemanager/yarn_test.go: Added test for bare yarn command
- extractor/ecosystems.go: Added Yarn PackageManagerName and extractor
- extractor/npm.go: Added YarnExtractor implementation
- go.mod, go.sum: Updated dependencies

Addresses review feedback from @Sahilb315
- Bare yarn command now triggers manifest install per docs
- yarn install <package> is now properly rejected
- yarn.lock extraction support added

Related to #30

Signed-off-by: shrvansudhakara <shrvansudhakara@gmail.com>

* chore: tidy go.mod and go.sum to remove unused dependencies

Signed-off-by: shrvansudhakara <shrvansudhakara@gmail.com>

* fix: add yarn.lock extractor mapping

- Add yarn.lock case in getExtractorForFile switch
- Import yarnlock extractor from osv-scalibr
- Enables lockfile parsing for manifest-based installations

Tested both package-based and manifest-based installations successfully.

Addresses review feedback from @Sahilb315

Signed-off-by: shrvansudhakara <shrvansudhakara@gmail.com>

* test: add validation test for yarn install with package name

- Add test case to verify 'yarn install <package>' is rejected
- Ensures invalid syntax returns no install targets
- Confirms IsManifestInstall is false for invalid commands

Addresses review feedback from @Sahilb315

Signed-off-by: shrvansudhakara <shrvansudhakara@gmail.com>

---------

Signed-off-by: shrvansudhakara <shrvansudhakara@gmail.com>
2025-11-05 13:49:19 +05:30