mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
fix: pip args & manifest files handling (#41)
* fix: pip args & manifest files handling * chore: add pflag dependency * chore: word fixes * fix: multiple refs for suspicious packages * refactor: introduce block config * fix: makefile for windows build * test: add test cases for manifest based installation * refactor: Makefile * refactor: remove .exe for windows build
This commit is contained in:
+18
-2
@@ -26,6 +26,20 @@ const (
|
||||
VerbosityLevelVerbose
|
||||
)
|
||||
|
||||
type BlockConfig struct {
|
||||
// ShowReference determines whether to show detailed information for suspicious packages.
|
||||
// If false, the details are omitted to avoid repeating information already shown to the user.
|
||||
ShowReference bool
|
||||
|
||||
MalwarePackages []*analyzer.PackageVersionAnalysisResult
|
||||
}
|
||||
|
||||
func NewDefaultBlockConfig() *BlockConfig {
|
||||
return &BlockConfig{
|
||||
ShowReference: true,
|
||||
}
|
||||
}
|
||||
|
||||
var verbosityLevel VerbosityLevel = VerbosityLevelNormal
|
||||
|
||||
func SetVerbosityLevel(level VerbosityLevel) {
|
||||
@@ -37,13 +51,15 @@ func ClearStatus() {
|
||||
fmt.Print("\r")
|
||||
}
|
||||
|
||||
func Block(malwarePackages ...*analyzer.PackageVersionAnalysisResult) error {
|
||||
func Block(config *BlockConfig) error {
|
||||
StopSpinner()
|
||||
|
||||
fmt.Println()
|
||||
fmt.Println(Colors.Red("❌ Malicious package blocked!"))
|
||||
|
||||
printMaliciousPackagesList(malwarePackages)
|
||||
if config.ShowReference {
|
||||
printMaliciousPackagesList(config.MalwarePackages)
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user