Skip to content

Commit 11d0e86

Browse files
committed
chore: Update dependencies and workflows
1 parent 5a6d788 commit 11d0e86

File tree

9 files changed

+118
-248
lines changed

9 files changed

+118
-248
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: ci
2+
env:
3+
commit_msg: ""
24
on:
35
push:
46
branches:
57
- "*"
68
pull_request:
79
branches:
810
- master
11+
- main
912
workflow_dispatch: {}
1013
jobs:
1114
# Scan direct Go dependencies for known vulnerabilities
@@ -54,14 +57,14 @@ jobs:
5457
needs: scan
5558
strategy:
5659
matrix:
57-
go-version: [1.19.x, 1.20.x]
60+
go-version: [1.19.x, 1.20.x, 1.21.x]
5861
os: [ubuntu-latest]
5962
runs-on: ${{ matrix.os }}
6063
timeout-minutes: 15
6164
steps:
6265
# Checkout code
6366
- name: Checkout repository
64-
uses: actions/checkout@v3
67+
uses: actions/checkout@v4
6568

6669
# Configure runner environment
6770
- name: Set up runner environment
@@ -88,7 +91,7 @@ jobs:
8891
- name: Static analysis
8992
uses: golangci/golangci-lint-action@v3
9093
with:
91-
version: v1.51.2
94+
version: v1.54.2
9295

9396
# Run unit tests
9497
- name: Test

.github/workflows/codeql.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
pull_request:
77
branches:
88
- master
9+
- main
910
workflow_dispatch: {}
1011
jobs:
1112
# Semantic code analysis to discover vulnerabilities in the codebase
@@ -21,7 +22,7 @@ jobs:
2122
steps:
2223
# Checkout code
2324
- name: Checkout repository
24-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2526

2627
# Prepare runner environment
2728
- name: Set up runner environment

.github/workflows/release.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: release
2+
env:
3+
commit_msg: ""
24
on:
35
push:
46
tags:
@@ -13,7 +15,7 @@ jobs:
1315
steps:
1416
# Checkout code
1517
- name: Checkout repository
16-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1719
# This is required for the changelog to be properly generated
1820
with:
1921
fetch-depth: 0
@@ -36,28 +38,16 @@ jobs:
3638
- name: Set up Go
3739
uses: actions/setup-go@v4
3840
with:
39-
go-version: 1.20.x
40-
41-
# If "vendor" is in cache, restore.
42-
# To run conditional steps use:
43-
# if: steps.vendor-cache.outputs.cache-hit != 'true'
44-
- name: Restore vendor from cache
45-
id: vendor-cache
46-
uses: actions/cache@v3
47-
env:
48-
cache-name: vendor
49-
with:
50-
path: ./vendor
51-
key: ${{ env.cache-name }}-${{ hashFiles('go.sum') }}
41+
go-version: 1.21.x
5242

5343
# Use goreleaser to create the new release
5444
# https://github.com/goreleaser/goreleaser-action
5545
- name: Create release
56-
uses: goreleaser/goreleaser-action@v4
46+
uses: goreleaser/goreleaser-action@v5
5747
if: startsWith(github.ref, 'refs/tags/')
5848
with:
5949
version: latest
60-
args: release --rm-dist --skip-validate
50+
args: release --clean --skip=validate
6151
env:
6252
# https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow
6353
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}

.golangci.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ linters:
2525
- typecheck
2626
- gocyclo
2727
- goconst
28-
- depguard
2928
- misspell
3029
- lll
3130
- nakedret
@@ -45,16 +44,17 @@ linters:
4544
- predeclared
4645
- exportloopref
4746
- whitespace
47+
- nestif
48+
- funlen
4849
# Deprecated linters
49-
#- wrapcheck
50-
#- nestif
51-
#- funlen
52-
#- ifshort
53-
#- varcheck
50+
# - wrapcheck
51+
# - ifshort
52+
# - varcheck
5453
disable:
5554
- deadcode
5655
- unused
5756
- dupl
57+
- depguard
5858
# https://github.com/golangci/golangci-lint/issues/2649
5959
- structcheck
6060
- wastedassign
@@ -96,17 +96,15 @@ linters-settings:
9696
- unusedresult
9797
- tests
9898
#- fieldalignment
99+
nestif:
100+
min-complexity: 6
99101
gofmt:
100102
simplify: true
101103
gocyclo:
102104
min-complexity: 18
103105
goconst:
104106
min-len: 3
105107
min-occurrences: 5
106-
depguard:
107-
list-type: blacklist
108-
include-go-root: false
109-
packages: []
110108
misspell:
111109
locale: US
112110
ignore-words: []

