Cx1ClientGo

package module
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: GPL-3.0 Imports: 14 Imported by: 9

README

This is a basic CheckmarxOne REST API client written in GoLang. It already covers much of the CheckmarxOne API allowing Read operations on Applications, Clients, Groups, Presets, Projects, Queries, Reports, Results, Roles, Scans, and Users. Many of these include full CRUD support but this is still a work in progress.

Feel free to use or modify this code, open issues, or submit pull requests. Please submit pull requests against the Dev branch - I will try to keep the main branch clean with only tagged versions. Since this code is changing regularly, consider using a specific tag of Cx1ClientGo until you can test against a newer release.

Basic usage:

package main

import (
	"github.com/cxpsemea/Cx1ClientGo"
	log "github.com/sirupsen/logrus"
	"os"
    "net/http"
)

func main() {
	logger := log.New()
	logger.Info( "Starting" )

	base_url := os.Args[1]
	iam_url := os.Args[2]
	tenant := os.Args[3]
	api_key := os.Args[4]

	cx1client, err := Cx1ClientGo.NewAPIKeyClient( &http.Client{}, base_url, iam_url, tenant, api_key, logger )
	if err != nil {
		log.Error( "Error creating client: " + err.Error() )
		return 
	}

	// no err means that the client is initialized
	logger.Info( "Client initialized: " + cx1client.ToString() )
}

More complete workflow example:

package main

import (
	"github.com/cxpsemea/Cx1ClientGo"
	log "github.com/sirupsen/logrus"
	"os"
	"time"
	"net/http"
	"net/url"
	"crypto/tls"
)

func main() {
	logger := log.New()
	logger.Info( "Starting" )
	//logger.SetLevel( log.TraceLevel ) 

	base_url := os.Args[1]
	iam_url := os.Args[2]
	tenant := os.Args[3]
	api_key := os.Args[4]
	project_name := os.Args[5]
	group_name := os.Args[6]
	project_repo := os.Args[7]
	branch_name := os.Args[8]
	
	proxyURL, err := url.Parse( "http://127.0.0.1:8080" )
	transport := &http.Transport{}
	transport.Proxy = http.ProxyURL(proxyURL)
	transport.TLSClientConfig = &tls.Config{ InsecureSkipVerify: true, }
	
	httpClient := &http.Client{}
	//httpClient.Transport = transport
	
	
	cx1client, err := Cx1ClientGo.NewAPIKeyClient( httpClient, base_url, iam_url, tenant, api_key, logger )
	if err != nil {
		log.Error( "Error creating client: " + err.Error() )
		return 
	}

	// no err means that the client is initialized
	logger.Info( "Client initialized: " + cx1client.ToString() )
	
	group, err := cx1client.GetGroupByName( group_name )
	if err != nil {
		if err.Error() != "No matching group found" {
			logger.Infof( "Failed to retrieve group named %s: %v", group_name, err )
			return
		}
		
		logger.Infof( "No group named %s exists - it will now be created", group_name )
		group, err = cx1client.CreateGroup( group_name )
		if err != nil {
			logger.Errorf( "Failed to create group %s: %v", group_name, err )
			return
		}
		
		logger.Infof( "Created group named '%v' with ID %v", group.Name, group.GroupID )
	} else {	
		logger.Infof( "Found group named %v with ID %v", group.Name, group.GroupID )
	}
	
	projects, err := cx1client.GetProjectsByNameAndGroup( project_name, group.GroupID )
	if err != nil {
		logger.Errorf( "Failed to retrieve project named %s: %v", project_name, err )
		return
	}	
	
	var project Cx1ClientGo.Project
	if len(projects) == 0 {
		logger.Infof( "No project named %s found under group %s - it will now be created", project_name, group_name )
		project, err = cx1client.CreateProject( project_name, group.GroupID, map[string]string{ "CreatedBy" : "Cx1ClientGo" } )
		if err != nil {
			logger.Errorf( "Failed to create project %s: %v", project_name, err )
			return
		}
		logger.Infof( "Created project named '%v' with ID %v", project.Name, project.ProjectID )
	} else {
		project = projects[0]
		logger.Infof( "First project matching '%v' in group '%v' is named '%v' with ID %v", project_name, group_name, project.Name, project.ProjectID )
	}
	
	scanConfig := Cx1ClientGo.ScanConfiguration{}
	scanConfig.ScanType = "sast"
	scanConfig.Values = map[string]string{ "incremental" : "false" }
	
	scan, err := cx1client.ScanProjectGitByID( project.ProjectID, project_repo, branch_name, []Cx1ClientGo.ScanConfiguration{scanConfig}, map[string]string{ "CreatedBy" : "Cx1ClientGo" } )
	
	if err != nil {
		logger.Errorf( "Failed to trigger scan with repository '%v' branch '%v': %s", project_repo, branch_name, err )
		return
	}
	
	logger.Infof( "Triggered scan %v, polling status", scan.ScanID )
	for scan.Status == "Running" {
		time.Sleep( 10 * time.Second )
		scan, err = cx1client.GetScanByID( scan.ScanID )
		if err != nil {
			logger.Errorf( "Failed to get scan status: %v", err )
			return
		}
		logger.Infof( " - %v", scan.Status )
	}
	
	reportID, err := cx1client.RequestNewReportByID( scan.ScanID, project.ProjectID, branch_name, "pdf" )
	if err != nil {
		logger.Errorf( "Failed to trigger new report generation for scan ID %v, project ID %v: %s", scan.ScanID, project.ProjectID, err )
		return
	}
	
	logger.Infof( "Generating report %v, polling status", reportID )
	var status Cx1ClientGo.ReportStatus
	
	for status.Status != "completed" {
		time.Sleep( 10 * time.Second )
		status, err = cx1client.GetReportStatusByID( reportID )
		if err != nil {
			logger.Errorf( "Failed to get report status: %v", err )
			return
		}
		
		logger.Infof( " - %v", status.Status )
	}
	
	logger.Infof( "Downloading report from %v", status.ReportURL )
	reportData, err := cx1client.DownloadReport( status.ReportURL )
	if err != nil {
		logger.Errorf( "Failed to download report: %s", err )
		return
	}
	
	err = os.WriteFile( "report.pdf", reportData, 0o700 )
	if err != nil {
		logger.Errorf( "Failed to Update report: %s", err )
		return
	}
	logger.Info( "Report Updated to report.pdf" )
	
	scanresults, err := cx1client.GetScanResultsByID( scan.ScanID )
	if err != nil && len(scanresults) == 0 {
		logger.Errorf( "Failed to retrieve scan results: %s", err )
		return
	}
	
	if err != nil {
		logger.Infof( "Results retrieved but error thrown: %s", err ) // can be "remote error: tls: user canceled" but still returns results
	} else {
		logger.Infof( "%d results retrieved", len(scanresults) )
	}
	
	for _, result := range scanresults {
		logger.Infof( "Finding with similarity ID: %v", result.SimilarityID )
	}
}

Invocation for the more complicated example: go run . "https://eu.ast.checkmarx.net" "https://eu.iam.checkmarx.net" "tenant" "API Key" "Project Name" "Group Name" "https://my.github/project/repo" "branch"

Current API coverage:

