forked from canonical/chisel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add CLA check, linting and security scanning (canonical#31)
* ci: add cla-check, lint and security scan workflows This commit adds the following github workflows: - CLA check: Check if Canonical's Contributor License Agreement has been signed by the PR author(s). - Lint: Ensure fomatting changes using ``gofmt`` and run errcheck, unused, staticcheck linters using golangci-lint. - Security: Run Trivy vulnerability scanner to check for known vulnerabilities. Co-authored-by: Cristovao Cordeiro <[email protected]> * refactor: format with ``go fmt ./...`` * refactor: remove unused code This commit removes unused code (variables, functions etc.) across the codebase, with a few exceptions. Namely the unused functions from ``log.go`` in various packages are kept for future use. Additionally the ``addDebugCommand`` function in `cmd/chisel/main.go` is kept too. * refactor: remove deprecated (imported) packages The ``io/ioutil`` package has been deprecated since Go 1.19. Usage of this package have been removed appropriately. The ``golang.org/x/crypto/ssh/terminal`` package has been deprecated and moved to ``golang.org/x/term`` package. Usage have been updated likewise. * refactor: always check errors * ci: configure linters This commit adds a config file ``.golangci.yaml`` for the lint workflow. It removes the previous arguments passed to golangci-lint in favor of the new configuration file. --------- Co-authored-by: Cristovao Cordeiro <[email protected]>
- Loading branch information
1 parent
ac629b1
commit 379ddae
Showing
46 changed files
with
304 additions
and
234 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: CLA check | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
cla-check: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check if Canonical's Contributor License Agreement has been signed | ||
uses: canonical/has-signed-canonical-cla@v1 |
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 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- '**.md' | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- name: Ensure no formatting changes | ||
run: | | ||
go fmt ./... | ||
git diff --exit-code | ||
- name: Check bugs and unused code | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.54.1 |
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,20 @@ | ||
name: Security | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
scan: | ||
name: Scan for known vulnerabilities | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Run Trivy vulnerability scanner in fs mode | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
scan-type: 'fs' | ||
scan-ref: '.' |
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,55 @@ | ||
linters: | ||
# Disable all linters. | ||
# Default: false | ||
disable-all: true | ||
# Enable specific linter | ||
# https://golangci-lint.run/usage/linters/#enabled-by-default | ||
enable: | ||
- errcheck | ||
- staticcheck | ||
- unused | ||
|
||
issues: | ||
exclude-rules: | ||
# exclusions for errcheck | ||
- path: "^.*/log.go$" | ||
text: "globalLogger.Output.*not checked" | ||
linters: | ||
- errcheck | ||
- path: "^.*_test.go$" | ||
text: "release.Render.*not checked" | ||
linters: | ||
- errcheck | ||
- path: "^.*_test.go$" | ||
text: "release.Walk.*not checked" | ||
linters: | ||
- errcheck | ||
- path: "internal/setup/fetch.go" | ||
text: "lockFile.Unlock.*not checked" | ||
linters: | ||
- errcheck | ||
# exclusions for unused | ||
# addDebugCommand is an useful function that may be used later | ||
- path: "cmd/chisel/main.go" | ||
text: "addDebugCommand.*unused" | ||
linters: | ||
- unused | ||
# exclude common (unused) issues from log.go files | ||
- path: "^.*/log.go$" | ||
text: "logf.*unused" | ||
linters: | ||
- unused | ||
- path: "^.*/log.go$" | ||
text: "debugf.*unused" | ||
linters: | ||
- unused | ||
- path: "^.*/log.go$" | ||
text: "globalDebug.*unused" | ||
linters: | ||
- unused | ||
- path: "^.*/log.go$" | ||
text: "globalLogger.*unused" | ||
linters: | ||
- unused | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 |
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
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
Oops, something went wrong.