ionic

package module
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2022 License: Apache-2.0 Imports: 42 Imported by: 3

README

Ionic

Ion Channel Status Build Status Go Reportcard GoDoc License Release

A Golang SDK for the Ion Channel API

Requirements

Golang Version 1.10 or higher

Installation

go get github.com/ion-channel/ionic

Versioning

The SDK will be versioned in accordance with Semver 2.0.0. See the releases section for the latest version. Until version 1.0.0 the SDK is considered to be unstable.

It is always highly recommended to vendor the version you are using.

License

This SDK is distributed under the Apache License, Version 2.0. See LICENSE.md for more information.

Documentation

Overview

Package ionic provides a direct representation of the endpoints and objects within the Ion Channel API. Use NewDefault or NewWithOptions to create a client.

Index

Examples

Constants

View Source
const (
	// RubyEcosystem represents the ruby ecosystem for resolving dependencies
	RubyEcosystem = "ruby"
)

Variables

This section is empty.

Functions

func GetDifferenceBetweenVersions added in v0.21.0

func GetDifferenceBetweenVersions(newerVersion, olderVersion string) (outdatedMeta scans.OutdatedMeta, err error)

GetDifferenceBetweenVersions calculates the difference between two version strings, returning an OutdatedMeta object, or an error.

func InjectIntoContext added in v0.22.0

func InjectIntoContext(ctx context.Context, ionClient *IonClient) context.Context

InjectIntoContext returns the given context with the given IonClient added to it.

Types

type AddAliasOptions added in v0.19.1

type AddAliasOptions struct {
	Name      string `json:"name"`
	ProjectID string `json:"project_id"`
	TeamID    string `json:"team_id"`
	Version   string `json:"version"`
	Org       string `json:"org"`
}

AddAliasOptions struct that allows for adding an alias to a project

type CreateOrganizationOptions added in v0.22.0

type CreateOrganizationOptions struct {
	Name string `json:"name"`
}

CreateOrganizationOptions represents all the values that can be provided for an organization at the time of creation

type CreateProjectsResponse added in v0.19.1

type CreateProjectsResponse struct {
	Projects []projects.Project `json:"projects"`
	Errors   []struct {
		Message string `json:"message"`
	} `json:"errors"`
}

CreateProjectsResponse represents the response from the API when sending a list of projects to be created. It contains the details of each project created, and a list of any errors that were encountered.

type CreateTeamOptions added in v0.10.1

type CreateTeamOptions struct {
	Name           string `json:"name"`
	OrganizationID string `json:"organization_id"`
	POCName        string `json:"poc_name"`
	POCEmail       string `json:"poc_email"`
}

CreateTeamOptions represents all the values that can be provided for a team at the time of creation

type CreateTeamUserOptions added in v0.19.1