Cx1: Delete /api/applications/%v
Cx1: Delete /api/presets/%d
Cx1: Delete /api/projects/%v
Cx1: Get /api/applications?%v
Cx1: Get /api/applications?%v
Cx1: Get /api/applications?%v
Cx1: Get /api/applications?%v
Cx1: Get /api/configuration/project?%v
Cx1: Get /api/presets/%d
Cx1: Get /api/presets/queries
Cx1: Get /api/projects/
Cx1: Get /api/projects/%v
Cx1: Get /api/projects/?%v
Cx1: Get /api/projects/?%v
Cx1: Get /api/projects?%v
Cx1: Get /api/projects?%v
Cx1: Get /api/projects?%v
Cx1: Get /api/queries/%d
Cx1: Get /api/queries/presets
Cx1: Get /api/reports/%v
Cx1: Get /api/results/?%v
Cx1: Get /api/results/?%v
Cx1: Get /api/sast-metadata/%v
Cx1: Get /api/sast-results-predicates/%d?project-ids=%v
Cx1: Get /api/scans/%v
Cx1: Get /api/scans?%v
Cx1: Get /api/scans?%v
Cx1: Get /api/scan-summary/?%v
Cx1: Patch /api/configuration/project?%v
Cx1: Post /api/applications
Cx1: Post /api/presets
Cx1: Post /api/projects
Cx1: Post /api/reports
Cx1: Post /api/sast-results-predicates
Cx1: Post /api/scans
Cx1: Post /api/uploads
Cx1: Put /api/applications/%v
Cx1: Put /api/presets/%d
Cx1: Put /api/projects/%v
IAM: Delete /auth/admin/tenant/groups/%v
IAM: Delete /auth/admin/tenant/groups/%v/role-mappings/clients/%v
IAM: Delete /auth/admin/tenant/roles-by-id/%v
IAM: Delete /auth/admin/tenant/roles-by-id/%v/composites
IAM: Delete /auth/admin/tenant/users/%v
IAM: Delete /auth/admin/tenant/users/%v/groups/%v
IAM: Delete /auth/admin/tenant/users/%v/role-mappings/clients/%v
IAM: Delete /auth/admin/tenant/users/%v/role-mappings/realm
IAM: Get /auth/admin/tenant
IAM: Get /auth/admin/tenant/clients/%v/roles/%v
IAM: Get /auth/admin/tenant/clients/%v/roles?briefRepresentation=true
IAM: Get /auth/admin/tenant/clients?briefRepresentation=true
IAM: Get /auth/admin/tenant/groups/%v?%v
IAM: Get /auth/admin/tenant/groups?briefRepresentation=true
IAM: Get /auth/admin/tenant/groups?briefRepresentation=true&search=%v
IAM: Get /auth/admin/tenant/groups?briefRepresentation=true&search=%v
IAM: Get /auth/admin/tenant/roles/%v
IAM: Get /auth/admin/tenant/roles?briefRepresentation=true
IAM: Get /auth/admin/tenant/roles-by-id/%v
IAM: Get /auth/admin/tenant/roles-by-id/%v/composites
IAM: Get /auth/admin/tenant/users
IAM: Get /auth/admin/tenant/users/%v
IAM: Get /auth/admin/tenant/users/%v/groups
IAM: Get /auth/admin/tenant/users/%v/role-mappings/clients/%v
IAM: Get /auth/admin/tenant/users/%v/role-mappings/realm
IAM: Get /auth/admin/tenant/users/?exact=true&email=%v
IAM: Get /auth/admin/tenant/users/?exact=true&username=%v
IAM: Get /auth/tenant/pip/groups
IAM: Post /auth/admin/tenant/children
IAM: Post /auth/admin/tenant/clients/%v/roles
IAM: Post /auth/admin/tenant/groups
IAM: Post /auth/admin/tenant/groups/%v/children
IAM: Post /auth/admin/tenant/groups/%v/role-mappings/clients/%v
IAM: Post /auth/admin/tenant/roles-by-id/%v/composites
IAM: Post /auth/admin/tenant/users/%v/role-mappings/clients/%v
IAM: Post /auth/admin/tenant/users/%v/role-mappings/realm
IAM: Put /auth/admin/tenant/groups/%v
IAM: Put /auth/admin/tenant/users/%v
IAM: Put /auth/admin/tenant/users/%v/groups/%v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveIndex added in v0.0.11

func RemoveIndex(slice []interface{}, index int) []interface{}

func ShortenGUID

func ShortenGUID(guid string) string

Types

type AccessAssignment added in v0.0.15

type AccessAssignment struct {
	TenantID     string   `json:"tenantID"`
	EntityID     string   `json:"entityID"`
	EntityType   string   `json:"entityType"`
	EntityName   string   `json:"entityName"`
	EntityRoles  []string `json:"entityRoles"`
	ResourceID   string   `json:"resourceID"`
	ResourceType string   `json:"resourceType"`
	ResourceName string   `json:"resourceName"`
	CreatedAt    string   `json:"createdAt"`
}

type AccessibleResource added in v0.0.15

type AccessibleResource struct {
	ResourceID   string   `json:"resourceId"`
	ResourceType string   `json:"resourceType"`
	Roles        []string `json:"roles"`
}

type Application

type Application struct {
	ApplicationID string            `json:"id"`
	Name          string            `json:"name"`
	Description   string            `json:"description"`
	Criticality   uint              `json:"criticality"`
	Rules         []ApplicationRule `json:"rules"`
	Tags          map[string]string `json:"tags"`
	ProjectIds    []string          `json:"projectIds"`
	CreatedAt     string            `json:"createdAt"`
	UpdatedAt     string            `json:"updatedAt"`
}

func (*Application) AddRule

func (a *Application) AddRule(ruletype, value string)

func (*Application) AssignProject

func (a *Application) AssignProject(project *Project)

func (*Application) GetRuleByType

func (a *Application) GetRuleByType(ruletype string) *ApplicationRule

func (*Application) String

func (a *Application) String() string

type ApplicationRule

type ApplicationRule struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

type AuditQuery added in v0.0.11

type AuditQuery struct {
	QueryID            uint64 `json:"Id,string"`
	Level              string
	Path               string
	Modified           string
	Source             string
	Cwe                int64
	Severity           uint
	IsExecutable       bool
	CxDescriptionId    int64
	QueryDescriptionId string

	Language string `json:"-"`
	Group    string `json:"-"`
	Name     string `json:"-"`
	LevelID  string `json:"-"`
}

func FindQueryByName added in v0.0.12

func FindQueryByName(queries []AuditQuery, level, language, group, name string) (AuditQuery, error)

func (AuditQuery) CreateApplicationOverrideByID added in v0.0.12

func (q AuditQuery) CreateApplicationOverrideByID(applicationId string) AuditQuery

func (AuditQuery) CreateProjectOverrideByID added in v0.0.12

func (q AuditQuery) CreateProjectOverrideByID(projectId string) AuditQuery

func (AuditQuery) CreateTenantOverride added in v0.0.12

func (q AuditQuery) CreateTenantOverride() AuditQuery

func (*AuditQuery) ParsePath added in v0.0.11

func (q *AuditQuery) ParsePath()

func (AuditQuery) String added in v0.0.11

func (q AuditQuery) String() string

type AuditQueryMetadata added in v0.0.11

type AuditQueryMetadata struct {
	Cwe                int64
	CxDescriptionID    int64
	IsExecutable       bool
	Modified           string
	Path               string
	QueryDescriptionID string
	Severity           uint
}

type ClientVars added in v0.0.19

type ClientVars struct {
	MigrationPollingMaxSeconds       int
	MigrationPollingDelaySeconds     int
	AuditEnginePollingMaxSeconds     int
	AuditEnginePollingDelaySeconds   int
	AuditScanPollingMaxSeconds       int
	AuditScanPollingDelaySeconds     int
	AuditLanguagePollingMaxSeconds   int
	AuditLanguagePollingDelaySeconds int
	AuditCompilePollingMaxSeconds    int
	AuditCompilePollingDelaySeconds  int
	ScanPollingMaxSeconds            int
	ScanPollingDelaySeconds          int
}

type Cx1Cache

type Cx1Cache struct {
	ProjectRefresh bool
	Projects       []Project
	GroupRefresh   bool
	Groups         []Group
	UserRefresh    bool
	Users          []User
	QueryRefresh   bool
	Queries        QueryCollection
	PresetRefresh  bool
	Presets        []Preset
	RoleRefresh    bool
	Roles          []Role
}

func (*Cx1Cache) GetGroup

func (c *Cx1Cache) GetGroup(groupID string) (*Group, error)

func (*Cx1Cache) GetGroupByName

func (c *Cx1Cache) GetGroupByName(name string) (*Group, error)

func (*Cx1Cache) GetPreset

func (c *Cx1Cache) GetPreset(presetID uint64) (*Preset, error)

func (*Cx1Cache) GetPresetByName

func (c *Cx1Cache) GetPresetByName(name string) (*Preset, error)

func (*Cx1Cache) GetProject

func (c *Cx1Cache) GetProject(projectID string) (*Project, error)

