Skip to content

Commit b2410af

Browse files
authored
Add source request details to logs
* update linting rules and versions * update dependencies * add request details logging
1 parent 0719827 commit b2410af

19 files changed

+382
-78
lines changed

.github/workflows/go-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Go
2020
uses: actions/setup-go@v3
2121
with:
22-
go-version: 1.22.x
22+
go-version: 1.24.x
2323

2424
- name: Build
2525
run: make build_amd

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Go
2020
uses: actions/setup-go@v3
2121
with:
22-
go-version: 1.22.x
22+
go-version: 1.24.x
2323

2424
- name: Setup Version
2525
run: make version

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v3
1919
with:
20-
go-version: 1.22.x
20+
go-version: 1.24.x
2121

2222
- name: Build
2323
run: |

.golangci.yml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,56 @@
11
run:
2-
timeout: 3m
3-
skip-dirs:
4-
- tests
2+
timeout: 5m
53

64
linters-settings:
75
cyclop:
86
max-complexity: 30
97
package-average: 10.0
10-
118
errcheck:
129
check-type-assertions: true
13-
1410
exhaustive:
1511
check:
1612
- switch
1713
- map
18-
1914
funlen:
2015
lines: 150
2116
statements: 80
22-
2317
gocognit:
2418
min-complexity: 25
25-
2619
gosec:
2720
excludes:
2821
- G204
29-
3022
govet:
31-
check-shadowing: true
3223
enable-all: true
3324
disable-all: false
3425
disable:
3526
- fieldalignment
36-
3727
nakedret:
3828
max-func-lines: 10
39-
4029
lll:
4130
line-length: 180
31+
revive:
32+
# Increase confidence to reduce false positives
33+
confidence: 0.8
34+
rules:
35+
- name: exported
36+
severity: error
37+
disabled: false
38+
arguments:
39+
- "checkPrivateReceivers"
40+
- name: package-comments
41+
severity: error
42+
disabled: false
43+
- name: comment-spacings
44+
severity: warning
45+
disabled: false
46+
godot:
47+
scope: toplevel
48+
exclude:
49+
- "^fixme:"
50+
- "^todo:"
51+
- "^NOTE:"
52+
period: true
53+
capital: true
4254

4355
linters:
4456
enable:
@@ -62,13 +74,19 @@ linters:
6274
- nonamedreturns
6375
- predeclared
6476
- reassign
77+
- revive
6578
- stylecheck
6679
- unconvert
6780
- unparam
6881
- usestdlibvars
6982
- whitespace
83+
7084
issues:
85+
exclude-dirs:
86+
- tests
7187
exclude-rules:
7288
- path: _test\.go
7389
linters:
7490
- gocognit
91+
- godot
92+
- funlen

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99
### Added
1010
- Upcoming changes...
11+
12+
## [1.4.5] - 2025-09-10
13+
### Added
14+
- Added formatted logging for request details including:
15+
- method, path, source_ip, and x_forwarded_for
16+
1117
## [1.4.4] - 2025-08-28
1218
### Added
1319
- Added option to select scanning KB.
@@ -134,3 +140,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
134140
[1.4.1]: https://github.com/scanoss/api.go/compare/v1.4.0...v1.4.1
135141
[1.4.2]: https://github.com/scanoss/api.go/compare/v1.4.1...v1.4.2
136142
[1.4.3]: https://github.com/scanoss/api.go/compare/v1.4.2...v1.4.3
143+
[1.4.4]: https://github.com/scanoss/api.go/compare/v1.4.3...v1.4.4
144+
[1.4.5]: https://github.com/scanoss/api.go/compare/v1.4.4...v1.4.5

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22 as build
1+
FROM golang:1.24 AS build
22

33
WORKDIR /app
44

@@ -12,11 +12,11 @@ COPY . ./
1212
RUN go generate ./pkg/cmd/server.go
1313
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" -o ./scanoss-go-api ./cmd/server
1414

15-
FROM build as test
15+
FROM build AS test
1616

1717
COPY test-support/scanoss.sh /app/scanoss.sh
1818

19-
FROM debian:buster-slim as production
19+
FROM debian:buster-slim AS production
2020

