Skip to content

Commit b949d30

Browse files
committed
SentinelGate v2.1
0 parents  commit b949d30

File tree

653 files changed

+213285
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

653 files changed

+213285
-0
lines changed

.githooks/pre-commit

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
# Pre-commit hook: runs golangci-lint on staged Go files.
3+
# Install via: scripts/install-hooks.sh
4+
5+
# Check if there are staged Go files.
6+
STAGED_GO=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$' || true)
7+
if [ -z "$STAGED_GO" ]; then
8+
exit 0
9+
fi
10+
11+
echo "pre-commit: running golangci-lint..."
12+
if ! golangci-lint run ./...; then
13+
echo ""
14+
echo "pre-commit: lint failed. Fix the issues above before committing."
15+
exit 1
16+
fi

.githooks/pre-push

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
# Pre-push hook: runs tests with race detector.
3+
# Install via: scripts/install-hooks.sh
4+
5+
echo "pre-push: running tests with race detector..."
6+
if ! go test -race -count=1 -timeout 300s ./...; then
7+
echo ""
8+
echo "pre-push: tests failed. Fix the issues above before pushing."
9+
exit 1
10+
fi
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Bug Report
2+
description: Report a bug in SentinelGate
3+
labels: ["bug"]
4+
body:
5+
- type: textarea
6+
id: description
7+
attributes:
8+
label: Description
9+
description: What happened? Provide a clear and concise description of the bug.
10+
placeholder: A clear description of the bug...
11+
validations:
12+
required: true
13+
14+
- type: textarea
15+
id: steps
16+
attributes:
17+
label: Steps to Reproduce
18+
description: How can we reproduce this issue?
19+
placeholder: |
20+
1. Start SentinelGate with config...
21+
2. Send request to...
22+
3. Observe...
23+
validations:
24+
required: true
25+
26+
- type: textarea
27+
id: expected
28+
attributes:
29+
label: Expected Behavior
30+
description: What should have happened?
31+
placeholder: I expected...
32+
validations:
33+
required: true
34+
35+
- type: textarea
36+
id: actual
37+
attributes:
38+
label: Actual Behavior
39+
description: What actually happened?
40+
placeholder: Instead, what happened was...
41+
validations:
42+
required: true
43+
44+
- type: input
45+
id: version
46+
attributes:
47+
label: Version
48+
description: Output of `sentinel-gate version`
49+
placeholder: "v1.1.0"
50+
validations:
51+
required: true
52+
53+
- type: dropdown
54+
id: installation
55+
attributes:
56+
label: Installation Method
57+
options:
58+
- Docker
59+
- Binary
60+
- Source
61+
validations:
62+
required: false
63+
64+
- type: input
65+
id: os
66+
attributes:
67+
label: OS
68+
description: Operating system and version
69+
placeholder: "e.g. Ubuntu 22.04, macOS 14, Windows 11"
70+
validations:
71+
required: false
72+
73+
- type: textarea
74+
id: logs
75+
attributes:
76+
label: Logs
77+
description: Relevant log output (sensitive data redacted)
78+
render: shell
79+
validations:
80+
required: false
81+
82+
- type: textarea
83+
id: config
84+
attributes:
85+
label: Configuration
86+
description: Relevant configuration (sensitive data redacted)
87+
render: yaml
88+
validations:
89+
required: false
90+
91+
- type: checkboxes
92+
id: search
93+
attributes:
94+
label: Due Diligence
95+
options:
96+
- label: I have searched existing issues for duplicates
97+
required: true
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Feature Request
2+
description: Suggest an improvement for SentinelGate
3+
labels: ["enhancement"]
4+
body:
5+
- type: textarea
6+
id: problem
7+
attributes:
8+
label: Problem
9+
description: What problem does this feature solve?
10+
placeholder: I'm always frustrated when...
11+
validations:
12+
required: true
13+
14+
- type: textarea
15+
id: solution
16+
attributes:
17+
label: Proposed Solution
18+
description: How should it work? Describe the desired behavior.
19+
placeholder: It would be great if...
20+
validations:
21+
required: true
22+
23+
- type: textarea
24+
id: alternatives
25+
attributes:
26+
label: Alternatives Considered
27+
description: Other approaches you've considered
28+
placeholder: I also thought about...
29+
validations:
30+
required: false
31+
32+
- type: dropdown
33+
id: component
34+
attributes:
35+
label: Component
36+
description: Which part of SentinelGate does this affect?
37+
options:
38+
- Core Proxy
39+
- Admin UI
40+
- Policy Engine
41+
- CLI
42+
- Docker
43+
- Other
44+
validations:
45+
required: false
46+
47+
- type: checkboxes
48+
id: search
49+
attributes:
50+
label: Due Diligence
51+
options:
52+
- label: I have searched existing issues for duplicates
53+
required: true
54+
- label: "This is NOT a Pro/Enterprise feature (SSO, SIEM, multi-tenant, etc.)"
55+
required: false

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Summary
2+
3+
<!-- Brief description of what this PR does -->
4+
5+
## Related Issues
6+
7+
<!-- Link related issues: Fixes #123, Closes #456 -->
8+
9+
## Changes
10+
11+
<!-- List the key changes -->
12+
13+
-
14+
15+
## Checklist
16+
17+
- [ ] Tests pass (`go test ./...`)
18+
- [ ] Lint passes (`golangci-lint run`)
19+
- [ ] New code has tests
20+
- [ ] Documentation updated (if applicable)
21+
- [ ] No breaking changes (or documented below)
22+
- [ ] CLA signed (required for all contributors)
23+
24+
## Breaking Changes
25+
26+
<!-- If any, describe migration steps -->
27+
28+
None.
29+
30+
## Screenshots
31+
32+
<!-- If UI changes, add before/after screenshots -->

