Skip to content

fix(bmc-discovery): Narrow the credential Role and check its namespace - #223

Merged
scotwells merged 3 commits into
feat/manual-inventory-recordsfrom
fix/bmc-discovery-credential-scope
Nov 29, 2026
Merged

scotwells merged 3 commits into
feat/manual-inventory-recordsfrom
fix/bmc-discovery-credential-scope

Conversation

@scotwells

Copy link
Copy Markdown
Contributor

Related to #182, as a follow-up to its review.

BMC discovery could read every Secret in its namespace, and RBAC can't limit it to the labelled credentials. Discovery now has list and watch only, and CI fails when any other Secret lands in a credential namespace.

The discovery guide says why the Role stays namespace-wide.

Test plan

  • Every validate step at the head, except the Docker build-context test, which had no local Docker daemon and is left to CI
  • The new check fails on a stray Secret in each kind of credential namespace, from any root, and passes the real roots
  • An envtest runs discovery's Secret cache and its one-shot list under the shipped Role, and a read by name is refused

Decisions for a person

  • Narrowing further means discovery reads each Device's Secret by a derived name, with a Role built from the enrolled Devices. That changes the credential naming contract for every deploying repository and loses the instant pin approval. Should Fleet take that on?
  • The new credential-namespace label on Namespaces is a public contract that deploying repositories would copy. Confirm its name, or drop it.

🤖 Generated with Claude Code

scotwells and others added 3 commits November 25, 2026 21:15
Discovery reads credential Secrets only through its label-selected cache
and the --once list, so the Role's get verb was never used. Drop it and
pin the Role with a manifest test and an envtest that runs the real
Secret cache and --once list under the shipped Role, and checks that a
get by name and another namespace are refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RBAC cannot narrow discovery's Secret Role to the labelled credential
Secrets, so any Secret in its namespace is readable by discovery. Render
every Kustomize entry point under config/ and fail when a Secret without
the credential label and Device annotations lands in a namespace that
holds discovery, a credential Secret, or the new credential-namespace
label, which the site's Redfish credential namespace now carries. A
namespace found in any root is checked in every root, and discovery's
own Milo kubeconfig is admitted only beside discovery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record why the Secret Role stays namespace-wide, what the render check
enforces, and how a sidecar deployment keeps its credential namespace
separate from the host pod's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells requested review from ecv and kevwilliams November 26, 2026 03:36
Base automatically changed from feat/device-custody-cutover to feat/manual-inventory-records November 28, 2026 14:54
@scotwells
scotwells marked this pull request as ready for review November 29, 2026 17:25
@scotwells
scotwells requested a review from a team as a code owner November 29, 2026 17:25

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve.

Discovery's Role drops get on Secrets, and every read path already goes through list and watch: the label-selected cache in credentialCluster and the one-shot SecretList for --once. TestShippedRoleServesTheCredentialCacheAndRefusesGet runs both under the shipped Role and asserts that a read by name and a list in another namespace are Forbidden. The new validator renders every Kustomize entry point, treats a namespace as a credential namespace if it is labelled, holds discovery's Role or ServiceAccount, or holds a labelled credential, and fails on any Secret there that is not a credential naming a Device, apart from discovery's own Milo kubeconfig. It also fails when no entry point renders a credential namespace, so it cannot pass vacuously.

  • Dropping get narrows little on its own: list still returns every Secret's data in the namespace, as the updated Role comment and guide say. The guard is keeping the namespace credential-only, and the validator checks that only for renders in this repo. A deploying repository needs to run it against its own overlays, or one stray Secret there is readable by discovery.

Follow-ups:

  • Ship the validator so a deploying repository can run it against its own config root, for example as a released binary or a documented go run against a pinned tag, and say so in the guide.

@scotwells
scotwells merged commit 76285e0 into feat/manual-inventory-records Nov 29, 2026
9 checks passed
@scotwells
scotwells deleted the fix/bmc-discovery-credential-scope branch November 29, 2026 17:36
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.

3 participants