Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup prompts library #1

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/bulwark-gitleaks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: BulwarkGitLeaks

on:
pull_request:
workflow_dispatch:

concurrency:
group: gitleaks-${{ github.ref }}
cancel-in-progress: true

jobs:
gitleaks-pr-scan:
runs-on: ubuntu-latest
container:
image: gcr.io/spectro-dev-public/bulwark/gitleaks:latest
env:
REPO: ${{ github.event.repository.name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_CONFIG: /workspace/config.toml
steps:

- name: run-bulwark-gitleaks-scan
shell: sh
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: /workspace/bulwark -name CodeSASTGitLeaks -organization spectrocloud-labs -target $REPO -tags "branch:$BRANCH,options:--log-opts origin..HEAD"

- name: check-result
shell: sh
run: |
resultPath=./$REPO/gitleaks.json
cat $resultPath | grep -v \"Match\"\: | grep -v \"Secret\"\:
total_failed_tests=`cat $resultPath | grep \"Fingerprint\"\: | wc -l`
if [ "$total_failed_tests" -gt 0 ]; then
echo "GitLeaks validation check failed with above findings..."
exit 1
else
echo "GitLeaks validation check passed"
fi
31 changes: 31 additions & 0 deletions .github/workflows/bulwark-golicenses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: GoLicenses

on:
pull_request:
workflow_dispatch:

concurrency:
group: golicenses-${{ github.ref }}
cancel-in-progress: true

jobs:
golicense-pr-scan:
runs-on: ubuntu-latest
steps:
- name: install-git
run: sudo apt-get install -y git

- name: install-golicenses
run: GOBIN=/usr/local/bin go install github.com/google/go-licenses@v1.0.0

- name: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
with:
go-version: '1.22'

- name: golicense-scan
run: |
go-licenses check ./...
49 changes: 49 additions & 0 deletions .github/workflows/bulwark-gosec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: BulwarkGoSec

on:
pull_request:
workflow_dispatch:

concurrency:
group: gosec-${{ github.ref }}
cancel-in-progress: true

jobs:
gosec-pr-scan:
runs-on: ubuntu-latest
container:
image: gcr.io/spectro-dev-public/bulwark/gosec:latest
env:
REPO: ${{ github.event.repository.name }}
steps:

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
with:
go-version: '1.22'

- name: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: run-gosec-scan
shell: sh
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
GO111MODULE: on
run: /workspace/bulwark -name CodeSASTGoSec -verbose -organization spectrocloud-labs -target $REPO -tags "branch:$BRANCH"

- name: check-result
shell: sh
run: |
resultPath=$REPO-result.json
issues=$(cat $resultPath | jq -r '.Stats.found')
echo "Found ${issues} issues"
echo "Issues by Rule ID"
jq -r '.Issues | group_by (.rule_id)[] | {rule: .[0].rule_id, count: length}' $resultPath
if [ "$issues" -gt 0 ]; then
echo "GoSec SAST scan failed with below findings..."
cat $resultPath
exit 1
else
echo "GoSec SAST scan passed"
fi
27 changes: 27 additions & 0 deletions .github/workflows/bulwark-govulncheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: GoVulnCheck

on:
pull_request:
workflow_dispatch:

concurrency:
group: govulncheck-${{ github.ref }}
cancel-in-progress: true

jobs:
govulncheck-pr-scan:
runs-on: ubuntu-latest
container:
image: gcr.io/spectro-images-public/golang:1.22-alpine
steps:
- name: install-govulncheck
run: GOBIN=/usr/local/bin go install golang.org/x/vuln/cmd/govulncheck@latest

- name: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: govulncheck-scan
run: |
go version
govulncheck -mode source ./...

19 changes: 19 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
push:
workflow_dispatch:

jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
- name: Test
run: make test

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin/*
!bin/.gitkeep
_build
.DS_Store
53 changes: 53 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## golangci-lint v1.55.2

# References:
# - https://golangci-lint.run/usage/linters/
# - https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322

run:
timeout: 10m # default 1m

linters-settings:
gosimple:
go: "1.21" # default 1.13
govet:
enable-all: true
disable:
- fieldalignment # too strict
- shadow # too strict
staticcheck:
go: "1.21" # default 1.13

# Non-default
cyclop:
max-complexity: 12 # maximal code complexity to report; default 10
package-average: 0.0 # maximal average package complexity to report; default 0.0
gocognit:
min-complexity: 30 # minimal code complexity to report; default: 30

linters:
disable-all: true
enable:
## enabled by default
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- ineffassign # Detects when assignments to existing variables are not used
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
- gosimple # Linter for Go source code that specializes in simplifying a code
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- unused # Checks Go code for unused constants, variables, functions and types
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
## disabled by default
- cyclop # checks function and package cyclomatic complexity
- gocognit # Computes and checks the cognitive complexity of functions

issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- path: _test\.go
linters:
- errcheck
- gosimple
- ineffassign
- staticcheck
- unused
48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# If you update this file, please follow:
# https://suva.sh/posts/well-documented-makefiles/

.DEFAULT_GOAL:=help

# binary versions
BIN_DIR ?= ./bin
GOLANGCI_VERSION ?= 1.55.2

GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)

##@ Help Targets
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[0m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Test Targets
.PHONY: test
test: static ## Run tests
@mkdir -p _build/cov
go test -covermode=atomic -coverpkg=./... -coverprofile _build/cov/coverage.out ./... -timeout 120m

##@ Static Analysis Targets
static: fmt lint vet
fmt: ## Run go fmt against code
go fmt ./...
lint: golangci-lint ## Run golangci-lint
$(GOLANGCI_LINT) run
vet: ## Run go vet against code
go vet ./...

## Tools & binaries
golangci-lint:
if ! test -f $(BIN_DIR)/golangci-lint-linux-amd64; then \
curl -LOs https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-linux-amd64.tar.gz; \
tar -zxf golangci-lint-$(GOLANGCI_VERSION)-linux-amd64.tar.gz; \
mv golangci-lint-$(GOLANGCI_VERSION)-*/golangci-lint $(BIN_DIR)/golangci-lint-linux-amd64; \
chmod +x $(BIN_DIR)/golangci-lint-linux-amd64; \
rm -rf ./golangci-lint-$(GOLANGCI_VERSION)-linux-amd64*; \
fi
if ! test -f $(BIN_DIR)/golangci-lint-$(GOOS)-$(GOARCH); then \
curl -LOs https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-$(GOARCH).tar.gz; \
tar -zxf golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-$(GOARCH).tar.gz; \
mv golangci-lint-$(GOLANGCI_VERSION)-*/golangci-lint $(BIN_DIR)/golangci-lint-$(GOOS)-$(GOARCH); \
chmod +x $(BIN_DIR)/golangci-lint-$(GOOS)-$(GOARCH); \
rm -rf ./golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-$(GOARCH)*; \
fi
GOLANGCI_LINT=$(BIN_DIR)/golangci-lint-$(GOOS)-$(GOARCH)
Empty file added bin/.gitkeep
Empty file.
32 changes: 32 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module github.com/spectrocloud-labs/prompts-tui

go 1.22.3

require (
emperror.dev/errors v0.8.1
github.com/Masterminds/semver v1.5.0
github.com/pterm/pterm v0.12.79
golang.org/x/crypto v0.23.0
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10
k8s.io/apimachinery v0.30.1
)

require (
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
)
Loading
Loading