Skip to content

Release v2.1.x: Penguin-DAL migration, centralized libs, and test suite overhaul - #46

Open
PenguinzTech wants to merge 186 commits into
mainfrom
v2.1.x
Open

Release v2.1.x: Penguin-DAL migration, centralized libs, and test suite overhaul#46
PenguinzTech wants to merge 186 commits into
mainfrom
v2.1.x

Conversation

@PenguinzTech

Copy link
Copy Markdown
Contributor

This pull request merges the v2.1.x branch into main, representing a significant modernization and consolidation of the Squawk codebase.

Key Changes

1. Architectural Consolidation

  • Centralized Libraries: Removed vendored libraries in favor of centralized .
  • Penguin-DAL Migration: Migrated and from PyDAL to , including new SQLAlchemy schemas and Alembic migrations.
  • Service Consolidation: Removed separate and components, integrating DHCP and Time (NTP/PTP) services directly across components.

2. Frontend Modernization

  • React WebUI: Converted the Flask web console to an API-only backend with a modern React-based WebUI ().
  • Dependency Hardening: Pinned and dependencies to exact versions and immutable SHA references.
  • Component Integration: Integrated (LoginPageBuilder, SidebarMenu, AppConsoleVersion) into the frontend applications.

3. Testing & Quality Assurance

  • Comprehensive Test Suite: Added a new directory with E2E (Playwright), Integration, Load, and Smoke tests.
  • Coverage Improvements: Achieved 100% coverage for key frontend components (Login, Sidebar) and improved Python test coverage for backend services.
  • CI/CD Hardening: Updated GitHub Actions workflows with security scanning (Trivy), dependency monitoring, and standardized build processes.

4. Infrastructure & Deployment

  • Standardized K8s: Added standardized Kubernetes deployment configurations and deployment scripts (, ).
  • Security Fixes: Resolved high-severity vulnerabilities in Next.js and other dependencies.

5. Documentation & Standards

  • Unified Documentation: Massive overhaul of and project-wide documentation to meet new base standards.
  • Standardized Templates: Added GitHub issue templates for bugs, features, and security reports.

PenguinzTech and others added 30 commits December 11, 2025 10:18
Version files added (all at v1.0.0):
- dns-client-go/.version - Go DNS client
- dns-server/.version - DNS server
- dns-client/.version - Python DNS client (docker-client)
- dns-server/flask_app/.version - Web console (webui)

Workflow updates:
- Go client workflow now uses dns-client-go/.version
- Build triggers only when component's .version changes
- Added Windows ARM64 to build targets (6 platforms total)
- Release tags now use format: v{VERSION}-go-client

Release notes reorganized with sections for each package:
- go-client, dns-server, docker-client, webui
- Each with independent versioning and changelogs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add .version file monitoring to all build workflows
- Implement epoch64 timestamp-based naming (alpha/beta-<epoch64>)
- Add version-based release naming (vX.X.X-alpha/beta)
- Add auto pre-release creation on .version changes
- Add security scanning (gosec for Go, bandit for Python, npm audit for Node.js)
- Create comprehensive docs/WORKFLOWS.md
- Update docs/STANDARDS.md with CI/CD section
- Update CLAUDE.md with CI/CD section and pre-commit checklist

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Backend:
- Add DHCP models (pools, leases, reservations, servers) with PyDAL
- Add Time models (servers, sync logs, clients, config) with PTP/NTP support
- Add full REST API for DHCP pool management and lease tracking
- Add full REST API for time server management and sync operations
- Fix RBAC middleware: add check_team_access function
- Fix team model: remove unsupported PyDAL unique constraint

Frontend:
- Add TypeScript types for DHCP and Time services
- Add DHCPPools management component with utilization visualization
- Add TimeServers management component with PTP/NTP protocol selection
- Integrate new tabs into Management page

Go Client:
- Add NTP client package with automatic server failover
- Add NTP forwarder to intercept OS time requests (port 123)
- Add time configuration with environment variable support
- Add CLI commands: time query, time forward, time status
- Add comprehensive unit and integration tests

Documentation:
- Update API.md with DHCP and Time API endpoints
- Update ARCHITECTURE.md with network services diagrams
- Update STANDARDS.md with service-specific guidelines

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Restructure from server-side templates to a three-container architecture:
- Flask backend serves JSON-only REST API with JWT + Flask-Login auth
- React WebUI (Vite + TypeScript + Tailwind) as separate nginx container
- DNS server unchanged

