Skip to content

[Linting Rule] Process State In Session

github-actions[bot] edited this page Nov 8, 2026 · 1 revision

Generated from 'wiki-linter.ts' on 2026-11-03, 06:39:52 UTC (v2.16.8), do not edit directly.

Process State in Session [overview]

bug security shiny

This rule is a best-effort rule.

Finds per-session Shiny code changing state all sessions share: globals, options, environment variables, the working directory, namespaces, top-level reactive values, shared caches (memoise, bindCache, cachem) whose key misses session values, and resource paths.
This linting rule is implemented in src/linter/rules/process-state-in-session.ts.

Configuration

Linting rules can be configured by passing a configuration object to the linter query as shown in the example below. The process-state-in-session rule accepts the following configuration options:

  • caches
    cache constructors
  • memoisers
    memoisers
  • sessionSignatures
    parameter lists marking a session function (Shiny server or module), all of one must be present
  • settings
    process-wide setters, with what to use instead
  • sharedState
    functions creating state, shared when called at the top level

Examples

counter <- reactiveVal(0)
addResourcePath("data", "/srv/data")
server <- function(input, output, session) {
  user <<- input$name
  options(digits = input$digits)
  counter(counter() + 1)
  output$plot <- renderPlot(plot(load_for(session$user, input$n))) |> bindCache(input$n)
}

The linting query can be used to run this rule on the above example:

[ { "type": "linter",   "rules": [ { "name": "process-state-in-session",     "config": {} } ] } ]

Results (prettified and summarized):

Query: linter (7 ms)
   ╰ Process State in Session (process-state-in-session):
       ╰ certain:
           ╰ resource-path by addResourcePath at 3.1-36
           ╰ global-superassignment by user at 5.3-21
           ╰ process-setting by options at 6.3-32
           ╰ shared-state by counter at 7.3-24
           ╰ cache-key by bindCache at 8.71-88

More examples are the test cases in test/functionality/linter/lint-process-state-in-session.test.ts.

Clone this wiki locally

⌂ 换网址