Skip to content

Commit

Permalink
ci: begin transition from circleci to gh actions and goreleaser
Browse files Browse the repository at this point in the history
Build + test + vet all push/PR events.  Pushing tags starting with 'v'
will perform a draft release driven by GoReleaser.

Fixes to allow vet to pass.
  • Loading branch information
kmroz authored and ioj committed Jul 28, 2021
1 parent c551390 commit 193e216
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 92 deletions.
88 changes: 0 additions & 88 deletions .circleci/config.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: builder-releaser

on:
push:
pull_request:

permissions:
contents: write

jobs:
build-test-vet-release:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
-
name: Build
run: go build -v ./...
-
name: Test
run: go test -v ./...
-
name: Vet
run: go vet -v ./...
-
if: startsWith(github.ref, 'refs/tags/v') == true
name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
-
if: startsWith(github.ref, 'refs/tags/v') == true
name: GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
64 changes: 64 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
builds:
# You can have multiple builds defined as a yaml list.
-
goos:
- linux
- freebsd
- darwin
- windows
# GOARCH to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
# Defaults are 386, amd64 and arm64.
goarch:
- amd64

nfpms:
# note that this is an array of nfpm configs
-
# Replacements for GOOS and GOARCH in the package name.
# Keys should be valid GOOSs or GOARCHs.
# Values are the respective replacements.
# Default is empty.
replacements:
amd64: 64-bit
darwin: macOS
vendor: alphasoc
homepage: https://alphasoc.com/
maintainer: AlphaSOC <support@alphasoc.com>
description: A lightweight utility used to generate malicious network traffic and help
security teams to evaluate security controls and network visibility.
license: CCPL
# Formats to be generated.
formats:
- deb
- rpm
- apk

release:
# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
# If set to true, will mark the release as not ready for production.
# Default is false.
prerelease: auto
# If set to true, will not auto-publish the release.
# Default is false.
draft: true
# Header template for the release body.
header: |
## Flightsim Release - {{ time "2006-02-01" }}
Welcome to this new release!
# Footer template for the release body.
footer: |
## Enjoy!
Those were the changes on {{ .Tag }}!
# You can change the name of the release.
# Default is `{{.Tag}}` on OSS and `{{.PrefixedTag}}` on Pro.
name_template: "{{.ProjectName}}-v{{.Version}}"

# Sign all artifacts.
signs:
- artifacts: all
3 changes: 2 additions & 1 deletion simulator/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func (s *PortScan) Simulate(ctx context.Context, dst string) error {
// TODO: allow for multiple connection in parallel and hence a longer deadline

for _, port := range scanPorts {
ctx, _ := context.WithTimeout(ctx, callTimeout)
ctx, cancelFn := context.WithTimeout(ctx, callTimeout)
defer cancelFn()
err := s.tcp.Simulate(ctx, fmt.Sprintf("%s:%d", dst, port))
if err != nil {
return err
Expand Down
5 changes: 2 additions & 3 deletions simulator/tunnel-dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func (s *Tunnel) Simulate(ctx context.Context, host string) error {

label := strings.ToLower(utils.RandString(30))

ctx, _ := context.WithTimeout(ctx, 200*time.Millisecond)
ctx, cancelFn := context.WithTimeout(ctx, 200*time.Millisecond)
defer cancelFn()
_, err := r.LookupTXT(ctx, fmt.Sprintf("%s.%s", label, host))

// ignore timeout and "no such host"
Expand All @@ -61,8 +62,6 @@ func (s *Tunnel) Simulate(ctx context.Context, host string) error {
// wait until context expires so we don't flood
<-ctx.Done()
}

return nil
}

// Hosts returns random generated hosts to alphasoc sandbox.
Expand Down

0 comments on commit 193e216

Please sign in to comment.