func (*Cx1Cache) GetProjectByName

func (c *Cx1Cache) GetProjectByName(name string) (*Project, error)

func (*Cx1Cache) GetQuery

func (c *Cx1Cache) GetQuery(queryID uint64) (*Query, error)

func (*Cx1Cache) GetQueryByNames

func (c *Cx1Cache) GetQueryByNames(language, group, query string) (*Query, error)

func (*Cx1Cache) GetRole

func (c *Cx1Cache) GetRole(roleID string) (*Role, error)

func (*Cx1Cache) GetRoleByName

func (c *Cx1Cache) GetRoleByName(name string) (*Role, error)

func (*Cx1Cache) GetUser

func (c *Cx1Cache) GetUser(userID string) (*User, error)

func (*Cx1Cache) GetUserByEmail

func (c *Cx1Cache) GetUserByEmail(email string) (*User, error)

func (*Cx1Cache) GetUserByString

func (c *Cx1Cache) GetUserByString(displaystring string) (*User, error)

func (*Cx1Cache) GroupSummary

func (c *Cx1Cache) GroupSummary() string

func (*Cx1Cache) PresetSummary

func (c *Cx1Cache) PresetSummary() string

func (*Cx1Cache) ProjectSummary

func (c *Cx1Cache) ProjectSummary() string

func (*Cx1Cache) QuerySummary

func (c *Cx1Cache) QuerySummary() string

func (*Cx1Cache) Refresh

func (c *Cx1Cache) Refresh(client *Cx1Client) error

func (*Cx1Cache) RefreshGroups

func (c *Cx1Cache) RefreshGroups(client *Cx1Client) error

func (*Cx1Cache) RefreshPresets

func (c *Cx1Cache) RefreshPresets(client *Cx1Client) error

func (*Cx1Cache) RefreshProjects

func (c *Cx1Cache) RefreshProjects(client *Cx1Client) error

func (*Cx1Cache) RefreshQueries

func (c *Cx1Cache) RefreshQueries(client *Cx1Client) error

func (*Cx1Cache) RefreshRoles

func (c *Cx1Cache) RefreshRoles(client *Cx1Client) error

func (*Cx1Cache) RefreshUsers

func (c *Cx1Cache) RefreshUsers(client *Cx1Client) error

func (*Cx1Cache) UserSummary

func (c *Cx1Cache) UserSummary() string

type Cx1Client

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

func NewAPIKeyClient

func NewAPIKeyClient(client *http.Client, base_url string, iam_url string, tenant string, api_key string, logger *logrus.Logger) (*Cx1Client, error)

func NewOAuthClient

func NewOAuthClient(client *http.Client, base_url string, iam_url string, tenant string, client_id string, client_secret string, logger *logrus.Logger) (*Cx1Client, error)

Main entry for users of this client:

func (Cx1Client) AddAccessAssignment added in v0.0.15

func (c Cx1Client) AddAccessAssignment(access AccessAssignment) error

func (Cx1Client) AddClientScopeByID added in v0.0.15

func (c Cx1Client) AddClientScopeByID(oidcId, clientScopeId string) error

func (Cx1Client) AddResultsPredicates

func (c Cx1Client) AddResultsPredicates(predicates []ResultsPredicates) error

results

func (Cx1Client) AddRoleComposites

func (c Cx1Client) AddRoleComposites(role *Role, roles *[]Role) error

func (Cx1Client) AddRolesToGroup added in v0.0.16

func (c Cx1Client) AddRolesToGroup(g *Group, clientRoles map[string][]string) error

clientRoles map looks like: "ast-app" : { "ast-scanner", "ast-viewer" }

func (Cx1Client) AddUserASTRoleMappings

func (c Cx1Client) AddUserASTRoleMappings(userID string, roles []Role) error

func (Cx1Client) AddUserAppRoles

func (c Cx1Client) AddUserAppRoles(user *User, roles *[]Role) error

func (Cx1Client) AddUserIAMRoles

func (c Cx1Client) AddUserIAMRoles(user *User, roles *[]Role) error

func (Cx1Client) AddUserRoleMappings

func (c Cx1Client) AddUserRoleMappings(userID string, clientID string, roles []Role) error

func (Cx1Client) AddUserRoles

func (c Cx1Client) AddUserRoles(user *User, roles *[]Role) error

func (Cx1Client) AssignUserToGroup

func (c Cx1Client) AssignUserToGroup(user *User, groupId string) error

func (Cx1Client) AssignUserToGroupByID

func (c Cx1Client) AssignUserToGroupByID(user *User, groupId string) error

func (Cx1Client) AuditCheckLanguagesByID added in v0.0.11

func (c Cx1Client) AuditCheckLanguagesByID(auditSessionId string) error

func (Cx1Client) AuditCompilePollingByID added in v0.0.11

func (c Cx1Client) AuditCompilePollingByID(auditSessionId string) error

func (Cx1Client) AuditCompilePollingByIDWithTimeout added in v0.0.25

func (c Cx1Client) AuditCompilePollingByIDWithTimeout(auditSessionId string, delaySeconds, maxSeconds int) error

func (Cx1Client) AuditCompileQuery added in v0.0.11

func (c Cx1Client) AuditCompileQuery(auditSessionId string, query AuditQuery) error

func (Cx1Client) AuditCreateCorpQuery added in v0.0.12

func (c Cx1Client) AuditCreateCorpQuery(auditSessionId string, query AuditQuery) (AuditQuery, error)

func (Cx1Client) AuditCreateSessionByID added in v0.0.11

func (c Cx1Client) AuditCreateSessionByID(projectId, scanId string) (string, error)

func (Cx1Client) AuditEnginePollingByID added in v0.0.11

func (c Cx1Client) AuditEnginePollingByID(auditSessionId string) error

func (Cx1Client) AuditEnginePollingByIDWithTimeout added in v0.0.25

func (c Cx1Client) AuditEnginePollingByIDWithTimeout(auditSessionId string, delaySeconds, maxSeconds int) error

func (Cx1Client) AuditFindSessionsByID added in v0.0.11

func (c Cx1Client) AuditFindSessionsByID(projectId, scanId string) (bool, []string, error)

func (Cx1Client) AuditGetEngineStatusByID added in v0.0.19

func (c Cx1Client) AuditGetEngineStatusByID(auditSessionId string) (bool, error)

func (Cx1Client) AuditGetLanguagesByID added in v0.0.19

func (c Cx1Client) AuditGetLanguagesByID(auditSessionId string) ([]string, error)

func (Cx1Client) AuditGetScanStatusByID added in v0.0.19

func (c Cx1Client) AuditGetScanStatusByID(auditSessionId string) (bool, error)

func (Cx1Client) AuditLanguagePollingByID added in v0.0.11

func (c Cx1Client) AuditLanguagePollingByID(auditSessionId string) ([]string, error)

func (Cx1Client) AuditLanguagePollingByIDWithTimeout added in v0.0.25

func (c Cx1Client) AuditLanguagePollingByIDWithTimeout(auditSessionId string, delaySeconds, maxSeconds int) ([]string, error)

func (Cx1Client) AuditNewQuery added in v0.0.12

func (c Cx1Client) AuditNewQuery(language, group, name string) (AuditQuery, error)

func (Cx1Client) AuditRunScanByID added in v0.0.11

func (c Cx1Client) AuditRunScanByID(auditSessionId string) error

func (Cx1Client) AuditScanPollingByID added in v0.0.11

func (c Cx1Client) AuditScanPollingByID(auditSessionId string) error

func (Cx1Client) AuditScanPollingByIDWithTimeout added in v0.0.25

func (c Cx1Client) AuditScanPollingByIDWithTimeout(auditSessionId string, delaySeconds, maxSeconds int) error

func (Cx1Client) AuditSessionKeepAlive added in v0.0.11

func (c Cx1Client) AuditSessionKeepAlive(auditSessionId string) error

func (Cx1Client) CheckAccessToResourceByID added in v0.0.15

func (c Cx1Client) CheckAccessToResourceByID(resourceId, resourceType, action string) (bool, error)

func (Cx1Client) CheckAccessibleResources added in v0.0.15