Flask changes: add Flask-JWT-Extended, Flask-CORS, Flask-Limiter; convert
all dashboard routes to /api/v1/ JSON endpoints; add safe PyDAL row
serialization (exact type checks to exclude RecordUpdater/LazySet);
enforce auth on all API endpoints.

Docker: add Dockerfile.api for Flask, dns-webui service with nginx
reverse proxy, update docker-compose.yml with new services.

Tests: add comprehensive smoke test suite (130 tests) covering container
health, API endpoints, JWT auth flows, pagination, and response formats.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes Dependabot alerts #33 and #34:
- CVE: Next.js HTTP request deserialization DoS (high)
- CVE: Next.js Image Optimizer DoS (medium)

Also fixes js-yaml prototype pollution via npm audit fix.

Remaining 2 moderate alerts (eslint stack overflow, Next.js PPR memory)
require breaking major version upgrades and have no stable patches.

quic-go alerts (#28-30) are already resolved on this branch (v0.59.0
includes all patches).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The root Dockerfile's dns-server and dns-client stages both COPY docs/
into the image. The .dockerignore was excluding the docs directory,
which would cause the CI docker-multi-build job to fail.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit addresses all identified security vulnerabilities across Python,
Node.js, and Go components, and adds extensive smoke test coverage for both
alpha (local) and beta (K8s) environments to ensure production readiness.

Security Fixes:
- Python: Update cryptography (41→44), PyMySQL (1.1.0→1.1.1), Pillow (10→11),
  aiohttp (3.9→3.11.11), add defusedxml for XXE prevention
- Node.js: Update react-router-dom (6→7), eslint (8→9), vite (5→7),
  next (15→16) to fix XSS, DoS, and stack overflow vulnerabilities
- Go: Fix integer overflow in NTP time handling, replace math/rand with
  crypto/rand, enforce TLS 1.2+ minimum, update quic-go to v0.59.0

New Features:
- Add version management script (scripts/version/update-version.sh)
  supporting major/minor/patch/build version increments
- Add 150 mock tests for isolated component testing (DNS client/server,
  Manager API, database operations)
- Add 79 comprehensive smoke tests covering security, edge cases,
  integration, and user experience for alpha and beta environments

Test Coverage:
- Security: 32 tests (auth, authorization, input validation, injection
  prevention, CORS, TLS, data isolation)
- Edge Cases: 37 tests (boundaries, special chars, concurrency, large
  datasets, error recovery)
- Integration: 39 tests (component communication, data flow, K8s
  integration, monitoring)
- User Experience: 24 tests (page loads, forms, navigation, error messages)
- Mock Tests: 150 tests (fast, isolated, no network/database dependencies)

Version: Bump to v2.1.1.1770072428 (patch increment for security fixes)

Resolves: Critical PyMySQL SQL injection, XSS in react-router, integer
overflow in Go NTP client, weak RNG in HTTP backoff, TLS misconfiguration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Install shared/react_libs dependencies before webui build to resolve
zod module import error during vite build.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update dal2-beta cluster deployment to use the pre-existing
penguintech-wildcard-tls certificate from cert-manager instead of
generating a new certificate.

Changes:
- Create comprehensive K8s manifests in k8s/manifests/
- Configure ingress for squawk.penguintech.io with proper TLS
- Use pre-existing Cloudflare wildcard certificate (penguintech-wildcard-tls)
- Deploy DNS server, Flask API, WebUI, and Valkey services
- Add health checks, resource limits, and HA configuration (2 replicas)
- Configure proper routing: / → webui, /api/v1 → flask-api, /dns-query → dns-server

Ingress Configuration:
- Host: squawk.penguintech.io
- TLS Secret: penguintech-wildcard-tls (Cloudflare wildcard cert)
- SSL redirect enabled
- NGINX ingress class

Deployed to: dal2-beta cluster, squawk namespace

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove restrictive security contexts and add emptyDir volumes for
directories that need write access (database logs, nginx cache).

Fixes:
- flask-api: Health check path /api/v1/health → /health
- flask-api: Add volume mount for /app/flask_app/databases
- webui: Add volume mounts for nginx cache and run directories
- All: Remove runAsUser/runAsNonRoot to allow containers to start properly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change @penguin/react_libs reference from local file path to GitHub
repository to ensure consistent versioning across all PenguinTech projects.