.goreleaser.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ builds:
1717
# code entrypoint
1818
main: main.go
1919
# CLI flags for the 'go build' command
20-
flags:
21-
-v
20+
flags: -v
2221
ldflags:
2322
- -s -w
2423
- -X github.com/bryk-io/tred-cli/cmd.coreVersion={{.Version}}
2524
- -X github.com/bryk-io/tred-cli/cmd.buildCode={{.Commit}}
2625
- -X github.com/bryk-io/tred-cli/cmd.buildTimestamp={{.CommitDate}}
2726
# set the modified timestamp on the output binary to ensure a
2827
# reproducible build
29-
mod_timestamp: '{{ .CommitTimestamp }}'
28+
mod_timestamp: "{{ .CommitTimestamp }}"
3029
# disable CGO since it's not supported
3130
env:
3231
- CGO_ENABLED=0
@@ -48,7 +47,6 @@ builds:
4847
archives:
4948
# a single project can produce multiple archives
5049
- name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
51-
rlcp: true
5250
builds:
5351
# artifacts to pack
5452
- tredctl
@@ -60,7 +58,7 @@ archives:
6058
# include documentation files in the package for distribution
6159
- README.md
6260
- LICENSE*
63-
- src: '*.md'
61+
- src: "*.md"
6462
dst: docs
6563
strip_parent: true
6664
# generate integrity checksums
@@ -72,7 +70,6 @@ checksum:
7270
# https://goreleaser.com/customization/source/
7371
source:
7472
enabled: true
75-
rlcp: true
7673
# produce test releases
7774
# https://goreleaser.com/customization/snapshots/
7875
snapshot:
@@ -81,7 +78,7 @@ snapshot:
8178
# https://goreleaser.com/customization/release/#customize-the-changelog
8279
changelog:
8380
# Sorts the changelog by the commit messages (asc, desc or '')
84-
sort: ''
81+
sort: ""
8582
# Remove certain commit messages from the changelog
8683
filters:
8784
# Standard commit messages can help to produce better changelogs
@@ -94,21 +91,20 @@ changelog:
9491
# Produce homebrew formulas for the project artifacts
9592
# https://goreleaser.com/customization/homebrew/
9693
brews:
97-
-
98-
# Formula name
94+
- # Formula name
9995
name: tredctl
10096
# Push the formula to the tap repository
10197
skip_upload: "false"
10298
# TAP repository
103-
tap:
99+
repository:
104100
owner: bryk-io
105101
name: homebrew-tap
106102
# Use 'github-actions' as commit author
107103
# https://github.community/t/github-actions-bot-email-address/17204
108104
commit_author:
109105
name: github-actions
110106
email: 41898282+github-actions[bot]@users.noreply.github.com
111-
homepage: 'https://github.com/bryk-io/tred-cli'
107+
homepage: "https://github.com/bryk-io/tred-cli"
112108
description: |
113109
CLI client for the 'Tamper Resistant Encrypted Data' protocol.
114110
install: |
@@ -123,8 +119,7 @@ brews:
123119
# linux packages
124120
# https://goreleaser.com/customization/nfpm/
125121
nfpms:
126-
-
127-
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
122+
- file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
128123
builds:
129124
- tredctl
130125
vendor: Bryk Labs