.github/workflows/ci.yml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
name: Lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version-file: 'go.mod'
21+
- name: golangci-lint
22+
uses: golangci/golangci-lint-action@v7
23+
with:
24+
version: v2.10
25+
args: --timeout=5m
26+
27+
test:
28+
name: Test (${{ matrix.os }})
29+
runs-on: ${{ matrix.os }}
30+
strategy:
31+
matrix:
32+
os: [ubuntu-latest, macos-latest]
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: actions/setup-go@v5
36+
with:
37+
go-version-file: 'go.mod'
38+
- name: Run tests with race detector
39+
shell: bash
40+
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
41+
- name: Check coverage on critical packages
42+
continue-on-error: true
43+
if: matrix.os == 'ubuntu-latest'
44+
run: |
45+
# Extract coverage for critical packages and enforce 80% threshold
46+
CRITICAL_PKGS=(
47+
"github.com/Sentinel-Gate/Sentinelgate/internal/adapter/outbound/state"
48+
"github.com/Sentinel-Gate/Sentinelgate/internal/domain/proxy"
49+
"github.com/Sentinel-Gate/Sentinelgate/internal/service"
50+
"github.com/Sentinel-Gate/Sentinelgate/internal/adapter/inbound/admin"
51+
"github.com/Sentinel-Gate/Sentinelgate/internal/adapter/outbound/cel"
52+
)
53+
54+
FAIL=0
55+
for pkg in "${CRITICAL_PKGS[@]}"; do
56+
COV=$(go tool cover -func=coverage.out | grep "^${pkg}/" | tail -1 | awk '{print $NF}' | tr -d '%')
57+
if [ -z "$COV" ]; then
58+
echo "WARNING: No coverage data for $pkg"
59+
continue
60+
fi
61+
echo "$pkg: ${COV}%"
62+
COV_INT=${COV%.*}
63+
if [ "$COV_INT" -lt 50 ]; then
64+
echo "FAIL: $pkg coverage ${COV}% is below 50% threshold"
65+
FAIL=1
66+
fi
67+
done
68+
69+
echo ""
70+
echo "Overall coverage:"
71+
go tool cover -func=coverage.out | tail -1
72+
73+
if [ "$FAIL" -eq 1 ]; then
74+
echo "::error::Coverage below 50% on one or more critical packages"
75+
exit 1
76+
fi
77+
- name: Upload coverage report
78+
if: matrix.os == 'ubuntu-latest'
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: coverage-report
82+
path: coverage.out
83+
84+
build:
85+
name: Build
86+
runs-on: ubuntu-latest
87+
strategy:
88+
matrix:
89+
include:
90+
- goos: linux
91+
goarch: amd64
92+
- goos: linux
93+
goarch: arm64
94+
- goos: darwin
95+
goarch: amd64
96+
- goos: darwin
97+
goarch: arm64
98+
- goos: windows
99+
goarch: amd64
100+
steps:
101+
- uses: actions/checkout@v4
102+
- uses: actions/setup-go@v5
103+
with:
104+
go-version-file: 'go.mod'
105+
- name: Build binary
106+
env:
107+
GOOS: ${{ matrix.goos }}
108+
GOARCH: ${{ matrix.goarch }}
109+
run: |
110+
go build -ldflags="-s -w" -o sentinel-gate-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/sentinel-gate
111+
- name: Upload binary
112+
uses: actions/upload-artifact@v4
113+
with:
114+
name: sentinel-gate-${{ matrix.goos }}-${{ matrix.goarch }}
115+
path: sentinel-gate-${{ matrix.goos }}-${{ matrix.goarch }}
116+
117+
smoke:
118+
name: Smoke Test
119+
runs-on: ubuntu-latest
120+
needs: [build]
121+
steps:
122+
- uses: actions/checkout@v4
123+
- uses: actions/setup-go@v5
124+
with:
125+
go-version-file: 'go.mod'
126+
- name: Install dependencies
127+
run: sudo apt-get update && sudo apt-get install -y jq
128+
- name: Run smoke tests
129+
continue-on-error: true
130+
run: bash scripts/smoke.sh
131+
132+
security:
133+
name: Security Scan
134+
runs-on: ubuntu-latest
135+
steps:
136+
- uses: actions/checkout@v4
137+
with:
138+
fetch-depth: 0 # gitleaks needs full history
139+
- uses: actions/setup-go@v5
140+
with:
141+
go-version-file: 'go.mod'
142+
143+
# Dependency vulnerability scanning
144+
- name: Install govulncheck
145+
run: go install golang.org/x/vuln/cmd/govulncheck@latest
146+
- name: govulncheck — dependency CVEs
147+
run: govulncheck ./...
148+
149+
# SAST — security bugs in Go code
150+
- name: Install gosec
151+
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
152+
- name: gosec — Go security analysis
153+
run: gosec -exclude-generated -exclude=G115,G118,G124,G204,G301,G304,G703 -severity medium ./...
154+
155+
# Secret scanning — leaked credentials in git history
156+
- name: gitleaks — secret detection
157+
uses: gitleaks/gitleaks-action@v2
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160+
161+
fuzz:
162+
name: Fuzz Tests
163+
runs-on: ubuntu-latest
164+
steps:
165+
- uses: actions/checkout@v4
166+
- uses: actions/setup-go@v5
167+
with:
168+
go-version-file: 'go.mod'
169+
- name: Fuzz MCP message parser (30s)
170+
run: go test -fuzz=FuzzDecodeMessage -fuzztime=30s ./pkg/mcp/
171+
- name: Fuzz JSON-RPC validation (30s)
172+
run: go test -fuzz=FuzzMessageValidator -fuzztime=30s ./internal/domain/validation/

0 commit comments

Comments
 (0)