func (c Cx1Client) CheckAccessibleResources(resourceTypes []string, action string) (bool, []AccessibleResource, error)

func (Cx1Client) CheckFlag added in v0.0.18

func (c Cx1Client) CheckFlag(flag string) (bool, error)

func (Cx1Client) CreateASTRole

func (c Cx1Client) CreateASTRole(roleName, createdBy string) (Role, error)

func (Cx1Client) CreateAppRole

func (c Cx1Client) CreateAppRole(roleName, createdBy string) (Role, error)

func (Cx1Client) CreateApplication

func (c Cx1Client) CreateApplication(appname string) (Application, error)

func (Cx1Client) CreateChildGroup

func (c Cx1Client) CreateChildGroup(parentGroup *Group, childGroupName string) (Group, error)

func (Cx1Client) CreateClient added in v0.0.15

func (c Cx1Client) CreateClient(name, notificationEmail string, secretExpiration int) (OIDCClient, error)

func (Cx1Client) CreateGroup

func (c Cx1Client) CreateGroup(groupname string) (Group, error)

func (Cx1Client) CreatePreset

func (c Cx1Client) CreatePreset(name, description string, queryIDs []uint64) (Preset, error)

func (Cx1Client) CreateProject

func (c Cx1Client) CreateProject(projectname string, cx1_group_ids []string, tags map[string]string) (Project, error)

Projects

func (Cx1Client) CreateProjectInApplication added in v0.0.31

func (c Cx1Client) CreateProjectInApplication(projectname string, cx1_group_ids []string, tags map[string]string, applicationId string) (Project, error)

func (Cx1Client) CreateUser

func (c Cx1Client) CreateUser(newuser User) (User, error)

func (Cx1Client) DeleteAccessAssignmentByID added in v0.0.15

func (c Cx1Client) DeleteAccessAssignmentByID(entityId, resourceId string) error

func (Cx1Client) DeleteApplication

func (c Cx1Client) DeleteApplication(applicationId string) error

func (Cx1Client) DeleteApplicationByID

func (c Cx1Client) DeleteApplicationByID(applicationId string) error

func (Cx1Client) DeleteClientByID added in v0.0.15

func (c Cx1Client) DeleteClientByID(id string) error

func (Cx1Client) DeleteGroup

func (c Cx1Client) DeleteGroup(group *Group) error

func (Cx1Client) DeletePreset

func (c Cx1Client) DeletePreset(preset *Preset) error

func (Cx1Client) DeleteProject

func (c Cx1Client) DeleteProject(p *Project) error

func (Cx1Client) DeleteQuery added in v0.0.11

func (c Cx1Client) DeleteQuery(query AuditQuery) error

func (Cx1Client) DeleteQueryByName added in v0.0.11

func (c Cx1Client) DeleteQueryByName(level, levelID, language, group, query string) error

func (Cx1Client) DeleteRoleByID

func (c Cx1Client) DeleteRoleByID(roleId string) error

func (Cx1Client) DeleteRolesFromGroup added in v0.0.16

func (c Cx1Client) DeleteRolesFromGroup(g *Group, clientRoles map[string][]string) error

clientRoles map looks like: "ast-app" : { "ast-scanner", "ast-viewer" }

func (Cx1Client) DeleteScanByID added in v0.0.12

func (c Cx1Client) DeleteScanByID(scanID string) error

func (Cx1Client) DeleteUser

func (c Cx1Client) DeleteUser(user *User) error

func (Cx1Client) DeleteUserByID

func (c Cx1Client) DeleteUserByID(userid string) error

func (Cx1Client) DownloadReport

func (c Cx1Client) DownloadReport(reportUrl string) ([]byte, error)

func (Cx1Client) GetASTAppID

func (c Cx1Client) GetASTAppID() string

convenience function

func (Cx1Client) GetASTRoleByName

func (c Cx1Client) GetASTRoleByName(name string) (Role, error)

func (Cx1Client) GetASTRoles

func (c Cx1Client) GetASTRoles() ([]Role, error)

func (Cx1Client) GetAccessAssignmentByID added in v0.0.15

func (c Cx1Client) GetAccessAssignmentByID(entityId, resourceId string) (AccessAssignment, error)

func (Cx1Client) GetAllPresets added in v0.0.10

func (c Cx1Client) GetAllPresets() ([]Preset, error)

convenience

func (Cx1Client) GetAppRoleByName

func (c Cx1Client) GetAppRoleByName(name string) (Role, error)

func (Cx1Client) GetAppRoles

func (c Cx1Client) GetAppRoles() ([]Role, error)

func (Cx1Client) GetApplicationById added in v0.0.15

func (c Cx1Client) GetApplicationById(id string) (Application, error)

func (Cx1Client) GetApplicationByName

func (c Cx1Client) GetApplicationByName(name string) (Application, error)

func (Cx1Client) GetApplicationCount

func (c Cx1Client) GetApplicationCount() (uint64, error)

convenience

func (Cx1Client) GetApplicationCountByName

func (c Cx1Client) GetApplicationCountByName(name string) (uint64, error)

func (Cx1Client) GetApplications

func (c Cx1Client) GetApplications(limit uint) ([]Application, error)

Applications

func (Cx1Client) GetApplicationsByName

func (c Cx1Client) GetApplicationsByName(name string, limit uint64) ([]Application, error)

func (Cx1Client) GetAuditSessionByID added in v0.0.11

func (c Cx1Client) GetAuditSessionByID(projectId, scanId string, fastInit bool) (string, error)

Convenience function

func (Cx1Client) GetClientByID added in v0.0.22

func (c Cx1Client) GetClientByID(id string) (OIDCClient, error)

func (Cx1Client) GetClientByName

func (c Cx1Client) GetClientByName(clientName string) (OIDCClient, error)

func (Cx1Client) GetClientScopeByName added in v0.0.15

func (c Cx1Client) GetClientScopeByName(name string) (OIDCClientScope, error)

func (Cx1Client) GetClientScopes added in v0.0.15

func (c Cx1Client) GetClientScopes() ([]OIDCClientScope, error)

func (Cx1Client) GetClientVars added in v0.0.19

func (c Cx1Client) GetClientVars() ClientVars

func (Cx1Client) GetClients

func (c Cx1Client) GetClients() ([]OIDCClient, error)

Clients

func (Cx1Client) GetCombinedRoleByName

func (c Cx1Client) GetCombinedRoleByName(name string) (Role, error)

func (Cx1Client) GetCombinedRoles

func (c Cx1Client) GetCombinedRoles() ([]Role, error)

convenience function to get both KeyCloak (system) roles plus the AST-APP-specific roles

func (Cx1Client) GetCurrentUser

func (c Cx1Client) GetCurrentUser() (User, error)

func (Cx1Client) GetEntitiesAccessToResourceByID added in v0.0.15

func (c Cx1Client) GetEntitiesAccessToResourceByID(resourceId, resourceType string) ([]AccessAssignment, error)

func (Cx1Client) GetFlags added in v0.0.18

func (c Cx1Client) GetFlags() map[string]bool

func (Cx1Client) GetGroupByID

func (c Cx1Client) GetGroupByID(groupID string) (Group, error)

func (Cx1Client) GetGroupByName

func (c Cx1Client) GetGroupByName(groupname string) (Group, error)

func (Cx1Client) GetGroupPIPByName

func (c Cx1Client) GetGroupPIPByName(groupname string) (Group, error)

func (Cx1Client) GetGroups

func (c Cx1Client) GetGroups() ([]Group, error)

func (Cx1Client) GetGroupsByName

func (c Cx1Client) GetGroupsByName(groupname string) ([]Group, error)

func (Cx1Client) GetGroupsPIP

func (c Cx1Client) GetGroupsPIP() ([]Group, error)

func (Cx1Client) GetIAMRoleByName

func (c Cx1Client) GetIAMRoleByName(name string) (Role, error)

func (Cx1Client) GetIAMRoles

func (c Cx1Client) GetIAMRoles() ([]Role, error)

func (Cx1Client) GetImportByID added in v0.0.14

func (c Cx1Client) GetImportByID(importID string) (DataImport, error)

func (Cx1Client) GetImportLogsByID added in v0.0.14