cmd/decrypt.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,25 @@ func runDecrypt(_ *cobra.Command, args []string) error {
102102

103103
// Get decryption key
104104
var key []byte
105+
106+
// ... from file
105107
if viper.GetString("decrypt.key") != "" {
106108
if key, err = os.ReadFile(viper.GetString("decrypt.key")); err != nil {
107109
log.WithField("error", err).Fatal("could not read key file provided")
108110
return err
109111
}
110-
} else {
112+
}
113+
114+
// ... from user input
115+
if len(key) == 0 {
111116
log.Info("no key file provided, asking for a secret key now")
112117
if key, err = secureAsk("Decryption Key: \n"); err != nil {
113118
log.WithField("error", err).Fatal("failed to retrieve key")
114119
return err
115120
}
116121
}
117122

118-
// Start tred workers pool
123+
// Start TRED worker pool
119124
wp, err := newPool(viper.GetInt("decrypt.workers"), key, viper.GetString("decrypt.cipher"), log)
120125
if err != nil {
121126
log.WithField("error", err).Fatal("could not initialize TRED workers")
@@ -126,38 +131,31 @@ func runDecrypt(_ *cobra.Command, args []string) error {
126131
start := time.Now()
127132
if isDir(input) {
128133
_ = filepath.Walk(input, func(f string, i os.FileInfo, err error) error {
134+
fields := xlog.Fields{"location": f}
135+
129136
// Unexpected error walking the directory
130137
if err != nil {
131-
log.WithFields(xlog.Fields{
132-
"location": f,
133-
"error": err,
134-
}).Warning("failed to traverse location")
138+
fields["error"] = err
139+
log.WithFields(fields).Warning("failed to traverse location")
135140
return err
136141
}
137142

138143
// Ignore hidden files
139144
if strings.HasPrefix(filepath.Base(f), ".") && !viper.GetBool("decrypt.all") {
140-
log.WithFields(xlog.Fields{
141-
"location": f,
142-
}).Debug("ignoring hidden file")
145+
log.WithFields(fields).Debug("ignoring hidden file")
143146
return nil
144147
}
145148

146149
// Don't go into sub-directories if not required
147150
if i.IsDir() && !viper.GetBool("decrypt.recursive") {
148-
log.WithFields(xlog.Fields{
149-
"location": f,
150-
}).Debug("ignoring directory on non-recursive run")
151+
log.WithFields(fields).Debug("ignoring directory on non-recursive run")
151152
return filepath.SkipDir
152153
}
153154

154-
// Ignore subdir markers
155-
if i.IsDir() {
156-
return nil
155+
// Add files as jobs on processing pool
156+
if !i.IsDir() {
157+
wp.add(job{file: f, showBar: false})
157158
}
158-
159-
// Add job to processing pool
160-
wp.add(job{file: f, showBar: false})
161159
return nil
162160
})
163161
} else {

cmd/encrypt.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,25 @@ func runEncrypt(_ *cobra.Command, args []string) error {
102102

103103
// Get encryption key
104104
var key []byte
105+
106+
// ... from file
105107
if viper.GetString("encrypt.key") != "" {
106108
if key, err = os.ReadFile(viper.GetString("encrypt.key")); err != nil {
107109
log.WithField("error", err).Fatal("could not read key file provided")
108110
return err
109111
}
110-
} else {
112+
}
113+
114+
// ... from user input
115+
if len(key) == 0 {
111116
log.Info("no key file provided, asking for a secret key now")
112117
if key, err = getInteractiveKey(); err != nil {
113118
log.WithField("error", err).Fatal("failed to retrieve key")
114119
return err
115120
}
116121
}
117122

118-
// Start tred workers pool
123+
// Start TRED worker pool
119124
wp, err := newPool(viper.GetInt("encrypt.workers"), key, viper.GetString("encrypt.cipher"), log)
120125
if err != nil {
121126
log.WithField("error", err).Fatal("could not initialize TRED workers")
@@ -126,38 +131,31 @@ func runEncrypt(_ *cobra.Command, args []string) error {
126131
start := time.Now()
127132
if isDir(input) {
128133
err = filepath.Walk(input, func(f string, i os.FileInfo, err error) error {
134+
fields := xlog.Fields{"location": f}
135+
129136
// Unexpected error walking the directory
130137
if err != nil {
131-
log.WithFields(xlog.Fields{
132-
"location": f,
133-
"error": err,
134-
}).Warning("failed to traverse location")
138+
fields["error"] = err
139+
log.WithFields(fields).Warning("failed to traverse location")
135140
return err
136141
}
137142

138143
// Ignore hidden files
139144
if strings.HasPrefix(filepath.Base(f), ".") && !viper.GetBool("encrypt.all") {
140-
log.WithFields(xlog.Fields{
141-
"location": f,
142-
}).Debug("ignoring hidden file")
145+
log.WithFields(fields).Debug("ignoring hidden file")
143146
return nil
144147
}
145148

146149
// Don't go into sub-directories if not required
147150
if i.IsDir() && !viper.GetBool("encrypt.recursive") {
148-
log.WithFields(xlog.Fields{
149-
"location": f,
150-
}).Debug("ignoring directory on non-recursive run")
151+
log.WithFields(fields).Debug("ignoring directory on non-recursive run")
151152
return filepath.SkipDir
152153
}
153154

154-
// Ignore subdir markers
155-
if i.IsDir() {
156-
return nil
155+
// Add files as jobs on processing pool
156+
if !i.IsDir() {
157+
wp.add(job{file: f, showBar: false, encrypt: true})
157158
}
158-
159-
// Add job to processing pool
160-
wp.add(job{file: f, showBar: false, encrypt: true})
161159
return nil
162160
})
163161
} else {

0 commit comments

Comments
 (0)