Skip to content

feat(sources): add allow-listed journald and Kubernetes container log sources with DaemonSet (#92) - #313

Merged
jusso-dev merged 1 commit into
mainfrom
feat/journald-and-kubernetes-sources
Nov 21, 2026
Merged

jusso-dev merged 1 commit into
mainfrom
feat/journald-and-kubernetes-sources

Conversation

@jusso-dev

Copy link
Copy Markdown
Owner

Summary

Closes #92.

Adds bounded, allow-listed, cursor-durable systemd journald and Kubernetes container log sources with a hardened namespaced DaemonSet example:

  • systemd journald source (src/Bower.Source.Journald):
    • Enforces explicit systemd unit (Units) and/or SYSLOG_IDENTIFIER (Identifiers) allow-lists (refusing empty lists and wildcards) at both validation and runtime.
    • Provides platform-neutral IJournalReader seam plus Native AOT-safe LibSystemdJournalReader (LibraryImport against libsystemd.so.0 on Linux, zero external NuGet dependencies).
    • Emits bounded JSON records (<= 32 KiB) directly compatible with packs/linux-journald-ssh and commits durable cursors in ISourceCursorStore strictly after caller acknowledgement (at-least-once semantics; handles backpressure and oversized/malformed entries safely).
  • Kubernetes container log source (src/Bower.Source.Kubernetes):
    • Enforces explicit allow-listed Namespaces (DNS-1123, max 32) and LabelSelectors (key=value, max 16) — no cluster-wide default collection and no pod annotation auto-discovery.
    • Includes minimal KubernetesApiPodCatalog (namespaced GET /api/v1/namespaces/{ns}/pods, ServiceAccount bearer token read from file, 4 MiB response cap, Native AOT source-generated JSON, zero third-party packages).
    • Reuses Bower.Source.File.FileTailReader for symlink-safe, bounded, rotation-aware /var/log/pods tailing and durable FileTailCursor checkpoints.
    • Parses CRI container log lines (<timestamp> <stdout|stderr> <P|F> <message>), joins partial (P) fragments up to MaxPartialBytes, drops unrecognised non-envelope stdout noise, attaches minimal pod metadata (k8s.namespace, k8s.pod, k8s.container, k8s.stream) plus explicitly allow-listed pod labels only, and assigns deterministic EventIds for replay deduplication.
  • Deployment, docs & threat model:
    • Adds hardened deploy/kubernetes/daemonset.yaml (namespaced Role/RoleBinding get/list pods only — never ClusterRole, read-only /var/log/pods mount, runAsNonRoot, readOnlyRootFilesystem, capabilities.drop: ["ALL"], seccompProfile: RuntimeDefault).
    • Adds docs/deployment/journald-source.md, docs/deployment/kubernetes-source.md, updates website/sidebars.ts, and documents both trust boundaries in docs/security/threat-model.md.
    • Adds scoped AGENTS.md in both new source projects.

Verification

  • dotnet build --configuration Release — 0 warnings, 0 errors
  • dotnet test (JournaldAndKubernetesSourceTests) — 5 passed, 0 failed (unit/identifier allow-list, SQLite cursor persistence + backpressure + restart recovery + packs/linux-journald-ssh integration, K8s namespace/label allow-list, CRI partial join, rename log rotation + restart recovery, K8s API namespaced bearer-token client)
  • dotnet format --verify-no-changes — passed
  • python3 -m unittest tools/docs/tests/test_build_tools.py — 7/7 passed

Security and compatibility impact

  • Zero new third-party NuGet dependencies; strictly additive projects, deployment manifest, and docs.
  • Note: live systemd container / kind cluster integration tests were not executed in this macOS environment; platform-neutral unit and SQLite durability tests cover all parsing, filtering, rotation, and cursor semantics.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d60ad92c-1e7c-45af-b9ad-6d75a08ff616
Commits

Reviewing files that changed from the base of the PR and between 71a3693 and 7e3a6c6.

Files selected for processing: 23

  • Bower.sln
  • deploy/kubernetes/daemonset.yaml
  • docs/deployment/journald-source.md
  • docs/deployment/kubernetes-source.md
  • docs/security/threat-model.md
  • src/Bower.Source.Journald/AGENTS.md
  • src/Bower.Source.Journald/Bower.Source.Journald.csproj
  • src/Bower.Source.Journald/IJournalReader.cs
  • src/Bower.Source.Journald/JournaldSource.cs
  • src/Bower.Source.Journald/JournaldSourceOptions.cs
  • src/Bower.Source.Journald/LibSystemdJournalReader.cs
  • src/Bower.Source.Journald/packages.lock.json
  • src/Bower.Source.Kubernetes/AGENTS.md
  • src/Bower.Source.Kubernetes/Bower.Source.Kubernetes.csproj
  • src/Bower.Source.Kubernetes/CriLogParser.cs
  • src/Bower.Source.Kubernetes/KubernetesLogSource.cs
  • src/Bower.Source.Kubernetes/KubernetesLogSourceOptions.cs
  • src/Bower.Source.Kubernetes/KubernetesPodCatalog.cs
  • src/Bower.Source.Kubernetes/packages.lock.json
  • tests/Bower.UnitTests/Bower.UnitTests.csproj
  • tests/Bower.UnitTests/JournaldAndKubernetesSourceTests.cs
  • tests/Bower.UnitTests/packages.lock.json
  • website/sidebars.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@jusso-dev
jusso-dev merged commit a0b3fc1 into main Nov 21, 2026
32 checks passed
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.

journald and Kubernetes container log sources

1 participant