Git Product home page Git Product logo

go-sona-types's Introduction

Go Sonatypes

Circle CI Build Status Go Reference

This project is a nice lil set of libraries that we created for working with:

  • Sonatype's OSS Index
  • Sonatype's Nexus IQ Server
  • Building different types of CycloneDX SBOMs
  • Obtaining a User Agent for communicating with different services

A lot of our projects were starting to depend heavily on nancy, and it was slowing the pace of development on nancy down quite a bit, as well as making importing nancy a bit of a kitchen sink if you wanted to use some of it's libraries. Thusly, go-sona-types is born! The name is credited to @zendern or @fitzoh, who are good with puns!

Development

You'll need Go 1.16, and that's about it!

Everything (tests, lint, etc...) can be run with make locally.

Adding new files? Get the license header correct with:

go get -u github.com/google/addlicense addlicense -v -f ./header.txt .

Usage

This section is only created for suggested use of each package.

OSS Index

// Setup fake logger, use a real one when you consume this package
logger, _ := logrus.NewNullLogger()

// Obtains a pointer to a Server struct, with rational defaults set
ossi := ossindex.Default(logger)

// Obtains a pointer to a Server struct, with options you set
ossi = ossindex.New(loggger, types.Options{Username: "username", Token: "token", DBCachePath: "/tmp"})

// Audits a slice of purls, returns results or an error
results, err := ossi.AuditPackages([]string{"a", "list", "of", "purls"})

// Removes database cache
err = ossi.NoCacheNoProblems()

IQ Server

// Setup fake logger, use a real one when you consume this package
logger, _ := logrus.NewNullLogger()

// Obtains a pointer to a Server struct
iq := iq.New(logger, iq.Options{Username: "username", Token: "token"})

// Audits a slice of purls, given a public IQ Server application ID, and returns results or an error
results, err := iq.AuditPackages([]string{"a", "list", "of", "purls"}, "public-application-id")

CycloneDX

// Setup fake logger, use a real one when you consume this package
logger, _ := logrus.NewNullLogger()

// Obtains a pointer to a CycloneDX struct
sbom := cyclonedx.Default(logger)

// Obtains a SBOM from []types.Coordinates
results := sbom.FromCoordinates([]types.Coordinates{})

User Agent

// Setup fake logger, use a real one when you consume this package
logger, _ := logrus.NewNullLogger()

// Obtains a pointer to aa Agent struct, useful in testing or if you need to override ClientTool or Version
ua := useragent.New(logger, useragent.Options{ClientTool: "your-client-tool", Version: "1.0.0", GoOS: runtime.GOOS, GoArch: runtime.GOARCH})

// Can be used to get aa Agent struct populated with defaults
ua = useragent.Default(logger)

// Obtains a properly formatted user-agent string for communicating with OSS Index or Nexus IQ Server
useragent := ua.GetUserAgent()

Release Process

Follow the steps below to release a new version.

  1. Checkout/pull the latest main branch, and create a new tag with the desired semantic version and a helpful note:

    git tag -a v0.0.x -m "Helpful message in tag."
    
  2. Push the tag up:

    git push origin v0.0.x
    
  3. Click the GitHub buttons to make a new release from this new tag.

go-sona-types's People

Contributors

bhamail avatar darthhater avatar donrenando avatar scherzhaft avatar greut avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.