This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
generated from trussworks/golang-cli-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from trussworks/cblkwell-initial-prototype
Initial prototype build
- Loading branch information
Showing
13 changed files
with
269 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
FROM alpine:3 | ||
COPY my-cli-tool /bin/my-cli-tool | ||
ENTRYPOINT [ "my-cli-tool" ] | ||
COPY security-hub-collector /bin/security-hub-collector | ||
ENTRYPOINT [ "security-hub-collector" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,38 @@ | ||
# Truss CLI Template | ||
|
||
This repository is meant to be a template repo to set up new CLIs with our general format. Everywhere | ||
the tool or binary is listed in this repo the name `my-cli-tool` will be used for search and replace | ||
purposes. | ||
|
||
## Creating a new CLI repo | ||
|
||
1. Clone this rep, renaming appropriately. | ||
1. Write your golang code in the `main.go` file. | ||
1. Run `go mod init github.com/trussworks/my-cli-tool | ||
1. Run `go mod tidy` to update the `go.mod` and `go.sum` files | ||
1. Build your tool with `go build .` | ||
|
||
## Actual readme below - Delete above here | ||
|
||
# my-binary | ||
# Security Hub Collector | ||
|
||
## Description | ||
|
||
Please include a description of the CLI tool here | ||
This tool pulls findings from AWS Security Hub and outputs them for | ||
consumption by visualization tools. | ||
|
||
## Installation | ||
|
||
Include installation instructions with an example | ||
|
||
```sh | ||
brew tap trussworks/tap | ||
brew install my-cli-tool | ||
go get -u github.com/trussworks/security-hub-collector | ||
``` | ||
|
||
## Usage | ||
|
||
Include usage information here: | ||
|
||
```sh | ||
TBD | ||
security-hub-collector is an application for retrieving Security Hub findings for visualization | ||
|
||
Usage: | ||
security-hub-collector [OPTIONS] | ||
|
||
Application Options: | ||
-o, --output= File to direct output to. | ||
-p, --profile= The AWS profile to use. [$AWS_PROFILE] | ||
-r, --region= The AWS region to use. [$AWS_REGION] | ||
|
||
Help Options: | ||
-h, --help Show this help message | ||
|
||
``` | ||
|
||
## Examples | ||
|
||
Run the command like this: | ||
|
||
```sh | ||
TBD | ||
security-hub-collector -o output.csv | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package session | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
) | ||
|
||
// MakeSession creates an AWS Session, with appropriate defaults, | ||
// using shared credentials, and with region and profile overrides. | ||
func MakeSession(region, profile string) (*session.Session, error) { | ||
sessOpts := session.Options{ | ||
SharedConfigState: session.SharedConfigEnable, | ||
} | ||
if profile != "" { | ||
sessOpts.Profile = profile | ||
} | ||
if region != "" { | ||
sessOpts.Config = aws.Config{ | ||
Region: aws.String(region), | ||
} | ||
} | ||
return session.NewSessionWithOptions(sessOpts) | ||
} | ||
|
||
// MustMakeSession creates an AWS Session using MakeSession and ensures | ||
// that it is valid. | ||
func MustMakeSession(region, profile string) *session.Session { | ||
return session.Must(MakeSession(region, profile)) | ||
} |
Oops, something went wrong.