Skip to content

CFE-3293: make callers declare intent when reading a variable - #6304

Open
nickanderson wants to merge 2 commits into
cfengine:masterfrom
nickanderson:CFE-3293-accessor-split/master
Open

CFE-3293: make callers declare intent when reading a variable#6304
nickanderson wants to merge 2 commits into
cfengine:masterfrom
nickanderson:CFE-3293-accessor-split/master

Conversation

@nickanderson

@nickanderson nickanderson commented Aug 18, 2026

Copy link
Copy Markdown
Member

EvalContextVariableGet() always returned the plaintext value, so a caller had no
way to ask for a secret-tagged variable to be redacted. This adds a get_secret
parameter, plus EvalContextVariableGetPlaintext() and friends, and moves the 20
existing call sites in core onto the plaintext form.

No behaviour change: every call site asks for plaintext, exactly as before. It is
the groundwork for the CFE-3294 leak fixes, which switch selected sites over.

The second commit fixes an indexed read of a secret-tagged container
(mydata[key]) aborting in RvalContainerValue(): the declared type was reported
while the returned value was the redacted scalar sentinel. Not reachable until a
caller passes get_secret=false, which the CFE-3294 work does.

Needs paired changes in the enterprise and nova repos, which call these accessors
and will not compile against the new signature — enterprise/libcfserverd/server.c
and four sites in nova/cf-hub/cf-hub.c.

@victormlg victormlg 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.

Nice! Some comments:

Comment thread libpromises/eval_context.c
Comment thread cf-agent/cf-agent.c
VarRef *ref = VarRefParseFromScope(cp->lval, "control_agent");
DataType value_type;
const void *value = EvalContextVariableGet(ctx, ref, &value_type);
const void *value = EvalContextVariableGetPlaintext(ctx, ref, &value_type);

@victormlg victormlg Aug 19, 2026

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.

You should remember to replace these inside the enterprise and nova repos as well

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yep enterprise and nova.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

EvalContextVariableGet() always returned the plaintext value, so a caller had
no way to ask for a secret-tagged variable to be redacted. Adds a get_secret
parameter and *Plaintext wrappers, and moves every existing caller onto the
plaintext form.

No behaviour change: every call site asks for plaintext, exactly as before.

Ticket: CFE-3293
Changelog: None
EvalContextVariableGet() kept the variable's declared type while returning the
redacted scalar sentinel, so an indexed read of a secret-tagged container --
mydata[key] -- took the container branch and handed that string to
RvalContainerValue(), which aborts with a ProgrammingError. Deriving the type
from the value actually being returned fixes it and removes the separate
type_out special case.

Not reachable yet: no caller passes get_secret=false until the CFE-3294 work.

test_secret_container_redacts_indexed_read aborts (SIGABRT) without this and
passes with it, and asserts the plaintext reads still work so redaction cannot
be faked by breaking container reads.

Ticket: CFE-3293
Changelog: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants