8000 Fix CI failures and implement Phase 7 Security Hardening (complete) by Copilot · Pull Request #9 · tulm4/dsub · GitHub
[go: up one dir, main page]

Skip to content

Fix CI failures and implement Phase 7 Security Hardening (complete) - #9

Open
tulm4 with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-ci-errors-again
Open

tulm4 with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-ci-errors-again

Conversation

Copilot AI commented Mar 23, 2026 •
Copy link
Copy Markdown
Contributor

Two CI blockers on main: golangci-lint v2 rejects gosimple (merged into staticcheck), and migration 24 audit_log fails on YugabyteDB due to missing HASH column in SPLIT INTO primary key. Phase 7 implements the complete security architecture defined in docs/security.md.

CI Fixes

  • Remove gosimple from .golangci.yml — subsumed by staticcheck in golangci-lint v2
  • Fix audit_log PK from (id ASC) → (supi HASH, id ASC) — YugabyteDB requires ≥1 HASH column for SPLIT INTO

Phase 7: Security Hardening (internal/common/middleware/, internal/common/crypto/, deploy/networkpolicies/)

  • OAuth2 middleware — ****** validation, per-service scope enforcement for all 10 Nudm scopes, TokenValidator interface with StaticTokenValidator for dev/test. Claims propagated via ClaimsFromContext(ctx).
  • Rate limiting — Token bucket per-service (UEAU: 10K/s, SDM: 20K/s, etc.), 429 + Retry-After per TS 29.500 §6.10.4
  • Input validation — Content-Type enforcement, body size limiting (1MB default via MaxBytesReader), 415/413 responses
  • Audit logging — Per-request structured events with SUPI redaction, OAuth2 claim correlation, AuditLogger interface (slog impl + in-memory for tests)
  • Column encryption — AES-256-GCM for K/OPc credential columns, random nonce per row, key isolation via internal copy, ZeroKey() for memory cleanup
  • mTLS middleware — Client certificate verification, NF identity extraction from 3GPP SAN format (<nfInstanceId>.5gc.mnc<MNC>.mcc<MCC>.3gppnetwork.org), TLS 1.3 enforcement, NewTLSConfig() helper, PeerIdentityFromContext(ctx) for downstream handlers
  • Security event logger — 6 event categories (AUTHENTICATION_FAILURE, AUTHORIZATION_VIOLATION, CREDENTIAL_ACCESS_ANOMALY, IDENTITY_ATTACK, INFRASTRUCTURE, RATE_LIMIT_BREACH) with 3 severity levels (WARNING/HIGH/CRITICAL) per docs/security.md §9.1, configurable threat detection thresholds for brute-force SUCI, SQN resync storms, and credential scans per §9.2
  • Kubernetes NetworkPolicy manifests — 10 per-service allow-list policies for pod-to-pod micro-segmentation (UEAU←AUSF, SDM←AMF/SMF/SMSF, UECM←AMF/SMF/SMSF, EE←NEF/AMF, PP←NEF/PCF, MT←SMSF, UEID←AUSF+HSM, SSAU←NEF, NIDDAU←NEF, RSDS←SMSF), egress restricted to YugabyteDB (5433), NRF (8443), and DNS

Middleware follows standard Handler(next http.Handler) http.Handler chaining:

mux := http.NewServeMux()
// register service routes on mux...

var handler http.Handler = mux
handler = auditMW.Handler(handler)
handler = rateLimitMW.Handler(handler)
handler = oauth2MW.Handler(handler)
handler = mtlsMW.Handler(handler)
handler = inputValidationMW.Handler(handler)

80+ unit tests with -race. Roadmap updated to Phase 7 DONE (100%).

Original prompt
  • Check CI logs then fix all errors
  • Implement Phase 7 of Implement roadmap

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 23, 2026 05:54
- Remove 'gosimple' from .golangci.yml (merged into staticcheck in v2)
- Fix migration 24 audit_log: add HASH column for SPLIT INTO tablets
- Add OAuth2 token validation middleware (internal/common/middleware/oauth2.go)
- Add rate limiting middleware with token bucket (internal/common/middleware/ratelimit.go)
- Add input validation middleware (internal/common/middleware/inputvalidation.go)
- Add audit logging middleware (internal/common/middleware/audit.go)
- Add AES-256-GCM column encryption (internal/common/crypto/encryption.go)
- Add comprehensive unit tests for all new security components
- Update IMPLEMENTATION_ROADMAP.md Phase 7 status to IN_PROGRESS (60%)

Co-authored-by: tulm4 <16435986+tulm4@users.noreply.github.com>
Agent-Logs-Url: https://github.com/tulm4/dsub/sessions/01bc09db-a5e5-4198-a1a2-101703d46ab6
Copilot AI changed the title [WIP] Fix CI errors and implement Phase 7 of roadmap Fix CI failures and implement Phase 7 Security Hardening Mar 23, 2026
Copilot AI requested a review from tulm4 March 23, 2026 05:57
@tulm4 tulm4 left a comment
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement remaining part of Phase 7

…icies

- Add mTLS middleware with client cert verification and NF identity extraction
  from 3GPP SAN format (internal/common/middleware/mtls.go)
- Add security event logger with severity levels (WARNING/HIGH/CRITICAL),
  6 event categories, and threat detection thresholds per docs/security.md §9
  (internal/common/middleware/securityevent.go)
- Add Kubernetes NetworkPolicy manifests for all 10 Nudm services with
  per-service ingress/egress allow-lists (deploy/networkpolicies/)
- Add comprehensive tests for mTLS and security event components
- Update IMPLEMENTATION_ROADMAP.md Phase 7 to DONE (100%)

Co-authored-by: tulm4 <16435986+tulm4@users.noreply.github.com>
Agent-Logs-Url: https://github.com/tulm4/dsub/sessions/a3effe67-d447-401b-acd4-fd11dc8284fd
Copilot AI commented Mar 23, 2026
Copy link
Copy Markdown
Contributor Author

Implement remaining part of Phase 7

Completed the remaining Phase 7 in 99ab5d4:

  • mTLS middleware (internal/common/middleware/mtls.go) — client cert verification, NF identity extraction from 3GPP SAN format, TLS 1.3 enforcement, NewTLSConfig() helper
  • Security event logger (internal/common/middleware/securityevent.go) — 6 event categories (auth failure, authz violation, credential anomaly, identity attack, infrastructure, rate limit breach), 3 severity levels (WARNING/HIGH/CRITICAL), configurable threat detection thresholds per docs/security.md §9.1-§9.2
  • K8s NetworkPolicy manifests (deploy/networkpolicies/) — 10 per-service policies with allow-list ingress/egress
  • Tests for all new components

Phase 7 is now DONE (100%) in the roadmap.

Copilot AI changed the title Fix CI failures and implement Phase 7 Security Hardening Fix CI failures and implement Phase 7 Security Hardening (complete) Mar 23, 2026
Copilot AI requested a review from tulm4 March 23, 2026 08:28
@tulm4
tulm4 marked this pull request as ready for review March 23, 2026 09:10
@tulm4 tulm4 left a comment
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0