func (c Cx1Client) GetImportLogsByID(importID, engine string) ([]byte, error)

func (Cx1Client) GetImports added in v0.0.14

func (c Cx1Client) GetImports() ([]DataImport, error)

func (Cx1Client) GetKeyCloakRoleByName

func (c Cx1Client) GetKeyCloakRoleByName(name string) (Role, error)

func (Cx1Client) GetKeyCloakRoles

func (c Cx1Client) GetKeyCloakRoles() ([]Role, error)

func (Cx1Client) GetLastScansByID

func (c Cx1Client) GetLastScansByID(projectID string, limit int) ([]Scan, error)

func (Cx1Client) GetLastScansByIDFiltered added in v0.0.13

func (c Cx1Client) GetLastScansByIDFiltered(projectID string, filter ScanFilter) ([]Scan, error)

func (Cx1Client) GetLastScansByStatus

func (c Cx1Client) GetLastScansByStatus(status []string) ([]Scan, error)

func (Cx1Client) GetLastScansByStatusAndID

func (c Cx1Client) GetLastScansByStatusAndID(projectID string, limit int, status []string) ([]Scan, error)

func (Cx1Client) GetLastScansFiltered added in v0.0.30

func (c Cx1Client) GetLastScansFiltered(filter ScanFilter) ([]Scan, error)

func (Cx1Client) GetOrCreateApplication

func (c Cx1Client) GetOrCreateApplication(name string) (Application, error)

func (Cx1Client) GetOrCreateApplicationByName

func (c Cx1Client) GetOrCreateApplicationByName(name string) (Application, error)

func (Cx1Client) GetOrCreateGroup

func (c Cx1Client) GetOrCreateGroup(name string) (Group, error)

convenience

func (Cx1Client) GetOrCreateGroupByName

func (c Cx1Client) GetOrCreateGroupByName(name string) (Group, error)

func (Cx1Client) GetOrCreateProject

func (c Cx1Client) GetOrCreateProject(name string) (Project, error)

func (Cx1Client) GetOrCreateProjectByName

func (c Cx1Client) GetOrCreateProjectByName(name string) (Project, error)

func (Cx1Client) GetOrCreateProjectInApplicationByName added in v0.0.31

func (c Cx1Client) GetOrCreateProjectInApplicationByName(projectName, applicationName string) (Project, Application, error)

func (Cx1Client) GetPresetByID

func (c Cx1Client) GetPresetByID(id uint64) (Preset, error)

func (Cx1Client) GetPresetByName

func (c Cx1Client) GetPresetByName(name string) (Preset, error)

func (Cx1Client) GetPresetContents

func (c Cx1Client) GetPresetContents(p *Preset, qc *QueryCollection) error

func (Cx1Client) GetPresetCount added in v0.0.10

func (c Cx1Client) GetPresetCount() (uint64, error)

func (Cx1Client) GetPresets

func (c Cx1Client) GetPresets(count uint64) ([]Preset, error)

func (Cx1Client) GetProjectByID

func (c Cx1Client) GetProjectByID(projectID string) (Project, error)

func (Cx1Client) GetProjectByName

func (c Cx1Client) GetProjectByName(projectname string) (Project, error)

func (Cx1Client) GetProjectConfiguration

func (c Cx1Client) GetProjectConfiguration(project *Project) error

func (Cx1Client) GetProjectConfigurationByID

func (c Cx1Client) GetProjectConfigurationByID(projectID string) ([]ProjectConfigurationSetting, error)

func (Cx1Client) GetProjectCount

func (c Cx1Client) GetProjectCount() (uint64, error)

convenience

func (Cx1Client) GetProjectCountByName

func (c Cx1Client) GetProjectCountByName(name string) (uint64, error)

func (Cx1Client) GetProjects

func (c Cx1Client) GetProjects(limit uint64) ([]Project, error)

func (Cx1Client) GetProjectsByName

func (c Cx1Client) GetProjectsByName(projectname string, limit uint64) ([]Project, error)

func (Cx1Client) GetProjectsByNameAndGroup

func (c Cx1Client) GetProjectsByNameAndGroup(projectName string, groupID string) ([]Project, error)

func (Cx1Client) GetProjectsByNameAndGroupID

func (c Cx1Client) GetProjectsByNameAndGroupID(projectName string, groupID string) ([]Project, error)

func (Cx1Client) GetQueries

func (c Cx1Client) GetQueries() (QueryCollection, error)

func (Cx1Client) GetQueriesByLevelID added in v0.0.12

func (c Cx1Client) GetQueriesByLevelID(level, levelId string) ([]AuditQuery, error)

func (Cx1Client) GetQueryByID

func (c Cx1Client) GetQueryByID(qid uint64) (Query, error)

func (Cx1Client) GetQueryByName added in v0.0.11

func (c Cx1Client) GetQueryByName(level, language, group, query string) (AuditQuery, error)

func (Cx1Client) GetQueryByPath added in v0.0.30

func (c Cx1Client) GetQueryByPath(level, path string) (AuditQuery, error)

func (Cx1Client) GetReportStatus

func (c Cx1Client) GetReportStatus(reportID string) (ReportStatus, error)

func (Cx1Client) GetReportStatusByID

func (c Cx1Client) GetReportStatusByID(reportID string) (ReportStatus, error)

func (Cx1Client) GetResourcesAccessibleToEntityByID added in v0.0.16

func (c Cx1Client) GetResourcesAccessibleToEntityByID(entityId, entityType string, resourceTypes []string) ([]AccessAssignment, error)

func (Cx1Client) GetResultsPredicates

func (c Cx1Client) GetResultsPredicates(SimilarityID string, ProjectID string) ([]ResultsPredicates, error)

func (Cx1Client) GetResultsPredicatesByID

func (c Cx1Client) GetResultsPredicatesByID(SimilarityID string, ProjectID string) ([]ResultsPredicates, error)

func (Cx1Client) GetRoleByClientAndName

func (c Cx1Client) GetRoleByClientAndName(clientId string, name string) (Role, error)

func (Cx1Client) GetRoleByClientIDAndName

func (c Cx1Client) GetRoleByClientIDAndName(clientId string, name string) (Role, error)

func (Cx1Client) GetRoleByID

func (c Cx1Client) GetRoleByID(roleId string) (Role, error)

func (Cx1Client) GetRoleByName

func (c Cx1Client) GetRoleByName(name string) (Role, error)

func (Cx1Client) GetRoleComposites

func (c Cx1Client) GetRoleComposites(role *Role) ([]Role, error)

func (Cx1Client) GetRoles

func (c Cx1Client) GetRoles() ([]Role, error)

func (Cx1Client) GetRolesByClient

func (c Cx1Client) GetRolesByClient(clientId string) ([]Role, error)

func (Cx1Client) GetRolesByClientID

func (c Cx1Client) GetRolesByClientID(clientId string) ([]Role, error)

func (Cx1Client) GetScan

func (c Cx1Client) GetScan(scanID string) (Scan, error)

func (Cx1Client) GetScanByID

func (c Cx1Client) GetScanByID(scanID string) (Scan, error)

func (Cx1Client) GetScanLogs

func (c Cx1Client) GetScanLogs(scanID, engine string) ([]byte, error)

func (Cx1Client) GetScanLogsByID

func (c Cx1Client) GetScanLogsByID(scanID, engine string) ([]byte, error)

func (Cx1Client) GetScanMetadata

func (c Cx1Client) GetScanMetadata(scanID string) (ScanMetadata, error)

func (Cx1Client) GetScanMetadataByID

func (c Cx1Client) GetScanMetadataByID(scanID string) (ScanMetadata, error)

func (Cx1Client) GetScanResultSummary

func (c Cx1Client) GetScanResultSummary(results []ScanResult) ScanResultSummary

func (Cx1Client) GetScanResults

func (c Cx1Client) GetScanResults(scanID string, limit uint64) ([]ScanResult, error)

func (Cx1Client) GetScanResultsByID

func (c Cx1Client) GetScanResultsByID(scanID string, limit uint64) ([]ScanResult, error)

func (Cx1Client) GetScanResultsCount

func (c Cx1Client) GetScanResultsCount(scanID string) (uint64, error)