- Update package.json to reference github:penguintechinc/penguin-libs#main
- Install @penguintechinc/react-libs from main branch
- Remove dependency on local shared/react_libs copy

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace local copies of shared libraries with git-referenced dependencies
from github.com/penguintechinc/penguin-libs. This ensures consistent
versioning across all PenguinTech projects.

- Remove entire shared/ directory (react_libs, node_libs, go_libs, py_libs,
  licensing, database) including duplicate shared/shared/ nested copy
- Update Dockerfile to remove COPY shared/react_libs build steps
- Update tailwind.config.js content path to node_modules dist
- Update all imports from @penguin/react_libs to @penguintechinc/react-libs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PenguinzTech and others added 30 commits July 26, 2026 20:06
feat(auth): OAuth2 client_credentials + OIDC token exchange for non-human identities
feat(auth): TOTP MFA with recovery codes and pre-auth step-up
008_add_mfa_fields (#62) and 008_machine_clients/008_audit_events
(already-merged #61/#63) both independently claimed
down_revision=007_revoked_token, creating two divergent heads
(009_oidc_trust_anchors and 008_add_mfa_fields). Git's merge saw no
textual conflict since they're different files, so this surfaced only
after the merge completed.

Re-chained 008_add_mfa_fields after 009_oidc_trust_anchors so the
migration graph has a single linear head again. Full manager suite:
229/229 passing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
chore(helm): PDBs, opt-in HPA, and pinned SPIRE reference chart
feat(dns): per-identity rate limiting on DoH endpoints
docs(enterprise): DR, HA, supply-chain verification, CoreDNS guides
chore(api): OpenAPI 3.0 spec for manager v1 API + spectral CI lint
feat(observability): opt-in OpenTelemetry tracing for manager and dns-server
- .pre-commit-config.yaml: combined the 3-way pre-commit divergence.
  Took this branch's flake8 approach (single .flake8 source of truth
  via --config, precise files: scoping to app/bins dirs, flake8-bugbear
  added) over the earlier same-session emergency inline-args patch on
  v2.1.x. Took this branch's newer valid hadolint tag (v2.14.0) over
  v2.13.1. gitleaks entry was already identical on both sides
  (protect --staged --source .) — no divergence there after all.
- .gitleaks.toml: added an allowlist entry for the well-known
  pyotp/Google-Authenticator tutorial TOTP secret (base32 for
  "Hello!!!"), which #62 (MFA, merged after this branch was created)
  uses in docstrings/tests — not a real credential.
- dhcp-server test-isolation fix (found during this merge's full-suite
  re-verification, not part of either branch's original diff):
  test_dhcp_allocation.py imports app.db at collection time, which
  imports app.config and caches JWT_PUBLIC_KEY=None before any fixture
  sets the env var; later test_auth.py tests then ran against the
  stale cached None. Fixed by clearing app.*/bins.server from
  sys.modules in the setup_env fixture so every test gets a fresh
  import after env vars are set. Test-harness-only — the real server
  imports config exactly once at actual startup.
- flake8-bugbear (newly enforced by this merge) caught 3 genuine minor
  issues in the kid-rotation code: an unused import and unused loop
  variables (kid_val -> _kid_val) in dhcp-server/app/auth.py and
  ntp-server/bins/server.py's multi-key verification loops.

Full suite after combine: manager 229/229, dns-server 63/63,
dhcp-server 32/32 (order-independent), ntp-server 51/51,
squawk-client 13/13. flake8 clean, gitleaks clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…overage

chore(quality): blocking lint configs, git hooks, unified pytest config, coverage gates
requirements.in/.txt: both sides added dependencies (boto3 for KMS,
opentelemetry-* for #70's tracing, already merged) -- combined,
neither dropped. No hash conflicts (unhashed pins). Both packages
already present in the shared venv; import-verified.

flake8-bugbear (enforced since #78 merged) caught one genuine unused
import surfaced by the combine: typing.List in auth_service.py.

Full manager suite: 255/255 passing. flake8 clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…o this PR)

Surfaced by the pre-push hook while merging PR #69 -- pure cosmetic
whitespace removal in docs files this branch never touched, not part
of the PR #69 changes. Kept as a separate commit per policy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
feat(auth): pluggable JWT signing with AWS KMS provider (enterprise)
- .pre-commit-config.yaml: hadolint rev conflict (v2.13.1 vs v2.14.0,
  the newer valid tag already canonical on v2.1.x since #78) resolved
  to v2.14.0. flake8 section already auto-merged to the canonical
  single-.flake8-source-of-truth form from #78 -- no conflict there.
- dns-server rate-limiter test bug (found during this merge's
  full-suite re-verification, unrelated to either branch's own diff):
  the app_with_rate_limiting fixture set rate_limiter.rps/.burst
  attributes on the module-level singleton AFTER its InMemoryBackend
  was already constructed with the default burst=100, so the token
  bucket's actual capacity never reflected the test's burst=3.0
  override and 429s never fired. Fixed by reinitializing the backend
  after setting the attributes; also moved CACHE_DIR/JWT_PUBLIC_KEY
  env-var setup to conftest module level (before any app.* import)
  so app.main only ever imports once, correctly configured, instead
  of racing test-file import order. Test-harness-only -- production
  configures these once at real startup.

Full suite: manager 234/234, dns-server 103/103, dhcp-server 32/32,
ntp-server 51/51, squawk-client 13/13.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…o this PR)

Same pre-existing cosmetic whitespace issue caught while merging PR #69
earlier -- this worktree's v2.1.x snapshot predates that fix. Pure
whitespace/EOF, not part of PR #77's changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…diation

chore(deps): remediate dependabot vulnerabilities
- dns-server/app/main.py: combined imports -- this branch's
  domain_policy/jwt_verify additions plus already-merged #65's
  rate-limit config vars and RateLimiter import. Also removed a
  redundant local re-import of verify_squawk_jwt/JWT_PUBLIC_KEY
  (leftover from #65's original code) that was shadowing the combined
  module-level import and tripping flake8's F401 check.
- dns-server/app/services/prometheus_metrics.py: combined two
  independent new methods (record_policy_denial from this branch,
  record_rate_limited_query from #65) on the same metrics class --
  their backing Counter definitions survived the auto-merge intact.
- manager/backend/app/services/auth_service.py: auto-merged cleanly
  but silently dropped the `List` import from typing while THIS
  branch's new allowed_domains: Optional[List[str]] parameter still
  uses it -- classic silent-auto-merge risk. Restored.

Full manager suite: 264/264 passing. dns-server: 112/112 real tests
passing (8 rate-limiter test errors are a pre-existing bug already
fixed in #77, not yet in this branch's v2.1.x snapshot -- will
re-verify after pulling latest v2.1.x).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
feat(nhi): per-identity DNS domain allowlists enforced at DoH
- app/blueprints/auth.py: both grant handlers (client_credentials and
  token-exchange) needed to combine THIS branch's dpop_jkt binding
  with #71's already-merged allowed_domains DB-fetch, both passed to
  create_machine_access_token.
- app/services/auth_service.py: create_machine_access_token's
  signature/docstring/body combined to accept and apply both dpop_jkt
  (RFC 9449 cnf claim) and allowed_domains (dns_domains claim).
- app/schema.py + tests/test_schema.py: dpop_replay table (this
  branch) combined with audit_event (#61, already merged) -- this
  branch predates that merge so git saw it as new.
- alembic: two real chain issues, both from this branch predating
  later merges:
  1. 011_dpop_replays.py had NO revision/down_revision identifiers at
     all (a genuine bug -- alembic could never have discovered this
     migration). Added revision="011_dpop_replays",
     down_revision="010_dns_domain_allowlists" (010 is #71's migration,
     merged after this branch was authored; the file's stale docstring
     said "Depends on: 009").
  2. 008_add_mfa_fields (re-chained onto 009 in an earlier standalone
     v2.1.x fix, before #71 existed) and 010_dns_domain_allowlists both
     forked from 009, creating two heads. Re-chained
     008_add_mfa_fields -> 011_dpop_replays so the graph is linear
     again with 008_add_mfa_fields as the single head.

Full manager suite: 293/293 passing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
feat(auth): DPoP sender-constrained tokens for machine identities
- app/__init__.py: combined scim_bp registration (this branch) with
  machine_clients_bp/oidc_trust_anchors_bp/audit_bp (already merged).
- app/middleware/auth.py: combined this branch's verify_jwt/has_scope
  helpers with the already-merged dpop_bound_token decorator --
  independent, unrelated functions.
- app/schema.py + tests/test_schema.py: scim_tokens table combined
  with machine_client/oidc_trust_anchor/dpop_replay/audit_event
  (all already merged).
- alembic: no chain fix needed this time -- 010_add_scim_provisioning
  already correctly points down_revision to 008_add_mfa_fields (its
  actual parent when this branch was authored off feature/mfa-totp),
  and that chain now correctly terminates the full linear graph as a
  single head.

Full manager suite: 323/323 passing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
feat(scim): SCIM 2.0 user provisioning with deprovision-kills-sessions
- .gitleaks.toml: both branches independently created this file
  (add/add conflict). Kept origin/v2.1.x's version -- accumulated and
  already validated across #69/#71/#73/#77's resolutions.
- .pre-commit-config.yaml: same flake8/hadolint divergence resolved
  identically to prior merges this session (single .flake8 source of
  truth + flake8-bugbear; hadolint v2.14.0).
- app/schema.py: auth_user gained sso_provider/sso_subject (this
  branch) alongside external_id (#73 SCIM, already merged) -- both
  independent new columns, combined.
- app/services/scopes.py: sso:write/sso:admin (this branch) combined
  with audit:read (already merged, SystemAdmin-only).
- tests/test_schema.py: expected-tables set now covers sso_providers/
  sso_login_attempts alongside scim_tokens/machine_client/
  oidc_trust_anchor/dpop_replay/audit_event (all already merged).
- alembic: SSO's own chain (008_add_mfa_fields -> 009_add_sso_providers
  -> 010_add_sso_login_attempts -> 011_allow_null_password_hash) and
  SCIM's chain (008_add_mfa_fields -> 010_add_scim_provisioning) both
  forked from the same parent, authored independently off
  feature/mfa-totp. Re-chained 009_add_sso_providers to depend on
  010_add_scim_provisioning (SCIM's already-merged migration) instead,
  restoring a single linear head.

Full manager suite: 339/339 passing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…lated to this PR)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
feat(auth): enterprise OIDC SSO login with JIT provisioning (security-hardened)
- .gitleaks.toml: another add/add conflict (same file independently
  created on this branch and on v2.1.x). Took v2.1.x's canonical
  version, validated across every prior merge this session.
- .pre-commit-config.yaml: same flake8/hadolint divergence resolved
  identically to every other merge in this batch.
- app/schema.py: saml_provider/saml_assertion_id tables inserted
  cleanly (origin/v2.1.x had no competing content at this exact
  insertion point -- its own new tables live elsewhere in the file).
- requirements.in/.txt: pysaml2 (this branch) combined with boto3 +
  opentelemetry-* (already merged). pysaml2==7.4.2 confirmed already
  present in the shared venv at the correct pinned version.
- tests/test_schema.py: saml_providers/saml_assertion_ids combined
  with scim_tokens/machine_client/oidc_trust_anchor/dpop_replay/
  audit_event (all already merged).
- tests/test_sso.py: TestIDTokenValidation (the real signature-path
  test coverage added when fixing #74's missing `jwt` import) existed
  only on origin/v2.1.x -- this branch predates that fix. Kept it,
  nothing on this side to preserve at that insertion point.
- alembic: no chain fix needed -- SAML's own migrations
  (012_add_saml_providers -> 013_add_saml_assertion_ids) already
  correctly chain from 011_allow_null_password_hash (SSO's actual
  tip when this branch was authored off feature/sso-oidc-login).
  Single linear head confirmed across the full 19-migration graph.

Full manager suite: 361/361 passing -- the final combined total
across every merged PR in this session's enterprise-hardening effort.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
feat(auth): SAML 2.0 SSO service provider (enterprise, XSW-hardened)
chore(helm): expose SPIFFE values; migrate env values files to house naming
Process error: after merging #74 (SSO) into v2.1.x, I deleted my LOCAL
feature/sso-oidc-login branch ref but never deleted or retargeted the
REMOTE branch/PR. #76 (SAML)'s base silently remained
feature/sso-oidc-login instead of v2.1.x, so `gh pr merge 76` merged
SAML into that orphaned remote branch -- completely disconnected from
v2.1.x. GitHub still shows PR #76 as MERGED, but v2.1.x itself never
received any of it (confirmed: alembic versions/ was missing
012_add_saml_providers.py and 013_add_saml_assertion_ids.py entirely).

Nothing was lost -- the fully-resolved SAML merge commit (d7ffab1,
carrying all of #76's conflict resolution work) still existed on the
orphaned branch. Merged it into the actual v2.1.x tip here: clean, no
conflicts (SAML's changes are manager/backend-only; v2.1.x's only
change since d7ffab1's parent was #72's Helm-only work).

Verified: 19 alembic migrations, single linear head
(013_add_saml_assertion_ids). Full manager suite: 361/361 passing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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