Skip to content

Commit

Permalink
Merge branch 'master' into rudder_20231114
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceMacBuche committed Jun 9, 2024
2 parents 5706008 + 0533069 commit 3377c0d
Show file tree
Hide file tree
Showing 85 changed files with 6,808 additions and 1,944 deletions.
19 changes: 15 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: github-actions
directory: /
schedule:
interval: "weekly"
target-branch: "master"
interval: monthly
target-branch: master
- package-ecosystem: gomod # See documentation for possible values
open-pull-requests-limit: 10
directory: / # Location of package manifests
schedule:
interval: weekly
groups:
aws:
patterns:
- github.com/aws/aws-sdk-go-v2
- github.com/aws/aws-sdk-go-v2/*
target-branch: master
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build

on:
pull_request:

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: build
run: make build
- name: build-scanner
run: make build-scanner
- name: build-trivy-to-vuls
run: make build-trivy-to-vuls
- name: build-future-vuls
run: make build-future-vuls
- name: build-snmp2cpe
run: make build-snmp2cpe
13 changes: 9 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.mod

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -50,7 +55,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -64,4 +69,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
16 changes: 8 additions & 8 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: vuls/vuls image meta
id: oss-meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: vuls/vuls
tags: |
type=ref,event=tag
- name: vuls/fvuls image meta
id: fvuls-meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: vuls/fvuls
tags: |
type=ref,event=tag
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: OSS image build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
Expand All @@ -56,7 +56,7 @@ jobs:
platforms: linux/amd64,linux/arm64

- name: FutureVuls image build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
file: ./contrib/Dockerfile
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.54
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: go.mod
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
args: release --clean --timeout 60m
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Test
Expand Down
4 changes: 2 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
install \
all \
vendor \
lint \
lint \
vet \
fmt \
fmtcheck \
Expand Down Expand Up @@ -90,7 +90,7 @@ NOW=$(shell date '+%Y-%m-%dT%H-%M-%S%z')
NOW_JSON_DIR := '${BASE_DIR}/$(NOW)'
ONE_SEC_AFTER=$(shell date -d '+1 second' '+%Y-%m-%dT%H-%M-%S%z')
ONE_SEC_AFTER_JSON_DIR := '${BASE_DIR}/$(ONE_SEC_AFTER)'
LIBS := 'bundler' 'pip' 'pipenv' 'poetry' 'composer' 'npm' 'yarn' 'pnpm' 'cargo' 'gomod' 'gosum' 'gobinary' 'jar' 'pom' 'gradle' 'nuget-lock' 'nuget-config' 'dotnet-deps' 'conan' 'nvd_exact' 'nvd_rough' 'nvd_vendor_product' 'nvd_match_no_jvn' 'jvn_vendor_product' 'jvn_vendor_product_nover'
LIBS := 'bundler' 'dart' 'elixir' 'pip' 'pipenv' 'poetry' 'composer' 'npm-v1' 'npm-v2' 'npm-v3' 'yarn' 'pnpm' 'cargo' 'gomod' 'gosum' 'gobinary' 'jar' 'jar-wrong-name-log4j-core' 'war' 'pom' 'gradle' 'nuget-lock' 'nuget-config' 'dotnet-deps' 'dotnet-package-props' 'conan-v1' 'conan-v2' 'swift-cocoapods' 'swift-swift' 'rust-binary'

diff:
# git clone [email protected]:vulsio/vulsctl.git
Expand Down
50 changes: 47 additions & 3 deletions config/awsconf.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
package config

import (
"fmt"
"slices"

"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
)

// AWSConf is aws config
type AWSConf struct {
// AWS profile to use
Profile string `json:"profile"`
// AWS S3 Endpoint to use
S3Endpoint string `json:"s3Endpoint"`

// AWS region to use
Region string `json:"region"`

// AWS profile to use
Profile string `json:"profile"`

// use credential provider
CredentialProvider CredentialProviderType `json:"credentialProvider"`

// S3 bucket name
S3Bucket string `json:"s3Bucket"`

Expand All @@ -17,14 +31,44 @@ type AWSConf struct {
// The Server-side encryption algorithm used when storing the reports in S3 (e.g., AES256, aws:kms).
S3ServerSideEncryption string `json:"s3ServerSideEncryption"`

// use s3 path style
S3UsePathStyle bool `json:"s3UsePathStyle"`

// report s3 enable
Enabled bool `toml:"-" json:"-"`
}

// CredentialProviderType is credential provider type
type CredentialProviderType string

const (
// CredentialProviderAnonymous is credential provider type: anonymous
CredentialProviderAnonymous CredentialProviderType = "anonymous"
)

// Validate configuration
func (c *AWSConf) Validate() (errs []error) {
// TODO
if !c.Enabled {
return
}

switch c.CredentialProvider {
case CredentialProviderType(""):
case CredentialProviderAnonymous:
default:
errs = append(errs, fmt.Errorf("CredentialProvider: %s is not supported", c.CredentialProvider))
}

if c.S3Bucket == "" {
errs = append(errs, fmt.Errorf("S3Bucket is empty"))

}

if c.S3ServerSideEncryption != "" {
if !slices.Contains(s3.PutObjectInput{}.ServerSideEncryption.Values(), types.ServerSideEncryption(c.S3ServerSideEncryption)) {
errs = append(errs, fmt.Errorf("S3ServerSideEncryption: %s is not supported server side encryption type", c.S3ServerSideEncryption))
}
}

return
}
14 changes: 14 additions & 0 deletions config/azureconf.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package config

import (
"fmt"
"os"

"golang.org/x/xerrors"
)

// AzureConf is azure config
type AzureConf struct {
// Azure storage endpoint
Endpoint string `json:"endpoint"`

// Azure account name to use. AZURE_STORAGE_ACCOUNT environment variable is used if not specified
AccountName string `json:"accountName"`

Expand Down Expand Up @@ -35,9 +39,19 @@ func (c *AzureConf) Validate() (errs []error) {
if os.Getenv(azureAccount) != "" {
c.AccountName = os.Getenv(azureAccount)
}
if c.AccountName == "" {
errs = append(errs, xerrors.Errorf("Azure account name is required"))
}
if os.Getenv(azureKey) != "" {
c.AccountKey = os.Getenv(azureKey)
}
if c.AccountKey == "" {
errs = append(errs, xerrors.Errorf("Azure account key is required"))
}

if c.Endpoint == "" {
c.Endpoint = fmt.Sprintf("https://%s.blob.core.windows.net/", c.AccountName)
}

if c.ContainerName == "" {
errs = append(errs, xerrors.Errorf("Azure storage container name is required"))
Expand Down
15 changes: 11 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build !windows

package config

import (
Expand All @@ -11,6 +9,7 @@ import (
"github.com/asaskevich/govalidator"
"golang.org/x/xerrors"

"github.com/future-architect/vuls/config/syslog"
"github.com/future-architect/vuls/constant"
"github.com/future-architect/vuls/logging"
)
Expand Down Expand Up @@ -50,7 +49,7 @@ type Config struct {
Slack SlackConf `json:"-"`
EMail SMTPConf `json:"-"`
HTTP HTTPConf `json:"-"`
Syslog SyslogConf `json:"-"`
Syslog syslog.Conf `json:"-"`
AWS AWSConf `json:"-"`
Azure AzureConf `json:"-"`
ChatWork ChatWorkConf `json:"-"`
Expand All @@ -76,7 +75,6 @@ type ScanOpts struct {
type ReportOpts struct {
CvssScoreOver float64 `json:"cvssScoreOver,omitempty"`
ConfidenceScoreOver int `json:"confidenceScoreOver,omitempty"`
TrivyCacheDBDir string `json:"trivyCacheDBDir,omitempty"`
NoProgress bool `json:"noProgress,omitempty"`
RefreshCve bool `json:"refreshCve,omitempty"`
IgnoreUnfixed bool `json:"ignoreUnfixed,omitempty"`
Expand All @@ -85,6 +83,15 @@ type ReportOpts struct {
DiffMinus bool `json:"diffMinus,omitempty"`
Diff bool `json:"diff,omitempty"`
Lang string `json:"lang,omitempty"`

TrivyOpts
}

// TrivyOpts is options for trivy DBs
type TrivyOpts struct {
TrivyCacheDBDir string `json:"trivyCacheDBDir,omitempty"`
TrivyJavaDBRepository string `json:"trivyJavaDBRepository,omitempty"`
TrivySkipJavaDBUpdate bool `json:"trivySkipJavaDBUpdate,omitempty"`
}

// ValidateOnConfigtest validates
Expand Down
Loading

0 comments on commit 3377c0d

Please sign in to comment.