func (Cx1Client) GetScanResultsCountByID

func (c Cx1Client) GetScanResultsCountByID(scanID string) (uint64, error)

func (Cx1Client) GetScanSummary

func (c Cx1Client) GetScanSummary(scanID string) (ScanSummary, error)

func (Cx1Client) GetScanSummaryByID

func (c Cx1Client) GetScanSummaryByID(scanID string) (ScanSummary, error)

func (Cx1Client) GetScanWorkflowByID added in v0.0.11

func (c Cx1Client) GetScanWorkflowByID(scanID string) ([]WorkflowLog, error)

func (Cx1Client) GetServiceAccountByID added in v0.0.15

func (c Cx1Client) GetServiceAccountByID(oidcId string) (User, error)

func (Cx1Client) GetSeverityID added in v0.0.12

func (c Cx1Client) GetSeverityID(severity string) uint

convenience

func (Cx1Client) GetTenantID

func (c Cx1Client) GetTenantID() string

func (Cx1Client) GetTenantName added in v0.0.27

func (c Cx1Client) GetTenantName() string

func (Cx1Client) GetUploadURL

func (c Cx1Client) GetUploadURL() (string, error)

func (Cx1Client) GetUserASTRoleMappings

func (c Cx1Client) GetUserASTRoleMappings(userID string) ([]Role, error)

func (Cx1Client) GetUserAppRoles

func (c Cx1Client) GetUserAppRoles(user *User) ([]Role, error)

func (Cx1Client) GetUserByEmail

func (c Cx1Client) GetUserByEmail(email string) (User, error)

func (Cx1Client) GetUserByID

func (c Cx1Client) GetUserByID(userID string) (User, error)

func (Cx1Client) GetUserByUserName

func (c Cx1Client) GetUserByUserName(name string) (User, error)

func (Cx1Client) GetUserGroups

func (c Cx1Client) GetUserGroups(user *User) ([]Group, error)

func (Cx1Client) GetUserIAMRoles

func (c Cx1Client) GetUserIAMRoles(user *User) ([]Role, error)

func (Cx1Client) GetUserRoleMappings

func (c Cx1Client) GetUserRoleMappings(userID string, clientID string) ([]Role, error)

these functions to be deprecated/hidden in favor of simpler functions below

func (Cx1Client) GetUserRoles

func (c Cx1Client) GetUserRoles(user *User) ([]Role, error)

New generic functions for roles for convenience

func (Cx1Client) GetUsers

func (c Cx1Client) GetUsers() ([]User, error)
func (c Cx1Client) GroupLink(g *Group) string

func (Cx1Client) ImportPollingByID added in v0.0.14

func (c Cx1Client) ImportPollingByID(importID string) (string, error)

func (Cx1Client) ImportPollingByIDWithTimeout added in v0.0.25

func (c Cx1Client) ImportPollingByIDWithTimeout(importID string, delaySeconds, maxSeconds int) (string, error)

func (*Cx1Client) InitializeClient added in v0.0.18

func (c *Cx1Client) InitializeClient()
func (c Cx1Client) PresetLink(p *Preset) string
func (c Cx1Client) ProjectLink(p *Project) string

func (Cx1Client) PutFile

func (c Cx1Client) PutFile(URL string, filename string) (string, error)
func (c Cx1Client) QueryGroupLink(q *QueryGroup) string
func (c Cx1Client) QueryLanguageLink(q *QueryLanguage) string
func (c Cx1Client) QueryLink(q *Query) string

func (*Cx1Client) RefreshFlags added in v0.0.18

func (c *Cx1Client) RefreshFlags() error

func (Cx1Client) RegenerateClientSecret added in v0.0.28

func (c Cx1Client) RegenerateClientSecret(client OIDCClient) (string, error)

func (Cx1Client) RemoveRoleComposites

func (c Cx1Client) RemoveRoleComposites(role *Role, roles *[]Role) error

func (Cx1Client) RemoveUserASTRoleMappings

func (c Cx1Client) RemoveUserASTRoleMappings(userID string, roles []Role) error

func (Cx1Client) RemoveUserAppRoles

func (c Cx1Client) RemoveUserAppRoles(user *User, roles *[]Role) error

func (Cx1Client) RemoveUserFromGroup

func (c Cx1Client) RemoveUserFromGroup(user *User, groupId string) error

func (Cx1Client) RemoveUserFromGroupByID

func (c Cx1Client) RemoveUserFromGroupByID(user *User, groupId string) error

func (Cx1Client) RemoveUserIAMRoles

func (c Cx1Client) RemoveUserIAMRoles(user *User, roles *[]Role) error

func (Cx1Client) RemoveUserRoleMappings

func (c Cx1Client) RemoveUserRoleMappings(userID string, clientID string, roles []Role) error

func (Cx1Client) RemoveUserRoles

func (c Cx1Client) RemoveUserRoles(user *User, roles *[]Role) error

func (Cx1Client) ReportPollingByID added in v0.0.13

func (c Cx1Client) ReportPollingByID(reportID string) (string, error)

convenience

func (Cx1Client) RequestNewReport

func (c Cx1Client) RequestNewReport(scanID, projectID, branch, reportType string) (string, error)

Reports

func (Cx1Client) RequestNewReportByID

func (c Cx1Client) RequestNewReportByID(scanID, projectID, branch, reportType string) (string, error)
func (c Cx1Client) RoleLink(r *Role) string

func (Cx1Client) ScanPolling

func (c Cx1Client) ScanPolling(s *Scan) (Scan, error)

convenience

func (Cx1Client) ScanPollingDetailed added in v0.0.12

func (c Cx1Client) ScanPollingDetailed(s *Scan) (Scan, error)

func (Cx1Client) ScanPollingWithTimeout added in v0.0.25

func (c Cx1Client) ScanPollingWithTimeout(s *Scan, detailed bool, delaySeconds, maxSeconds int) (Scan, error)

func (Cx1Client) ScanProject

func (c Cx1Client) ScanProject(projectID, sourceUrl, branch, scanType string, settings []ScanConfiguration, tags map[string]string) (Scan, error)

convenience function

func (Cx1Client) ScanProjectByID

func (c Cx1Client) ScanProjectByID(projectID, sourceUrl, branch, scanType string, settings []ScanConfiguration, tags map[string]string) (Scan, error)

func (Cx1Client) ScanProjectGit

func (c Cx1Client) ScanProjectGit(projectID, repoUrl, branch string, settings []ScanConfiguration, tags map[string]string) (Scan, error)

func (Cx1Client) ScanProjectGitByID

func (c Cx1Client) ScanProjectGitByID(projectID, repoUrl, branch string, settings []ScanConfiguration, tags map[string]string) (Scan, error)

func (Cx1Client) ScanProjectZip

func (c Cx1Client) ScanProjectZip(projectID, sourceUrl, branch string, settings []ScanConfiguration, tags map[string]string) (Scan, error)

func (Cx1Client) ScanProjectZipByID

func (c Cx1Client) ScanProjectZipByID(projectID, sourceUrl, branch string, settings []ScanConfiguration, tags map[string]string) (Scan, error)

func (*Cx1Client) SetClientVars added in v0.0.19

func (c *Cx1Client) SetClientVars(clientvars ClientVars)

func (Cx1Client) SetGroupParent

func (c Cx1Client) SetGroupParent(g *Group, parent *Group) error

func (Cx1Client) SetProjectBranch

func (c Cx1Client) SetProjectBranch(projectID, branch string, allowOverride bool) error

func (Cx1Client) SetProjectBranchByID

func (c Cx1Client) SetProjectBranchByID(projectID, branch string, allowOverride bool) error

func (Cx1Client) SetProjectFileFilter

func (c Cx1Client) SetProjectFileFilter(projectID, filter string, allowOverride bool) error

func (Cx1Client) SetProjectFileFilterByID

func (c Cx1Client) SetProjectFileFilterByID(projectID, filter string, allowOverride bool) error

func (Cx1Client) SetProjectLanguageMode

func (c Cx1Client) SetProjectLanguageMode(projectID, languageMode string, allowOverride bool) error

func (Cx1Client) SetProjectLanguageModeByID

