Install Go agent with Contrast installer
Use the Agent Wizard to install and configure the Go agent with the Contrast installer. Using the wizard is the simplest way to deploy a new agent.
Before you begin a Go agent installation
Make sure you have everything you need before you start.
Install Go and build your application with a supported Go version. If you build with an unsupported version,
contrast-gostops with an error. See Go supported technologies for the Go agent for the current versions. You also need access to your application’s build environment, becausecontrast-goinstruments the application when you build it.The agent will need to be able to reach your Contrast instance. It can be a local/on-premise instance, or a hosted instance. A proxy can be configured if the environment has limited network access.
Understand the agent order of precedence.
You will also need access to a command line interface and to your organization's instance of Contrast.
Start the Agent Wizard
To open the Agent Wizard:
In Northstar: From the left navigation, select Administration > Agent management, then select Add agent at the top of the view.
In Contrast: Use one of the following options:
From the header, select Add New, and then select the Application card.
From the header, select Administration > Agent Management, and then select Add agent at the top of the view.
Select the Go agent
To select the Go agent in the Agent Wizard:
Under Select an installation method, select Language-specific.
Under Select a language, select Go.
The Go agent supports Linux and macOS. Windows is not yet supported.
Build and install the agent
Under Select application deployment method, select Install manually.
Under Run installer:
Install the latest
contrast-gowith the following command:go run github.com/contrast-security-oss/contrast-go-installer@latest latest
Alternatively, specify a specific version instead of
latest.The installer places
contrast-goin the directory set by GOBIN. If GOBIN is not set, it uses the bin directory under the first entry inGOPATH. Make sure that directory is on your PATH.
Under Build application, build the application by replacing
go buildwithcontrast-go buildin your normal build command to embed the Contrast agent in your application binary.contrast-go build -o [output-name-of-application]
For example, if your application is built with
go build -o myapp ./cmd/myapp/, run the following command to add Contrast to this application:contrast-go build -o myapp ./cmd/myapp
Configure the agent
The easiest way to configure the agent is to use the Agent Wizard or the Contrast Agent Configuration Editor.
You can configure the Go agent using a connection token, environment variables, or the Go YAML template. A connection token is the recommended option. Set CONTRAST__API__TOKEN in the environment where you run your application.
Under Configure the agent, select the Agent Key you want to use to generate your API keys.
If only one key exists, it is preselected. See Configure agent keys to learn how to create multiple agent keys.
Optionally, select Register the application to assign it to groups for access control.
You can also assign tags and metadata to the application.
Select Use Connection Token and copy the displayed command. A single variable is used to specify authentication values.
The command sets the connection token as an environment variable in your terminal. Set the variable in the environment where you run your application, and set it before the application starts.
The first command sets the connection token as an environment variable in your terminal.
The second command starts your container and passes the token into it, so the token is not stored in the image.
Download the configuration.
Under Download Configuration, you can copy and run the commands displayed in the wizard. You will need to raise your permissions to write the configuration file to
/etc/contrast/goto do so.Or, you can download
contrast_security.yamlfrom the configuration editor and place the file in a supported YAML file location.
Verify the agent deployment
Interact with your application as you normally would. For example, interact with your application's web interface or send API commands.
In the Agent Wizard, select View agent activity to verify that your agent appears in the agents list.
Verify that you see the name of your application in the applications list.
In Northstar, select Applications from the left navigation.
In Contrast, select Applications from the header.
Verify that you see the name of your local server in the servers list.
In Northstar, select Servers from the left navigation.
In Contrast, select Servers from the header.