mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
Support for scanning manifest files (#36)
* feat: add extractor logic for manifest files * feat: add manifest-based package installation detection * feat: add osv-scanner for extracting lockfiles * refactor: add comment for cmd parse * refactor: add Ecosystem() method to PackageManager interface * refactor: implement package-manager-specific extractors & replace osv-scanner with scalibr * Update extractor/extractor.go 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>
This commit is contained in:
@@ -30,12 +30,28 @@ type ParsedCommand struct {
|
||||
|
||||
// Parsed install target if this is an install command
|
||||
InstallTargets []*PackageInstallTarget
|
||||
|
||||
// IsManifestInstall indicates if this is a manifest-based installation
|
||||
// (e.g., npm install, pip install -r requirements.txt)
|
||||
IsManifestInstall bool
|
||||
|
||||
// ManifestFiles contains the list of manifest files to install from
|
||||
// (e.g., ["requirements.txt"] for pip install -r requirements.txt)
|
||||
ManifestFiles []string
|
||||
}
|
||||
|
||||
func (pc *ParsedCommand) HasInstallTarget() bool {
|
||||
return len(pc.InstallTargets) > 0
|
||||
}
|
||||
|
||||
func (pc *ParsedCommand) HasManifestInstall() bool {
|
||||
return pc.IsManifestInstall
|
||||
}
|
||||
|
||||
func (pc *ParsedCommand) ShouldExtractFromManifest() bool {
|
||||
return pc.IsManifestInstall && !pc.HasInstallTarget()
|
||||
}
|
||||
|
||||
// PackageManager is the contract for implementing a package manager
|
||||
type PackageManager interface {
|
||||
// Name of the package manager implementation
|
||||
@@ -44,6 +60,9 @@ type PackageManager interface {
|
||||
// ParseCommand parses the command and returns a parsed command
|
||||
// specific to the package manager implementation
|
||||
ParseCommand(args []string) (*ParsedCommand, error)
|
||||
|
||||
// Ecosystem of the package manager
|
||||
Ecosystem() packagev1.Ecosystem
|
||||
}
|
||||
|
||||
// PackageResolver is the contract for resolving package info
|
||||
|
||||
Reference in New Issue
Block a user