func (c Cx1Client) SetProjectLanguageModeByID(projectID, languageMode string, allowOverride bool) error

func (Cx1Client) SetProjectPreset

func (c Cx1Client) SetProjectPreset(projectID, presetName string, allowOverride bool) error

func (Cx1Client) SetProjectPresetByID

func (c Cx1Client) SetProjectPresetByID(projectID, presetName string, allowOverride bool) error

func (Cx1Client) StartImport added in v0.0.14

func (c Cx1Client) StartImport(dataFilename, mappingFilename, encryptionKey string) (string, error)

func (Cx1Client) StartMigration added in v0.0.14

func (c Cx1Client) StartMigration(dataArchive, projectMapping []byte, encryptionKey string) (string, error)

func (Cx1Client) String

func (c Cx1Client) String() string

func (Cx1Client) UpdateApplication

func (c Cx1Client) UpdateApplication(app *Application) error

func (Cx1Client) UpdateGroup

func (c Cx1Client) UpdateGroup(g *Group) error

func (Cx1Client) UpdatePreset

func (c Cx1Client) UpdatePreset(preset *Preset) error

func (Cx1Client) UpdateProject

func (c Cx1Client) UpdateProject(project *Project) error

func (Cx1Client) UpdateProjectConfiguration

func (c Cx1Client) UpdateProjectConfiguration(project *Project, settings []ProjectConfigurationSetting) error

UpdateProjectConfiguration updates the configuration of the project addressed by projectID

func (Cx1Client) UpdateProjectConfigurationByID

func (c Cx1Client) UpdateProjectConfigurationByID(projectID string, settings []ProjectConfigurationSetting) error

func (Cx1Client) UpdateQueries added in v0.0.12

func (c Cx1Client) UpdateQueries(level string, queries []QueryUpdate) error

func (Cx1Client) UpdateQuery added in v0.0.11

func (c Cx1Client) UpdateQuery(query AuditQuery) error

updating queries via PUT is possible, but only allows changing the source code, not metadata around each query. this will be fixed in the future PUT is the only option to create an override on the project-level (and maybe in the future on application-level)

func (Cx1Client) UpdateUser

func (c Cx1Client) UpdateUser(user *User) error

func (Cx1Client) UploadBytes added in v0.0.9

func (c Cx1Client) UploadBytes(fileContents *[]byte) (string, error)

creates upload URL, uploads, returns upload URL

func (Cx1Client) UploadBytesForProjectByID added in v0.0.9

func (c Cx1Client) UploadBytesForProjectByID(projectID string, fileContents *[]byte) (string, error)
func (c Cx1Client) UserLink(u *User) string

func (Cx1Client) Whoami added in v0.0.15

func (c Cx1Client) Whoami() (WhoAmI, error)

type DataImport added in v0.0.14

type DataImport struct {
	MigrationId string             `json:"migrationId"`
	Status      string             `json:"status"`
	CreatedAt   string             `json:"createdAt"`
	Logs        []DataImportStatus `json:"logs"`
}

type DataImportStatus added in v0.0.20

type DataImportStatus struct {
	Level   string `json:"level"`
	Message string `json:"msg"`
	Error   string `json:"error"`
	Worker  string `json:"worker"`
	RawLog  string `json:"raw_log"`
}

type Group

type Group struct {
	GroupID     string              `json:"id"`
	Name        string              `json:"name"`
	Path        string              `json:"path"`
	SubGroups   []Group             `json:"subGroups"`
	ClientRoles map[string][]string `json:"clientRoles"`
	Filled      bool                `json:"-"`
}

func RemoveGroup added in v0.0.11

func RemoveGroup(slice []Group, index int) []Group

func RemoveGroupByID added in v0.0.11

func RemoveGroupByID(slice []Group, ID string) []Group

func (*Group) AddRole added in v0.0.16

func (g *Group) AddRole(clientName, roleName string) error

func (*Group) FindSubgroupByName

func (g *Group) FindSubgroupByName(name string) (Group, error)

func (*Group) RemoveRole added in v0.0.16

func (g *Group) RemoveRole(clientName, roleName string) error

func (*Group) String

func (g *Group) String() string

type OIDCClient added in v0.0.15

type OIDCClient struct {
	ID           string `json:"id"`
	ClientID     string `json:"clientId"`
	Enabled      bool   `json:"enabled"`
	ClientSecret string `json:"secret"`
	Creator      string `json:"-"`
}

type OIDCClientScope added in v0.0.15

type OIDCClientScope struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Protocol    string `json:"protocol"`
}

type Preset

