Skip to content

Commit d2f1b16

Browse files
authored
Merge pull request #405 from meshery/fix/security-issue
Fixed the security issues
2 parents 0ba626a + ee6564a commit d2f1b16

File tree

12 files changed

+487
-860
lines changed

12 files changed

+487
-860
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
1-
name: Meshery Consul Default Workflow
1+
name: Meshery Consul Code Quality
22
on:
33
push:
44
branches: [ master ] # keep it simple and reduce the abuse of CI resources
55
pull_request:
66
branches: [ master ]
77
jobs:
8-
golangci-lint:
9-
name: golangci-lint
8+
lint:
9+
name: lint
1010
runs-on: ubuntu-latest
1111
steps:
12+
- uses: actions/setup-go@v4
13+
with:
14+
go-version: 1.21.x
15+
cache: true
16+
cache-dependency-path: go.sum
1217
- uses: actions/checkout@master
1318
- name: golangci-lint
1419
uses: golangci/golangci-lint-action@v3
1520
with:
16-
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
1721
version: latest
18-
args: --timeout 5m
22+
- name: Run golangci-lint
23+
run: make lint
24+
tidy:
25+
name: Go mod tidy
26+
needs: [lint]
27+
runs-on: ubuntu-22.04
28+
steps:
29+
- name: set up Go
30+
uses: actions/setup-go@v4
31+
with:
32+
go-version: 1.21.x
33+
cache: true
34+
cache-dependency-path: go.sum
35+
- uses: actions/checkout@master
36+
- name: tidy
37+
run: make tidy
1938
codecov:
2039
# golandci-lint need to be run before codecov and succeed
21-
needs: golangci-lint
40+
needs: [tidy]
2241
name: Code Coverage
2342
if: github.repository == 'meshery/meshery-consul'
2443
runs-on: ubuntu-22.04
@@ -28,7 +47,9 @@ jobs:
2847
- name: Set up Go
2948
uses: actions/setup-go@v4
3049
with:
31-
go-version: 1.19.x
50+
go-version: 1.21.x
51+
cache: true
52+
cache-dependency-path: go.sum
3253
- name: Run unit tests
3354
run: go test --short ./... -race -coverprofile=coverage.txt -covermode=atomic
3455
- name: Upload coverage to Codecov
@@ -40,7 +61,7 @@ jobs:
4061
build:
4162
name: Build check
4263
runs-on: ubuntu-latest
43-
# needs: [lint, error_check, static_check, vet, sec_check, tests]
64+
needs: [codecov]
4465
steps:
4566
- name: Check out code
4667
uses: actions/checkout@master
@@ -49,5 +70,7 @@ jobs:
4970
- name: Setup Go
5071
uses: actions/setup-go@v4
5172
with:
52-
go-version: '1.19'
53-
- run: GOPROXY=direct GOSUMDB=off GO111MODULE=on go build .
73+
go-version: 1.21.x
74+
cache: true
75+
cache-dependency-path: go.sum
76+
- run: make gobuild

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ log.txt
2121

2222
**errorutil_analyze_errors.json
2323
**errorutil_analyze_summary.json
24-
**errorutil_errors_export.json
24+
**errorutil_errors_export.json
25+
bin/consul

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ linters:
5353
- testpackage
5454

5555
run:
56+
timeout: 5m
5657
enable-cache: true
5758
skip-dirs:
5859
- vendor

Makefile

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,17 @@ ADAPTER=consul
2929

3030
## Lint check Golang
3131
lint:
32-
golangci-lint run ./...
32+
golangci-lint run -c .golangci.yml -v ./...
33+
34+
tidy:
35+
go mod tidy
36+
37+
verify:
38+
go mod verify
39+
40+
gobuild:
41+
go build -o bin/$(ADAPTER) main.go
42+
3343

3444
## Build Adapter container image with "edge-latest" tag
3545
docker:
@@ -47,28 +57,3 @@ docker-run:
4757
run:
4858
go mod tidy; \
4959
DEBUG=true GOPROXY=direct GOSUMDB=off go run main.go
50-
51-
## Build and run Adapter locally; force component registration
52-
run-force-dynamic-reg: dep-check
53-
FORCE_DYNAMIC_REG=true DEBUG=true GOPROXY=direct GOSUMDB=off go run main.go
54-
55-
#-----------------------------------------------------------------------------
56-
# Dependencies
57-
#-----------------------------------------------------------------------------
58-
.PHONY: dep-check
59-
#.SILENT: dep-check
60-
61-
INSTALLED_GO_VERSION=$(shell go version)
62-
63-
dep-check:
64-
65-
ifeq (,$(findstring $(GOVERSION), $(INSTALLED_GO_VERSION)))
66-
# Only send a warning.
67-
# @echo "Dependency missing: go$(GOVERSION). Ensure 'go$(GOVERSION).x' is installed and available in your 'PATH'"
68-
@echo "GOVERSION: " $(GOVERSION)
69-
@echo "INSTALLED_GO_VERSION: " $(INSTALLED_GO_VERSION)
70-
# Force error and stop.
71-
$(error Found $(INSTALLED_GO_VERSION). \
72-
Required golang version is: 'go$(GOVERSION).x'. \
73-
Ensure go '$(GOVERSION).x' is installed and available in your 'PATH'.)
74-
endif

build/config.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"path/filepath"
1010
"strings"
1111

12-
"github.com/layer5io/meshery-adapter-library/adapter"
1312
"github.com/layer5io/meshery-consul/internal/config"
1413

1514
"github.com/layer5io/meshkit/utils"
@@ -33,11 +32,6 @@ var AllVersions []Versions
3332

3433
var meshmodelmetadata = make(map[string]interface{})
3534

36-
var MeshModelConfig = adapter.MeshModelConfig{ //Move to build/config.go
37-
Category: "Cloud Native Network",
38-
Metadata: meshmodelmetadata,
39-
}
40-
4135
// NewConfig creates the configuration for creating components
4236
func NewConfig(version string) manifests.Config {
4337
return manifests.Config{
@@ -98,5 +92,4 @@ func init() {
9892
CRDnames, _ = config.GetFileNames("hashicorp", "consul-k8s", "control-plane/config/crd/bases/")
9993
LatestAppVersion = AllVersions[len(AllVersions)-1].AppVersion
10094
LatestVersion = AllVersions[len(AllVersions)-1].ChartVersion
101-
DefaultGenerationMethod = adapter.Manifests
10295
}

consul/oam/doc.go

Lines changed: 0 additions & 4 deletions
This file was deleted.

consul/oam/error.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

consul/oam/parser.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

consul/oam/register.go

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)