Git Product home page Git Product logo

gonexus's Introduction

gonexus DepShield Badge CircleCI

Provides a go client library for connecting to, and interacting with, Sonatype Nexus applications such as Nexus Repository Manager and Nexus IQ Server.

Organization of this library

The library is broken into two packages. One for each application.

nexusrm GoDoc nexusrm coverage

Create a connection to an instance of Nexus Repository Manager

// import "github.com/sonatype-nexus-community/gonexus/rm"
rm, err := nexusrm.New("http://localhost:8081", "username", "password")
if err != nil {
    panic(err)
}

Supported RM Endpoints

Endpoint Status Min RM Version
Assets ๐ŸŒ•
Blob Store ๐ŸŒ‘ 3.19
Components ๐ŸŒ–
Content Selectors ๐ŸŒ‘ 3.19
Email ๐ŸŒ‘ 3.19
IQ Server ๐ŸŒ‘ 3.19
Licensing ๐ŸŒ‘ 3.19
Lifecycle ๐ŸŒ‘
Maintenance pro ๐ŸŒ˜
Nodes pro ๐ŸŒ‘
Read-Only ๐ŸŒ•
Repositories ๐ŸŒ•
Routing Rules ๐ŸŒ‘ 3.17
Search ๐ŸŒ–
Script ๐ŸŒ•
Security Management ๐ŸŒ‘ 3.19
Staging pro ๐ŸŒ–
Status ๐ŸŒ•
Support ๐ŸŒ•
Tagging pro ๐ŸŒ–
Tasks ๐ŸŒ‘

Supported Provisioning API

API Status
Core ๐ŸŒ‘
Security ๐ŸŒ‘
Blob Store ๐ŸŒ–
Repository ๐ŸŒ–

Legend: ๐ŸŒ• complete ๐ŸŒ‘ untouched ๐ŸŒ˜๐ŸŒ—๐ŸŒ– partial support

nexusiq GoDoc nexusiq coverage

Create a connection to an instance of Nexus IQ Server

// import "github.com/sonatype-nexus-community/gonexus/iq"
iq, err := nexusiq.New("http://localhost:8070", "username", "password")
if err != nil {
    panic(err)
}

Supported IQ Endpoints

Endpoint Status Min IQ Version
Application ๐ŸŒ•
Authorization Configuration ๐ŸŒ• r70
Component Details ๐ŸŒ•
Component Evaluation ๐ŸŒ•
Component Labels ๐ŸŒ•
Component Remediation ๐ŸŒ• r64
Component Search ๐ŸŒ•
Component Versions ๐ŸŒ•
Component Waivers ๐ŸŒ‘ r76
Configuration ๐ŸŒ‘ r65
Data Retention Policy ๐ŸŒ•
Organization ๐ŸŒ•
Policy Violation ๐ŸŒ•
Policy Waiver ๐ŸŒ‘ r71
Promote Scan ๐ŸŒ‘
Report-related ๐ŸŒ•
Role ๐ŸŒ• r70
SAML ๐ŸŒ‘ r74
Source Control ๐ŸŒ•
Success Metrics Data ๐ŸŒ•
Users ๐ŸŒ• r70
User Token ๐ŸŒ‘ r76
Vulnerability Details ๐ŸŒ‘ r75
Webhooks ๐ŸŒ•

Legend: ๐ŸŒ• complete ๐ŸŒ‘ untouched ๐ŸŒ˜๐ŸŒ—๐ŸŒ– partial support

iqwebhooks GoDoc nexusiq webhooks coverage

The iq/iqwebhooks subpackage provides structs for all of the event types along with helper functions.

Most notably it provides a function called Listen which is an http.HandlerFunc that can be used as an endpoint handler for a server functioning as a webhook listener. The handler will place any webhook event it finds in a channel to be consumed at will.

An example of using the handler to listen for Application Evaluation events:

// import "github.com/sonatype-nexus-community/gonexus/iq/webhooks"
appEvals, _ := iqwebhooks.ApplicationEvaluationEvents()

go func() {
    for _ = range appEvals:
        log.Println("Received Application Evaluation event")
    }
}()

http.HandleFunc("/ingest", iqwebhooks.Listen)

See the documentation for a full example showing other event types.

The Fine Print

It is worth noting that this is NOT SUPPORTED by Sonatype, and is a contribution of @HokieGeek plus us to the open source community (read: you!)

Remember:

  • Use this contribution at the risk tolerance that you have
  • Do NOT file Sonatype support tickets related to this
  • DO file issues here on GitHub, so that the community can pitch in

gonexus's People

Contributors

bhamail avatar defrankland avatar hokiegeek avatar overag3 avatar scherzhaft avatar tom-b-gw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gonexus's Issues

sha-256 and sha-512 are unavailable

This library only returns sha-1 and md5 for SearchAssets request:

type repositoryItemAssetsChecksum struct {
	Sha1 string `json:"sha1"`
	Md5  string `json:"md5"`
}

Nexus API supports sha-256 and sha-512.

SIGSEGV in components.go with too large files for timeout

Getting a stack crash on a timeout in the gonexus api which is located here

	if _ , resp, err := rm.Do(req); err != nil /* && resp.StatusCode != http.StatusNoContent*/ {
		return doError(err)
	}

will sigsegv with this type of error

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x620f0f]

goroutine 1 [running]:
gonexus/rm.UploadComponent({0x70b868, 0xc000078230}, {0x7fff259a4f07, 0xd}, {0x702f20, 0xc00002a2c0})
        ~/nexus_api/gonexus/rm/components.go:394 +0x6cf
main.upload_components({0x70b868, 0xc000078230}, {0x7fff259a4f07, 0xd}, {0x7fff259a4f15, 0x4}, {0x7fff259a4f1a, 0x7}, {0xc000151e60, 0x1b})
        ~nexus_api/nexus_api.go:76 +0x2c6
main.main()
        ~/nexus_api/nexus_api.go:126 +0x5f8

The problem is the rm.Do(req) in ~ Components.go:394
if the Do function returns a timeout error then accessing resp again will cause a stack crash. My solution was to change the line to this

	if _ , _, err := rm.Do(req); err != nil {
		return doError(err)
	}

will correctly print the timeout error I am not sure what that code was there for but it may need to be fixed differently.

To reproduce do a nexusrm.UploadComponent with a file larger then can be uploaded then the timeout in nexus.go file and it will sigsegv. Since its returning

	if err != nil {
		return nil, nil, err
	}

If you need more details let me know.

PyPi uploads of .whl are zipped in Nexus

Thanks for creating an issue! Please fill out this form so we can be
sure to have all the information we need, and to minimize back and forth.

  • What are you trying to do?
    I am uploading a pip package (stored as a .whl/wheel locally) to an existing PyPi Nexus repository. The upload succeeds, but attempting to install pip packages from this repository fails because the uploaded wheel is zipped (into a .zip) somewhere in the upload process. I've been looking through this SDK's source and I don't see where it's zipping any component, so it must be the Nexus 3 backend zipping the file. Any advice on how to avoid this while uploading Python wheels?

  • What feature or behavior is this required for?
    Component upload

  • How could we solve this issue? (Not knowing is okay!)
    Help me figure out how to avoid the Nexus backend zipping the uploaded wheel file.

  • Anything else?

Can't use CreateProxyRepository (probably any of the others)

Thanks for creating an issue! Please fill out this form so we can be
sure to have all the information we need, and to minimize back and forth.

  • What are you trying to do?
    call nexusrm.CreateProxyRepository
  • What feature or behavior is this required for?
    Creating a proxy repo automatically
  • How could we solve this issue? (Not knowing is okay!)
    Make the parameter structure (currently private proxyRepository) public, by using a capital letter.
  • Anything else?
    Make the CreateProxyRepository function private if it isn't meant to be exposed.

Adding policyViolationId

Thanks for creating an issue! Please fill out this form so we can be
sure to have all the information we need, and to minimize back and forth.

  • What are you trying to do?
    Obtain the policyviolationid of a violation for a component

  • What feature or behavior is this required for?
    using the id to post waivers

  • How could we solve this issue? (Not knowing is okay!)
    #15

Support for `beta` API version endpoints

Hi!

  • What are you trying to do?
    Is there any chance that I can send a PR to support the beta API for the endpoint security/users and repositories/maven? Since now the Groovy API must be enabled to work, most of the use cases that people used to use (like creating repositories), won't work unless this setting is enabled.

  • What feature or behavior is this required for?
    To interact with the users and Maven repositories use cases.

  • How could we solve this issue? (Not knowing is okay!)
    I'll send a PR

  • Anything else?
    No :)

Missing fields in RepositoryItemAsset

The following fields are missing, when quering v1/assets or v1/assets/ID for RepositoryItemAsset

ContentType    string                           `json:"contentType"`
LastModified   *time.Time                       `json:"lastModified"`
BlobCreated    *time.Time                       `json:"blobCreated"`
LastDownloaded *time.Time                       `json:"lastDownloaded"`

It seems like RepositoryItemAsset was mapped for v1/search or v1/search/assets where those fields are not returned, so it is a smaller projection then under v1/assets .

Still those 2 of that for are also returned in the search but not yet mapped

ContentType    string                           `json:"contentType"`
LastModified   *time.Time                       `json:"lastModified"`

Is there any interest for PR fixing this? We would need to split the structs though, thus

  • RepositoryItemAsset for the full set of fields v1/assets
  • SearchRepositoryItemAsset for the limitted set of fields for v1/search

This would be a breaking change for all users here.

Alternatively, we can fill up the fields in RepositoryItemAsset, neglecting the fact that those fields are always empty for v1/search - hackish way but without a breaking change for the lib

What do you guys suggest?

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.