feat(security): validate shell and Kubernetes sources #13
No reviewers
Labels
No labels
app-migration
bug
ci-cd
cluster
Documentation
duplicate
enhancement
gpu
invalid
networking
question
security
Storage
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Homelab/workflows!13
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/kubernetes-validation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds ShellCheck to source scans and explicit Helm/Kustomize rendering, strict Kubernetes schema validation, and Trivy scanning of rendered manifests through
.pipeline/validation.json. Tool downloads are checksum-pinned, paths are constrained to the checkout, and Helm does not fetch dependencies.Kubeconform fails on missing schemas, including misspelled built-in kinds and unsupported custom resources. Skipping is disabled; success requires at least one valid resource and zero invalid, errored, or skipped resources. Controller-specific schema support remains a future capability.
Incorporates current main, resolves the test conflict while retaining PR #12 self-scan tests and policy, and updates the exact existing Semgrep mitigation for the relocated rule-download line without changing its controls or expiry.
Validation: 38 unit/contract tests; YAML/Bash syntax and 16 mocked scaffold cases; five production-command cases using checksum-verified Kubeconform 0.7.0 (valid resource, misspelled built-in, invalid built-in, unknown custom resource, and empty input). These real-tool cases also run in Library checks. Both Library checks and Repository security are required verification for this updated branch.
Advances #4.
Blocking:
pipeline/security.py:247-249combines Kubeconform-strictwith-ignore-missing-schemas, which silently accepts every unknown GVK, not only CRDs. I reproduced this with the exact checksum-pinned Kubeconform 0.7.0 binary: anapps/v1resource whose kind was misspelled asDeploymntproducedvalid: 0, invalid: 0, errors: 0, skipped: 1and exited 0. This defeats the stated strict built-in validation. Make CRD skipping explicit (for example, declared custom-kind/schema handling), reject every unexpected skipped resource, and add a production-command regression using a misspelled built-in kind.The branch is three commits behind current
main, Forgejo reports it non-mergeable, and a three-way merge simulation produces a content conflict intests/test_security.py. Incorporate currentmain, preserve PR #12's self-scan mitigation coverage while resolving the conflict, and rerun both the library and repository-security checks. The current green result contains onlyLibrary checksbecause this branch predates the repository self-scan.Validation at this head: 35 Python 3.12 tests passed; YAML/Bash and all 16 mocked scaffold cases passed;
git diff --checkpassed; the Kubeconform reproduction used a binary whose SHA-256 matchedtools.lock.json.Re-review: the two previous blockers are resolved. The branch now contains current
main, is mergeable, preserves PR #12 coverage, removes-ignore-missing-schemas, and exercises the exact Kubeconform command against the reported negative cases. One blocker remains:validation_config()accepts{"manifests": [], "render": []}. Inscan(), that leavesmanifestsempty, so theif manifests:guard skipsvalidate_kubernetes()entirely and the configured Kubernetes-validation stage succeeds without producing or checking a Kubeconform report. This contradicts the documented contract that success requires at least one valid resource. The newemptyproduction-command fixture does not cover this path because it callsvalidate_kubernetes()directly with an empty file rather than loading an empty validation plan. Require at least one manifest pattern or render entry at configuration validation, and add a regression covering an empty.pipeline/validation.jsonplan through the configuration/scan path.Verification at this head: 38 Python 3.12 tests pass; YAML/Bash and all 16 mocked scaffold cases pass; all five exact-binary Kubeconform production cases pass;
git diff --checkis clean; both hosted workflows are green; the hosted security decision reportspassed: true, zero blocking findings, five exact mitigations, and zero scanner errors.Re-review complete. The empty-plan bypass is fixed at configuration validation, with both focused unit coverage and a full scan-path regression proving that an empty
.pipeline/validation.jsonplan produces a failed decision and no Kubeconform report. The earlier unknown-GVK and branch-synchronization blockers remain resolved.Verified at this head: the branch contains current
mainand is mergeable; all three Forgejo checks are green; 39 Python 3.12 unit/contract tests pass locally; YAML/Bash and all 16 mocked scaffold cases pass; all five exact-binary Kubeconform production cases pass;git diff --checkis clean. The fresh hosted security artifact reportspassed: true, zero blocking findings, five exact mitigations, and zero scanner errors. No blocking findings remain.