🚫 GetAbandonedPackages
Runs a security audit and filters out the list of packages marked as "abandoned". Under the hood it calls AuditWithJSON.
When to use
Using abandoned packages carries security and maintainability risks — upstream no longer releases security patches. This method helps you quickly discover such packages so you can plan replacements.
Signature
go
func (c *Composer) GetAbandonedPackages() ([]Vulnerability, error)Parameters
This method takes no parameters.
Return value
| Return value | Type | Description |
|---|---|---|
| First return value | []Vulnerability | Entries whose Abandoned field is true; empty slice when there are no matches |
| Second return value | error | Returned when an error occurs during execution or parsing |
Note
The return type reuses the Vulnerability struct, where Package, Version, and Link carry information about the abandoned package, and Abandoned is true.
Example
go
package main
import (
"fmt"
"log"
"github.com/scagogogo/composer-skills/pkg/composer"
)
func main() {
comp, err := composer.NewComposer("")
if err != nil {
log.Fatalf("initialization failed: %v", err)
}
abandoned, err := comp.GetAbandonedPackages()
if err != nil {
log.Fatalf("failed to get abandoned packages: %v", err)
}
if len(abandoned) > 0 {
fmt.Printf("Found %d abandoned packages:\n", len(abandoned))
for _, pkg := range abandoned {
fmt.Printf("Package: %s Version: %s\n", pkg.Package, pkg.Version)
fmt.Printf("Details: %s\n\n", pkg.Link)
}
fmt.Println("Consider replacing these packages to avoid potential security risks.")
} else {
fmt.Println("No abandoned packages found.")
}
}Advanced
- For the full vulnerability list: use AuditWithJSON.
- For only high-severity vulnerabilities: use GetHighSeverityVulnerabilities.
- For a boolean "are there any issues" conclusion: use HasVulnerabilities.