Skip to content

Documented the complete list of unsafe functions for --simulate mode - #3799

Open
nickanderson wants to merge 1 commit into
cfengine:masterfrom
nickanderson:doc-unsafe-functions-simulate
Open

nickanderson wants to merge 1 commit into
cfengine:masterfrom
nickanderson:doc-unsafe-functions-simulate

Conversation

@nickanderson

@nickanderson nickanderson commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

The --simulate documentation mentioned "unsafe functions" but only gave
execresult() as an example without listing all four unsafe functions.

  • Added a comprehensive table of all unsafe functions (execresult,
    execresult_as_data, returnszero, usemodule) to the --simulate section
  • Restructured the --simulate section with subheadings for clarity
  • Added a "Simulate mode" note to each of the four unsafe function
    reference pages linking back to the --simulate documentation
  • Noted that variables depending on unsafe functions will be unresolved
    unless tagged simulate_safe

@nickanderson
nickanderson force-pushed the doc-unsafe-functions-simulate branch 2 times, most recently from 730dcb3 to 331b218 Compare October 21, 2026 16:10
The --simulate documentation mentioned "unsafe functions" but only gave
execresult() as an example without listing all four unsafe functions.

- Added a comprehensive table of all unsafe functions (execresult,
  execresult_as_data, returnszero, usemodule) to the --simulate section
- Restructured the --simulate section with subheadings for clarity
- Added a "Simulate mode" note to each of the four unsafe function
  reference pages linking back to the --simulate documentation
- Noted that variables depending on unsafe functions will be unresolved
  unless tagged simulate_safe

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

I do think this would be improved by changing "tagged" to "meta attribute added" in general.


If a promise uses an unsafe function but you know the command is read-only (no
side effects), you can tag the promise with `simulate_safe` to allow it to
execute in simulate mode:

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.

"can tag the promise" probably deserves an example bit of code to make sure folks understand what that means... or a link to where we describe how to "tag a promise".

https://docs.cfengine.com/docs/master/reference/components/cf-agent/#simulate

bundle agent __main__
{
  vars:
    "msg"
      string => execresult("/bin/echo Hello world!", "useshell"),
      meta => { "simulate_safe" };
}

- Supported on Linux for `files` and `packages` type promises
- Supported on Linux for `files` and `packages` type promises.
- Variables that depend on unsafe functions will be unresolved unless the
promise is tagged `simulate_safe`.

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.

again here maybe change "is tagged" to "has a meta attribute"

e.g. https://docs.cfengine.com/docs/master/reference/promise-types/#meta

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