type Preset struct {
	PresetID    uint64   `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Custom      bool     `json:"custom"`
	QueryIDs    []uint64 `json:"-"`
	Filled      bool     `json:"-"`
	Queries     []Query
}

func (*Preset) AddQueryID

func (p *Preset) AddQueryID(queryId uint64)

func (*Preset) String

func (p *Preset) String() string

type Project

type Project struct {
	ProjectID     string                        `json:"id"`
	Name          string                        `json:"name"`
	CreatedAt     string                        `json:"createdAt"`
	UpdatedAt     string                        `json:"updatedAt"`
	Groups        []string                      `json:"groups"`
	Applications  []string                      `json:"applicationIds"`
	Tags          map[string]string             `json:"tags"`
	RepoUrl       string                        `json:"repoUrl"`
	MainBranch    string                        `json:"mainBranch"`
	Origin        string                        `json:"origin"`
	Criticality   uint                          `json:"criticality"`
	Configuration []ProjectConfigurationSetting `json:"-"`
}

func (*Project) AssignGroup

func (p *Project) AssignGroup(group *Group)

func (Project) GetConfigurationByName added in v0.0.9

func (p Project) GetConfigurationByName(configKey string) *ProjectConfigurationSetting

func (*Project) GetTags

func (p *Project) GetTags() string

func (*Project) IsInGroup

func (p *Project) IsInGroup(group *Group) bool

func (*Project) IsInGroupID

func (p *Project) IsInGroupID(groupId string) bool

convenience

func (*Project) String

func (p *Project) String() string

type ProjectConfigurationSetting

type ProjectConfigurationSetting struct {
	Key             string `json:"key"`
	Name            string `json:"name"`
	Category        string `json:"category"`
	OriginLevel     string `json:"originLevel"`
	Value           string `json:"value"`
	ValueType       string `json:"valuetype"`
	ValueTypeParams string `json:"valuetypeparams"`
	AllowOverride   bool   `json:"allowOverride"`
}

type Query

type Query struct {
	QueryID            uint64 `json:"queryID,string"`
	Name               string `json:"queryName"`
	Group              string `json:"group"`
	Language           string `json:"language"`
	Severity           string `json:"severity"`
	CweID              int64  `json:"cweID"`
	QueryDescriptionId int64  `json:"queryDescriptionId"`
	Custom             bool   `json:"custom"`
}

func (Query) String

func (q Query) String() string

type QueryCollection

type QueryCollection struct {
	QueryLanguages []QueryLanguage
}

func (QueryCollection) GetQueryByID

func (qc QueryCollection) GetQueryByID(qid uint64) *Query

func (QueryCollection) GetQueryByName

func (qc QueryCollection) GetQueryByName(language, group, query string) *Query

func (QueryCollection) GetQueryLanguageByName

func (qc QueryCollection) GetQueryLanguageByName(language string) *QueryLanguage

type QueryGroup

type QueryGroup struct {
	Name     string
	Language string
	Queries  []Query
}

func (QueryGroup) GetQueryByName

func (qg QueryGroup) GetQueryByName(name string) *Query

func (QueryGroup) String

func (q QueryGroup) String() string

type QueryLanguage

type QueryLanguage struct {
	Name        string
	QueryGroups []QueryGroup
}

func (QueryLanguage) GetQueryGroupByName

func (ql QueryLanguage) GetQueryGroupByName(name string) *QueryGroup

func (QueryLanguage) String

func (q QueryLanguage) String() string

type QueryUpdate added in v0.0.11

type QueryUpdate struct {
	Name   string `json:"name"`
	Path   string `json:"path"`
	Source string `json:"source"`
}

type ReportStatus

type ReportStatus struct {
	ReportID  string `json:"reportId"`
	Status    string `json:"status"`
	ReportURL string `json:"url"`
}

type ResultsPredicates

type ResultsPredicates struct {
	PredicateID  string `json:"ID"`
	SimilarityID string `json:"similarityId"`
	ProjectID    string `json:"projectId"`
	State        string `json:"state"`
	Comment      string `json:"comment"`
	Severity     string `json:"severity"`
	CreatedBy    string `json:"createdBy"`
	CreatedAt    string `json:"createdAt"`
}

type Role

type Role struct {
	ClientID    string `json:"containerId"` // the 'client' in Keycloak - AST roles with have the "ast-app" client ID
	RoleID      string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Attributes  struct {
		Creator    []string
		Type       []string
		Category   []string
		LastUpdate []string // it is returned as [ "uint",... ]
	} `json:"attributes"`
	Composite  bool   `json:"composite"`
	ClientRole bool   `json:"clientRole"`
	SubRoles   []Role `json:"-"`
}

func RemoveRole added in v0.0.11

func RemoveRole(slice []Role, index int) []Role

func RemoveRoleByID added in v0.0.11

func RemoveRoleByID(slice []Role, ID string) []Role

func (*Role) HasCategory

func (r *Role) HasCategory(name string) bool

func (*Role) HasRole

func (r *Role) HasRole(name string) bool

func (*Role) String

func (r *Role) String() string

type RunningScan

type RunningScan struct {
	ScanID    string
	Status    string
	ProjectID string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type Scan

type Scan struct {
	ScanID        string              `json:"id"`
	Status        string              `json:"status"`
	StatusDetails []ScanStatusDetails `json:"statusDetails"`
	Branch        string              `json:"branch"`
	CreatedAt     string              `json:"createdAt"`
	UpdatedAt     string              `json:"updatedAt"`
	ProjectID     string              `json:"projectId"`
	ProjectName   string              `json:"projectName"`
	UserAgent     string              `json:"userAgent"`
	Initiator     string              `json:"initiator"`
	Tags          map[string]string   `json:"tags"`
	Metadata      struct {
		Type    string              `json:"type"`
		Configs []ScanConfiguration `json:"configs"`
	} `json:"metadata"`
	Engines      []string `json:"engines"`
	SourceType   string   `json:"sourceType"`
	SourceOrigin string   `json:"sourceOrigin"`
}

func (*Scan) IsIncremental

func (s *Scan) IsIncremental() (bool, error)

convenience function

func (*Scan) String

func (s *Scan) String() string

type ScanConfiguration

type ScanConfiguration struct {
	ScanType string            `json:"type"`
	Values   map[string]string `json:"value"`
}

type ScanFilter added in v0.0.13

type ScanFilter struct {
	ProjectID string   `json:"project-id"`
	Limit     int      `json:"limit"`
	Offset    int      `json:"offset"`
	TagKeys   []string `json:"tags-keys"`
	TagValues []string `json:"tags-values"`
	Statuses  []string `json:"statuses"`
	Branches  []string `json:"branches"`
}

func (ScanFilter) AddURLValues added in v0.0.13

func (f ScanFilter) AddURLValues(params *url.Values)

type ScanMetadata

type ScanMetadata struct {
	ScanID                string
	ProjectID             string
	LOC                   uint64
	FileCount             uint64
	IsIncremental         bool
	IsIncrementalCanceled bool
	PresetName            string `json:"queryPreset"`
}

type ScanResult

type ScanResult struct {
	Type                 string
	ResultID             string `json:"id"`
	SimilarityID         string `json:"similarityId"`
	Status               string
	State                string
	Severity             string
	CreatedAt            string `json:"created"`
	FirstFoundAt         string
	FoundAt              string
	FirstScanId          string
	Description          string
	Data                 ScanResultData
	VulnerabilityDetails ScanResultDetails
}

func (ScanResult) CreateResultsPredicate added in v0.0.12

func (r ScanResult) CreateResultsPredicate(projectId string) ResultsPredicates

convenience function

func (ScanResult) String

func (r ScanResult) String() string

type ScanResultData

type ScanResultData struct {
	QueryID      uint64
	QueryName    string
	Group        string
	ResultHash   string
	LanguageName string
	Nodes        []ScanResultNodes
}

type ScanResultDetails

type ScanResultDetails struct {
	CweId       int
	Compliances []string
}

type ScanResultNodes

type ScanResultNodes struct {
	ID          string
	Line        uint64
	Name        string
	Column      uint64
	Length      uint64
	Method      string
	NodeID      uint64
	DOMType     string
	FileName    string
	FullName    string
	TypeName    string
	MethodLine  uint64
	Definitions string
}

type ScanResultStatusSummary

type ScanResultStatusSummary struct {
	ToVerify               uint64
	NotExploitable         uint64
	Confirmed              uint64
	ProposedNotExploitable uint64
	Urgent                 uint64
}

func (ScanResultStatusSummary) String

func (s ScanResultStatusSummary) String() string

func (ScanResultStatusSummary) Total

func (s ScanResultStatusSummary) Total() uint64

type ScanResultSummary

type ScanResultSummary struct {
	High        ScanResultStatusSummary
	Medium      ScanResultStatusSummary
	Low         ScanResultStatusSummary
	Information ScanResultStatusSummary
}

func (ScanResultSummary) String

func (s ScanResultSummary) String() string

type ScanStatusDetails

type ScanStatusDetails struct {
	Name    string `json:"name"`
	Status  string `json:"status"`
	Details string `json:"details"`
}

type ScanSummary

type ScanSummary struct {
	TenantID     string
	ScanID       string
	SASTCounters struct {
		//QueriesCounters           []?
		//SinkFileCounters          []?
		LanguageCounters []struct {
			Language string
			Counter  uint64
		}
		ComplianceCounters []struct {
			Compliance string
			Counter    uint64
		}
		SeverityCounters []struct {
			Severity string
			Counter  uint64
		}
		StatusCounters []struct {
			Status  string
			Counter uint64
		}
		StateCounters []struct {
			State   string
			Counter uint64
		}
		TotalCounter        uint64
		FilesScannedCounter uint64
	}
}

Very simplified for now

func (*ScanSummary) TotalCount

func (s *ScanSummary) TotalCount() uint64

type Status

type Status struct {
	ID      int               `json:"id"`
	Name    string            `json:"name"`
	Details ScanStatusDetails `json:"details"`
}

type User

type User struct {
	Enabled   bool    `json:"enabled"`
	UserID    string  `json:"id,omitempty"`
	FirstName string  `json:"firstName"`
	LastName  string  `json:"lastName"`
	UserName  string  `json:"username"`
	Email     string  `json:"email"`
	Groups    []Group `json:"-"` // only returned from regular /auth/realms/../user endpoint, as string IDs
	Roles     []Role  `json:"-"` // only returned from regular /auth/realms/../user endpoint, as string IDs
}

func (*User) AddGroup added in v0.0.11

func (u *User) AddGroup(client *Cx1Client, group *Group) error

func (User) Delete added in v0.0.11

func (u User) Delete(client *Cx1Client) error

func (User) HasRole

func (u User) HasRole(role *Role) bool

func (User) HasRoleByID

func (u User) HasRoleByID(roleID string) bool

func (User) HasRoleByName

func (u User) HasRoleByName(role string) bool

func (User) IsInGroup

func (u User) IsInGroup(group *Group) bool

func (User) IsInGroupByID

func (u User) IsInGroupByID(groupId string) bool

func (User) IsInGroupByName

func (u User) IsInGroupByName(groupName string) bool
func (u User) Link(client *Cx1Client) string

func (User) Save added in v0.0.11

func (u User) Save(client *Cx1Client) error

func (User) String

func (u User) String() string

type WhoAmI added in v0.0.15

type WhoAmI struct {
	UserID string `json:"userId"`
	Name   string `json:"displayName"`
}

func (WhoAmI) String added in v0.0.15

func (u WhoAmI) String() string

type WorkflowLog

type WorkflowLog struct {
	Source    string `json:"Source"`
	Info      string `json:"Info"`
	Timestamp string `json:"Timestamp"`
}

Directories

Path Synopsis
_examples
MigrationImport command

Jump to

Keyboard shortcuts

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