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: add cluster scanning #199

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
blank_issues_enabled: false
contact_links:
- name: Bug report
Expand Down
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
Expand Down
39 changes: 29 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ on:
- 'LICENSE'
- 'NOTICE'

env:
GO_VERSION: "1.20.4"

# Disable permissions granted to the GITHUB_TOKEN for all the available scopes.
permissions: {}

Expand All @@ -42,12 +39,12 @@ jobs:
name: Verify code
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v3
go-version-file: go.mod
- name: Cached Go dependencies
uses: actions/cache@v3
with:
Expand All @@ -58,8 +55,8 @@ jobs:
- name: Verify Go code
uses: golangci/[email protected]
with:
args: --verbose --deadline=5m
version: latest
args: --verbose --deadline=10m
version: v1.52
skip-pkg-cache: true
skip-build-cache: true
- name: Verify YAML code
Expand All @@ -70,19 +67,41 @@ jobs:
name: Run unit tests
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: go.mod
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run unit tests
run: make unit-tests
- name: Upload code coverage
uses: codecov/codecov-action@v3
with:
files: ./coverage.txt
integration-tests:
name: Run integration tests
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run unit tests
- name: Run integration tests
run: make unit-tests
- name: Upload code coverage
uses: codecov/codecov-action@v3
Expand Down
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
builds:
- skip: true
changelog:
Expand Down
6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

82 changes: 0 additions & 82 deletions .idea/workspace.xml

This file was deleted.

34 changes: 34 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---

yaml-files:
- '*.yaml'
- '*.yml'
- '.yamllint'

rules:
anchors: enable
braces: enable
brackets: enable
colons: enable
commas: enable
comments:
level: warning
comments-indentation:
level: warning
document-end: disable
document-start:
level: warning
empty-lines: enable
empty-values: disable
float-values: disable
hyphens: enable
indentation: enable
key-duplicates: enable
key-ordering: disable
line-length: disable
new-line-at-end-of-file: enable
new-lines: enable
octal-values: disable
quoted-strings: disable
trailing-spaces: enable
truthy: disable
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ GOBIN=$(GOPATH)/bin

.PHONY: test
## Runs both unit and integration tests
test: unit-tests
test: unit-tests integration-tests

.PHONY: unit-tests
## Runs unit tests with code coverage enabled
unit-tests: $(SOURCES)
go test -v -short -race -timeout 30s -coverprofile=coverage.txt ./...

.PHONY: integration-tests
integration-tests: $(SOURCES)
kind create cluster --name kind-test
kubectl apply -f ./integration/testdata/fixtures/test_nginx.yaml

go test -v -tags=integration ./integration/...
kind delete cluster --name kind-test

$(GOBIN)/golangci-lint:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOBIN) v1.46.0

Expand Down
19 changes: 19 additions & 0 deletions cmd/trivy-kubernetes/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"github.com/aquasecurity/trivy-kubernetes/pkg/commands"
"github.com/aquasecurity/trivy/pkg/log"

_ "modernc.org/sqlite" // sqlite driver for RPM DB and Java DB
)

func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}

func run() error {
cmd := commands.NewCmd()
return cmd.Execute()
}
Loading
Loading