2121
WORKDIR /app
2222

Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,20 @@ int_test: clean_testcache ## Run all integration tests in the tests folder
3636
@echo "Running integration test framework..."
3737
go test -v ./tests
3838

39-
lint_local: ## Run local instance of linting across the code base
40-
golangci-lint run ./...
39+
lint_local_clean: ## Cleanup the local cache from the linter
40+
@echo "Cleaning linter cache..."
41+
golangci-lint cache clean
4142

42-
lint_local_fix: ## Run local instance of linting across the code base with FIX option
43-
golangci-lint run ./... --fix
43+
lint_local: lint_local_clean ## Run local instance of linting across the code base
44+
@echo "Running linter on codebase..."
45+
golangci-lint run ./pkg/... ./cmd/...
46+
47+
lint_local_fix: ## Run local instance of linting across the code base including auto-fixing
48+
@echo "Running linter with fix option..."
49+
golangci-lint run --fix ./pkg/... ./cmd/...
4450

4551
lint_docker: ## Run docker instance of linting across the code base
46-
docker run --rm -v $(pwd):/app -v ~/.cache/golangci-lint/v1.50.1:/root/.cache -w /app golangci/golangci-lint:v1.50.1 golangci-lint run ./...
52+
docker run --rm -v $(PWD):/app -v ~/.cache/golangci-lint/v1.64.8:/root/.cache -w /app golangci/golangci-lint:v1.64.8 golangci-lint run ./pkg/... ./cmd/...
4753

4854
run_local: ## Launch the API locally for test
4955
@echo "Launching API locally..."

cmd/server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1515
*/
1616

17-
// Package main loads the REST Scanning Server Service
17+
// Package main loads the REST Scanning Server Service.
1818
package main
1919

2020
import (

docker-compose.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
---
2-
3-
version: "3"
4-
51
services:
62
http:
73
image: scanoss_api_go_service_test

go.mod

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ require (
1212
github.com/jpillora/ipfilter v1.2.9
1313
github.com/scanoss/zap-logging-helper v0.4.0
1414
github.com/stretchr/testify v1.11.1
15-
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.62.0
16-
go.opentelemetry.io/otel v1.37.0
17-
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.37.0
18-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0
19-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.37.0
20-
go.opentelemetry.io/otel/metric v1.37.0
21-
go.opentelemetry.io/otel/sdk v1.37.0
22-
go.opentelemetry.io/otel/sdk/metric v1.37.0
23-
go.opentelemetry.io/otel/trace v1.37.0
15+
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.63.0
16+
go.opentelemetry.io/otel v1.38.0
17+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.38.0
18+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0
19+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0
20+
go.opentelemetry.io/otel/metric v1.38.0
21+
go.opentelemetry.io/otel/sdk v1.38.0
22+
go.opentelemetry.io/otel/sdk/metric v1.38.0
23+
go.opentelemetry.io/otel/trace v1.38.0
2424
go.uber.org/zap v1.27.0
2525
)
2626

@@ -35,7 +35,7 @@ require (
3535
github.com/golobby/dotenv v1.3.2 // indirect
3636
github.com/golobby/env/v2 v2.2.4 // indirect
3737
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
38-
github.com/phuslu/iploc v1.0.20250815 // indirect
38+
github.com/phuslu/iploc v1.0.20250901 // indirect
3939
github.com/pmezard/go-difflib v1.0.0 // indirect
4040
github.com/robfig/cron/v3 v3.0.1 // indirect
4141
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce // indirect
@@ -46,10 +46,10 @@ require (
4646
golang.org/x/net v0.43.0 // indirect
4747
golang.org/x/sys v0.35.0 // indirect
4848
golang.org/x/text v0.28.0 // indirect
49-
google.golang.org/genproto/googleapis/api v0.0.0-20250826171959-ef028d996bc1 // indirect
50-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250826171959-ef028d996bc1 // indirect
51-
google.golang.org/grpc v1.75.0 // indirect
52-
google.golang.org/protobuf v1.36.8 // indirect
49+
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090 // indirect
50+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090 // indirect
51+
google.golang.org/grpc v1.75.1 // indirect
52+
google.golang.org/protobuf v1.36.9 // indirect
5353
gopkg.in/yaml.v3 v3.0.1 // indirect
5454
)
5555

0 commit comments

Comments
 (0)