Skip to content

🔍 AuditWithoutDev

Performs a security audit on the current project's dependencies but excludes development dependencies (require-dev). Equivalent to running composer audit --no-dev, returning text-format output.

When to use

In production deployment or CI pipelines, you typically only care about the security of production dependencies. Use this method to ignore packages in require-dev and focus on vulnerabilities in real runtime dependencies.

Signature

go
func (c *Composer) AuditWithoutDev() (string, error)

Parameters

This method takes no parameters.

Return value

Return valueTypeDescription
First return valuestringStandard output text of composer audit --no-dev
Second return valueerrorReturned when an error occurs during execution

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("init failed: %v", err)
	}

	output, err := comp.AuditWithoutDev()
	if err != nil {
		log.Fatalf("failed to run security audit: %v", err)
	}
	fmt.Println("Production dependency security audit result:")
	fmt.Println(output)
}

Advanced

  • To both exclude development dependencies and get a JSON structured result, use AuditWithOptions:
go
output, err := comp.AuditWithOptions(map[string]string{
    "no-dev": "",
    "format": "json",
})

Released under the MIT License