Skip to content

Commit

Permalink
Merge pull request #58 from lacework/afiune/docs+install
Browse files Browse the repository at this point in the history
Update docs and `install.ps1` to add Windows supports
  • Loading branch information
afiune authored Apr 21, 2020
2 parents 3e099fb + ae53d6f commit 3cafb4c
Show file tree
Hide file tree
Showing 5 changed files with 274 additions and 43 deletions.
47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,39 @@

# Lacework Go SDK

This repository provides a Go API client, tools, libraries, relevant documentation, code
samples, processes, and/or guides that allow developers to interact with Lacework.
This repository provides a set of tools, libraries, relevant documentation, code
samples, processes, and/or guides that allow users and developers to interact with
the Lacework platform.

## API Client ([`api`](api/))

A Golang API client for interacting with the [Lacework API](https://support.lacework.com/hc/en-us/categories/360002496114-Lacework-API-).

### Basic Usage
```go
package main

import (
"fmt"
"log"

"github.com/lacework/go-sdk/api"
)

lacework, err := api.NewClient("account")
if err == nil {
log.Fatal(err)
}

tokenRes, err := lacework.GenerateTokenWithKeys("KEY", "SECRET")
if err != nil {
log.Fatal(err)
func main() {
lacework, err := api.NewClient("account")
if err != nil {
log.Fatal(err)
}

tokenRes, err := lacework.GenerateTokenWithKeys("KEY", "SECRET")
if err != nil {
log.Fatal(err)
}

// Output: YOUR-ACCESS-TOKEN
fmt.Println(tokenRes.Token())
}

// Output: YOUR-ACCESS-TOKEN
fmt.Println(tokenRes.Token())
```
Look at the [api/](api/) folder for more documentation.

Expand All @@ -39,15 +44,19 @@ The Lacework Command Line Interface is a tool that helps you manage the
Lacework cloud security platform. You can use it to manage compliance
reports, external integrations, vulnerability scans, and other operations.

### Basic Usage
### Install

Build and install the CLI by running `make install-cli`, the automation will
install the tool at `/usr/local/bin/lacework`:
#### Bash:
```
$ curl https://raw.githubusercontent.com/lacework/go-sdk/master/cli/install.sh | sudo bash
```
$ make install-cli
$ lacework version
lacework v0.1.1 (sha:ca9f95d17f4f2092f89dba7b64eaed6db7493a5a) (time:20200406091143)

#### Powershell:
```
C:\> Set-ExecutionPolicy Bypass -Scope Process -Force
C:\> iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/lacework/go-sdk/master/cli/install.ps1'))
```

Look at the [cli/](cli/) folder for more documentation.

## Lacework Logger ([`lwlogger`](lwlogger/))
Expand Down
23 changes: 23 additions & 0 deletions api/_examples/token-generation/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"fmt"
"log"

"github.com/lacework/go-sdk/api"
)

func main() {
lacework, err := api.NewClient("account")
if err != nil {
log.Fatal(err)
}

tokenRes, err := lacework.GenerateTokenWithKeys("KEY", "SECRET")
if err != nil {
log.Fatal(err)
}

// Output: YOUR-ACCESS-TOKEN
fmt.Println(tokenRes.Token())
}
77 changes: 61 additions & 16 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<img src="https://techally-content.s3-us-west-1.amazonaws.com/public-content/lacework_logo_full.png" width="600">

# Lacework cli
# Lacework CLI

The Lacework Command Line Interface is a tool that helps you manage the
Lacework cloud security platform. You can use it to manage compliance
Expand All @@ -9,66 +9,111 @@ reports, external integrations, vulnerability scans, and other operations.
## Install

### Bash:

```
$ curl https://raw.githubusercontent.com/lacework/go-sdk/master/cli/install.sh | sudo bash
```

### Powershell:

```
C:\> Set-ExecutionPolicy Bypass -Scope Process -Force
C:\> iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/lacework/go-sdk/master/cli/install.ps1'))
```

## Configuration File
## Quick Configuration

The `lacework configure` command is the fastest way to set up your Lacework
CLI installation. The command prompts you for three things:

The Lacework cli looks for a file named `.lacework.toml` inside your home
directory (`$HOME/.lacework.toml`) to access the following settings:
* `account`: Account subdomain of URL (i.e. `<ACCOUNT>.lacework.net`)
* `api_key`: API Access Key
* `api_secret`: API Access Secret

>To create a set of API keys, log in to your Lacework account and navigate to
>Settings -> API Keys, then click + Create New. Enter a name for the key and
>an optional description and click Save. To get the secret key, download the
>generated API key file and open it in an editor.
The following example shows sample values. Replace them with your own.

```bash
$ lacework configure
Account: example
Access Key ID: EXAMPLE_1234567890ABCDE1EXAMPLE1EXAMPLE123456789EXAMPLE
Secret Access Key: _d12345dcbde000d1232bbbe51234a609

You are all set!
```

The result of this command is the generation of a file named `.lacework.toml`
inside your home directory (`$HOME/.lacework.toml`) with a single profile
named `default`.

### Multiple Profiles
You can add additional profiles that you can refer to with a name by specifying
the `--profile` option. The following example creates a profile named `prod`.

```bash
$ lacework configure --profile prod
Account: prod.example
Access Key ID: PROD_1234567890ABCDE1EXAMPLE1EXAMPLE123456789EXAMPLE
Secret Access Key: _12345prode11111232bbbe51234a609

You are all set!
```

An example of a Lacework configuration file:
```toml
account = "example"
api_key = "EXAMPLE_1234567890ABC"
api_secret = "_super_secret_key"
Then, when you run a command, you can specify a `--profile prod` and use the
credentials and settings stored under that name.

```bash
$ lacework integration list --profile prod
```

You can provide a different configuration file with the option `--config`.
If there is no `--profile` option, the CLI will default to the `default` profile.

### Environment Variables
Default configuration parameters found in the `.lacework.toml` may also be
overriden by setting environment variables prefixed with `LW_`.

#### Example
To override the `account`, `api_key`, and `api_secret` configurations:
```
$ export LW_ACCOUNT='<MY_ACCOUNT>'
$ export LW_API_KEY='<MY_API_KEY>'
$ export LW_API_SECRET='<MY_API_SECRET>'
```

To override the profile to use:
```
$ export LW_PROFILE=prod
```

## Basic Usage
Once you have created your configuration file `$HOME/.lacework.toml`,
you are ready to use the Lacework cli, a few basic commands are:
A few basic commands are:

1) List all integration in your account:
```bash
$ lacework integration list
```
2) Use the `api` command to access Lacework's RestfulAPI, for example,
2) Request an on-demand vulnerability scan:
```bash
$ lacework vulnerability scan run index.docker.io techallylw/lacework-cli latest
```
3) Use the `api` command to access Lacework's RestfulAPI, for example,
to get details about a specific event:
```bash
$ lacework api get '/external/events/GetEventDetails?EVENT_ID=16700'
```

## Development

To build and install the CLI from source, use the `make install-cli` directive
defined at the top level of this repository:
defined at the top level of this repository, the automation will install the
tool at `/usr/local/bin/lacework`:
```
$ make install-cli
$ lacework help
$ lacework version
lacework v.dev (sha:ca9f95d17f4f2092f89dba7b64eaed6db7493a5a) (time:20200406091143)
```

## License and Copyright
Expand Down
Loading

0 comments on commit 3cafb4c

Please sign in to comment.