Skip to content

🚫 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 valueTypeDescription
First return value[]VulnerabilityEntries whose Abandoned field is true; empty slice when there are no matches
Second return valueerrorReturned 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

Released under the MIT License