type CreateTeamUserOptions struct {
	Status    string `json:"status"`
	Role      string `json:"role"`
	TeamID    string `json:"team_id"`
	UserID    string `json:"user_id"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

CreateTeamUserOptions represents all the values that can be provided for a team user at the time of creation

type GetReposInCommonOptions added in v0.21.0

type GetReposInCommonOptions struct {
	Subject   string `json:"subject"`
	Comparand string `json:"comparand"`
	ByActor   bool   `json:"by_actor"`
}

GetReposInCommonOptions encapsulates params for repos in common requests

type GetReposInCommonOutput added in v0.21.0

type GetReposInCommonOutput struct {
	community.Repo
	CommonCommitters []string `json:"common_committers,omitempty" xml:"common_committers,omitempty"`
	CommonActors     []string `json:"common_actors,omitempty" xml:"common_actors,omitempty"`
}

GetReposInCommonOutput encapsulates params for repos in common requests

type IonClient

type IonClient struct {
	// contains filtered or unexported fields
}

IonClient represents a communication layer with the Ion Channel API

Example (CustomPaginationRange)
pages := pagination.Pagination{Offset: 20, Limit: 100}

vulns, err := client.GetVulnerabilities("ruby", "1.9.3", "sometoken", pages)
if err != nil {
	fmt.Println(err.Error())
}

fmt.Printf("Vulnerabilities: %v\n", vulns)
Output:

Example (DefaultPaginationRange)
// nil for pagination will use the default set by the API and may vary for each object
vulns, err := client.GetVulnerabilities("ruby", "1.9.3", "sometoken", pagination.Pagination{})
if err != nil {
	fmt.Println(err.Error())
}

fmt.Printf("Vulnerabilities: %v\n", vulns)
Output:

Example (GetProduct)
package main

import (
	"fmt"

	"github.com/ion-channel/ionic"
)

func main() {
	client, err := ionic.New("https://api.test.ionchannel.io")
	if err != nil {
		panic(fmt.Sprintf("Panic creating Ion Client: %v", err.Error()))
	}

	ps, err := client.GetProducts("cpe:/a:ruby-lang:ruby:1.8.7", "someapikey")
	if err != nil {
		fmt.Println(err.Error())
	}

	fmt.Printf("Products: %v\n", ps)
}
Output:

Example (GetRawProduct)
package main

import (
	"fmt"

	"github.com/ion-channel/ionic"
)

func main() {
	client, err := ionic.New("https://api.test.ionchannel.io")
	if err != nil {
		panic(fmt.Sprintf("Panic creating Ion Client: %v", err.Error()))
	}

	bodyBytes, err := client.GetRawProducts("cpe:/a:ruby-lang:ruby:1.8.7", "someapikey")
	if err != nil {
		fmt.Println(err.Error())
	}

	fmt.Printf("Raw Products: %v\n", string(bodyBytes))
}
Output:

Example (New)
package main

import (
	"fmt"

	"github.com/ion-channel/ionic"
)

func main() {
	client, err := ionic.New("https://api.test.ionchannel.io")
	if err != nil {
		panic(fmt.Sprintf("Panic creating Ion Client: %v", err.Error()))
	}

	// Client can then call for the different actions
	client.GetProject("projectID", "teamID", "someapikey")
}
Output:

func FromContext added in v0.22.0

func FromContext(ctx context.Context) *IonClient

FromContext retrieves an IonClient from the given context, or returns a new default client if one is not found.

func New

func New(baseURL string) (*IonClient, error)

New takes the base URL of the API and returns a client for talking to the API and an error if any issues instantiating the client are encountered. DEPRECATED: this function is deprecated as of 2022/01/01. Use NewWithOptions instead.

func NewDefault added in v0.22.0

func NewDefault() *IonClient

NewDefault returns a new default IonClient. Some defaults can be overridden using environment variables, see the IonClientOptions struct.

func NewWithClient added in v0.8.0

func NewWithClient(baseURL string, client http.Client) (*IonClient, error)

NewWithClient takes the base URL of the API and an existing HTTP client. It returns a client for talking to the API and an error if any issues instantiating the client are encountered. DEPRECATED: this function is deprecated as of 2022/01/01. Use NewWithOptions instead.

func NewWithOptions added in v0.22.0

func NewWithOptions(options IonClientOptions) (*IonClient, error)

NewWithOptions takes an IonClientOptions to construct a client for talking to the API. Returns the client and any error that occurs. The defaults provided by an empty IonClientOptions object are sane and functional, so all the options are optional. Some defaults can be overridden using environment variables, see the IonClientOptions struct.

func (*IonClient) AddAlias added in v0.12.0

func (ic *IonClient) AddAlias(alias AddAliasOptions, token string) (*aliases.Alias, error)

AddAlias takes a project and adds an alias to it. It returns the project stored or an error encountered by the API

func (*IonClient) AddMemberToOrganization added in v0.22.0

func (ic *IonClient) AddMemberToOrganization(organizationID string, userID string, role organizations.OrganizationRole, token string) error

AddMemberToOrganization takes an organization ID, a user ID, and a role, and returns any errors that occurred.

func (*IonClient) AddScanResult added in v0.5.0

func (ic *IonClient) AddScanResult(scanResultID, teamID, projectID, status, scanType, token string, scanResults scanner.ExternalScan) (*scanner.AnalysisStatus, error)

AddScanResult takes a scanResultID, teamID, projectID, status, scanType, and client provided scan results, and adds them to the returned project analysis or an error encountered by the API

func (*IonClient) AddVulnerability added in v0.11.1

func (ic *IonClient) AddVulnerability(newVuln *vulnerabilities.VulnerabilityInput, token string) (*vulnerabilities.Vulnerability, error)

AddVulnerability takes in a vulnerability object populated with the desired data to send to the API and a token to use. It will return the inserted vulnerability and any errors it encounters with the API.

func (*IonClient) AnalyzeProject added in v0.5.0

func (ic *IonClient) AnalyzeProject(projectID, teamID, branch, token string) (*scanner.AnalysisStatus, error)

AnalyzeProject takes a projectID, teamID, and project branch, performs an analysis, and returns the result status or an error encountered by the API

func (*IonClient) AnalyzeProjects added in v0.19.1

func (ic *IonClient) AnalyzeProjects(teamID, token string, params url.Values) ([]string, error)

AnalyzeProjects takes a team ID to perform analyses on. An optional set of params can be provided to go along with the request, predominently for internal purposes. It will return the IDs of the analyses created and any errors it encounters with the request.

func (*IonClient) BulkSearch added in v0.22.0

func (ic *IonClient) BulkSearch(queries []string, tbs, token string) (map[string][]SearchMatch, error)

BulkSearch takes one or more query strings and a "to be searched" param, then performs a productidentifier search against the Ion API, returning a map of the original query string(s) to SearchMatch objects

func (*IonClient) CreateDeliveryDestinations added in v0.19.1

func (ic *IonClient) CreateDeliveryDestinations(dest *deliveries.CreateDestination, token string) (*deliveries.CreateDestination, error)

CreateDeliveryDestinations takes *CreateDestination, and token It returns a *CreateDestination and error

func (*IonClient) CreateOrganization added in v0.22.0

func (ic *IonClient) CreateOrganization(opts CreateOrganizationOptions, token string) (*organizations.Organization, error)

CreateOrganization takes a create team options, validates the minimum info is present, and makes the calls to create the team. It returns the ID of the created organization and any errors it encounters with the API.

func (*IonClient) CreateProject added in v0.12.0

func (ic *IonClient) CreateProject(project *projects.Project, teamID, token string) (*projects.Project, error)

CreateProject takes a project object, teamId, and token to use. It returns the project stored or an error encountered by the API

func (*IonClient) CreateProjectsFromCSV added in v0.19.1

func (ic *IonClient) CreateProjectsFromCSV(csvFile, teamID, token string) (*CreateProjectsResponse, error)

CreateProjectsFromCSV takes a csv file location, team ID, and token to send the specified file to the API. All projects that are able to be created will be with their info returned, and a list of any errors encountered during the process.

func (*IonClient) CreateRuleSet added in v0.19.1

func (ic *IonClient) CreateRuleSet(opts rulesets.CreateRuleSetOptions, token string) (*rulesets.RuleSet, error)

CreateRuleSet Creates a project attached to the team id supplied

func (*IonClient) CreateTag added in v0.14.0

func (ic *IonClient) CreateTag(teamID, name, description, token string) (*tags.Tag, error)

CreateTag takes a team ID, name, and description. It returns the details of the created tag, or any errors encountered with the API.

func (*IonClient) CreateTeam added in v0.10.1

func (ic *IonClient) CreateTeam(opts CreateTeamOptions, token string) (*teams.Team, error)

CreateTeam takes a create team options, validates the minimum info is present, and makes the calls to create the team. It returns the team created and any errors it encounters with the API.

func (*IonClient) CreateTeamUser added in v0.19.1

func (ic *IonClient) CreateTeamUser(opts CreateTeamUserOptions, token string) (*teamusers.TeamUser, error)

CreateTeamUser takes a create team options, validates the minimum info is present, and makes the calls to create the team. It returns the team created and any errors it encounters with the API.

func (*IonClient) CreateUser added in v0.10.0

func (ic *IonClient) CreateUser(email, username, password, token string) (*users.User, error)

CreateUser takes an email, username, and password. The username and password are not required, and can be left blank if so chosen. It will return the instantiated user object from the API or an error if it encounters one with the API.

func (*IonClient) Delete added in v0.9.1

func (ic *IonClient) Delete(endpoint, token string, params url.Values, headers http.Header) (json.RawMessage, error)

Delete takes an endpoint, token, params, and headers to pass as a delete call to the API. It will return a json RawMessage for the response and any errors it encounters with the API.

func (*IonClient) DeleteDeliveryDestination added in v0.19.1

func (ic *IonClient) DeleteDeliveryDestination(destinationID, token string) error

DeleteDeliveryDestination takes a team ID, and token. It returns errors.

func (*IonClient) DeleteTeamUser added in v0.19.1

func (ic *IonClient) DeleteTeamUser(teamuser *teamusers.TeamUser, token string) error

DeleteTeamUser takes a teamUser object and then makes the call to delete the teamUser. It returns any errors it encounters with the API.

func (*IonClient) DisableOrganization added in v0.22.0

func (ic *IonClient) DisableOrganization(id string, token string) error

DisableOrganization takes an organization ID and returns any errors that occurred.

func (*IonClient) DisableSessionAutoRenew added in v0.22.0

func (ic *IonClient) DisableSessionAutoRenew()

DisableSessionAutoRenew makes the IonClient stop automatically renewing its session.

func (*IonClient) EnableSessionAutoRenew added in v0.22.0

func (ic *IonClient) EnableSessionAutoRenew(username, password string) error

EnableSessionAutoRenew enables the periodic automatic renewal of the IonClient session using the given login information, ensuring that the client will always have a valid session token. To make the client stop automatically renewing its session, use the DisableSessionAutoRenew method.

func (*IonClient) FindScans added in v0.21.0

func (ic *IonClient) FindScans(parameters scans.SearchParameters, teamID, token string) ([]scans.Scan, error)

FindScans takes a set of search parameters and a team ID, and returns a slice of scan results

func (*IonClient) Get added in v0.9.1

func (ic *IonClient) Get(endpoint, token string, params url.Values, headers http.Header, page pagination.Pagination) (json.RawMessage, *responses.Meta, error)

Get takes an endpoint, token, params, headers, and pagination params to pass as a get call to the API. It will return a json RawMessage for the response and any errors it encounters with the API.

func (*IonClient) GetAnalyses added in v0.13.0

func (ic *IonClient) GetAnalyses(teamID, projectID, token string, page pagination.Pagination) ([]analyses.Analysis, error)

GetAnalyses takes a team ID, project ID, and token. It returns a slice of analyses for the project or an error for any API issues it encounters.

func (*IonClient) GetAnalysesExportData added in v0.20.0

func (ic *IonClient) GetAnalysesExportData(teamID string, ids []string, token string) ([]analyses.ExportData, error)

GetAnalysesExportData takes team id and a slice of analysis ids returns a slice of analyses exported data

func (*IonClient) GetAnalysesStatuses added in v0.20.0

func (ic *IonClient) GetAnalysesStatuses(teamID string, ids []string, token string) ([]rulesets.Status, error)

GetAnalysesStatuses takes a team id, slice of analysis ids and token returns a slice of project ids, analysis ids, and status

func (*IonClient) GetAnalysesVulnerabilityExportData added in v0.21.0

func (ic *IonClient) GetAnalysesVulnerabilityExportData(teamID string, ids []string, token string) ([]analyses.VulnerabilityExportData, error)

GetAnalysesVulnerabilityExportData takes team id and a slice of analysis ids returns a slice of vulnerability analyses exported data

func (*IonClient) GetAnalysis added in v0.3.0

func (ic *IonClient) GetAnalysis(id, teamID, projectID, token string) (*analyses.Analysis, error)

GetAnalysis takes an analysis ID, team ID, project ID, and token. It returns the analysis found. If the analysis is not found it will return an error, and will return an error for any other API issues it encounters.

func (*IonClient) GetAnalysisNavigation added in v0.19.1

func (ic *IonClient) GetAnalysisNavigation(analysisID, teamID, projectID, token string) (*scanner.Navigation, error)

GetAnalysisNavigation takes an analysisID, teamID, projectID, and a token. It returns the related/tangential analyses to the analysis provided or returns any errors encountered with the API.

func (*IonClient) GetAnalysisReport added in v0.5.0

func (ic *IonClient) GetAnalysisReport(analysisID, teamID, projectID, token string) (*reports.AnalysisReport, error)

GetAnalysisReport takes an analysisID, teamID, projectID, and token. It returns the corresponding analysis report or an error encountered by the API

func (*IonClient) GetAnalysisStatus added in v0.5.0

func (ic *IonClient) GetAnalysisStatus(analysisID, teamID, projectID, token string) (*scanner.AnalysisStatus, error)

GetAnalysisStatus takes an analysisID, teamID, and projectID and returns the analysis status or an error encountered by the API

func (*IonClient) GetAppliedRuleSet added in v0.5.0

func (ic *IonClient) GetAppliedRuleSet(projectID, teamID, analysisID, token string) (*rulesets.AppliedRulesetSummary, error)

GetAppliedRuleSet takes a projectID, teamID, and analysisID and returns the corresponding applied ruleset summary or an error encountered by the API

func (*IonClient) GetAppliedRuleSets added in v0.19.1

func (ic *IonClient) GetAppliedRuleSets(appliedRequestBatch []*rulesets.AppliedRulesetRequest, token string) (*[]rulesets.AppliedRulesetSummary, error)

GetAppliedRuleSets takes a slice of AppliedRulesetRequest and returns their applied ruleset results, omitting any not found

func (*IonClient) GetAppliedRuleSetsBrief added in v0.21.0

func (ic *IonClient) GetAppliedRuleSetsBrief(appliedRequestBatch []*rulesets.AppliedRulesetRequest, token string) (*[]rulesets.AppliedRulesetSummary, error)

GetAppliedRuleSetsBrief takes a slice of AppliedRulesetRequest and returns their applied ruleset results in brief/summarized form, omitting any not found

func (*IonClient) GetDefaultRuleSets added in v0.22.0

func (ic *IonClient) GetDefaultRuleSets(token string) ([]rulesets.RuleSet, error)

GetDefaultRuleSets returns a slice containing all the global default rulesets available to all teams, or an error.

func (*IonClient) GetDeliveryDestinations added in v0.19.1

func (ic *IonClient) GetDeliveryDestinations(teamID, token string) ([]deliveries.Destination, error)

GetDeliveryDestinations takes a team ID, and token. It returns list of deliveres and an error if it receives a bad response from the API or fails to unmarshal the JSON response from the API.

func (*IonClient) GetDependencyStats added in v0.20.0

func (ic *IonClient) GetDependencyStats(ids []string, token string) (*portfolios.DependencyStat, error)

GetDependencyStats takes slice of project ids and token and returns dependency stat and any errors

func (*IonClient) GetDependencyVersions added in v0.20.0

func (ic *IonClient) GetDependencyVersions(packageName, ecosystem, version, token string) ([]dependencies.Dependency, error)

GetDependencyVersions takes a package name, an ecosystem to find the package in, optional version, and a token for accessing the API. If version is supplied, it will return all known versions greater than what was given It returns a slice of Ionic dependencies.Dependency objects

func (*IonClient) GetExportedProjectsData added in v0.20.0

func (ic *IonClient) GetExportedProjectsData(ids []string, teamID, token string) (*reports.ExportedData, error)

GetExportedProjectsData takes slice of project ids, team id, and token returns slice of exported data for the requested projects

func (*IonClient) GetExportedVulnerabilityData added in v0.21.0

func (ic *IonClient) GetExportedVulnerabilityData(ids []string, teamID, token string) (*[]analyses.VulnerabilityExportData, error)

GetExportedVulnerabilityData takes slice of project ids, team id, and token returns slice of exported vulnerability data for the requested projects

func (*IonClient) GetLanguages added in v0.22.0

func (ic *IonClient) GetLanguages(text string, token string) ([]languages.Language, error)

GetLanguages takes a text input and returns any matching languages

func (*IonClient) GetLatestAnalysis added in v0.19.1

func (ic *IonClient) GetLatestAnalysis(teamID, projectID, token string) (*analyses.Analysis, error)

GetLatestAnalysis takes a team ID, project ID, and token. It returns the latest analysis found. If the analysis is not found it will return an error, and will return an error for any other API issues it encounters.

func (*IonClient) GetLatestAnalysisIDs added in v0.21.0

func (ic *IonClient) GetLatestAnalysisIDs(teamID string, projectIDs []string, token string) (*map[string]string, error)

GetLatestAnalysisIDs takes a team ID, project ID(s), and token. It returns the latest analysis IDs for the project as a map in the form map[project_id] = latest_analysis_id It returns an error for any API issues it encounters.

func (*IonClient) GetLatestAnalysisStatus added in v0.19.1

func (ic *IonClient) GetLatestAnalysisStatus(teamID, projectID, token string) (*scanner.AnalysisStatus, error)

GetLatestAnalysisStatus takes a teamID, and projectID and returns the latest analysis status or an error encountered by the API

func (*IonClient) GetLatestAnalysisStatuses added in v0.19.1

func (ic *IonClient) GetLatestAnalysisStatuses(teamID, token string) ([]scanner.AnalysisStatus, error)

GetLatestAnalysisStatuses takes a teamID and returns the latest analysis statuses or an error encountered by the API

func (*IonClient) GetLatestAnalysisSummaries added in v0.21.0

func (ic *IonClient) GetLatestAnalysisSummaries(teamID string, projectIDs []string, token string) ([]analyses.Summary, error)

GetLatestAnalysisSummaries takes a team ID, project IDs, and a token. It returns the latest analysis summaries for the given project. It returns an error for any API issues it encounters.

func (*IonClient) GetLatestAnalysisSummary added in v0.7.0

func (ic *IonClient) GetLatestAnalysisSummary(teamID, projectID, token string) (*analyses.Summary, error)

GetLatestAnalysisSummary takes a team ID, project ID, and token. It returns the latest analysis summary for the project. It returns an error for any API issues it encounters.

func (*IonClient) GetLatestPublicAnalysis added in v0.19.1

func (ic *IonClient) GetLatestPublicAnalysis(projectID, branch string) (*analyses.Analysis, error)

GetLatestPublicAnalysis takes a project ID and branch. It returns the analysis found. If the analysis is not found it will return an error, and will return an error for any other API issues it encounters.

func (*IonClient) GetLatestVersionForDependency added in v0.15.0

func (ic *IonClient) GetLatestVersionForDependency(packageName, ecosystem, token string) (*dependencies.Dependency, error)

GetLatestVersionForDependency takes a package name, an ecosystem to find the package in, and a token for accessing the API. It returns a dependency representation of the latest version and any errors it encounters with the API.

func (*IonClient) GetMttr added in v0.20.0

func (ic *IonClient) GetMttr(teamID, projectID string, token string) (*portfolios.Mttr, error)

GetMttr takes team id and optional project ID and returns the mttr for project If project id is not given, it will return mttr of all active projects on the team

func (*IonClient) GetOrganization added in v0.22.0

func (ic *IonClient) GetOrganization(id, token string) (*organizations.Organization, error)

GetOrganization takes an organization id and returns the Ion Channel representation of that organization.

func (*IonClient) GetOrganizations added in v0.22.0

func (ic *IonClient) GetOrganizations(ids requests.ByIDs, token string) (*[]organizations.Organization, error)

GetOrganizations takes one or more IDs and returns those organizations.

func (*IonClient) GetOwnOrganizations added in v0.22.0

func (ic *IonClient) GetOwnOrganizations(token string) (*[]organizations.UserOrganizationRole, error)

GetOwnOrganizations takes a token and returns a list of organizations the user belongs to.

func (*IonClient) GetPortfolioAffectedProjects added in v0.19.1

func (ic *IonClient) GetPortfolioAffectedProjects(teamID, externalID, token string) ([]portfolios.AffectedProject, error)

GetPortfolioAffectedProjects takes team id, external id, and a token (string) and returns a slice of affected projects

func (*IonClient) GetPortfolioAffectedProjectsInfo added in v0.19.1

func (ic *IonClient) GetPortfolioAffectedProjectsInfo(ids []string, token string) ([]portfolios.AffectedProject, error)

GetPortfolioAffectedProjectsInfo takes team id, external id, and a token (string) and returns a slice of affected projects

func (*IonClient) GetPortfolioPassFailSummary added in v0.19.1

func (ic *IonClient) GetPortfolioPassFailSummary(ids []string, token string) (*portfolios.PortfolioPassingFailingSummary, error)

GetPortfolioPassFailSummary takes project ids (slice of strings) and a token (string) and returns a status summary

func (*IonClient) GetPortfolioStartedErroredSummary added in v0.19.1

func (ic *IonClient) GetPortfolioStartedErroredSummary(ids []string, token string) (*portfolios.PortfolioStartedErroredSummary, error)

GetPortfolioStartedErroredSummary takes project ids (slice of strings) and a token (string) and returns PortfolioStartedErroredSummary

func (*IonClient) GetProductSearch added in v0.14.0

func (ic *IonClient) GetProductSearch(query string, page pagination.Pagination, token string) ([]products.Product, *responses.Meta, error)

GetProductSearch takes a search query. It returns a new raw json message of all the matching products in the Bunsen dependencies table

func (*IonClient) GetProductVersions added in v0.19.1

func (ic *IonClient) GetProductVersions(name, version, token string) ([]products.Product, error)

GetProductVersions takes a product name, version, and token. It returns the product versions found, and any API errors it may encounters.

func (*IonClient) GetProducts added in v0.6.0

func (ic *IonClient) GetProducts(idSearch, token string) ([]products.Product, error)

GetProducts takes a product ID search string and token. It returns the product found, and any API errors it may encounters.

func (*IonClient) GetProject added in v0.3.0

func (ic *IonClient) GetProject(id, teamID, token string) (*projects.Project, error)

GetProject takes a project ID, team ID, and token. It returns the project and an error if it receives a bad response from the API or fails to unmarshal the JSON response from the API.

func (*IonClient) GetProjectByURL added in v0.15.0

func (ic *IonClient) GetProjectByURL(uri, teamID, token string) (*projects.Project, error)

GetProjectByURL takes a uri, teamID, and API token to request the noted project from the API. It returns the project and any errors it encounters with the API.

func (*IonClient) GetProjectIdsByDependency added in v0.20.0

func (ic *IonClient) GetProjectIdsByDependency(teamID, name, org, version, token string) (*portfolios.ProjectsByDependency, error)

GetProjectIdsByDependency takes team id, external id, and a token (string) and returns a slice of affected projects

func (*IonClient) GetProjectPassFailHistory added in v0.20.0

func (ic *IonClient) GetProjectPassFailHistory(projectID, token string) ([]rulesets.ProjectPassFailHistory, error)

GetProjectPassFailHistory takes a project id and returns a daily history of pass/fail statuses

func (*IonClient) GetProjectReport added in v0.5.0

func (ic *IonClient) GetProjectReport(projectID, teamID, token string) (*reports.ProjectReport, error)

GetProjectReport takes a projectID, a teamID, and token. It returns the corresponding project report or an error encountered by the API

func (*IonClient) GetProjects added in v0.7.0

func (ic *IonClient) GetProjects(teamID, token string, page pagination.Pagination, filter *projects.Filter) ([]projects.Project, error)

GetProjects takes a team ID and returns the projects for that team. It returns an error for any API errors it may encounter.

func (*IonClient) GetProjectsNames added in v0.20.0

func (ic *IonClient) GetProjectsNames(teamID string, ids []string, token string) ([]projects.Name, error)

GetProjectsNames takes a team ID and slice of project ids. it returns slice of project ids, and project names

func (*IonClient) GetProjectsStates added in v0.19.1

func (ic *IonClient) GetProjectsStates(ids []string, filter string, token string) ([]scanner.ProjectsStates, error)

GetProjectsStates takes a slice of project ids and an optional filter returns a slice of id's with each respected state

func (*IonClient) GetProjectsStatusHistory added in v0.20.0

func (ic *IonClient) GetProjectsStatusHistory(ids []string, token string) ([]portfolios.StatusesHistory, error)

GetProjectsStatusHistory takes slice of project ids and token and returns list of status history for projects

func (*IonClient) GetPublicAnalysis added in v0.15.0

func (ic *IonClient) GetPublicAnalysis(id string) (*analyses.Analysis, error)

GetPublicAnalysis takes an analysis ID. It returns the analysis found. If the analysis is not found it will return an error, and will return an error for any other API issues it encounters.

func (*IonClient) GetRawAnalyses added in v0.13.0

func (ic *IonClient) GetRawAnalyses(teamID, projectID, token string, page pagination.Pagination) (json.RawMessage, error)

GetRawAnalyses takes a team ID, project ID, and token. It returns the raw JSON from the API. It returns an error for any API issue it encounters.

func (*IonClient) GetRawAnalysis added in v0.7.0

func (ic *IonClient) GetRawAnalysis(id, teamID, projectID, token string) (json.RawMessage, error)

GetRawAnalysis takes an analysis ID, team ID, project ID, and token. It returns the raw JSON from the API. It returns an error for any API issues it encounters.

func (*IonClient) GetRawAnalysisReport added in v0.5.0

func (ic *IonClient) GetRawAnalysisReport(analysisID, teamID, projectID, token string) (json.RawMessage, error)

GetRawAnalysisReport takes an analysisID, teamID, projectID, and token. It returns the corresponding analysis report json or an error encountered by the API

func (*IonClient) GetRawAppliedRuleSet added in v0.5.0

func (ic *IonClient) GetRawAppliedRuleSet(projectID, teamID, analysisID, token string, page pagination.Pagination) (json.RawMessage, error)

GetRawAppliedRuleSet takes a projectID, teamID, analysisID, and page definition and returns the corresponding applied ruleset summary json or an error encountered by the API

func (*IonClient) GetRawDependencyList added in v0.20.0

func (ic *IonClient) GetRawDependencyList(ids []string, listType, limit, token string) ([]byte, error)

GetRawDependencyList gets a raw response from the API

func (*IonClient) GetRawLatestAnalysisSummary added in v0.7.0

func (ic *IonClient) GetRawLatestAnalysisSummary(teamID, projectID, token string) (json.RawMessage, error)

GetRawLatestAnalysisSummary takes a team ID, project ID, and token. It returns the raw JSON from the API. It returns an error for any API issues it encounters.

func (*IonClient) GetRawProducts added in v0.6.0

func (ic *IonClient) GetRawProducts(idSearch, token string) (json.RawMessage, error)

GetRawProducts takes a product ID search string and token. It returns a raw json message of the product found, and any API errors it may encounters.

func (*IonClient) GetRawProject added in v0.4.0

func (ic *IonClient) GetRawProject(id, teamID, token string) (json.RawMessage, error)

GetRawProject takes a project ID, team ID, and token. It returns the raw json of the project. It also returns any API errors it may encounter.

func (*IonClient) GetRawProjectReport added in v0.5.0

func (ic *IonClient) GetRawProjectReport(projectID, teamID, token string) (json.RawMessage, error)

GetRawProjectReport takes a projectID, a teamID, and token. It returns the corresponding project report json or an error encountered by the API

func (*IonClient) GetRawTag added in v0.14.0

func (ic *IonClient) GetRawTag(id, teamID, token string) (json.RawMessage, error)

GetRawTag takes a tag ID and a team ID. It returns the details of a singular tag and any errors encountered with the API.

func (*IonClient) GetRawTags added in v0.14.0

func (ic *IonClient) GetRawTags(teamID, token string) (json.RawMessage, error)

GetRawTags takes a team ID. It returns the details of a singular tag and any errors encountered with the API.

func (*IonClient) GetRawVulnerability added in v0.6.0

func (ic *IonClient) GetRawVulnerability(id, token string) (json.RawMessage, error)

GetRawVulnerability takes an ID string and returns the raw json message found for that ID. An error is returned for API errors.

func (*IonClient) GetRawVulnerabilityList added in v0.19.1

func (ic *IonClient) GetRawVulnerabilityList(ids []string, listType, limit, token string) ([]byte, error)

GetRawVulnerabilityList gets a raw response from the API

func (*IonClient) GetRawVulnerabilityMetrics added in v0.19.1

func (ic *IonClient) GetRawVulnerabilityMetrics(ids []string, metric, token string) ([]byte, error)

GetRawVulnerabilityMetrics takes slice of strings (project ids), metric, and token and returns raw response from the API

func (*IonClient) GetRepo added in v0.15.0

func (ic *IonClient) GetRepo(repo, token string) (*community.Repo, error)

GetRepo takes in a repository string and calls the Ion API to get a pointer to the Ionic community.Repo

func (*IonClient) GetReposForActor added in v0.21.0

func (ic *IonClient) GetReposForActor(name, token string) ([]community.Repo, error)

GetReposForActor takes in an user, committer or actor string and calls the Ion API to get a slice of Ionic community.Repo

func (*IonClient) GetReposInCommon added in v0.21.0

func (ic *IonClient) GetReposInCommon(options GetReposInCommonOptions, token string) ([]GetReposInCommonOutput, error)

GetReposInCommon takes in an subject repo, a slice of string camparands and bool option for actors

and calls the Ion API to get matches with the count of committers shared

func (*IonClient) GetRuleSet added in v0.2.0

func (ic *IonClient) GetRuleSet(ruleSetID, teamID, token string) (*rulesets.RuleSet, error)

GetRuleSet takes a rule set ID and a teamID returns the corresponding rule set or an error encountered by the API

func (*IonClient) GetRuleSets added in v0.2.0

func (ic *IonClient) GetRuleSets(teamID, token string, page pagination.Pagination) ([]rulesets.RuleSet, error)

GetRuleSets takes a teamID and page definition and returns a collection of rule sets or an error encountered by the API

func (*IonClient) GetRulesetNames added in v0.20.0

func (ic *IonClient) GetRulesetNames(ids []string, token string) ([]rulesets.NameForID, error)

GetRulesetNames takes slice of ids and returns the ruleset names with the ids

func (*IonClient) GetSBOM added in v0.21.0

func (ic *IonClient) GetSBOM(ids []string, teamID string, options reports.SBOMExportOptions, token string) (string, error)

GetSBOM takes slice of project ids, team id, SBOM format, and token. Returns one or more SBOMs for the requested project(s).

func (*IonClient) GetSbom added in v0.22.0

func (ic *IonClient) GetSbom(id, token string) (projects.SBOM, error)

GetSbom takes an SBOM ID. Returns the requested SBOM, or any error that occurred.

func (*IonClient) GetSboms added in v0.22.0

func (ic *IonClient) GetSboms(orgID, status, token string) ([]projects.SBOM, error)

GetSboms takes an organization ID, and a status to filter on, if given. Returns the organization's SBOMs, filtered on the status if given, or any error that occurred.

func (*IonClient) GetSearch added in v0.19.1

func (ic *IonClient) GetSearch(query, tbs, token string) ([]SearchMatch, *responses.Meta, error)

GetSearch takes a query to perform and a to be searched param a productidentifier search against the Ion API, assembling a slice of Ionic products.ProductSearchResponse objects

func (*IonClient) GetSecrets added in v0.21.0

func (ic *IonClient) GetSecrets(text string, token string) ([]secrets.Secret, error)

GetSecrets takes a text input and returns any matching secrets

func (*IonClient) GetSelf

func (ic *IonClient) GetSelf(token string) (*users.User, error)

GetSelf returns the user object associated with the bearer token provided. An error is returned if the client cannot talk to the API or the returned user object is nil or blank

func (*IonClient) GetTag added in v0.14.0

func (ic *IonClient) GetTag(id, teamID, token string) (*tags.Tag, error)

GetTag takes a tag ID and a team ID. It returns the details of a singular tag and any errors encountered with the API.

func (*IonClient) GetTags added in v0.14.0

func (ic *IonClient) GetTags(teamID, token string) ([]tags.Tag, error)

GetTags takes a team ID. It returns the details of a singular tag and any errors encountered with the API.

func (*IonClient) GetTeam added in v0.4.2

func (ic *IonClient) GetTeam(id, token string) (*teams.Team, error)

GetTeam takes a team id and returns the Ion Channel representation of that team. An error is returned for client communications and unmarshalling errors.

func (*IonClient) GetTeams added in v0.19.1

func (ic *IonClient) GetTeams(token string) ([]teams.Team, error)

GetTeams returns the Ion Channel representation of that team. An error is returned for client communications and unmarshalling errors.

func (*IonClient) GetUsedRulesetIds added in v0.20.0

func (ic *IonClient) GetUsedRulesetIds(teamID, token string) ([]projects.RulesetID, error)

GetUsedRulesetIds takes a team ID and returns rulesets used by all projects in that team

func (*IonClient) GetUser added in v0.19.1

func (ic *IonClient) GetUser(id, token string) (*users.User, error)

GetUser returns the user object associated with the bearer token provided. An error is returned if the client cannot talk to the API or the returned user object is nil or blank

func (*IonClient) GetUserNames added in v0.20.0

func (ic *IonClient) GetUserNames(ids []string, teamID, token string) ([]users.NameAndID, error)

GetUserNames takes slice of ids and teamID and returns user names with their ids

func (*IonClient) GetUsers added in v0.19.1

func (ic *IonClient) GetUsers(token string) ([]users.User, error)

GetUsers requests and returns all users for a given installation

func (*IonClient) GetVersionsForDependency added in v0.19.1

func (ic *IonClient) GetVersionsForDependency(packageName, ecosystem, token string) ([]dependencies.Dependency, error)

GetVersionsForDependency takes a package name, an ecosystem to find the package in, and a token for accessing the API. It returns a dependency representation of the latest versions and any errors it encounters with the API.

func (*IonClient) GetVulnerabilities

func (ic *IonClient) GetVulnerabilities(product, version, token string, page pagination.Pagination) ([]vulnerabilities.Vulnerability, error)

GetVulnerabilities returns a slice of Vulnerability for a given product and version string over a specified pagination range. If version is left blank, it will not be considered in the search query. An error is returned for client communication and unmarshalling errors.

Example
package main

import (
	"fmt"

	"github.com/ion-channel/ionic"
	"github.com/ion-channel/ionic/pagination"
)

func main() {
	client, err := ionic.New("https://api.test.ionchannel.io")
	if err != nil {
		panic(fmt.Sprintf("Panic creating Ion Client: %v", err.Error()))
	}

	vulns, err := client.GetVulnerabilities("jdk", "", "atoken", pagination.AllItems)
	if err != nil {
		fmt.Println(err.Error())
	}

	fmt.Printf("Vulnerabilities: %v\n", vulns)
}
Output:

Example (Version)
package main

import (
	"fmt"

	"github.com/ion-channel/ionic"
	"github.com/ion-channel/ionic/pagination"
)

func main() {
	client, err := ionic.New("https://api.test.ionchannel.io")
	if err != nil {
		panic(fmt.Sprintf("Panic creating Ion Client: %v", err.Error()))
	}

	vulns, err := client.GetVulnerabilities("jdk", "1.7.0", "atoken", pagination.AllItems)
	if err != nil {
		fmt.Println(err.Error())
	}

	fmt.Printf("Vulnerabilities: %v\n", vulns)
}
Output:

func (*IonClient) GetVulnerabilitiesInFile

func (ic *IonClient) GetVulnerabilitiesInFile(filePath, token string) ([]vulnerabilities.Vulnerability, error)

GetVulnerabilitiesInFile takes the location of a dependency file and returns a slice of vulnerabilities found for the list of dependencies. An error is returned if the file can't be cannot be read, the API returns an error, or marshalling issues.

func (*IonClient) GetVulnerability

func (ic *IonClient) GetVulnerability(id, token string) (*vulnerabilities.Vulnerability, error)

GetVulnerability takes an ID string and returns the vulnerability found for that ID. An error is returned for API errors and marshalling errors.

Example
package main

import (
	"fmt"

	"github.com/ion-channel/ionic"
)

func main() {
	client, err := ionic.New("https://api.test.ionchannel.io")
	if err != nil {
		panic(fmt.Sprintf("Panic creating Ion Client: %v", err.Error()))
	}

	vuln, err := client.GetVulnerability("CVD-2014-0030", "atoken")
	if err != nil {
		fmt.Println(err.Error())
	}

	fmt.Printf("Vulnerability: %v\n", vuln)
}
Output:

func (*IonClient) GetVulnerabilityStats added in v0.19.1

func (ic *IonClient) GetVulnerabilityStats(ids []string, token string) (*portfolios.VulnerabilityStat, error)

GetVulnerabilityStats takes slice of project ids and token and returns vulnerability stats and any errors

func (*IonClient) Head added in v0.19.1

func (ic *IonClient) Head(endpoint, token string, params url.Values, headers http.Header, page pagination.Pagination) error

Head takes an endpoint, token, params, headers, and pagination params to pass as a head call to the API. It will return any errors it encounters with the API.

func (*IonClient) Login

func (ic *IonClient) Login(username, password string) (Session, error)

Login performs basic auth requests with a username and returns a Login response with bearer token and user for the session. Returns an error for HTTP and JSON errors.

Example
package main

import (
	"fmt"

	"github.com/ion-channel/ionic"
)

func main() {
	client, err := ionic.New("https://api.test.ionchannel.io")
	if err != nil {
		panic(fmt.Sprintf("Panic creating Ion Client: %v", err.Error()))
	}

	sess, err := client.Login("someusername", "supersecretpassword")
	if err != nil {
		fmt.Println(err.Error())
	}

	vuln, _ := client.GetVulnerability("CVE-1234-1234", sess.BearerToken)
	fmt.Printf("Vulns: %v\n", vuln)
}
Output:

func (*IonClient) Patch added in v0.19.1

func (ic *IonClient) Patch(endpoint, token string, params url.Values, payload bytes.Buffer, headers http.Header) (json.RawMessage, error)

Patch takes an endpoint, token, params, payload, and headers to pass as a patch call to the API. It will return a json RawMessage for the response and any errors it encounters with the API.

func (*IonClient) Post added in v0.9.1

func (ic *IonClient) Post(endpoint, token string, params url.Values, payload bytes.Buffer, headers http.Header) (json.RawMessage, error)

Post takes an endpoint, token, params, payload, and headers to pass as a post call to the API. It will return a json RawMessage for the response and any errors it encounters with the API.

func (*IonClient) ProductSearch added in v0.15.0

func (ic *IonClient) ProductSearch(searchInput products.ProductSearchQuery, token string) ([]products.Product, error)

ProductSearch takes a search query. It returns a new raw json message of all the matching products in the Bunsen dependencies table

func (*IonClient) Put added in v0.9.1

func (ic *IonClient) Put(endpoint, token string, params url.Values, payload bytes.Buffer, headers http.Header) (json.RawMessage, error)

Put takes an endpoint, token, params, payload, and headers to pass as a put call to the API. It will return a json RawMessage for the response and any errors it encounters with the API.

func (*IonClient) ResolveDependenciesInFile added in v0.19.1

ResolveDependenciesInFile takes a dependency file location and token to send the specified file to the API. All dependencies that are able to be resolved will be with their info returned, and a list of any errors encountered during the process.

func (*IonClient) RuleSetExists added in v0.19.1

func (ic *IonClient) RuleSetExists(ruleSetID, teamID, token string) (bool, error)

RuleSetExists takes a ruleSetID, teamId and token string and checks against api to see if ruleset exists. It returns whether or not ruleset exists and any errors it encounters with the API.

func (*IonClient) SearchDependencies added in v0.19.1

func (ic *IonClient) SearchDependencies(q string, page pagination.Pagination, token string) ([]dependencies.Dependency, *responses.Meta, error)

SearchDependencies takes a query `org AND name` and calls the Ion API to retrieve the information, then forms a slice of Ionic dependencies.Dependency objects

func (*IonClient) SearchRepo added in v0.15.0

func (ic *IonClient) SearchRepo(q string, page pagination.Pagination, token string) ([]community.Repo, *responses.Meta, error)

SearchRepo takes a query `org AND name` and calls the Ion API to retrieve the information, then forms a slice of Ionic community.Repo objects

func (*IonClient) Session added in v0.22.0

func (ic *IonClient) Session() Session

Session returns the client's internal Session. This Session is set and renewed automatically if the EnableSessionAutoRenew method is used.

func (*IonClient) SetSession added in v0.22.0

func (ic *IonClient) SetSession(session Session)

SetSession sets the client's internal Session that can be used to authenticate when making API requests. The session can safely be set to null. Example: myClient.GetSelf(myClient.Session().BearerToken)

func (*IonClient) UpdateOrganization added in v0.22.0

func (ic *IonClient) UpdateOrganization(id string, name string, token string) (*organizations.Organization, error)

UpdateOrganization takes an organization ID, and the fields to update, returns the updated organization.

func (*IonClient) UpdateOwnUserPreferences added in v0.22.0

func (ic *IonClient) UpdateOwnUserPreferences(preferences users.Preferences, token string) error

UpdateOwnUserPreferences takes a Preferences object and returns any errors that occurred while updating your preferences.

func (*IonClient) UpdateProject added in v0.7.1

func (ic *IonClient) UpdateProject(project *projects.Project, token string) (*projects.Project, error)

UpdateProject takes a project to update and token to use. It returns the project stored or an error encountered by the API

func (*IonClient) UpdateTag added in v0.15.0

func (ic *IonClient) UpdateTag(id, teamID, name, description, token string) (*tags.Tag, error)

UpdateTag takes an ID, team ID, name, and description. It returns the details of the updated tag, or any errors encountered with the API.

func (*IonClient) UpdateTeamUser added in v0.19.1

func (ic *IonClient) UpdateTeamUser(teamuser *teamusers.TeamUser, token string) (*teamusers.TeamUser, error)

UpdateTeamUser takes a teamUser object in the desired state and then makes the calls to update the teamUser. It returns the update teamUser and any errors it encounters with the API.

func (*IonClient) UpdateUserPreferences added in v0.22.0

func (ic *IonClient) UpdateUserPreferences(userID string, preferences users.Preferences, token string) error

UpdateUserPreferences takes a user ID and a Preferences object and returns any errors that occurred while updating the user's preferences.

func (IonClient) WithContext added in v0.22.0

func (ic IonClient) WithContext(ctx context.Context) *IonClient

WithContext can be used to create a new temporary IonClient with all the same options as the one this method is called on. NOTICE: the receiver (ic IonClient) is NOT a pointer, so the receiver is not mutated. This returns a copy.

type IonClientOptions added in v0.22.0

type IonClientOptions struct {
	BaseURL string          `envconfig:"BASE_URL" default:"https://api.ionchannel.io"`
	Client  *http.Client    `ignored:"true"`
	Context context.Context `ignored:"true"`
}

IonClientOptions represents the options available when creating a new IonClient. All the options are optional and will be replaced with working defaults if left empty/nil. Some options can be set via environment variables; prefix the envconfig value with "IONIC_" to get the variable name.

type SearchMatch added in v0.20.0

type SearchMatch struct {
	// Requires common fields to be explicitly
	// defined here
	Name       string    `json:"name"`
	CreatedAt  time.Time `json:"created_at,omitempty"`
	UpdatedAt  time.Time `json:"updated_at"`
	Confidence float32   `json:"confidence"`
	Version    string    `json:"version,omitempty"`
	Org        string    `json:"org,omitempty"`
	Type       string    `json:"type,omitempty"`
	ExternalID string    `json:"external_id,omitempty"`

	// Clean up the output
	Vulnerabilities *interface{} `json:"vulnerabilities,omitempty"`
	Source          *interface{} `json:"source,omitempty"`
	References      *interface{} `json:"references,omitempty"`
	Aliases         *interface{} `json:"aliases,omitempty"`
	Dependencies    *interface{} `json:"dependencies,omitempty"`

	*community.Repo          `json:",omitempty"`
	*products.Product        `json:",omitempty"`
	*dependencies.Dependency `json:",omitempty"`
	*searches.Report         `json:",omitempty"`
}

SearchMatch structure for holding multiple search response types

type Session

type Session struct {
	BearerToken string     `json:"jwt"`
	User        users.User `json:"user"`
}

Session represents the BearerToken and User for the current session

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL