README ¶
Trustero Receptor SDK for Golang
ReceptorSDK documentation is available on pkg.go.dev. Users are advised to consult this ReceptorSDK documentation together with the comprehensive Receptor Developer Guide
and protobuf definitions. To obtain a copy of the guide, please reach out to Trustero Support. The easiest way to learn about the SDK is to consult the set of examples built on top of the SDK. What follows is a subset of these examples that can be found useful as stand-alone programs.
Example | Description |
---|---|
GitLab Receptor | A Receptor that posts GitLab users as evidence |
ReceptorSDK is an open source Trustero project and contributions are welcome.
ReceptorSDK is periodically refreshed to reflect the newest additions to the Trustero API. Users of the SDK are advised to track the latest releases rather closely to ensure proper function in the unlikely event of an incompatible change to a Trustero API.
Installation
go get github.com/trustero/api/go@latest
Usage
The developer needs to implement the Receptor interface in their project to create a Receptor.
Required Functions
As a developer, you will need to implement the following functions to have a working receptor:
- func (r *Receptor) GetReceptorType() string {}
- This function will return a string, signifying the receptor type (e.g. “trr-gitlab”)
- func (r *Receptor) GetKnownServices() []string {}
- This function will return an array of string, signifying a list of service types the receptor collects
- func (r *Receptor) GetCredentialObj() (credentialObj interface{}) {}
- func (r *Receptor) GetConfigObj() (configObj interface{}) {}
- func (r *Receptor) GetConfigObjDesc() (configObjDesc interface{}) {}
- func (r *Receptor) GetAuthMethods() (authMethods interface{}) {}
- func (r *Receptor) Verify(credentials interface{}) (ok bool, err error) {}
- func (r *Receptor) Discover(credentials interface{}) (svcs []*receptor_v1.ServiceEntity, err error) {}
- func (r *Receptor) Report(credentials interface{}) (evidences []*receptor_sdk.Evidence, err error) {}
- func (r *Receptor) GetEvidenceInfo() (evidences []*receptor_sdk.Evidence) {}
- func (r *Receptor) ReportBatch(credentials interface{}, evidenceChan chan []*receptor_sdk.Evidence) {}
- func (r *Receptor) Configure(credentials interface{}) (config *receptor_v1.ReceptorConfiguration, err error) {}
- func (r *Receptor) GetInstructions() (instructions string, err error) {}
- func (r *Receptor) GetLogo() (svgContent string, err error) {}
package main
import (
"github.com/trustero/api/go/receptor_sdk"
"github.com/trustero/api/go/receptor_sdk/cmd"
"github.com/trustero/api/go/receptor_v1"
)
const (
receptorName = "trr-custom"
serviceName = "Custom Service"
)
type Receptor struct {
// YOUR CODE HERE
}
func (r *Receptor) GetReceptorType() string {
return receptorName
}
func (r *Receptor) GetKnownServices() []string {
return []string{serviceName}
}
func (r *Receptor) GetCredentialObj() (credentialObj interface{}) {
return r
}
func (r *Receptor) GetConfigObj() (configObj interface{}){
return
}
func (r *Receptor) GetConfigObjDesc() (configObjDesc interface{}) {
return
}
func (r *Receptor) GetConfigObjDesc() (configObjDesc interface{}) {
return
}
func (r *Receptor) GetAuthMethods() (authMethods interface{}) {
return
}
func (r *Receptor) Verify(credentials interface{}) (ok bool, err error) {
// YOUR CODE HERE
return
}
func (r *Receptor) Discover(credentials interface{}) (svcs []*receptor_v1.ServiceEntity, err error) {
// YOUR CODE HERE
return
}
func (r *Receptor) Report(credentials interface{}) (evidences []*receptor_sdk.Evidence, err error) {
// YOUR CODE HERE
return
}
func (r *Receptor) ReportBatch(credentials interface{}, evidenceChan chan []*receptor_sdk.Evidence) {
// YOUR CODE HERE
close(evidenceChan)
}
func (r *Receptor) GetEvidenceInfo() (evidences []*receptor_sdk.Evidence) {
//YOUR CODE HERE
return
}
func (r *Receptor) Configure(credentials interface{}) (config *receptor_v1.ReceptorConfiguration, err error) {
// YOUR CODE HERE
return
}
func (r *Receptor) GetInstructions() (instructions string, err error) {
// YOUR CODE HERE
return
}
func (r *Receptor) GetLogo() (svgContent string, err error) {
// YOUR CODE HERE
return
}
func main() {
cmd.Execute(&Receptor{})
}
A real-life example can be found in the examples directory.
Testing A Receptor
You should be able to run your receptor code via the command line to confirm the Verify and Scan functions produce the correct output.
You can run the Receptor code with the dryrun
flag and it will print the output to the console.
You can compile the Receptor code into a binary or run the main file directly.
If you run the main file directly, your command should look something like this:
go run main.go scan dryrun --find-evidence
This command will run the Verify, Discover, and Report functions that you wrote and print their output to the console. You should be able to see the final Evidences that are generated by the receptor.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
gitlab_receptor
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
|
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package. |
gitlab_receptor/logging
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
|
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package. |
gitlab_receptor/receptorPackage
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
|
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package. |
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
|
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package. |
client
Package client provides GRPC utilities to simplify connecting to Trustero GRPC service.
|
Package client provides GRPC utilities to simplify connecting to Trustero GRPC service. |
cmd
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
|
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package. |
config
Package config provides default development server certificate
|
Package config provides default development server certificate |
multipartkit
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
|
This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package. |
Package receptor_v1 provides the Go GRPC client bindings to communicate with the Trustero service.
|
Package receptor_v1 provides the Go GRPC client bindings to communicate with the Trustero service. |