Skip to content

Commit

Permalink
chore: add gci linter (#271)
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Pivkin <[email protected]>
  • Loading branch information
nikpivkin authored Nov 26, 2024
1 parent 791d9a9 commit 574f9f8
Show file tree
Hide file tree
Showing 63 changed files with 218 additions and 207 deletions.
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ linters:
- goimports
- gocritic
- gosec
- gci

linters-settings:
cyclop:
Expand All @@ -27,6 +28,13 @@ linters-settings:
checks:
- all
- '-SA1019' # TODO
gci:
sections:
- standard
- default
- prefix(github.com/aquasecurity/)
- blank
- dot

issues:
exclude-rules:
Expand Down
8 changes: 4 additions & 4 deletions internal/adapters/cloud/aws/accessanalyzer/adapt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package api_gateway
import (
"fmt"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/accessanalyzer"
"github.com/aquasecurity/trivy/pkg/iac/state"
"github.com/aquasecurity/trivy/pkg/iac/types"
"github.com/aws/aws-sdk-go-v2/aws/arn"
api "github.com/aws/aws-sdk-go-v2/service/accessanalyzer"
aatypes "github.com/aws/aws-sdk-go-v2/service/accessanalyzer/types"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/accessanalyzer"
"github.com/aquasecurity/trivy/pkg/iac/state"
"github.com/aquasecurity/trivy/pkg/iac/types"
)

type adapter struct {
Expand Down
5 changes: 3 additions & 2 deletions internal/adapters/cloud/aws/api-gateway/adapt.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package api_gateway

import (
"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy/pkg/iac/state"
apiv1 "github.com/aws/aws-sdk-go-v2/service/apigateway"
apiv2 "github.com/aws/aws-sdk-go-v2/service/apigatewayv2"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy/pkg/iac/state"
)

type adapter struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/adapters/cloud/aws/api-gateway/apis_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package api_gateway
import (
"fmt"

v1 "github.com/aquasecurity/trivy/pkg/iac/providers/aws/apigateway/v1"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
api "github.com/aws/aws-sdk-go-v2/service/apigateway"
agTypes "github.com/aws/aws-sdk-go-v2/service/apigateway/types"

"github.com/aquasecurity/trivy-aws/pkg/concurrency"
v1 "github.com/aquasecurity/trivy/pkg/iac/providers/aws/apigateway/v1"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

func (a *adapter) getAPIsV1() ([]v1.API, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/adapters/cloud/aws/api-gateway/apis_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package api_gateway
import (
"fmt"

v2 "github.com/aquasecurity/trivy/pkg/iac/providers/aws/apigateway/v2"
"github.com/aquasecurity/trivy/pkg/iac/types"
api "github.com/aws/aws-sdk-go-v2/service/apigatewayv2"
agTypes "github.com/aws/aws-sdk-go-v2/service/apigatewayv2/types"

"github.com/aquasecurity/trivy-aws/pkg/concurrency"
v2 "github.com/aquasecurity/trivy/pkg/iac/providers/aws/apigateway/v2"
"github.com/aquasecurity/trivy/pkg/iac/types"
)

func (a *adapter) getAPIsV2() ([]v2.API, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/adapters/cloud/aws/api-gateway/domains_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package api_gateway
import (
"fmt"

v1 "github.com/aquasecurity/trivy/pkg/iac/providers/aws/apigateway/v1"
"github.com/aquasecurity/trivy/pkg/iac/types"
api "github.com/aws/aws-sdk-go-v2/service/apigateway"
agTypes "github.com/aws/aws-sdk-go-v2/service/apigateway/types"

"github.com/aquasecurity/trivy-aws/pkg/concurrency"
v1 "github.com/aquasecurity/trivy/pkg/iac/providers/aws/apigateway/v1"
"github.com/aquasecurity/trivy/pkg/iac/types"
)

func (a *adapter) getDomainNamesv1() ([]v1.DomainName, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/adapters/cloud/aws/api-gateway/domains_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package api_gateway
import (
"fmt"

v2 "github.com/aquasecurity/trivy/pkg/iac/providers/aws/apigateway/v2"
"github.com/aquasecurity/trivy/pkg/iac/types"
api "github.com/aws/aws-sdk-go-v2/service/apigatewayv2"
agTypes "github.com/aws/aws-sdk-go-v2/service/apigatewayv2/types"

"github.com/aquasecurity/trivy-aws/pkg/concurrency"
v2 "github.com/aquasecurity/trivy/pkg/iac/providers/aws/apigateway/v2"
"github.com/aquasecurity/trivy/pkg/iac/types"
)

func (a *adapter) getDomainNamesV2() ([]v2.DomainName, error) {
Expand Down
8 changes: 4 additions & 4 deletions internal/adapters/cloud/aws/athena/adapt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package athena
import (
"fmt"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/athena"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
api "github.com/aws/aws-sdk-go-v2/service/athena"
"github.com/aws/aws-sdk-go-v2/service/athena/types"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/athena"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

type adapter struct {
Expand Down
8 changes: 4 additions & 4 deletions internal/adapters/cloud/aws/cloudfront/adapt.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package cloudfront

import (
"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudfront"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
api "github.com/aws/aws-sdk-go-v2/service/cloudfront"
"github.com/aws/aws-sdk-go-v2/service/cloudfront/types"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudfront"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

type adapter struct {
Expand Down
8 changes: 4 additions & 4 deletions internal/adapters/cloud/aws/cloudtrail/adapt.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package cloudtrail

import (
"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudtrail"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
api "github.com/aws/aws-sdk-go-v2/service/cloudtrail"
"github.com/aws/aws-sdk-go-v2/service/cloudtrail/types"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudtrail"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

type adapter struct {
Expand Down
8 changes: 4 additions & 4 deletions internal/adapters/cloud/aws/cloudwatch/adapt.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package cloudwatch

import (
"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
cwApi "github.com/aws/aws-sdk-go-v2/service/cloudwatch"
cwTypes "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types"
api "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/cloudwatch"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

type adapter struct {
Expand Down
6 changes: 3 additions & 3 deletions internal/adapters/cloud/aws/codebuild/adapt.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package codebuild

import (
api "github.com/aws/aws-sdk-go-v2/service/codebuild"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/codebuild"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
api "github.com/aws/aws-sdk-go-v2/service/codebuild"

"github.com/aquasecurity/trivy-aws/pkg/concurrency"
)

type adapter struct {
Expand Down
6 changes: 3 additions & 3 deletions internal/adapters/cloud/aws/documentdb/adapt.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package documentdb

import (
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/documentdb"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
api "github.com/aws/aws-sdk-go-v2/service/docdb"
docdbTypes "github.com/aws/aws-sdk-go-v2/service/docdb/types"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy-aws/pkg/types"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/documentdb"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

type adapter struct {
Expand Down
14 changes: 7 additions & 7 deletions internal/adapters/cloud/aws/dynamodb/dynamodb.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package dynamodb

import (
aws2 "github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/dynamodb"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
"github.com/aws/aws-sdk-go-v2/aws"
dynamodbApi "github.com/aws/aws-sdk-go-v2/service/dynamodb"
dynamodbTypes "github.com/aws/aws-sdk-go-v2/service/dynamodb/types"

awsAdapter "github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/dynamodb"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

type adapter struct {
*aws2.RootAdapter
*awsAdapter.RootAdapter
client *dynamodbApi.Client
}

func init() {
aws2.RegisterServiceAdapter(&adapter{})
awsAdapter.RegisterServiceAdapter(&adapter{})
}

func (a *adapter) Name() string {
Expand All @@ -29,7 +29,7 @@ func (a *adapter) Provider() string {
return "aws"
}

func (a *adapter) Adapt(root *aws2.RootAdapter, state *state.State) error {
func (a *adapter) Adapt(root *awsAdapter.RootAdapter, state *state.State) error {
a.RootAdapter = root
a.client = dynamodbApi.NewFromConfig(root.SessionConfig())
var err error
Expand Down
4 changes: 2 additions & 2 deletions internal/adapters/cloud/aws/ec2/autoscaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package ec2
import (
"fmt"

"github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
ec2api "github.com/aws/aws-sdk-go-v2/service/ec2"
"github.com/aws/aws-sdk-go-v2/service/ec2/types"

"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

func (a *adapter) getLaunchTemplates() ([]ec2.LaunchTemplate, error) {
Expand Down
8 changes: 3 additions & 5 deletions internal/adapters/cloud/aws/ec2/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ package ec2

import (
"fmt"

"strings"

"github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"

awssdk "github.com/aws/aws-sdk-go-v2/aws"
ec2api "github.com/aws/aws-sdk-go-v2/service/ec2"
ec2Types "github.com/aws/aws-sdk-go-v2/service/ec2/types"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy-aws/pkg/types"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2"
"github.com/aquasecurity/trivy/pkg/iac/state"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

type adapter struct {
Expand Down
11 changes: 6 additions & 5 deletions internal/adapters/cloud/aws/ec2/ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package ec2
import (
"testing"

aws2 "github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws/test"
"github.com/aquasecurity/trivy/pkg/iac/state"
"github.com/aws/aws-sdk-go-v2/aws"
ec2api "github.com/aws/aws-sdk-go-v2/service/ec2"
ec2Types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

awsAdapter "github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws/test"
"github.com/aquasecurity/trivy/pkg/iac/state"
)

type volumeDetails struct {
Expand Down Expand Up @@ -113,7 +114,7 @@ func Test_EC2RootVolumeEncrypted(t *testing.T) {
}
}

func bootstrapEC2Instance(t *testing.T, ra *aws2.RootAdapter, spec instanceDetails) *string {
func bootstrapEC2Instance(t *testing.T, ra *awsAdapter.RootAdapter, spec instanceDetails) *string {

api := ec2api.NewFromConfig(ra.SessionConfig())

Expand Down Expand Up @@ -150,7 +151,7 @@ func bootstrapVolume(blockMappings []ec2Types.BlockDeviceMapping, deviceName str
return blockMappings
}

func removeInstance(t *testing.T, ra *aws2.RootAdapter, instanceID *string) {
func removeInstance(t *testing.T, ra *awsAdapter.RootAdapter, instanceID *string) {

api := ec2api.NewFromConfig(ra.SessionConfig())

Expand Down
4 changes: 2 additions & 2 deletions internal/adapters/cloud/aws/ec2/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package ec2
import (
"fmt"

"github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
ec2api "github.com/aws/aws-sdk-go-v2/service/ec2"
"github.com/aws/aws-sdk-go-v2/service/ec2/types"

"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

func (a *adapter) getVolumes() ([]ec2.Volume, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/adapters/cloud/aws/ec2/vpc.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package ec2

import (
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
"github.com/aws/aws-sdk-go-v2/aws"
ec2api "github.com/aws/aws-sdk-go-v2/service/ec2"
"github.com/aws/aws-sdk-go-v2/service/ec2/types"

"github.com/aquasecurity/trivy-aws/pkg/concurrency"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2"
trivyTypes "github.com/aquasecurity/trivy/pkg/iac/types"
)

func (a *adapter) getSecurityGroups() (securityGroups []ec2.SecurityGroup, err error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/adapters/cloud/aws/ec2/vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package ec2
import (
"testing"

"github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2"
"github.com/aquasecurity/trivy/pkg/iac/state"
awssdk "github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
vpcApi "github.com/aws/aws-sdk-go-v2/service/ec2"
Expand All @@ -15,6 +13,8 @@ import (

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws/test"
"github.com/aquasecurity/trivy/pkg/iac/providers/aws/ec2"
"github.com/aquasecurity/trivy/pkg/iac/state"
)

type rule struct {
Expand Down
Loading

0 comments on commit 574f9f8

Please sign in to comment.